diff --git a/libc/Android.mk b/libc/Android.mk index c0da9b2a1..2d56af052 100644 --- a/libc/Android.mk +++ b/libc/Android.mk @@ -98,6 +98,7 @@ libc_common_src_files += \ libc_bionic_src_files := \ bionic/abort.cpp \ + bionic/accept.cpp \ bionic/access.cpp \ bionic/assert.cpp \ bionic/atof.cpp \ diff --git a/libc/SYSCALLS.TXT b/libc/SYSCALLS.TXT index e9fb57522..83feb65c7 100644 --- a/libc/SYSCALLS.TXT +++ b/libc/SYSCALLS.TXT @@ -236,7 +236,7 @@ int socketpair(int, int, int, int*) arm,arm64,mips,mips64,x86_64 int bind(int, struct sockaddr*, int) arm,arm64,mips,mips64,x86_64 int __connect:connect(int, struct sockaddr*, socklen_t) arm,arm64,mips,mips64,x86_64 int listen(int, int) arm,arm64,mips,mips64,x86_64 -int accept(int, struct sockaddr*, socklen_t*) arm,arm64,mips,mips64,x86_64 +int __accept:accept(int, struct sockaddr*, socklen_t*) arm,arm64,mips,mips64,x86_64 int accept4(int, struct sockaddr*, socklen_t*, int) arm,arm64,mips,mips64,x86_64 int getsockname(int, struct sockaddr*, socklen_t*) arm,arm64,mips,mips64,x86_64 int getpeername(int, struct sockaddr*, socklen_t*) arm,arm64,mips,mips64,x86_64 @@ -255,7 +255,7 @@ int socket:socketcall:1(int, int, int) x86 int bind:socketcall:2(int, struct sockaddr*, int) x86 int __connect:socketcall:3(int, struct sockaddr*, socklen_t) x86 int listen:socketcall:4(int, int) x86 -int accept:socketcall:5(int, struct sockaddr*, socklen_t*) x86 +int __accept:socketcall:5(int, struct sockaddr*, socklen_t*) 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 diff --git a/libc/arch-arm/syscalls/accept.S b/libc/arch-arm/syscalls/__accept.S similarity index 89% rename from libc/arch-arm/syscalls/accept.S rename to libc/arch-arm/syscalls/__accept.S index e2a51f5db..bae11bcb7 100644 --- a/libc/arch-arm/syscalls/accept.S +++ b/libc/arch-arm/syscalls/__accept.S @@ -2,7 +2,7 @@ #include -ENTRY(accept) +ENTRY(__accept) mov ip, r7 ldr r7, =__NR_accept swi #0 @@ -11,4 +11,4 @@ ENTRY(accept) bxls lr neg r0, r0 b __set_errno -END(accept) +END(__accept) diff --git a/libc/arch-arm64/syscalls/accept.S b/libc/arch-arm64/syscalls/__accept.S similarity index 88% rename from libc/arch-arm64/syscalls/accept.S rename to libc/arch-arm64/syscalls/__accept.S index dae6121f2..21b68bc6b 100644 --- a/libc/arch-arm64/syscalls/accept.S +++ b/libc/arch-arm64/syscalls/__accept.S @@ -2,7 +2,7 @@ #include -ENTRY(accept) +ENTRY(__accept) stp x29, x30, [sp, #-16]! mov x29, sp str x8, [sp, #-16]! @@ -18,4 +18,5 @@ ENTRY(accept) b.hi __set_errno ret -END(accept) +END(__accept) +.hidden __accept diff --git a/libc/arch-mips/syscalls/accept.S b/libc/arch-mips/syscalls/__accept.S similarity index 89% rename from libc/arch-mips/syscalls/accept.S rename to libc/arch-mips/syscalls/__accept.S index 09496abdc..d8141feee 100644 --- a/libc/arch-mips/syscalls/accept.S +++ b/libc/arch-mips/syscalls/__accept.S @@ -2,7 +2,7 @@ #include -ENTRY(accept) +ENTRY(__accept) .set noreorder .cpload t9 li v0, __NR_accept @@ -16,4 +16,4 @@ ENTRY(accept) j t9 nop .set reorder -END(accept) +END(__accept) diff --git a/libc/arch-mips64/syscalls/accept.S b/libc/arch-mips64/syscalls/__accept.S similarity index 87% rename from libc/arch-mips64/syscalls/accept.S rename to libc/arch-mips64/syscalls/__accept.S index 6c3855698..4404a6862 100644 --- a/libc/arch-mips64/syscalls/accept.S +++ b/libc/arch-mips64/syscalls/__accept.S @@ -2,7 +2,7 @@ #include -ENTRY(accept) +ENTRY(__accept) .set push .set noreorder li v0, __NR_accept @@ -22,4 +22,5 @@ ENTRY(accept) j t9 move ra, t0 .set pop -END(accept) +END(__accept) +.hidden __accept diff --git a/libc/arch-x86/syscalls/accept.S b/libc/arch-x86/syscalls/__accept.S similarity index 94% rename from libc/arch-x86/syscalls/accept.S rename to libc/arch-x86/syscalls/__accept.S index f7e8a58eb..31cb35001 100644 --- a/libc/arch-x86/syscalls/accept.S +++ b/libc/arch-x86/syscalls/__accept.S @@ -2,7 +2,7 @@ #include -ENTRY(accept) +ENTRY(__accept) pushl %ebx pushl %ecx .cfi_def_cfa_offset 8 @@ -24,4 +24,4 @@ ENTRY(accept) popl %ecx popl %ebx ret -END(accept) +END(__accept) diff --git a/libc/arch-x86_64/syscalls/accept.S b/libc/arch-x86_64/syscalls/__accept.S similarity index 85% rename from libc/arch-x86_64/syscalls/accept.S rename to libc/arch-x86_64/syscalls/__accept.S index 588fb8231..ff0f5e765 100644 --- a/libc/arch-x86_64/syscalls/accept.S +++ b/libc/arch-x86_64/syscalls/__accept.S @@ -2,7 +2,7 @@ #include -ENTRY(accept) +ENTRY(__accept) movl $__NR_accept, %eax syscall cmpq $-MAX_ERRNO, %rax @@ -13,4 +13,5 @@ ENTRY(accept) orq $-1, %rax 1: ret -END(accept) +END(__accept) +.hidden __accept diff --git a/libc/bionic/NetdClient.cpp b/libc/bionic/NetdClient.cpp index 6826ee8ee..72d90b7bb 100644 --- a/libc/bionic/NetdClient.cpp +++ b/libc/bionic/NetdClient.cpp @@ -40,6 +40,7 @@ static void netdClientInitImpl() { // default implementations of functions that it would've overridden. return; } + netdClientInitFunction(netdClientHandle, "netdClientInitAccept", &__netdClientDispatch.accept); netdClientInitFunction(netdClientHandle, "netdClientInitConnect", &__netdClientDispatch.connect); } diff --git a/libc/bionic/NetdClientDispatch.cpp b/libc/bionic/NetdClientDispatch.cpp index 31728d2fe..adfe16d7f 100644 --- a/libc/bionic/NetdClientDispatch.cpp +++ b/libc/bionic/NetdClientDispatch.cpp @@ -22,8 +22,10 @@ #define __socketcall #endif +extern "C" __socketcall int __accept(int, sockaddr*, socklen_t*); extern "C" __socketcall int __connect(int, const sockaddr*, socklen_t); NetdClientDispatch __netdClientDispatch __attribute__((aligned(32))) = { - __connect + __accept, + __connect, }; diff --git a/libc/bionic/accept.cpp b/libc/bionic/accept.cpp new file mode 100644 index 000000000..46b4efc65 --- /dev/null +++ b/libc/bionic/accept.cpp @@ -0,0 +1,22 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include + +int accept(int sockfd, sockaddr* addr, socklen_t* addrlen) { + return __netdClientDispatch.accept(sockfd, addr, addrlen); +} diff --git a/libc/private/NetdClient.h b/libc/private/NetdClient.h index 48c05cb9d..b2ce7a664 100644 --- a/libc/private/NetdClient.h +++ b/libc/private/NetdClient.h @@ -20,6 +20,7 @@ #include struct NetdClientDispatch { + int (*accept)(int, sockaddr*, socklen_t*); int (*connect)(int, const sockaddr*, socklen_t); };