Use FOLLY_MOBILE to split some functionality
authorMichael Lee <mzlee@fb.com>
Tue, 22 Mar 2016 01:02:31 +0000 (18:02 -0700)
committerFacebook Github Bot 9 <facebook-github-bot-9-bot@fb.com>
Tue, 22 Mar 2016 17:35:21 +0000 (10:35 -0700)
Summary: The guards already look for __APPLE__, but __ANDROID__ needs this as well.

Reviewed By: yfeldblum

Differential Revision: D3053976

fb-gh-sync-id: a9ba7a612d29502d4a7e691c6741837d4a8b42f0
shipit-source-id: a9ba7a612d29502d4a7e691c6741837d4a8b42f0

folly/Portability.h
folly/RWSpinLock.h
folly/configure.ac
folly/detail/MemoryIdler.cpp
folly/detail/ThreadLocalDetail.h
folly/futures/Future-inl.h

index 0eb1e1d81707f6e99fd38cedf36fc71bb1b6b11b..363fe3041018aaf9ee493130e88dbdad7be52a05 100644 (file)
@@ -210,7 +210,7 @@ namespace std { typedef ::max_align_t max_align_t; }
 # error cannot define platform specific thread local storage
 #endif
 
-#if defined(__APPLE__) && (TARGET_IPHONE_SIMULATOR || TARGET_OS_IPHONE)
+#if FOLLY_MOBILE
 #undef FOLLY_TLS
 #endif
 
index ae1aa6bff6da56cfb954a13b4de755929242f6bd..3091dc1c350b1c87ba3a462c112b1c32212fe8a2 100644 (file)
@@ -150,7 +150,7 @@ pthread_rwlock_t Read        728698     24us       101ns     7.28ms     194us
 #endif
 
 // iOS doesn't define _mm_cvtsi64_si128 and friends
-#if (FOLLY_SSE >= 2) && !TARGET_OS_IPHONE
+#if (FOLLY_SSE >= 2) && !FOLLY_MOBILE
 #define RW_SPINLOCK_USE_SSE_INSTRUCTIONS_
 #else
 #undef RW_SPINLOCK_USE_SSE_INSTRUCTIONS_
index 6e031f13436c6fd8687f597e128cdc4321994534..dc19b559b911a72470b9787938e3f87856ba57ab 100644 (file)
@@ -236,7 +236,7 @@ AC_CACHE_CHECK(
   [for c++11 atomic support without GNU Atomic library],
   [folly_cv_lib_libatomic],
   [AC_LINK_IFELSE(
-    [AC_LANG_PROGRAM[
+    [AC_LANG_SOURCE[
       #include <atomic>
       int main() {
         struct Test { int val; };
@@ -501,6 +501,15 @@ else
    AC_CHECK_HEADERS([libunwind.h],, [use_follytestmain=no])
 fi
 
+AC_ARG_ENABLE([mobile],
+   AS_HELP_STRING([--enable-mobile],
+                  [enables using main function from folly for tests]),
+                  [mobile=${enableval}], [mobile=no])
+AS_IF([test "x${mobile}" = "xyes"], [
+    AC_DEFINE([MOBILE], [1],
+              [Define to 1 for compiler guards for mobile targets.])
+])
+
 # Include directory that contains "folly" so #include <folly/Foo.h> works
 AM_CPPFLAGS='-I$(top_srcdir)/..'
 AM_CPPFLAGS="$AM_CPPFLAGS $BOOST_CPPFLAGS"
index 1f17f8cc37d1aa76bdcf70142680018b1654e1c8..bb9691b97fa36ac2b9396cd24c153d88b5cfeac9 100644 (file)
  */
 
 #include <folly/detail/MemoryIdler.h>
+
 #include <folly/Logging.h>
 #include <folly/Malloc.h>
+#include <folly/Portability.h>
 #include <folly/ScopeGuard.h>
 #include <folly/detail/CacheLocality.h>
 #include <limits.h>
 #include <pthread.h>
 #include <stdio.h>
 #include <string.h>
-#include <unistd.h>
 #include <sys/mman.h>
+#include <unistd.h>
 #include <utility>
 
-
 namespace folly { namespace detail {
 
 AtomicStruct<std::chrono::steady_clock::duration>
@@ -92,7 +93,8 @@ void MemoryIdler::flushLocalMallocCaches() {
 // Stack madvise isn't Linux or glibc specific, but the system calls
 // and arithmetic (and bug compatibility) are not portable.  The set of
 // platforms could be increased if it was useful.
-#if (FOLLY_X64 || FOLLY_PPC64 ) && defined(_GNU_SOURCE) && defined(__linux__)
+#if (FOLLY_X64 || FOLLY_PPC64) && defined(_GNU_SOURCE) && \
+    defined(__linux__) && !FOLLY_MOBILE
 
 static FOLLY_TLS uintptr_t tls_stackLimit;
 static FOLLY_TLS size_t tls_stackSize;
index 7eeb1f581780a5eb48632004428540e9b2c8a423..57d1767e7ec7d71ffca13e486ad0e76c70ed1ca1 100644 (file)
 
 #include <glog/logging.h>
 
-#include <folly/Foreach.h>
 #include <folly/Exception.h>
+#include <folly/Foreach.h>
 #include <folly/Malloc.h>
 #include <folly/MicroSpinLock.h>
+#include <folly/Portability.h>
 
 #include <folly/detail/StaticSingletonManager.h>
 
@@ -41,7 +42,7 @@
 //
 // XXX: Ideally we would instead determine if emutls is in use at runtime as it
 // is possible to configure glibc on Linux to use emutls regardless.
-#if !__APPLE__ && !__ANDROID__
+#if !FOLLY_MOBILE && !defined(__APPLE__)
 #define FOLLY_TLD_USE_FOLLY_TLS 1
 #else
 #undef FOLLY_TLD_USE_FOLLY_TLS
index 7ada66e7d8a2cf2651f55170e9eea302156dde4a..8df0d88cc1b5d287a72e0cd84ff77d58f968fb1e 100644 (file)
@@ -28,7 +28,7 @@
 #include <folly/futures/detail/Core.h>
 #include <folly/futures/Timekeeper.h>
 
-#if defined(__ANDROID__) || defined(__APPLE__)
+#if FOLLY_MOBILE || defined(__APPLE__)
 #define FOLLY_FUTURE_USING_FIBER 0
 #else
 #define FOLLY_FUTURE_USING_FIBER 1