diff options
author | Chris Robinson <[email protected]> | 2021-12-20 10:27:39 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2021-12-20 10:27:39 -0800 |
commit | 633c332deee0500b85927906be1084606a286ac9 (patch) | |
tree | 31d178782d6ed65163c4f9f945ccace31a1c0ad1 /alc/context.cpp | |
parent | a88803f21e1b44633de1aa5e068df8e9f371c2c2 (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/context.cpp')
-rw-r--r-- | alc/context.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/alc/context.cpp b/alc/context.cpp index 1dff00bc..c2d3e351 100644 --- a/alc/context.cpp +++ b/alc/context.cpp @@ -96,6 +96,13 @@ thread_local ALCcontext::ThreadCtx ALCcontext::sThreadContext; ALeffect ALCcontext::sDefaultEffect; +#ifdef __MINGW32__ +ALCcontext *ALCcontext::getThreadContext() noexcept +{ return sLocalContext; } +void ALCcontext::setThreadContext(ALCcontext *context) noexcept +{ sThreadContext.set(context); } +#endif + ALCcontext::ALCcontext(al::intrusive_ptr<ALCdevice> device) : ContextBase{device.get()}, mALDevice{std::move(device)} { |