am d2ac8787: am 49ec2a0c: Merge "Mark sockets on accept()."

* commit 'd2ac8787496422ee70e44f6e5abf65b570015470':
  Mark sockets on accept().
This commit is contained in:
Sreeram Ramachandran 2014-05-14 19:51:36 +00:00 committed by Android Git Automerger
commit 62090bb6b9
12 changed files with 45 additions and 15 deletions

View File

@ -98,6 +98,7 @@ libc_common_src_files += \
libc_bionic_src_files := \ libc_bionic_src_files := \
bionic/abort.cpp \ bionic/abort.cpp \
bionic/accept.cpp \
bionic/access.cpp \ bionic/access.cpp \
bionic/assert.cpp \ bionic/assert.cpp \
bionic/atof.cpp \ bionic/atof.cpp \

View File

@ -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 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 __connect:connect(int, struct sockaddr*, socklen_t) arm,arm64,mips,mips64,x86_64
int listen(int, int) 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 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 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 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 bind:socketcall:2(int, struct sockaddr*, int) x86
int __connect:socketcall:3(int, struct sockaddr*, socklen_t) x86 int __connect:socketcall:3(int, struct sockaddr*, socklen_t) x86
int listen:socketcall:4(int, int) 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 getsockname:socketcall:6(int, struct sockaddr*, socklen_t*) x86
int getpeername:socketcall:7(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

View File

@ -2,7 +2,7 @@
#include <private/bionic_asm.h> #include <private/bionic_asm.h>
ENTRY(accept) ENTRY(__accept)
mov ip, r7 mov ip, r7
ldr r7, =__NR_accept ldr r7, =__NR_accept
swi #0 swi #0
@ -11,4 +11,4 @@ ENTRY(accept)
bxls lr bxls lr
neg r0, r0 neg r0, r0
b __set_errno b __set_errno
END(accept) END(__accept)

View File

@ -2,7 +2,7 @@
#include <private/bionic_asm.h> #include <private/bionic_asm.h>
ENTRY(accept) ENTRY(__accept)
stp x29, x30, [sp, #-16]! stp x29, x30, [sp, #-16]!
mov x29, sp mov x29, sp
str x8, [sp, #-16]! str x8, [sp, #-16]!
@ -18,4 +18,5 @@ ENTRY(accept)
b.hi __set_errno b.hi __set_errno
ret ret
END(accept) END(__accept)
.hidden __accept

View File

@ -2,7 +2,7 @@
#include <private/bionic_asm.h> #include <private/bionic_asm.h>
ENTRY(accept) ENTRY(__accept)
.set noreorder .set noreorder
.cpload t9 .cpload t9
li v0, __NR_accept li v0, __NR_accept
@ -16,4 +16,4 @@ ENTRY(accept)
j t9 j t9
nop nop
.set reorder .set reorder
END(accept) END(__accept)

View File

@ -2,7 +2,7 @@
#include <private/bionic_asm.h> #include <private/bionic_asm.h>
ENTRY(accept) ENTRY(__accept)
.set push .set push
.set noreorder .set noreorder
li v0, __NR_accept li v0, __NR_accept
@ -22,4 +22,5 @@ ENTRY(accept)
j t9 j t9
move ra, t0 move ra, t0
.set pop .set pop
END(accept) END(__accept)
.hidden __accept

View File

@ -2,7 +2,7 @@
#include <private/bionic_asm.h> #include <private/bionic_asm.h>
ENTRY(accept) ENTRY(__accept)
pushl %ebx pushl %ebx
pushl %ecx pushl %ecx
.cfi_def_cfa_offset 8 .cfi_def_cfa_offset 8
@ -24,4 +24,4 @@ ENTRY(accept)
popl %ecx popl %ecx
popl %ebx popl %ebx
ret ret
END(accept) END(__accept)

View File

@ -2,7 +2,7 @@
#include <private/bionic_asm.h> #include <private/bionic_asm.h>
ENTRY(accept) ENTRY(__accept)
movl $__NR_accept, %eax movl $__NR_accept, %eax
syscall syscall
cmpq $-MAX_ERRNO, %rax cmpq $-MAX_ERRNO, %rax
@ -13,4 +13,5 @@ ENTRY(accept)
orq $-1, %rax orq $-1, %rax
1: 1:
ret ret
END(accept) END(__accept)
.hidden __accept

View File

@ -40,6 +40,7 @@ static void netdClientInitImpl() {
// default implementations of functions that it would've overridden. // default implementations of functions that it would've overridden.
return; return;
} }
netdClientInitFunction(netdClientHandle, "netdClientInitAccept", &__netdClientDispatch.accept);
netdClientInitFunction(netdClientHandle, "netdClientInitConnect", netdClientInitFunction(netdClientHandle, "netdClientInitConnect",
&__netdClientDispatch.connect); &__netdClientDispatch.connect);
} }

View File

@ -22,8 +22,10 @@
#define __socketcall #define __socketcall
#endif #endif
extern "C" __socketcall int __accept(int, sockaddr*, socklen_t*);
extern "C" __socketcall int __connect(int, const sockaddr*, socklen_t); extern "C" __socketcall int __connect(int, const sockaddr*, socklen_t);
NetdClientDispatch __netdClientDispatch __attribute__((aligned(32))) = { NetdClientDispatch __netdClientDispatch __attribute__((aligned(32))) = {
__connect __accept,
__connect,
}; };

22
libc/bionic/accept.cpp Normal file
View File

@ -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 <private/NetdClient.h>
#include <sys/socket.h>
int accept(int sockfd, sockaddr* addr, socklen_t* addrlen) {
return __netdClientDispatch.accept(sockfd, addr, addrlen);
}

View File

@ -20,6 +20,7 @@
#include <sys/socket.h> #include <sys/socket.h>
struct NetdClientDispatch { struct NetdClientDispatch {
int (*accept)(int, sockaddr*, socklen_t*);
int (*connect)(int, const sockaddr*, socklen_t); int (*connect)(int, const sockaddr*, socklen_t);
}; };