diff options
| author | Chaoren Lin <chaorenl@google.com> | 2015-07-15 19:22:12 +0000 |
|---|---|---|
| committer | Chaoren Lin <chaorenl@google.com> | 2015-07-15 19:22:12 +0000 |
| commit | e271658ec1d7ef546d44c70f72baaa26d5903cec (patch) | |
| tree | 1d3fdac6b1758b07c4207a65b197fa37a6c2f0b6 | |
| parent | f7ee0870aeae2667e7b0c4b580e96407622727dd (diff) | |
| download | bcm5719-llvm-e271658ec1d7ef546d44c70f72baaa26d5903cec.tar.gz bcm5719-llvm-e271658ec1d7ef546d44c70f72baaa26d5903cec.zip | |
Use accept instead of accept4 for Android.
Summary:
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.
Reviewers: vharron, tberghammer, labath
Subscribers: ovyalov, chaoren, labath, tberghammer, aemerson, lldb-commits
Differential Revision: http://reviews.llvm.org/D10887
llvm-svn: 242319
| -rw-r--r-- | lldb/cmake/platforms/Android.cmake | 4 | ||||
| -rw-r--r-- | lldb/source/Host/common/Socket.cpp | 21 |
2 files changed, 23 insertions, 2 deletions
diff --git a/lldb/cmake/platforms/Android.cmake b/lldb/cmake/platforms/Android.cmake index 3374bcc7f0d..adf947a7a9c 100644 --- a/lldb/cmake/platforms/Android.cmake +++ b/lldb/cmake/platforms/Android.cmake @@ -102,6 +102,10 @@ elseif( ANDROID_ABI STREQUAL "armeabi" ) # 64 bit atomic operations used in c++ libraries require armv7-a instructions # armv5te and armv6 were tried but do not work. set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -march=armv7-a" ) + if ( LLVM_BUILD_STATIC ) + # Temporary workaround for static linking with the latest API. + set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -DANDROID_ARM_BUILD_STATIC" ) + endif() endif() # linker flags diff --git a/lldb/source/Host/common/Socket.cpp b/lldb/source/Host/common/Socket.cpp index f7e93c634a1..4be8b74658e 100644 --- a/lldb/source/Host/common/Socket.cpp +++ b/lldb/source/Host/common/Socket.cpp @@ -24,7 +24,11 @@ #include <asm-generic/errno-base.h> #include <errno.h> #include <arpa/inet.h> -#endif +#if defined(ANDROID_ARM_BUILD_STATIC) +#include <unistd.h> +#include <sys/syscall.h> +#endif // ANDROID_ARM_BUILD_STATIC +#endif // __ANDROID_NDK__ #ifndef LLDB_DISABLE_POSIX #include <arpa/inet.h> @@ -70,7 +74,20 @@ NativeSocket CreateSocket(const int domain, const int type, const int protocol, NativeSocket Accept(NativeSocket sockfd, struct sockaddr *addr, socklen_t *addrlen, bool child_processes_inherit) { -#ifdef SOCK_CLOEXEC +#if defined(ANDROID_ARM_BUILD_STATIC) + // Temporary workaround for statically linking Android lldb-server with the + // latest API. + int fd = syscall(__NR_accept, sockfd, addr, addrlen); + if (fd >= 0 && !child_processes_inherit) + { + int flags = ::fcntl(fd, F_GETFD); + if (flags == -1) + return -1; + if (::fcntl(fd, F_SETFD, flags | FD_CLOEXEC) == -1) + return -1; + } + return fd; +#elif defined(SOCK_CLOEXEC) int flags = 0; if (!child_processes_inherit) { flags |= SOCK_CLOEXEC; |

