Browse Source

Workaround for Apple's clang not compiling thread_local correctly.

tags/v2.0.0
Andrew Belt 5 years ago
parent
commit
c18370bf9a
1 changed files with 8 additions and 4 deletions
  1. +8
    -4
      src/context.cpp

+ 8
- 4
src/context.cpp View File

@@ -45,15 +45,19 @@ Context::~Context() {
} }




static thread_local Context* context = NULL;
static thread_local Context* threadContext = NULL;


Context* contextGet() { Context* contextGet() {
assert(context);
return context;
assert(threadContext);
return threadContext;
} }


// Apple's clang incorrectly compiles this function when -O2 or higher is enabled.
#ifdef ARCH_MAC
__attribute__((optnone))
#endif
void contextSet(Context* context) { void contextSet(Context* context) {
rack::context = context;
threadContext = context;
} }






Loading…
Cancel
Save