aboutsummaryrefslogtreecommitdiffstats
path: root/alc
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2023-09-11 19:34:55 -0700
committerChris Robinson <[email protected]>2023-09-11 19:34:55 -0700
commit6722ad196145ef7334d7478bdd375308801e7096 (patch)
tree60ca9a830e7601e8eb4289696b565d852cbb9760 /alc
parent43fac7e95568a2b7205db365a49e3938b05e913b (diff)
Make some global and static member variables inline
This also seems to work around the problematic MinGW code generation, so the indirection to access it can be removed.
Diffstat (limited to 'alc')
-rw-r--r--alc/context.cpp8
-rw-r--r--alc/context.h11
2 files changed, 1 insertions, 18 deletions
diff --git a/alc/context.cpp b/alc/context.cpp
index bba74a59..3b1de7b9 100644
--- a/alc/context.cpp
+++ b/alc/context.cpp
@@ -102,7 +102,6 @@ std::vector<std::string_view> getContextExtensions() noexcept
std::atomic<bool> ALCcontext::sGlobalContextLock{false};
std::atomic<ALCcontext*> ALCcontext::sGlobalContext{nullptr};
-thread_local ALCcontext *ALCcontext::sLocalContext{nullptr};
ALCcontext::ThreadCtx::~ThreadCtx()
{
if(ALCcontext *ctx{std::exchange(ALCcontext::sLocalContext, nullptr)})
@@ -117,13 +116,6 @@ 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, ContextFlagBitset flags)
: ContextBase{device.get()}, mALDevice{std::move(device)}, mContextFlags{flags}
{
diff --git a/alc/context.h b/alc/context.h
index f936bbe8..201c8873 100644
--- a/alc/context.h
+++ b/alc/context.h
@@ -211,7 +211,7 @@ struct ALCcontext : public al::intrusive_ref<ALCcontext>, ContextBase {
private:
/* Thread-local current context. */
- static thread_local ALCcontext *sLocalContext;
+ static inline thread_local ALCcontext *sLocalContext{};
/* Thread-local context handling. This handles attempting to release the
* context which may have been left current when the thread is destroyed.
@@ -224,17 +224,8 @@ private:
static thread_local ThreadCtx sThreadContext;
public:
- /* HACK: MinGW generates bad code when accessing an extern thread_local
- * object. Add a wrapper function for it that only accesses it where it's
- * defined.
- */
-#ifdef __MINGW32__
- static ALCcontext *getThreadContext() noexcept;
- static void setThreadContext(ALCcontext *context) noexcept;
-#else
static ALCcontext *getThreadContext() noexcept { return sLocalContext; }
static void setThreadContext(ALCcontext *context) noexcept { sThreadContext.set(context); }
-#endif
/* Default effect that applies to sources that don't have an effect on send 0. */
static ALeffect sDefaultEffect;