500-eventfd.patch 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. From 7810e4f8027b5c4c8ceec6fefec4eb779362ebb5 Mon Sep 17 00:00:00 2001
  2. From: Khem Raj <raj.khem@gmail.com>
  3. Date: Sun, 10 Jun 2012 16:36:23 +0000
  4. Subject: eventfd: Implement eventfd2 and fix eventfd
  5. eventfd: evntfd assumes to take two arguments instead it
  6. should be one evntfd expects two therefore implement both syscalls with
  7. correct parameters
  8. Thanks Eugene Rudoy for reporting it and also providing the patch
  9. Signed-off-by: Khem Raj <raj.khem@gmail.com>
  10. ---
  11. --- a/libc/sysdeps/linux/common/eventfd.c
  12. +++ b/libc/sysdeps/linux/common/eventfd.c
  13. @@ -7,12 +7,24 @@
  14. * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
  15. */
  16. +#include <errno.h>
  17. #include <sys/syscall.h>
  18. #include <sys/eventfd.h>
  19. /*
  20. * eventfd()
  21. */
  22. -#ifdef __NR_eventfd
  23. -_syscall2(int, eventfd, int, count, int, flags)
  24. +#if defined __NR_eventfd || defined __NR_eventfd2
  25. +int eventfd (int count, int flags)
  26. +{
  27. +#if defined __NR_eventfd2
  28. + return INLINE_SYSCALL (eventfd2, 2, count, flags);
  29. +#elif defined __NR_eventfd
  30. + if (flags != 0) {
  31. + __set_errno (EINVAL);
  32. + return -1;
  33. + }
  34. + return INLINE_SYSCALL (eventfd, 1, count);
  35. +#endif
  36. +}
  37. #endif
  38. --- a/libc/sysdeps/linux/common/stubs.c
  39. +++ b/libc/sysdeps/linux/common/stubs.c
  40. @@ -93,7 +93,7 @@ make_stub(epoll_ctl)
  41. make_stub(epoll_wait)
  42. #endif
  43. -#if !defined __NR_eventfd && defined __UCLIBC_LINUX_SPECIFIC__
  44. +#if !defined __NR_eventfd && !defined __NR_eventfd2 && defined __UCLIBC_LINUX_SPECIFIC__
  45. make_stub(eventfd)
  46. #endif