summaryrefslogtreecommitdiff
path: root/src/basic/fd-util.h
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2015-11-17 00:51:24 +0100
committerLennart Poettering <lennart@poettering.net>2015-11-17 00:52:10 +0100
commit23e096cc60eb73f24b812e4ceba7c4c2c141e2db (patch)
treecb29a125f9e1028d51a12182e261aa7d493ff0d5 /src/basic/fd-util.h
parentb16fee15ff0dbaa8140beb62dc27f3a686c70258 (diff)
tree-wide: make macros for converting fds to pointers and back generic and use them everywhere
Diffstat (limited to 'src/basic/fd-util.h')
-rw-r--r--src/basic/fd-util.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/basic/fd-util.h b/src/basic/fd-util.h
index 1ca10f0383..0e9182d75b 100644
--- a/src/basic/fd-util.h
+++ b/src/basic/fd-util.h
@@ -28,6 +28,10 @@
#include "macro.h"
+/* Make sure we can distinguish fd 0 and NULL */
+#define FD_TO_PTR(fd) INT_TO_PTR((fd)+1)
+#define PTR_TO_FD(p) (PTR_TO_INT(p)-1)
+
int close_nointr(int fd);
int safe_close(int fd);
void safe_close_pair(int p[]);