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 /router/alc.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 'router/alc.cpp')
-rw-r--r-- | router/alc.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/router/alc.cpp b/router/alc.cpp index d43c78ce..5532c047 100644 --- a/router/alc.cpp +++ b/router/alc.cpp @@ -469,21 +469,21 @@ ALC_API ALCboolean ALC_APIENTRY alcMakeContextCurrent(ALCcontext *context) */ if(idx < 0) { - DriverIface *oldiface = ThreadCtxDriver; + DriverIface *oldiface = GetThreadDriver(); if(oldiface) oldiface->alcSetThreadContext(nullptr); oldiface = CurrentCtxDriver.exchange(nullptr); if(oldiface) oldiface->alcMakeContextCurrent(nullptr); } else { - DriverIface *oldiface = ThreadCtxDriver; + DriverIface *oldiface = GetThreadDriver(); if(oldiface && oldiface != &DriverList[idx]) oldiface->alcSetThreadContext(nullptr); oldiface = CurrentCtxDriver.exchange(&DriverList[idx]); if(oldiface && oldiface != &DriverList[idx]) oldiface->alcMakeContextCurrent(nullptr); } - ThreadCtxDriver = nullptr; + SetThreadDriver(nullptr); return ALC_TRUE; } @@ -526,7 +526,7 @@ ALC_API void ALC_APIENTRY alcDestroyContext(ALCcontext *context) ALC_API ALCcontext* ALC_APIENTRY alcGetCurrentContext(void) { - DriverIface *iface = ThreadCtxDriver; + DriverIface *iface = GetThreadDriver(); if(!iface) iface = CurrentCtxDriver.load(); return iface ? iface->alcGetCurrentContext() : nullptr; } @@ -932,10 +932,10 @@ ALC_API ALCboolean ALC_APIENTRY alcSetThreadContext(ALCcontext *context) if(!context) { - DriverIface *oldiface = ThreadCtxDriver; + DriverIface *oldiface = GetThreadDriver(); if(oldiface && !oldiface->alcSetThreadContext(nullptr)) return ALC_FALSE; - ThreadCtxDriver = nullptr; + SetThreadDriver(nullptr); return ALC_TRUE; } @@ -944,10 +944,10 @@ ALC_API ALCboolean ALC_APIENTRY alcSetThreadContext(ALCcontext *context) { if(DriverList[idx].alcSetThreadContext(context)) { - DriverIface *oldiface = ThreadCtxDriver; + DriverIface *oldiface = GetThreadDriver(); if(oldiface != &DriverList[idx]) { - ThreadCtxDriver = &DriverList[idx]; + SetThreadDriver(&DriverList[idx]); if(oldiface) oldiface->alcSetThreadContext(nullptr); } return ALC_TRUE; @@ -960,7 +960,7 @@ ALC_API ALCboolean ALC_APIENTRY alcSetThreadContext(ALCcontext *context) ALC_API ALCcontext* ALC_APIENTRY alcGetThreadContext(void) { - DriverIface *iface = ThreadCtxDriver; + DriverIface *iface = GetThreadDriver(); if(iface) return iface->alcGetThreadContext(); return nullptr; } |