signalfd.c 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  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. int signalfd (int fd, const sigset_t *mask, int flags)
  23. {
  24. #if defined __NR___syscall_signalfd4
  25. return __syscall_signalfd4(fd, mask, _NSIG / 8, flags);
  26. #elif defined __NR___syscall_signalfd
  27. if (flags != 0) {
  28. __set_errno(EINVAL);
  29. return -1;
  30. }
  31. return __syscall_signalfd(fd, mask, _NSIG / 8);
  32. #endif
  33. }
  34. #endif