summaryrefslogtreecommitdiff
path: root/libc
diff options
context:
space:
mode:
authorJosh Gao <jmgao@google.com>2020-04-30 03:00:49 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2020-04-30 03:00:49 +0000
commit797cc656bcd8c7d1325e2cb1376e6f10947666cf (patch)
tree76e44fec0b88514f7db56e595129ad6fa4a41478 /libc
parente0e399c24d568ace1f76dca1f3511a6ebe4e67b4 (diff)
parentc85598a2f20d8fff1a44c3cbab8b5d55623573dc (diff)
Merge changes I8b25accf,I59013f0c,I6c881e5d,I66826f31,I552692ae, ... am: 4d0c40be89 am: 68ab0fb97c am: 4522336e86 am: c85598a2f2
Change-Id: I603e5cf887be89c6316eefd2f49e0c67a772120e
Diffstat (limited to 'libc')
-rw-r--r--libc/Android.bp4
-rw-r--r--libc/SYSCALLS.TXT10
-rw-r--r--libc/bionic/eventfd.cpp (renamed from libc/bionic/eventfd_read.cpp)12
-rw-r--r--libc/bionic/eventfd_write.cpp3
-rw-r--r--libc/bionic/pipe.cpp20
-rw-r--r--libc/bionic/socketpair.cpp43
-rw-r--r--libc/bionic/sys_epoll.cpp8
7 files changed, 88 insertions, 12 deletions
diff --git a/libc/Android.bp b/libc/Android.bp
index f73ae4a58..d5d0afbbe 100644
--- a/libc/Android.bp
+++ b/libc/Android.bp
@@ -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",
@@ -1114,6 +1113,7 @@ cc_library_static {
"bionic/signal.cpp",
"bionic/sigprocmask.cpp",
"bionic/sleep.cpp",
+ "bionic/socketpair.cpp",
"bionic/spawn.cpp",
"bionic/stat.cpp",
"bionic/stdlib_l.cpp",
diff --git a/libc/SYSCALLS.TXT b/libc/SYSCALLS.TXT
index ab309e629..6142bafb0 100644
--- a/libc/SYSCALLS.TXT
+++ b/libc/SYSCALLS.TXT
@@ -126,7 +126,7 @@ int __fcntl64:fcntl64(int, int, void*) lp32
int __fcntl:fcntl(int, int, void*) lp64
int flock(int, int) all
int __fchmod:fchmod(int, mode_t) all
-int pipe2(int*, int) all
+int __pipe2:pipe2(int*, int) all
int __dup:dup(int) all
int __dup3:dup3(int, int, int) all
int fsync(int) all
@@ -243,7 +243,7 @@ int __signalfd4:signalfd4(int, const sigset64_t*, size_t, int) all
# sockets
int __socket:socket(int, int, int) arm,lp64
-int socketpair(int, int, int, int*) arm,lp64
+int __socketpair:socketpair(int, int, int, int*) arm,lp64
int bind(int, struct sockaddr*, socklen_t) arm,lp64
int __connect:connect(int, struct sockaddr*, socklen_t) arm,lp64
int listen(int, int) arm,lp64
@@ -267,7 +267,7 @@ int __connect:socketcall:3(int, struct sockaddr*, socklen_t) x86
int listen:socketcall:4(int, int) x86
int getsockname:socketcall:6(int, struct sockaddr*, socklen_t*) x86
int getpeername:socketcall:7(int, struct sockaddr*, socklen_t*) x86
-int socketpair:socketcall:8(int, int, int, int*) x86
+int __socketpair:socketcall:8(int, int, int, int*) x86
ssize_t __sendto:socketcall:11(int, const void*, size_t, int, const struct sockaddr*, socklen_t) x86
ssize_t recvfrom:socketcall:12(int, void*, size_t, unsigned int, struct sockaddr*, socklen_t*) x86
int shutdown:socketcall:13(int, int) x86
@@ -308,11 +308,11 @@ ssize_t tee(int, int, size_t, unsigned int) all
ssize_t splice(int, off64_t*, int, off64_t*, size_t, unsigned int) all
ssize_t vmsplice(int, const struct iovec*, size_t, unsigned int) all
-int epoll_create1(int) all
+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
diff --git a/libc/bionic/eventfd_read.cpp b/libc/bionic/eventfd.cpp
index 50e73fd54..f13c6a309 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 3c3d3f1cc..6d86d8ca9 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;
-}
diff --git a/libc/bionic/pipe.cpp b/libc/bionic/pipe.cpp
index a81afe8e0..f1976568f 100644
--- a/libc/bionic/pipe.cpp
+++ b/libc/bionic/pipe.cpp
@@ -28,6 +28,24 @@
#include <unistd.h>
+#include "private/bionic_fdtrack.h"
+
+extern "C" int __pipe2(int pipefd[2], int flags);
+
int pipe(int pipefd[2]) {
- return pipe2(pipefd, 0);
+ int rc = __pipe2(pipefd, 0);
+ if (rc == 0) {
+ FDTRACK_CREATE(pipefd[0]);
+ FDTRACK_CREATE(pipefd[1]);
+ }
+ return rc;
+}
+
+int pipe2(int pipefd[2], int flags) {
+ int rc = __pipe2(pipefd, flags);
+ if (rc == 0) {
+ FDTRACK_CREATE(pipefd[0]);
+ FDTRACK_CREATE(pipefd[1]);
+ }
+ return rc;
}
diff --git a/libc/bionic/socketpair.cpp b/libc/bionic/socketpair.cpp
new file mode 100644
index 000000000..d2b4c1907
--- /dev/null
+++ b/libc/bionic/socketpair.cpp
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/socket.h>
+#include <unistd.h>
+
+#include "private/bionic_fdtrack.h"
+
+extern "C" int __socketpair(int domain, int type, int protocol, int sv[2]);
+
+int socketpair(int domain, int type, int protocol, int sv[2]) {
+ int rc = __socketpair(domain, type, protocol, sv);
+ if (rc == 0) {
+ FDTRACK_CREATE(sv[0]);
+ FDTRACK_CREATE(sv[1]);
+ }
+ return rc;
+}
diff --git a/libc/bionic/sys_epoll.cpp b/libc/bionic/sys_epoll.cpp
index 9f829127f..22d0a98d7 100644
--- a/libc/bionic/sys_epoll.cpp
+++ b/libc/bionic/sys_epoll.cpp
@@ -30,7 +30,9 @@
#include <sys/epoll.h>
#include "private/SigSetConverter.h"
+#include "private/bionic_fdtrack.h"
+extern "C" int __epoll_create1(int flags);
extern "C" int __epoll_pwait(int, epoll_event*, int, int, const sigset64_t*, size_t);
int epoll_create(int size) {
@@ -38,7 +40,11 @@ int epoll_create(int size) {
errno = EINVAL;
return -1;
}
- return epoll_create1(0);
+ return FDTRACK_CREATE(__epoll_create1(0));
+}
+
+int epoll_create1(int flags) {
+ return FDTRACK_CREATE(__epoll_create1(flags));
}
int epoll_pwait(int fd, epoll_event* events, int max_events, int timeout, const sigset_t* ss) {