Fix Android build of gtest and lib/Support.
authorEvgeniy Stepanov <eugeni.stepanov@gmail.com>
Tue, 4 Sep 2012 09:14:45 +0000 (09:14 +0000)
committerEvgeniy Stepanov <eugeni.stepanov@gmail.com>
Tue, 4 Sep 2012 09:14:45 +0000 (09:14 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@163131 91177308-0d34-0410-b5e6-96231b3b80d8

cmake/config-ix.cmake
lib/Support/DynamicLibrary.cpp
lib/Support/LockFileManager.cpp
utils/unittest/googletest/include/gtest/internal/gtest-port.h

index 9637363d38c984e725a4a97131dc70f2824a3f6d..fcd5dd556676cdcc26663b7b60ac3ecd05d71b02 100755 (executable)
@@ -85,9 +85,19 @@ check_include_file(mach-o/dyld.h HAVE_MACH_O_DYLD_H)
 # library checks
 if( NOT PURE_WINDOWS )
   check_library_exists(pthread pthread_create "" HAVE_LIBPTHREAD)
-  check_library_exists(pthread pthread_getspecific "" HAVE_PTHREAD_GETSPECIFIC)
-  check_library_exists(pthread pthread_rwlock_init "" HAVE_PTHREAD_RWLOCK_INIT)
-  check_library_exists(pthread pthread_mutex_lock "" HAVE_PTHREAD_MUTEX_LOCK)
+  if (HAVE_LIBPTHREAD)
+    check_library_exists(pthread pthread_getspecific "" HAVE_PTHREAD_GETSPECIFIC)
+    check_library_exists(pthread pthread_rwlock_init "" HAVE_PTHREAD_RWLOCK_INIT)
+    check_library_exists(pthread pthread_mutex_lock "" HAVE_PTHREAD_MUTEX_LOCK)
+  else()
+    # this could be Android
+    check_library_exists(c pthread_create "" PTHREAD_IN_LIBC)
+    if (PTHREAD_IN_LIBC)
+      check_library_exists(c pthread_getspecific "" HAVE_PTHREAD_GETSPECIFIC)
+      check_library_exists(c pthread_rwlock_init "" HAVE_PTHREAD_RWLOCK_INIT)
+      check_library_exists(c pthread_mutex_lock "" HAVE_PTHREAD_MUTEX_LOCK)
+    endif()
+  endif()
   check_library_exists(dl dlopen "" HAVE_LIBDL)
 endif()
 
index fb02c07e4af81e81221d720289ed6ea2061b9144..45fec361c1a6cf26b1768f10032c025fbfe62be4 100644 (file)
@@ -160,7 +160,7 @@ void* DynamicLibrary::SearchForAddressOfSymbol(const char *symbolName) {
 // On linux we have a weird situation. The stderr/out/in symbols are both
 // macros and global variables because of standards requirements. So, we
 // boldly use the EXPLICIT_SYMBOL macro without checking for a #define first.
-#if defined(__linux__)
+#if defined(__linux__) and !defined(__ANDROID__)
   {
     EXPLICIT_SYMBOL(stderr);
     EXPLICIT_SYMBOL(stdout);
index 64404a1a8e77cc23f8f417f44620f4706c96a694..59bfcfcd254ccd8c42c499b27031f461eedc97e1 100644 (file)
@@ -49,7 +49,7 @@ LockFileManager::readLockFile(StringRef LockFileName) {
 }
 
 bool LockFileManager::processStillExecuting(StringRef Hostname, int PID) {
-#if LLVM_ON_UNIX
+#if LLVM_ON_UNIX && !defined(__ANDROID__)
   char MyHostname[256];
   MyHostname[255] = 0;
   MyHostname[0] = 0;
index 8ef5d7dd26a2210a3cfc6d9154f8065c420256ed..58f6cafa75fb1f911858eca78e6466d92e26e029 100644 (file)
 # define GTEST_OS_MAC 1
 #elif defined __linux__
 # define GTEST_OS_LINUX 1
-# ifdef ANDROID
+# if defined(ANDROID) || defined(__ANDROID__)
 #  define GTEST_OS_LINUX_ANDROID 1
 # endif  // ANDROID
 #elif defined __MVS__