[Lldb-commits] [PATCH] Use accept instead of accept4 for Android.

Chaoren Lin chaorenl at google.com
Wed Jul 1 15:46:01 PDT 2015


Hi tberghammer, vharron,

The accept4 syscall is missing on older ARM Android kernels, and the accept()
call is implemented with the accept4 syscall, so we'll need to call the accept
syscall directly.

http://reviews.llvm.org/D10887

Files:
  source/Host/common/Socket.cpp

Index: source/Host/common/Socket.cpp
===================================================================
--- source/Host/common/Socket.cpp
+++ source/Host/common/Socket.cpp
@@ -24,6 +24,8 @@
 #include <asm-generic/errno-base.h>
 #include <errno.h>
 #include <arpa/inet.h>
+#include <unistd.h>
+#include <sys/syscall.h>
 #endif
 
 #ifndef LLDB_DISABLE_POSIX
@@ -70,7 +72,12 @@
 
 NativeSocket Accept(NativeSocket sockfd, struct sockaddr *addr, socklen_t *addrlen, bool child_processes_inherit)
 {
-#ifdef SOCK_CLOEXEC
+#if defined(__ANDROID_NDK__)
+	int fd = syscall(__NR_accept, sockfd, addr, addrlen);
+	if (fd >= 0 && !child_processes_inherit)
+		fcntl(fd, F_SETFD, FD_CLOEXEC);
+	return fd;
+#elif defined(SOCK_CLOEXEC)
     int flags = 0;
     if (!child_processes_inherit) {
         flags |= SOCK_CLOEXEC;

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D10887.28911.patch
Type: text/x-patch
Size: 812 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20150701/6b13bbdd/attachment.bin>


More information about the lldb-commits mailing list