Prevent name conflict for eventfd.cpp and eventfd.s when building libc.a

 - eventfd.cpp and eventfd.s will output to the same file when building libc.a
   out/target/product/*/obj/STATIC_LIBRARIES/libc_intermediates/WHOLE/libc_common_objs/eventfd.o
 - And then `eventfd` will undefined when statically linked to libc.

Also add a unit test.

Change-Id: Ib310ade3256712ca617a90539e8eb07459c98505
diff --git a/libc/Android.mk b/libc/Android.mk
index c47cc67..3c387d2 100644
--- a/libc/Android.mk
+++ b/libc/Android.mk
@@ -238,7 +238,8 @@
     bionic/brk.cpp \
     bionic/dirent.cpp \
     bionic/__errno.c \
-    bionic/eventfd.cpp \
+    bionic/eventfd_read.cpp \
+    bionic/eventfd_write.cpp \
     bionic/__fgets_chk.cpp \
     bionic/getauxval.cpp \
     bionic/getcwd.cpp \
diff --git a/libc/bionic/eventfd.cpp b/libc/bionic/eventfd_read.cpp
similarity index 75%
rename from libc/bionic/eventfd.cpp
rename to libc/bionic/eventfd_read.cpp
index fc7a6b9..50e73fd 100644
--- a/libc/bionic/eventfd.cpp
+++ b/libc/bionic/eventfd_read.cpp
@@ -29,25 +29,6 @@
 #include <sys/eventfd.h>
 #include <unistd.h>
 
-/* We duplicate the GLibc error semantics, which are poorly defined
- * if the read() or write() does not return the proper number of bytes.
- */
-int eventfd_read(int fd, eventfd_t *counter)
-{
-    int ret = read(fd, counter, sizeof(*counter));
-
-    if (ret == sizeof(*counter))
-        return 0;
-
-    return -1;
-}
-
-int eventfd_write(int fd, eventfd_t counter)
-{
-    int ret = write(fd, &counter, sizeof(counter));
-
-    if (ret == sizeof(counter))
-        return 0;
-
-    return -1;
+int eventfd_read(int fd, eventfd_t* value) {
+  return (read(fd, value, sizeof(*value)) == sizeof(*value)) ? 0 : -1;
 }
diff --git a/libc/bionic/eventfd.cpp b/libc/bionic/eventfd_write.cpp
similarity index 74%
copy from libc/bionic/eventfd.cpp
copy to libc/bionic/eventfd_write.cpp
index fc7a6b9..3c3d3f1 100644
--- a/libc/bionic/eventfd.cpp
+++ b/libc/bionic/eventfd_write.cpp
@@ -29,25 +29,6 @@
 #include <sys/eventfd.h>
 #include <unistd.h>
 
-/* We duplicate the GLibc error semantics, which are poorly defined
- * if the read() or write() does not return the proper number of bytes.
- */
-int eventfd_read(int fd, eventfd_t *counter)
-{
-    int ret = read(fd, counter, sizeof(*counter));
-
-    if (ret == sizeof(*counter))
-        return 0;
-
-    return -1;
-}
-
-int eventfd_write(int fd, eventfd_t counter)
-{
-    int ret = write(fd, &counter, sizeof(counter));
-
-    if (ret == sizeof(counter))
-        return 0;
-
-    return -1;
+int eventfd_write(int fd, eventfd_t value) {
+  return (write(fd, &value, sizeof(value)) == sizeof(value)) ? 0 : -1;
 }
diff --git a/libc/include/sys/eventfd.h b/libc/include/sys/eventfd.h
index 19244a5..ec84e27 100644
--- a/libc/include/sys/eventfd.h
+++ b/libc/include/sys/eventfd.h
@@ -33,17 +33,16 @@
 
 __BEGIN_DECLS
 
-#define  EFD_CLOEXEC   O_CLOEXEC
-#define  EFD_NONBLOCK  O_NONBLOCK
+#define EFD_CLOEXEC O_CLOEXEC
+#define EFD_NONBLOCK O_NONBLOCK
 
 /* type of event counter */
-typedef uint64_t  eventfd_t;
+typedef uint64_t eventfd_t;
 
-extern int eventfd(unsigned int initval, int flags);
+extern int eventfd(unsigned int initial_value, int flags);
 
-/* Compatibility with GLibc */
-extern int eventfd_read(int fd, eventfd_t *counter);
-extern int eventfd_write(int fd, const eventfd_t counter);
+extern int eventfd_read(int fd, eventfd_t* value);
+extern int eventfd_write(int fd, eventfd_t value);
 
 __END_DECLS