Commit 2f828c04 authored by Dan Melnic's avatar Dan Melnic Committed by Facebook Github Bot

Enable FOLLY_TLS on FOLLY_MOBILE too

Summary: Enable FOLLY_TLS on FOLLY_MOBILE too

Reviewed By: guangyfb

Differential Revision: D16883165

fbshipit-source-id: 1a8f0991088f6963dc2acf84b74b294be998b877
parent 2fc030b4
...@@ -222,10 +222,6 @@ constexpr bool kIsSanitize = false; ...@@ -222,10 +222,6 @@ constexpr bool kIsSanitize = false;
#error cannot define platform specific thread local storage #error cannot define platform specific thread local storage
#endif #endif
#if FOLLY_MOBILE
#undef FOLLY_TLS
#endif
// It turns out that GNU libstdc++ and LLVM libc++ differ on how they implement // It turns out that GNU libstdc++ and LLVM libc++ differ on how they implement
// the 'std' namespace; the latter uses inline namespaces. Wrap this decision // the 'std' namespace; the latter uses inline namespaces. Wrap this decision
// up in a macro to make forward-declarations easier. // up in a macro to make forward-declarations easier.
......
...@@ -27,6 +27,13 @@ ...@@ -27,6 +27,13 @@
#include <folly/detail/UniqueInstance.h> #include <folly/detail/UniqueInstance.h>
#include <folly/functional/Invoke.h> #include <folly/functional/Invoke.h>
// we do not want to use FOLLY_TLS here for mobile
#if !FOLLY_MOBILE && defined(FOLLY_TLS)
#define FOLLY_STL_USE_FOLLY_TLS 1
#else
#undef FOLLY_STL_USE_FOLLY_TLS
#endif
namespace folly { namespace folly {
/// SingletonThreadLocal /// SingletonThreadLocal
...@@ -141,7 +148,7 @@ class SingletonThreadLocal { ...@@ -141,7 +148,7 @@ class SingletonThreadLocal {
return *getWrapperTL(); return *getWrapperTL();
} }
#ifdef FOLLY_TLS #ifdef FOLLY_STL_USE_FOLLY_TLS
FOLLY_NOINLINE static Wrapper& getSlow(LocalCache& cache) { FOLLY_NOINLINE static Wrapper& getSlow(LocalCache& cache) {
if (threadlocal_detail::StaticMetaBase::dying()) { if (threadlocal_detail::StaticMetaBase::dying()) {
return getWrapper(); return getWrapper();
...@@ -154,7 +161,7 @@ class SingletonThreadLocal { ...@@ -154,7 +161,7 @@ class SingletonThreadLocal {
public: public:
FOLLY_EXPORT FOLLY_ALWAYS_INLINE static T& get() { FOLLY_EXPORT FOLLY_ALWAYS_INLINE static T& get() {
#ifdef FOLLY_TLS #ifdef FOLLY_STL_USE_FOLLY_TLS
static thread_local LocalCache cache; static thread_local LocalCache cache;
return FOLLY_LIKELY(!!cache.cache) ? *cache.cache : getSlow(cache); return FOLLY_LIKELY(!!cache.cache) ? *cache.cache : getSlow(cache);
#else #else
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment