epoll.c 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. * epoll_create() / epoll_ctl() / epoll_wait() / epoll_pwait() for uClibc
  3. *
  4. * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
  5. *
  6. * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
  7. */
  8. #include <sys/syscall.h>
  9. #include <sys/epoll.h>
  10. #include <cancel.h>
  11. #ifdef L_epoll_create
  12. # ifdef __NR_epoll_create
  13. _syscall1(int, epoll_create, int, size)
  14. # endif
  15. # ifdef __NR_epoll_create1
  16. _syscall1(int, epoll_create1, int, flags)
  17. # endif
  18. # if defined __NR_epoll_create1 && !defined __NR_epoll_create
  19. int epoll_create(int size)
  20. {
  21. return INLINE_SYSCALL(epoll_create1, 1, 0);
  22. }
  23. # endif
  24. #endif
  25. #if defined L_epoll_ctl && defined __NR_epoll_ctl
  26. _syscall4(int, epoll_ctl, int, epfd, int, op, int, fd, struct epoll_event *, event)
  27. #endif
  28. #if defined L_epoll_pwait && defined __NR_epoll_pwait
  29. # include <signal.h>
  30. # define __NR___syscall_epoll_pwait __NR_epoll_pwait
  31. static __always_inline _syscall6(int, __syscall_epoll_pwait, int, epfd, struct epoll_event *, events,
  32. int, maxevents, int, timeout, const sigset_t *, sigmask, size_t, sigsetsize)
  33. static int __NC(epoll_pwait)(int epfd, struct epoll_event *events, int maxevents, int timeout,
  34. const sigset_t *set)
  35. {
  36. return __syscall_epoll_pwait(epfd, events, maxevents, timeout, set, __SYSCALL_SIGSET_T_SIZE);
  37. }
  38. CANCELLABLE_SYSCALL(int, epoll_pwait, (int epfd, struct epoll_event *events, int maxevents, int timeout,
  39. const sigset_t *set),
  40. (epfd, events, maxevents, timeout, set))
  41. #endif
  42. #if defined L_epoll_wait
  43. # if defined __NR_epoll_wait
  44. static int __NC(epoll_wait)(int epfd, struct epoll_event *events, int maxevents, int timeout)
  45. {
  46. return INLINE_SYSCALL(epoll_wait, 4, epfd, events, maxevents, timeout);
  47. }
  48. CANCELLABLE_SYSCALL(int, epoll_wait, (int epfd, struct epoll_event *events, int maxevents, int timeout),
  49. (epfd, events, maxevents, timeout))
  50. # elif /* !defined L_epoll_wait && */ defined __NR_epoll_pwait
  51. /*
  52. * If epoll_wait is not defined, then call epoll_pwait instead using NULL
  53. * for sigmask argument
  54. */
  55. # include <stddef.h>
  56. int epoll_wait(int epfd, struct epoll_event *events, int maxevents, int timeout)
  57. {
  58. return INLINE_SYSCALL(epoll_pwait, 5, epfd, events, maxevents, timeout, NULL);
  59. }
  60. # endif
  61. #endif