fdtrack: add wrapper for eventfd.
Bug: https://issuetracker.google.com/154450436
Test: bionic-unit-tests
Change-Id: I59013f0c4da0debbcc50269c64ae9db0cdc4eaa0
diff --git a/libc/Android.bp b/libc/Android.bp
index f73ae4a..ac961d4 100644
--- a/libc/Android.bp
+++ b/libc/Android.bp
@@ -1022,8 +1022,7 @@
"bionic/dup.cpp",
"bionic/environ.cpp",
"bionic/error.cpp",
- "bionic/eventfd_read.cpp",
- "bionic/eventfd_write.cpp",
+ "bionic/eventfd.cpp",
"bionic/exec.cpp",
"bionic/faccessat.cpp",
"bionic/fchmod.cpp",
diff --git a/libc/SYSCALLS.TXT b/libc/SYSCALLS.TXT
index e8445fd..f235bc8 100644
--- a/libc/SYSCALLS.TXT
+++ b/libc/SYSCALLS.TXT
@@ -312,7 +312,7 @@
int epoll_ctl(int, int op, int, struct epoll_event*) all
int __epoll_pwait:epoll_pwait(int, struct epoll_event*, int, int, const sigset64_t*, size_t) all
-int eventfd:eventfd2(unsigned int, int) all
+int __eventfd:eventfd2(unsigned int, int) all
void _exit|_Exit:exit_group(int) all
void __exit:exit(int) all
diff --git a/libc/bionic/eventfd_read.cpp b/libc/bionic/eventfd.cpp
similarity index 82%
rename from libc/bionic/eventfd_read.cpp
rename to libc/bionic/eventfd.cpp
index 50e73fd..f13c6a3 100644
--- a/libc/bionic/eventfd_read.cpp
+++ b/libc/bionic/eventfd.cpp
@@ -29,6 +29,18 @@
#include <sys/eventfd.h>
#include <unistd.h>
+#include "private/bionic_fdtrack.h"
+
+extern "C" int __eventfd(unsigned int initval, int flags);
+
+int eventfd(unsigned int initval, int flags) {
+ return FDTRACK_CREATE(__eventfd(initval, flags));
+}
+
int eventfd_read(int fd, eventfd_t* value) {
return (read(fd, value, sizeof(*value)) == sizeof(*value)) ? 0 : -1;
}
+
+int eventfd_write(int fd, eventfd_t value) {
+ return (write(fd, &value, sizeof(value)) == sizeof(value)) ? 0 : -1;
+}
diff --git a/libc/bionic/eventfd_write.cpp b/libc/bionic/eventfd_write.cpp
index 3c3d3f1..6d86d8c 100644
--- a/libc/bionic/eventfd_write.cpp
+++ b/libc/bionic/eventfd_write.cpp
@@ -29,6 +29,3 @@
#include <sys/eventfd.h>
#include <unistd.h>
-int eventfd_write(int fd, eventfd_t value) {
- return (write(fd, &value, sizeof(value)) == sizeof(value)) ? 0 : -1;
-}