epoll.c 2.2 KB

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