[git commit] Add eventfd_read() and eventfd_write()

Bernhard Reutner-Fischer rep.dot.nop at gmail.com
Tue Feb 17 22:42:30 UTC 2015


commit: http://git.uclibc.org/uClibc/commit/?id=9fc6da20daeac3f06116630764c36fc4943b1f3a
branch: http://git.uclibc.org/uClibc/commit/?id=refs/heads/master

Signed-off-by: Khem Raj <raj.khem at gmail.com>
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop at gmail.com>
---
 libc/sysdeps/linux/common/Makefile.in              |    2 +
 libc/sysdeps/linux/common/eventfd.c                |    2 +-
 .../bits/eventfd.h => common/eventfd_read.c}       |   24 ++++++++-----------
 .../bits/eventfd.h => common/eventfd_write.c}      |   25 ++++++++-----------
 libc/sysdeps/linux/common/sys/eventfd.h            |    6 +----
 libc/sysdeps/linux/sparc/bits/eventfd.h            |    2 +-
 6 files changed, 26 insertions(+), 35 deletions(-)

diff --git a/libc/sysdeps/linux/common/Makefile.in b/libc/sysdeps/linux/common/Makefile.in
index a175ab6..9d41771 100644
--- a/libc/sysdeps/linux/common/Makefile.in
+++ b/libc/sysdeps/linux/common/Makefile.in
@@ -25,6 +25,8 @@ CSRC-$(UCLIBC_LINUX_SPECIFIC) += \
 	capset.c \
 	dup3.c \
 	eventfd.c \
+	eventfd_read.c \
+	eventfd_write.c \
 	inotify.c \
 	ioperm.c \
 	iopl.c \
diff --git a/libc/sysdeps/linux/common/eventfd.c b/libc/sysdeps/linux/common/eventfd.c
index 96597ab..500b0c0 100644
--- a/libc/sysdeps/linux/common/eventfd.c
+++ b/libc/sysdeps/linux/common/eventfd.c
@@ -15,7 +15,7 @@
  * eventfd()
  */
 #if defined __NR_eventfd || defined __NR_eventfd2
-int eventfd (int count, int flags)
+int eventfd (unsigned int count, int flags)
 {
 #if defined __NR_eventfd2
   return INLINE_SYSCALL (eventfd2, 2, count, flags);
diff --git a/libc/sysdeps/linux/sparc/bits/eventfd.h b/libc/sysdeps/linux/common/eventfd_read.c
similarity index 65%
copy from libc/sysdeps/linux/sparc/bits/eventfd.h
copy to libc/sysdeps/linux/common/eventfd_read.c
index bed9f09..75f2aaa 100644
--- a/libc/sysdeps/linux/sparc/bits/eventfd.h
+++ b/libc/sysdeps/linux/common/eventfd_read.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2007-2013 Free Software Foundation, Inc.
+/* Copyright (C) 2007-2014 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -15,17 +15,13 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#ifndef	_SYS_EVENTFD_H
-# error "Never use <bits/eventfd.h> directly; include <sys/eventfd.h> instead."
-#endif
+#include <errno.h>
+#include <unistd.h>
+#include <sys/eventfd.h>
 
-/* Flags for eventfd.  */
-enum
-  {
-    EFD_SEMAPHORE = 1,
-#define EFD_SEMAPHORE EFD_SEMAPHORE
-    EFD_CLOEXEC = 0x400000,
-#define EFD_CLOEXEC EFD_CLOEXEC
-    EFD_NONBLOCK = 0x004000
-#define EFD_NONBLOCK EFD_NONBLOCK
-  };
+
+int
+eventfd_read (int fd, eventfd_t *value)
+{
+  return read (fd, value, sizeof (eventfd_t)) != sizeof (eventfd_t) ? -1 : 0;
+}
diff --git a/libc/sysdeps/linux/sparc/bits/eventfd.h b/libc/sysdeps/linux/common/eventfd_write.c
similarity index 65%
copy from libc/sysdeps/linux/sparc/bits/eventfd.h
copy to libc/sysdeps/linux/common/eventfd_write.c
index bed9f09..e1509cf 100644
--- a/libc/sysdeps/linux/sparc/bits/eventfd.h
+++ b/libc/sysdeps/linux/common/eventfd_write.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2007-2013 Free Software Foundation, Inc.
+/* Copyright (C) 2007-2014 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -15,17 +15,14 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#ifndef	_SYS_EVENTFD_H
-# error "Never use <bits/eventfd.h> directly; include <sys/eventfd.h> instead."
-#endif
+#include <errno.h>
+#include <unistd.h>
+#include <sys/eventfd.h>
 
-/* Flags for eventfd.  */
-enum
-  {
-    EFD_SEMAPHORE = 1,
-#define EFD_SEMAPHORE EFD_SEMAPHORE
-    EFD_CLOEXEC = 0x400000,
-#define EFD_CLOEXEC EFD_CLOEXEC
-    EFD_NONBLOCK = 0x004000
-#define EFD_NONBLOCK EFD_NONBLOCK
-  };
+
+int
+eventfd_write (int fd, eventfd_t value)
+{
+  return write (fd, &value,
+		sizeof (eventfd_t)) != sizeof (eventfd_t) ? -1 : 0;
+}
diff --git a/libc/sysdeps/linux/common/sys/eventfd.h b/libc/sysdeps/linux/common/sys/eventfd.h
index 1bf785f..a47b5fe 100644
--- a/libc/sysdeps/linux/common/sys/eventfd.h
+++ b/libc/sysdeps/linux/common/sys/eventfd.h
@@ -31,9 +31,7 @@ __BEGIN_DECLS
 
 /* Return file descriptor for generic event channel.  Set initial
    value to COUNT.  */
-extern int eventfd (int __count, int __flags) __THROW;
-
-#if 0 /* not (yet) implemented in uClibc */
+extern int eventfd (unsigned int __count, int __flags) __THROW;
 
 /* Read event counter and possibly wait for events.  */
 extern int eventfd_read (int __fd, eventfd_t *__value);
@@ -41,8 +39,6 @@ extern int eventfd_read (int __fd, eventfd_t *__value);
 /* Increment event counter.  */
 extern int eventfd_write (int __fd, eventfd_t __value);
 
-#endif
-
 __END_DECLS
 
 #endif /* sys/eventfd.h */
diff --git a/libc/sysdeps/linux/sparc/bits/eventfd.h b/libc/sysdeps/linux/sparc/bits/eventfd.h
index bed9f09..e348cc6 100644
--- a/libc/sysdeps/linux/sparc/bits/eventfd.h
+++ b/libc/sysdeps/linux/sparc/bits/eventfd.h
@@ -22,7 +22,7 @@
 /* Flags for eventfd.  */
 enum
   {
-    EFD_SEMAPHORE = 1,
+    EFD_SEMAPHORE = 0x000001,
 #define EFD_SEMAPHORE EFD_SEMAPHORE
     EFD_CLOEXEC = 0x400000,
 #define EFD_CLOEXEC EFD_CLOEXEC


More information about the uClibc-cvs mailing list