diff options
Diffstat (limited to 'libc')
-rw-r--r-- | libc/Android.bp | 6 | ||||
-rw-r--r-- | libc/SYSCALLS.TXT | 10 | ||||
-rw-r--r-- | libc/bionic/eventfd.cpp (renamed from libc/bionic/eventfd_read.cpp) | 12 | ||||
-rw-r--r-- | libc/bionic/eventfd_write.cpp | 3 | ||||
-rw-r--r-- | libc/bionic/pipe.cpp | 20 | ||||
-rw-r--r-- | libc/bionic/socketpair.cpp | 43 | ||||
-rw-r--r-- | libc/bionic/sys_epoll.cpp | 8 | ||||
-rw-r--r-- | libc/platform/bionic/mte_kernel.h | 3 |
8 files changed, 91 insertions, 14 deletions
diff --git a/libc/Android.bp b/libc/Android.bp index f73ae4a58..4c3663589 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", @@ -1751,6 +1751,7 @@ genrule { // Headers that only other parts of the platform can include. cc_library_headers { name: "bionic_libc_platform_headers", + defaults: ["linux_bionic_supported"], visibility: [ "//art:__subpackages__", "//bionic:__subpackages__", @@ -1762,7 +1763,6 @@ cc_library_headers { "//system/core/libunwindstack:__subpackages__", "//system/memory/libmemunreachable:__subpackages__", ], - host_supported: true, vendor_available: true, ramdisk_available: true, recovery_available: true, 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) { diff --git a/libc/platform/bionic/mte_kernel.h b/libc/platform/bionic/mte_kernel.h index d22d65eea..e8ef2a562 100644 --- a/libc/platform/bionic/mte_kernel.h +++ b/libc/platform/bionic/mte_kernel.h @@ -51,6 +51,7 @@ #define SEGV_MTEAERR 8 #define SEGV_MTESERR 9 -#define PTRACE_PEEKTAG 33 +#define PTRACE_PEEKMTETAGS 33 +#define PTRACE_POKEMTETAGS 34 #endif |