| 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 | |
| 6 | eventfd: evntfd assumes to take two arguments instead it |
| 7 | should be one evntfd expects two therefore implement both syscalls with |
| 8 | correct parameters |
| 9 | |
| 10 | Thanks Eugene Rudoy for reporting it and also providing the patch |
| 11 | |
| 12 | Signed-off-by: Khem Raj <raj.khem@gmail.com> |
| 13 | --- |
| 14 | diff --git a/libc/sysdeps/linux/common/eventfd.c b/libc/sysdeps/linux/common/eventfd.c |
| 15 | index cc3f3f0..96597ab 100644 |
| 16 | --- a/libc/sysdeps/linux/common/eventfd.c |
| 17 | +++ b/libc/sysdeps/linux/common/eventfd.c |
| 18 | @@ -7,12 +7,24 @@ |
| 19 | * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. |
| 20 | */ |
| 21 | |
| 22 | +#include <errno.h> |
| 23 | #include <sys/syscall.h> |
| 24 | #include <sys/eventfd.h> |
| 25 | |
| 26 | /* |
| 27 | * eventfd() |
| 28 | */ |
| 29 | -#ifdef __NR_eventfd |
| 30 | -_syscall2(int, eventfd, int, count, int, flags) |
| 31 | +#if defined __NR_eventfd || defined __NR_eventfd2 |
| 32 | +int eventfd (int count, int flags) |
| 33 | +{ |
| 34 | +#if defined __NR_eventfd2 |
| 35 | + return INLINE_SYSCALL (eventfd2, 2, count, flags); |
| 36 | +#elif defined __NR_eventfd |
| 37 | + if (flags != 0) { |
| 38 | + __set_errno (EINVAL); |
| 39 | + return -1; |
| 40 | + } |
| 41 | + return INLINE_SYSCALL (eventfd, 1, count); |
| 42 | +#endif |
| 43 | +} |
| 44 | #endif |
| 45 | diff --git a/libc/sysdeps/linux/common/stubs.c b/libc/sysdeps/linux/common/stubs.c |
| 46 | index 4d1e26c..7af14c1 100644 |
| 47 | --- a/libc/sysdeps/linux/common/stubs.c |
| 48 | +++ b/libc/sysdeps/linux/common/stubs.c |
| 49 | @@ -93,7 +93,7 @@ make_stub(epoll_ctl) |
| 50 | make_stub(epoll_wait) |
| 51 | #endif |
| 52 | |
| 53 | -#if !defined __NR_eventfd && defined __UCLIBC_LINUX_SPECIFIC__ |
| 54 | +#if !defined __NR_eventfd && !defined __NR_eventfd2 && defined __UCLIBC_LINUX_SPECIFIC__ |
| 55 | make_stub(eventfd) |
| 56 | #endif |
| 57 | |
| 58 | -- |
| 59 | cgit v0.9.0.1-2-gef13 |
| 60 | |