aboutsummaryrefslogtreecommitdiffstats
path: root/alc/alc.cpp
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2021-12-20 10:27:39 -0800
committerChris Robinson <[email protected]>2021-12-20 10:27:39 -0800
commit633c332deee0500b85927906be1084606a286ac9 (patch)
tree31d178782d6ed65163c4f9f945ccace31a1c0ad1 /alc/alc.cpp
parenta88803f21e1b44633de1aa5e068df8e9f371c2c2 (diff)
Work around a MinGW thread_local bug
MinGW-w64 generates bad code when accessing extern thread_local objects. Wrapper functions are used to ensure it only accesses them from the same place they're defined. This unfortunately adds a bit of overhead for what should be a relatively simple thing. These functions are inlined for non-MinGW targets, avoiding the overhead on non-affected targets.
Diffstat (limited to 'alc/alc.cpp')
-rw-r--r--alc/alc.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/alc/alc.cpp b/alc/alc.cpp
index c6ac6508..b63f0f82 100644
--- a/alc/alc.cpp
+++ b/alc/alc.cpp
@@ -2218,7 +2218,7 @@ ContextRef VerifyContext(ALCcontext *context)
/** Returns a new reference to the currently active context for this thread. */
ContextRef GetContextRef(void)
{
- ALCcontext *context{ALCcontext::sLocalContext};
+ ALCcontext *context{ALCcontext::getThreadContext()};
if(context)
context->add_ref();
else
@@ -3062,7 +3062,7 @@ END_API_FUNC
ALC_API ALCcontext* ALC_APIENTRY alcGetCurrentContext(void)
START_API_FUNC
{
- ALCcontext *Context{ALCcontext::sLocalContext};
+ ALCcontext *Context{ALCcontext::getThreadContext()};
if(!Context) Context = ALCcontext::sGlobalContext.load();
return Context;
}
@@ -3071,7 +3071,7 @@ END_API_FUNC
/** Returns the currently active thread-local context. */
ALC_API ALCcontext* ALC_APIENTRY alcGetThreadContext(void)
START_API_FUNC
-{ return ALCcontext::sLocalContext; }
+{ return ALCcontext::getThreadContext(); }
END_API_FUNC
ALC_API ALCboolean ALC_APIENTRY alcMakeContextCurrent(ALCcontext *context)
@@ -3098,8 +3098,8 @@ START_API_FUNC
* thread-local context. Take ownership of the thread-local context
* reference (if any), clearing the storage to null.
*/
- ctx = ContextRef{ALCcontext::sLocalContext};
- if(ctx) ALCcontext::sThreadContext.set(nullptr);
+ ctx = ContextRef{ALCcontext::getThreadContext()};
+ if(ctx) ALCcontext::setThreadContext(nullptr);
/* Reset (decrement) the previous thread-local reference. */
return ALC_TRUE;
@@ -3122,8 +3122,8 @@ START_API_FUNC
}
}
/* context's reference count is already incremented */
- ContextRef old{ALCcontext::sLocalContext};
- ALCcontext::sThreadContext.set(ctx.release());
+ ContextRef old{ALCcontext::getThreadContext()};
+ ALCcontext::setThreadContext(ctx.release());
return ALC_TRUE;
}