aboutsummaryrefslogtreecommitdiffstats
path: root/router/al.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 /router/al.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 'router/al.cpp')
-rw-r--r--router/al.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/router/al.cpp b/router/al.cpp
index 5e273236..db18206e 100644
--- a/router/al.cpp
+++ b/router/al.cpp
@@ -11,31 +11,31 @@ std::atomic<DriverIface*> CurrentCtxDriver{nullptr};
#define DECL_THUNK1(R,n,T1) AL_API R AL_APIENTRY n(T1 a) \
{ \
- DriverIface *iface = ThreadCtxDriver; \
+ DriverIface *iface = GetThreadDriver(); \
if(!iface) iface = CurrentCtxDriver.load(std::memory_order_acquire); \
return iface->n(a); \
}
#define DECL_THUNK2(R,n,T1,T2) AL_API R AL_APIENTRY n(T1 a, T2 b) \
{ \
- DriverIface *iface = ThreadCtxDriver; \
+ DriverIface *iface = GetThreadDriver(); \
if(!iface) iface = CurrentCtxDriver.load(std::memory_order_acquire); \
return iface->n(a, b); \
}
#define DECL_THUNK3(R,n,T1,T2,T3) AL_API R AL_APIENTRY n(T1 a, T2 b, T3 c) \
{ \
- DriverIface *iface = ThreadCtxDriver; \
+ DriverIface *iface = GetThreadDriver(); \
if(!iface) iface = CurrentCtxDriver.load(std::memory_order_acquire); \
return iface->n(a, b, c); \
}
#define DECL_THUNK4(R,n,T1,T2,T3,T4) AL_API R AL_APIENTRY n(T1 a, T2 b, T3 c, T4 d) \
{ \
- DriverIface *iface = ThreadCtxDriver; \
+ DriverIface *iface = GetThreadDriver(); \
if(!iface) iface = CurrentCtxDriver.load(std::memory_order_acquire); \
return iface->n(a, b, c, d); \
}
#define DECL_THUNK5(R,n,T1,T2,T3,T4,T5) AL_API R AL_APIENTRY n(T1 a, T2 b, T3 c, T4 d, T5 e) \
{ \
- DriverIface *iface = ThreadCtxDriver; \
+ DriverIface *iface = GetThreadDriver(); \
if(!iface) iface = CurrentCtxDriver.load(std::memory_order_acquire); \
return iface->n(a, b, c, d, e); \
}
@@ -46,7 +46,7 @@ std::atomic<DriverIface*> CurrentCtxDriver{nullptr};
*/
AL_API ALenum AL_APIENTRY alGetError(void)
{
- DriverIface *iface = ThreadCtxDriver;
+ DriverIface *iface = GetThreadDriver();
if(!iface) iface = CurrentCtxDriver.load(std::memory_order_acquire);
return iface ? iface->alGetError() : AL_NO_ERROR;
}