aboutsummaryrefslogtreecommitdiffstats
path: root/router/router.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/router.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/router.cpp')
-rw-r--r--router/router.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/router/router.cpp b/router/router.cpp
index 731db063..7eb0bddc 100644
--- a/router/router.cpp
+++ b/router/router.cpp
@@ -24,6 +24,11 @@ thread_local DriverIface *ThreadCtxDriver;
enum LogLevel LogLevel = LogLevel_Error;
FILE *LogFile;
+#ifdef __MINGW32__
+DriverIface *GetThreadDriver() noexcept { return ThreadCtxDriver; }
+void SetThreadDriver(DriverIface *driver) noexcept { ThreadCtxDriver = driver; }
+#endif
+
static void LoadDriverList(void);