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;
#error cannot define platform specific thread local storage
#endif
#if FOLLY_MOBILE
#undef FOLLY_TLS
#endif
// 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
// up in a macro to make forward-declarations easier.
......
......@@ -27,6 +27,13 @@
#include <folly/detail/UniqueInstance.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 {
/// SingletonThreadLocal
......@@ -141,7 +148,7 @@ class SingletonThreadLocal {
return *getWrapperTL();
}
#ifdef FOLLY_TLS
#ifdef FOLLY_STL_USE_FOLLY_TLS
FOLLY_NOINLINE static Wrapper& getSlow(LocalCache& cache) {
if (threadlocal_detail::StaticMetaBase::dying()) {
return getWrapper();
......@@ -154,7 +161,7 @@ class SingletonThreadLocal {
public:
FOLLY_EXPORT FOLLY_ALWAYS_INLINE static T& get() {
#ifdef FOLLY_TLS
#ifdef FOLLY_STL_USE_FOLLY_TLS
static thread_local LocalCache cache;
return FOLLY_LIKELY(!!cache.cache) ? *cache.cache : getSlow(cache);
#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