summaryrefslogtreecommitdiff
path: root/zen/thread.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'zen/thread.cpp')
-rwxr-xr-xzen/thread.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/zen/thread.cpp b/zen/thread.cpp
index 8016d4a9..08bfaa25 100755
--- a/zen/thread.cpp
+++ b/zen/thread.cpp
@@ -34,10 +34,7 @@ uint64_t getThreadIdNative()
}
-struct InitMainThreadIdOnStartup
-{
- InitMainThreadIdOnStartup() { getMainThreadId(); }
-} startupInitMainThreadId;
+const uint64_t globalMainThreadId = getThreadId(); //avoid code-gen for "magic static"!
}
@@ -50,6 +47,9 @@ uint64_t zen::getThreadId()
uint64_t zen::getMainThreadId()
{
- static const uint64_t mainThreadId = getThreadId();
- return mainThreadId;
+ //don't make this a function-scope static (avoid code-gen for "magic static")
+ if (globalMainThreadId == 0) //might be called during static initialization
+ return getThreadId();
+
+ return globalMainThreadId;
}
bgstack15