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.

(cherry-pick of 8baa929d5d3bcf63381cf78ba76168c80c303f5e.)

Change-Id: Icd0eb0f4ce0511fb9ec00a504d491afd47d744d3
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;
 }