Commit 3c1aca11 authored by topjohnwu's avatar topjohnwu

Wrap accept4 since some device does not have it

parent 18d0fd9d
...@@ -174,15 +174,16 @@ int xlisten(int sockfd, int backlog) { ...@@ -174,15 +174,16 @@ int xlisten(int sockfd, int backlog) {
} }
int xaccept4(int sockfd, struct sockaddr *addr, socklen_t *addrlen, int flags) { int xaccept4(int sockfd, struct sockaddr *addr, socklen_t *addrlen, int flags) {
#ifndef __NR_accept4 int fd = accept(sockfd, addr, addrlen);
#ifdef __i386__
#define __NR_accept4 364
#endif
#endif
int fd = (int) syscall(__NR_accept4, sockfd, addr, addrlen, flags);
if (fd == -1) { if (fd == -1) {
PLOGE("accept4"); PLOGE("accept4");
} }
if (flags & SOCK_CLOEXEC)
fcntl(fd, F_SETFD, FD_CLOEXEC);
if (flags & SOCK_NONBLOCK) {
int i = fcntl(fd, F_GETFL);
fcntl(fd, F_SETFL, i | O_NONBLOCK);
}
return fd; return fd;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment