From 8e36b7ce609efb05ecfba3e055a8eef7d8873a15 Mon Sep 17 00:00:00 2001 From: Bernhard Reutner-Fischer Date: Fri, 10 Oct 2008 17:10:26 +0000 Subject: - add signalfd() --- libc/sysdeps/linux/common/Makefile.in | 4 ++-- libc/sysdeps/linux/common/signalfd.c | 38 +++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 libc/sysdeps/linux/common/signalfd.c (limited to 'libc/sysdeps/linux/common') diff --git a/libc/sysdeps/linux/common/Makefile.in b/libc/sysdeps/linux/common/Makefile.in index d9c3116e9..521e561fd 100644 --- a/libc/sysdeps/linux/common/Makefile.in +++ b/libc/sysdeps/linux/common/Makefile.in @@ -34,8 +34,8 @@ CSRC := $(filter-out inotify.c ioperm.c iopl.c madvise.c \ modify_ldt.c personality.c prctl.c readahead.c reboot.c \ remap_file_pages.c sched_getaffinity.c sched_setaffinity.c \ sendfile64.c sendfile.c setfsgid.c setfsuid.c setresuid.c \ - splice.c vmsplice.c tee.c swapoff.c swapon.c sync_file_range.c \ - sysctl.c sysinfo.c uselib.c vhangup.c,$(CSRC)) + splice.c vmsplice.c tee.c signalfd.c swapoff.c swapon.c \ + sync_file_range.c sysctl.c sysinfo.c uselib.c vhangup.c,$(CSRC)) endif ifneq ($(UCLIBC_BSD_SPECIFIC),y) 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 + * + * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. + */ + +#include +#include +#include + +#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 +} -- cgit v1.2.3