From 328b22e8a15d3fb725a2f46850ae9d18491d74af Mon Sep 17 00:00:00 2001 From: Michael Lee Date: Mon, 21 Mar 2016 18:02:31 -0700 Subject: [PATCH] Use FOLLY_MOBILE to split some functionality 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 | 2 +- folly/RWSpinLock.h | 2 +- folly/configure.ac | 11 ++++++++++- folly/detail/MemoryIdler.cpp | 8 +++++--- folly/detail/ThreadLocalDetail.h | 5 +++-- folly/futures/Future-inl.h | 2 +- 6 files changed, 21 insertions(+), 9 deletions(-) diff --git a/folly/Portability.h b/folly/Portability.h index 0eb1e1d8..363fe304 100644 --- a/folly/Portability.h +++ b/folly/Portability.h @@ -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 diff --git a/folly/RWSpinLock.h b/folly/RWSpinLock.h index ae1aa6bf..3091dc1c 100644 --- a/folly/RWSpinLock.h +++ b/folly/RWSpinLock.h @@ -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_ diff --git a/folly/configure.ac b/folly/configure.ac index 6e031f13..dc19b559 100644 --- a/folly/configure.ac +++ b/folly/configure.ac @@ -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 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 works AM_CPPFLAGS='-I$(top_srcdir)/..' AM_CPPFLAGS="$AM_CPPFLAGS $BOOST_CPPFLAGS" diff --git a/folly/detail/MemoryIdler.cpp b/folly/detail/MemoryIdler.cpp index 1f17f8cc..bb9691b9 100644 --- a/folly/detail/MemoryIdler.cpp +++ b/folly/detail/MemoryIdler.cpp @@ -15,19 +15,20 @@ */ #include + #include #include +#include #include #include #include #include #include #include -#include #include +#include #include - namespace folly { namespace detail { AtomicStruct @@ -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; diff --git a/folly/detail/ThreadLocalDetail.h b/folly/detail/ThreadLocalDetail.h index 7eeb1f58..57d1767e 100644 --- a/folly/detail/ThreadLocalDetail.h +++ b/folly/detail/ThreadLocalDetail.h @@ -28,10 +28,11 @@ #include -#include #include +#include #include #include +#include #include @@ -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 diff --git a/folly/futures/Future-inl.h b/folly/futures/Future-inl.h index 7ada66e7..8df0d88c 100644 --- a/folly/futures/Future-inl.h +++ b/folly/futures/Future-inl.h @@ -28,7 +28,7 @@ #include #include -#if defined(__ANDROID__) || defined(__APPLE__) +#if FOLLY_MOBILE || defined(__APPLE__) #define FOLLY_FUTURE_USING_FIBER 0 #else #define FOLLY_FUTURE_USING_FIBER 1 -- 2.34.1