Skip to content

Commit

Permalink
Avoid running init_config() more than once per process
Browse files Browse the repository at this point in the history
Windows runs `DllMain` multiple times; when new threads are started, for
instance.  We want to run our `DllMain()` implementation only during
process attachment (e.g. when the first thread loads it).
  • Loading branch information
staticfloat committed May 5, 2023
1 parent 2272604 commit 8131615
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/libblastrampoline.c
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,9 @@ void * _win32_self_handle;
BOOL APIENTRY DllMain(HINSTANCE hModule, DWORD code, void *reserved) {
if (code == DLL_PROCESS_ATTACH) {
_win32_self_handle = (void *)hModule;
} else {
// We do not want to run our initialization more than once per process.
return TRUE;
}
#else
__attribute__((constructor)) void init(void) {
Expand Down

0 comments on commit 8131615

Please sign in to comment.