fea8ccdd1b8ed39892c9fbbad713811bcb847bd6
[packages/trusty/cirros-testvm.git] / cirros-testvm / src-cirros / buildroot-2015.05 / package / uclibc / 0.9.33.2 / 0013-eventfd-Implement-eventfd2-and-fix-eventfd.patch
1 From 7810e4f8027b5c4c8ceec6fefec4eb779362ebb5 Mon Sep 17 00:00:00 2001
2 From: Khem Raj <raj.khem@gmail.com>
3 Date: Sun, 10 Jun 2012 09:36:23 -0700
4 Subject: [PATCH] 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  libc/sysdeps/linux/common/eventfd.c |   16 ++++++++++++++--
15  libc/sysdeps/linux/common/stubs.c   |    2 +-
16  2 files changed, 15 insertions(+), 3 deletions(-)
17
18 diff --git a/libc/sysdeps/linux/common/eventfd.c b/libc/sysdeps/linux/common/eventfd.c
19 index cc3f3f0..96597ab 100644
20 --- a/libc/sysdeps/linux/common/eventfd.c
21 +++ b/libc/sysdeps/linux/common/eventfd.c
22 @@ -7,12 +7,24 @@
23   * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
24   */
25  
26 +#include <errno.h>
27  #include <sys/syscall.h>
28  #include <sys/eventfd.h>
29  
30  /*
31   * eventfd()
32   */
33 -#ifdef __NR_eventfd
34 -_syscall2(int, eventfd, int, count, int, flags)
35 +#if defined __NR_eventfd || defined __NR_eventfd2
36 +int eventfd (int count, int flags)
37 +{
38 +#if defined __NR_eventfd2
39 +  return INLINE_SYSCALL (eventfd2, 2, count, flags);
40 +#elif defined __NR_eventfd
41 +  if (flags != 0) {
42 +     __set_errno (EINVAL);
43 +    return -1;
44 +  }
45 +  return INLINE_SYSCALL (eventfd, 1, count);
46 +#endif
47 +}
48  #endif
49 diff --git a/libc/sysdeps/linux/common/stubs.c b/libc/sysdeps/linux/common/stubs.c
50 index 4d1e26c..7af14c1 100644
51 --- a/libc/sysdeps/linux/common/stubs.c
52 +++ b/libc/sysdeps/linux/common/stubs.c
53 @@ -93,7 +93,7 @@ make_stub(epoll_ctl)
54  make_stub(epoll_wait)
55  #endif
56  
57 -#if !defined __NR_eventfd && defined __UCLIBC_LINUX_SPECIFIC__
58 +#if !defined __NR_eventfd && !defined __NR_eventfd2 && defined __UCLIBC_LINUX_SPECIFIC__
59  make_stub(eventfd)
60  #endif
61  
62 -- 
63 1.7.10.4
64