aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPekka Paalanen <ppaalanen@gmail.com>2012-04-23 12:10:45 +0300
committerPekka Paalanen <ppaalanen@gmail.com>2012-04-25 09:32:57 +0300
commit3b29783dc8f0e856afce7a9edf10c0ca4d12f284 (patch)
tree9f5e1bc98cadea11f2a5ed1f2fb6b488acd61443 /src
parentos: remove unneeded errno assignment (diff)
downloadwayland-3b29783dc8f0e856afce7a9edf10c0ca4d12f284.tar
wayland-3b29783dc8f0e856afce7a9edf10c0ca4d12f284.tar.gz
wayland-3b29783dc8f0e856afce7a9edf10c0ca4d12f284.tar.bz2
wayland-3b29783dc8f0e856afce7a9edf10c0ca4d12f284.tar.lz
wayland-3b29783dc8f0e856afce7a9edf10c0ca4d12f284.tar.xz
wayland-3b29783dc8f0e856afce7a9edf10c0ca4d12f284.tar.zst
wayland-3b29783dc8f0e856afce7a9edf10c0ca4d12f284.zip
os: define SOCK_CLOEXEC on Linux
If it's not already defined, and we are on Linux, #define it. This gets rid of a load of #ifdefs. This should also allow to use it when the kernel supports it, but the libc does not define it. Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/wayland-os.c2
-rw-r--r--src/wayland-os.h13
2 files changed, 13 insertions, 2 deletions
diff --git a/src/wayland-os.c b/src/wayland-os.c
index 8f75976..4db8050 100644
--- a/src/wayland-os.c
+++ b/src/wayland-os.c
@@ -55,13 +55,11 @@ wl_os_socket_cloexec(int domain, int type, int protocol)
{
int fd;
-#ifdef SOCK_CLOEXEC
fd = socket(domain, type | SOCK_CLOEXEC, protocol);
if (fd >= 0)
return fd;
if (errno != EINVAL)
return -1;
-#endif
fd = socket(domain, type, protocol);
return set_cloexec_or_close(fd);
diff --git a/src/wayland-os.h b/src/wayland-os.h
index 49adc2b..a57b3aa 100644
--- a/src/wayland-os.h
+++ b/src/wayland-os.h
@@ -26,4 +26,17 @@
int
wl_os_socket_cloexec(int domain, int type, int protocol);
+/*
+ * The following are for wayland-os.c and the unit tests.
+ * Do not use them elsewhere.
+ */
+
+#ifdef __linux__
+
+#ifndef SOCK_CLOEXEC
+#define SOCK_CLOEXEC 02000000
+#endif
+
+#endif /* __linux__ */
+
#endif