Skip to content
This repository was archived by the owner on Jul 31, 2023. It is now read-only.

Commit 044b8c3

Browse files
authored
Fix TLS on Windows. (#228)
1 parent 877550f commit 044b8c3

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

opencensus/context/internal/context.cc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@
2222
#include "opencensus/tags/tag_map.h"
2323
#include "opencensus/trace/span.h"
2424

25+
#if defined(_MSC_VER)
26+
#define TLS __declspec(thread)
27+
#else
28+
#define TLS __thread
29+
#endif
30+
2531
namespace opencensus {
2632
namespace context {
2733

@@ -48,7 +54,7 @@ std::string Context::DebugString() const {
4854

4955
// static
5056
Context* Context::InternalMutableCurrent() {
51-
static __thread Context* thread_ctx = nullptr;
57+
static TLS Context* thread_ctx = nullptr;
5258
if (thread_ctx == nullptr) thread_ctx = new Context;
5359
return thread_ctx;
5460
}

0 commit comments

Comments
 (0)