fdtrack: add wrapper for eventfd.

Bug: https://issuetracker.google.com/154450436
Test: bionic-unit-tests
Change-Id: I59013f0c4da0debbcc50269c64ae9db0cdc4eaa0
This commit is contained in:
Josh Gao 2020-04-29 17:08:46 -07:00
parent a38331d833
commit 7de412443d
5 changed files with 17 additions and 6 deletions

View File

@ -1022,8 +1022,7 @@ cc_library_static {
"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",

View File

@ -312,7 +312,7 @@ int __epoll_create1:epoll_create1(int) all
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

View File

@ -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;
}

View File

@ -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;
}

View File

@ -23,6 +23,7 @@
#include <netinet/in.h>
#include <stdlib.h>
#include <sys/epoll.h>
#include <sys/eventfd.h>
#include <sys/types.h>
#include <unistd.h>
@ -205,6 +206,8 @@ FDTRACK_TEST(pipe2, ({
FDTRACK_TEST(epoll_create, epoll_create(1));
FDTRACK_TEST(epoll_create1, epoll_create1(0));
FDTRACK_TEST(eventfd, eventfd(0, 0));
#if 0
// Why is this generating an extra socket/close event?
FDTRACK_TEST(accept, ({