Commit 71255360 authored by Yedidya Feldblum's avatar Yedidya Feldblum Committed by Facebook GitHub Bot

avoid FOLLY_TLS in tests

Reviewed By: Orvid

Differential Revision: D27559344

fbshipit-source-id: cf90be5a19da87bffe72fb6646296dd46889bc90
parent 1af19a96
...@@ -1067,7 +1067,7 @@ TEST(ThreadId, SimplePthread) { ...@@ -1067,7 +1067,7 @@ TEST(ThreadId, SimplePthread) {
} }
#ifdef FOLLY_CL_USE_FOLLY_TLS #ifdef FOLLY_CL_USE_FOLLY_TLS
static FOLLY_TLS unsigned testingCpu = 0; static thread_local unsigned testingCpu = 0;
static int testingGetcpu(unsigned* cpu, unsigned* node, void* /* unused */) { static int testingGetcpu(unsigned* cpu, unsigned* node, void* /* unused */) {
if (cpu != nullptr) { if (cpu != nullptr) {
......
...@@ -114,7 +114,7 @@ TEST(DeterministicSchedule, buggyAdd) { ...@@ -114,7 +114,7 @@ TEST(DeterministicSchedule, buggyAdd) {
* to maintain global knowledge of shared and private state. * to maintain global knowledge of shared and private state.
* 3. Define: * 3. Define:
* static AuxData* aux_; * static AuxData* aux_;
* static FOLLY_TLS uint32_t tid_; * static thread_local uint32_t tid_;
* 4. (Optional) Define gflags for command line options. E.g.: * 4. (Optional) Define gflags for command line options. E.g.:
* DEFINE_int64(seed, 0, "Seed for random number generators"); * DEFINE_int64(seed, 0, "Seed for random number generators");
* 5. (Optionl) Define macros for mangement of auxiliary data. E.g., * 5. (Optionl) Define macros for mangement of auxiliary data. E.g.,
...@@ -208,7 +208,7 @@ struct AuxData { ...@@ -208,7 +208,7 @@ struct AuxData {
}; };
static AuxData* aux_; static AuxData* aux_;
static FOLLY_TLS uint32_t tid_; static thread_local uint32_t tid_;
/* Command line flags */ /* Command line flags */
DEFINE_int64(seed, 0, "Seed for random number generators"); DEFINE_int64(seed, 0, "Seed for random number generators");
......
...@@ -158,7 +158,7 @@ TEST(IndexedMemPool, locate_elem) { ...@@ -158,7 +158,7 @@ TEST(IndexedMemPool, locate_elem) {
} }
struct NonTrivialStruct { struct NonTrivialStruct {
static FOLLY_TLS size_t count; static thread_local size_t count;
size_t elem_; size_t elem_;
...@@ -175,7 +175,7 @@ struct NonTrivialStruct { ...@@ -175,7 +175,7 @@ struct NonTrivialStruct {
~NonTrivialStruct() { --count; } ~NonTrivialStruct() { --count; }
}; };
FOLLY_TLS size_t NonTrivialStruct::count; thread_local size_t NonTrivialStruct::count;
TEST(IndexedMemPool, eager_recycle) { TEST(IndexedMemPool, eager_recycle) {
typedef IndexedMemPool<NonTrivialStruct> Pool; typedef IndexedMemPool<NonTrivialStruct> Pool;
......
...@@ -128,7 +128,7 @@ void runElementTypeTest(T&& src) { ...@@ -128,7 +128,7 @@ void runElementTypeTest(T&& src) {
} }
struct RefCounted { struct RefCounted {
static FOLLY_TLS int active_instances; static thread_local int active_instances;
mutable std::atomic<int> rc; mutable std::atomic<int> rc;
...@@ -136,7 +136,7 @@ struct RefCounted { ...@@ -136,7 +136,7 @@ struct RefCounted {
~RefCounted() { --active_instances; } ~RefCounted() { --active_instances; }
}; };
FOLLY_TLS int RefCounted::active_instances; thread_local int RefCounted::active_instances;
void intrusive_ptr_add_ref(RefCounted const* p) { void intrusive_ptr_add_ref(RefCounted const* p) {
p->rc++; p->rc++;
...@@ -889,8 +889,8 @@ enum LifecycleEvent { ...@@ -889,8 +889,8 @@ enum LifecycleEvent {
MAX_LIFECYCLE_EVENT MAX_LIFECYCLE_EVENT
}; };
static FOLLY_TLS int lc_counts[MAX_LIFECYCLE_EVENT]; static thread_local int lc_counts[MAX_LIFECYCLE_EVENT];
static FOLLY_TLS int lc_prev[MAX_LIFECYCLE_EVENT]; static thread_local int lc_prev[MAX_LIFECYCLE_EVENT];
static int lc_outstanding() { static int lc_outstanding() {
return lc_counts[DEFAULT_CONSTRUCTOR] + lc_counts[COPY_CONSTRUCTOR] + return lc_counts[DEFAULT_CONSTRUCTOR] + lc_counts[COPY_CONSTRUCTOR] +
......
...@@ -160,11 +160,11 @@ class FakeMutex { ...@@ -160,11 +160,11 @@ class FakeMutex {
// Keep these two static for test access // Keep these two static for test access
// Keep them thread_local in case of tests are run in parallel within one // Keep them thread_local in case of tests are run in parallel within one
// process // process
static FOLLY_TLS int lockCount_; static thread_local int lockCount_;
static FOLLY_TLS int unlockCount_; static thread_local int unlockCount_;
}; };
FOLLY_TLS int FakeMutex::lockCount_{0}; thread_local int FakeMutex::lockCount_{0};
FOLLY_TLS int FakeMutex::unlockCount_{0}; thread_local int FakeMutex::unlockCount_{0};
// SynchronizedLockTest is used to verify the correct lock unlock behavior // SynchronizedLockTest is used to verify the correct lock unlock behavior
// happens per design // happens per design
......
...@@ -295,8 +295,8 @@ ThreadLocal<int64_t> globalTL64Baseline; ...@@ -295,8 +295,8 @@ ThreadLocal<int64_t> globalTL64Baseline;
ThreadLocal<int32_t> globalTL32Baseline; ThreadLocal<int32_t> globalTL32Baseline;
std::atomic<int64_t> globalInt64Baseline(0); std::atomic<int64_t> globalInt64Baseline(0);
std::atomic<int32_t> globalInt32Baseline(0); std::atomic<int32_t> globalInt32Baseline(0);
FOLLY_TLS int64_t global__thread64; thread_local int64_t global__thread64;
FOLLY_TLS int32_t global__thread32; thread_local int32_t global__thread32;
// Alternate lock-free implementation. Achieves about the same performance, // Alternate lock-free implementation. Achieves about the same performance,
// but uses about 20x more memory than ThreadCachedInt with 24 threads. // but uses about 20x more memory than ThreadCachedInt with 24 threads.
......
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