epoll.c 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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 __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. #ifdef __NR_epoll_ctl
  25. _syscall4(int, epoll_ctl, int, epfd, int, op, int, fd, struct epoll_event *, event)
  26. #endif
  27. #ifdef __NR_epoll_wait
  28. static int __NC(epoll_wait)(int epfd, struct epoll_event *events, int maxevents, int timeout)
  29. {
  30. return INLINE_SYSCALL(epoll_wait, 4, epfd, events, maxevents, timeout);
  31. }
  32. CANCELLABLE_SYSCALL(int, epoll_wait, (int epfd, struct epoll_event *events, int maxevents, int timeout),
  33. (epfd, events, maxevents, timeout))
  34. #endif
  35. #ifdef __NR_epoll_pwait
  36. # include <signal.h>
  37. # define __NR___syscall_epoll_pwait __NR_epoll_pwait
  38. static __always_inline _syscall6(int, __syscall_epoll_pwait, int, epfd, struct epoll_event *, events,
  39. int, maxevents, int, timeout, const sigset_t *, sigmask, size_t, sigsetsize)
  40. static int __NC(epoll_pwait)(int epfd, struct epoll_event *events, int maxevents, int timeout,
  41. const sigset_t *set)
  42. {
  43. return __syscall_epoll_pwait(epfd, events, maxevents, timeout, set, __SYSCALL_SIGSET_T_SIZE);
  44. }
  45. CANCELLABLE_SYSCALL(int, epoll_pwait, (int epfd, struct epoll_event *events, int maxevents, int timeout,
  46. const sigset_t *set),
  47. (epfd, events, maxevents, timeout, set))
  48. /*
  49. * If epoll_wait is not defined, then call epoll_pwait instead using NULL
  50. * for sigmask argument
  51. */
  52. # ifndef __NR_epoll_wait
  53. # include <stddef.h>
  54. int epoll_wait(int epfd, struct epoll_event *events, int maxevents, int timeout)
  55. {
  56. return INLINE_SYSCALL(epoll_pwait, 5, epfd, events, maxevents, timeout, NULL);
  57. }
  58. # endif
  59. #endif