summaryrefslogtreecommitdiff
path: root/libc/sysdeps/linux/common/signalfd.c
diff options
context:
space:
mode:
authorBernhard Reutner-Fischer <rep.dot.nop@gmail.com>2008-10-10 17:10:26 +0000
committerBernhard Reutner-Fischer <rep.dot.nop@gmail.com>2008-10-10 17:10:26 +0000
commit8e36b7ce609efb05ecfba3e055a8eef7d8873a15 (patch)
tree7d13c6a2c1f452e5817ddcf5697110a0fb0205cb /libc/sysdeps/linux/common/signalfd.c
parent840d49dc036274b0fded03b30c8d4a92c432378e (diff)
- add signalfd()
Diffstat (limited to 'libc/sysdeps/linux/common/signalfd.c')
-rw-r--r--libc/sysdeps/linux/common/signalfd.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/libc/sysdeps/linux/common/signalfd.c b/libc/sysdeps/linux/common/signalfd.c
new file mode 100644
index 000000000..e134a6fa9
--- /dev/null
+++ b/libc/sysdeps/linux/common/signalfd.c
@@ -0,0 +1,38 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * signalfd() for uClibc
+ *
+ * Copyright (C) 2008 Bernhard Reutner-Fischer <uclibc@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#include <sys/syscall.h>
+#include <signal.h>
+#include <sys/signalfd.h>
+
+#if defined __NR_signalfd4
+#define __NR___syscall_signalfd4 __NR_signalfd4
+static __inline__ _syscall4(int, __syscall_signalfd4, int, fd,
+ const sigset_t *, mask, size_t, sizemask, int, flags);
+#elif defined __NR_signalfd
+#define __NR___syscall_signalfd __NR_signalfd4
+static __inline__ _syscall3(int, __syscall_signalfd, int, fd,
+ const sigset_t *, mask, size_t, sizemask);
+#endif
+
+int signalfd (int fd, const sigset_t *mask, int flags)
+{
+#if defined __NR___syscall_signalfd4
+ return __syscall_signalfd4(fd, mask, _NSIG / 8, flags);
+#elif defined __NR___syscall_signalfd
+ if (flags != 0) {
+ __set_errno(EINVAL);
+ return 1;
+ }
+ return __syscall_signalfd(fd, mask, _NSIG / 8);
+#elif defined __UCLIBC_HAS_STUBS__
+ __set_errno(ENOSYS);
+ return -1;
+#endif
+}