signalfd.c 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /* vi: set sw=4 ts=4: */
  2. /*
  3. * signalfd() for uClibc
  4. *
  5. * Copyright (C) 2008 Bernhard Reutner-Fischer <uclibc@uclibc.org>
  6. *
  7. * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
  8. */
  9. #include <sys/syscall.h>
  10. #include <signal.h>
  11. #include <sys/signalfd.h>
  12. #if defined __NR_signalfd4
  13. #define __NR___syscall_signalfd4 __NR_signalfd4
  14. static __inline__ _syscall4(int, __syscall_signalfd4, int, fd,
  15. const sigset_t *, mask, size_t, sizemask, int, flags)
  16. #elif defined __NR_signalfd
  17. #define __NR___syscall_signalfd __NR_signalfd
  18. static __inline__ _syscall3(int, __syscall_signalfd, int, fd,
  19. const sigset_t *, mask, size_t, sizemask)
  20. #endif
  21. #if defined __NR_signalfd4 || defined __NR_signalfd \
  22. || defined __UCLIBC_HAS_STUBS__
  23. int signalfd (int fd, const sigset_t *mask, int flags)
  24. {
  25. #if defined __NR___syscall_signalfd4
  26. return __syscall_signalfd4(fd, mask, _NSIG / 8, flags);
  27. #elif defined __NR___syscall_signalfd
  28. if (flags != 0) {
  29. __set_errno(EINVAL);
  30. return -1;
  31. }
  32. return __syscall_signalfd(fd, mask, _NSIG / 8);
  33. #elif defined __UCLIBC_HAS_STUBS__
  34. __set_errno(ENOSYS);
  35. return -1;
  36. #endif
  37. }
  38. #endif