Commit 4a150ab2 authored by Dan Melnic's avatar Dan Melnic Committed by Facebook Github Bot

Use FOLLY_CL_USE_FOLLY_TLS for CacheLocality to avoid an iOS build issue

Summary: Use FOLLY_CL_USE_FOLLY_TLS for CacheLocality to avoid an iOS build issue

Reviewed By: mzlee

Differential Revision: D17085507

fbshipit-source-id: acd407c9e0045eb4d8a59348a20874dbe75fd651
parent 54f83501
......@@ -311,7 +311,7 @@ Getcpu::Func Getcpu::resolveVdsoFunc() {
#endif
}
#ifdef FOLLY_TLS
#ifdef FOLLY_CL_USE_FOLLY_TLS
/////////////// SequentialThreadId
template struct SequentialThreadId<std::atomic>;
#endif
......
......@@ -37,6 +37,12 @@
#include <folly/lang/Exception.h>
#include <folly/system/ThreadId.h>
#if !FOLLY_MOBILE && defined(FOLLY_TLS)
#define FOLLY_CL_USE_FOLLY_TLS 1
#else
#undef FOLLY_CL_USE_FOLLY_TLS
#endif
namespace folly {
// This file contains several classes that might be useful if you are
......@@ -141,7 +147,7 @@ struct Getcpu {
static Func resolveVdsoFunc();
};
#ifdef FOLLY_TLS
#ifdef FOLLY_CL_USE_FOLLY_TLS
template <template <typename> class Atom>
struct SequentialThreadId {
/// Returns the thread id assigned to the current thread
......@@ -196,7 +202,7 @@ struct FallbackGetcpu {
}
};
#ifdef FOLLY_TLS
#ifdef FOLLY_CL_USE_FOLLY_TLS
typedef FallbackGetcpu<SequentialThreadId<std::atomic>> FallbackGetcpuType;
#else
typedef FallbackGetcpu<HashingThreadId> FallbackGetcpuType;
......@@ -251,7 +257,7 @@ struct AccessSpreader {
[cpu % kMaxCpus];
}
#ifdef FOLLY_TLS
#ifdef FOLLY_CL_USE_FOLLY_TLS
/// Returns the stripe associated with the current CPU. The returned
/// value will be < numStripes.
/// This function caches the current cpu in a thread-local variable for a
......@@ -317,7 +323,7 @@ struct AccessSpreader {
unsigned cachedCpuUses_{0};
};
#ifdef FOLLY_TLS
#ifdef FOLLY_CL_USE_FOLLY_TLS
static FOLLY_TLS CpuCache cpuCache;
#endif
......@@ -385,7 +391,7 @@ template <template <typename> class Atom>
typename AccessSpreader<Atom>::CompactStripe
AccessSpreader<Atom>::widthAndCpuToStripe[kMaxCpus + 1][kMaxCpus] = {};
#ifdef FOLLY_TLS
#ifdef FOLLY_CL_USE_FOLLY_TLS
template <template <typename> class Atom>
FOLLY_TLS
typename AccessSpreader<Atom>::CpuCache AccessSpreader<Atom>::cpuCache;
......
......@@ -1042,7 +1042,7 @@ TEST(Getcpu, VdsoGetcpu) {
}
#endif
#ifdef FOLLY_TLS
#ifdef FOLLY_CL_USE_FOLLY_TLS
TEST(ThreadId, SimpleTls) {
unsigned cpu = 0;
auto rv = folly::FallbackGetcpu<SequentialThreadId<std::atomic>>::getcpu(
......@@ -1067,7 +1067,7 @@ TEST(ThreadId, SimplePthread) {
EXPECT_EQ(cpu, again);
}
#ifdef FOLLY_TLS
#ifdef FOLLY_CL_USE_FOLLY_TLS
static FOLLY_TLS unsigned testingCpu = 0;
static int testingGetcpu(unsigned* cpu, unsigned* node, void* /* unused */) {
......@@ -1111,7 +1111,7 @@ TEST(AccessSpreader, ConcurrentAccessCached) {
}
}
#ifdef FOLLY_TLS
#ifdef FOLLY_CL_USE_FOLLY_TLS
#define DECLARE_SPREADER_TAG(tag, locality, func) \
namespace { \
template <typename dummy> \
......
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