Incorrect/incomplete eventfd implementation?

Natanael Copa natanael.copa at gmail.com
Wed May 16 13:55:46 UTC 2012


On Wed, May 16, 2012 at 2:50 PM, Eugene Rudoy <gene.devel at googlemail.com> wrote:
> Hi,
>
> I believe the implementation of eventfd recently added to uClibc (s. [1],
> [2]) is incorrect. It incorrectly assumes eventfd takes two arguments
> whereas in reality it expects just one. It's eventfd2 which expects two
> arguments. Furthermore it doesn't properly support kernel versions which do
> provide eventfd but don't provide eventfd2 (s. [3]). glibc seems to support
> all possible cases (s. [4]).

I think you are absolutely right. We bumped into this issue when
upgrading to glib-2.32.

I pasted our IRC discussion in our commit message. It explains a bit
why it is this way.

http://git.alpinelinux.org/cgit/aports/commit/main/libc0.9.32/eventfd.patch?id=3161576d06aa52a0dfbfdc13a539fa6d14100855

I suggest this patch but it will require kernel2.6.27+ kernel:
diff --git a/libc/sysdeps/linux/common/eventfd.c
b/libc/sysdeps/linux/common/eventfd.c
index cc3f3f0..06a26ee 100644
--- a/libc/sysdeps/linux/common/eventfd.c
+++ b/libc/sysdeps/linux/common/eventfd.c
@@ -14,5 +14,9 @@
  * eventfd()
  */
 #ifdef __NR_eventfd
+#ifdef __NR_eventfd2
+#undef  __NR_eventfd
+#define __NR_eventfd __NR_eventfd2
+#endif
 _syscall2(int, eventfd, int, count, int, flags)
 #endif


> Best regards,
> Gene
>
> [1]
> http://git.uclibc.org/uClibc/commit/?id=9ed163dc0eaebe8734c35b356c406e9eb1c68d76
> [2] http://lists.uclibc.org/pipermail/uclibc/2011-October/045877.html
> [3]
> http://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/kernel-features.h;h=1090f8a809d7d14986722f796f96a75df4f7074d;hb=HEAD#l452
> [4]
> http://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/eventfd.c;h=4a0e8bc0caa676cdbb5f777780a06e43129a0e72;hb=HEAD
> _______________________________________________
> uClibc mailing list
> uClibc at uclibc.org
> http://lists.busybox.net/mailman/listinfo/uclibc



-- 
Natanael Copa


More information about the uClibc mailing list