Revision 5aaa94854367ca875375e38ae14f369f124e7315 authored by Kristoffer Carlsson on 03 November 2023, 07:44:08 UTC, committed by GitHub on 03 November 2023, 07:44:08 UTC
1 parent 1391444
Raw File
openblas-winexit.patch
diff --git a/driver/others/memory.c b/driver/others/memory.c
index 6e654ccf..1d2f9f12 100644
--- a/driver/others/memory.c
+++ b/driver/others/memory.c
@@ -1534,7 +1534,7 @@ void CONSTRUCTOR gotoblas_init(void) {
 
 }
 
-void DESTRUCTOR gotoblas_quit(void) {
+void gotoblas_quit(void) {
 
   if (gotoblas_initialized == 0) return;
 
@@ -1572,75 +1572,11 @@ void DESTRUCTOR gotoblas_quit(void) {
 }
 
 #if defined(_MSC_VER) && !defined(__clang__)
-BOOL APIENTRY DllMain(HMODULE hModule, DWORD  ul_reason_for_call, LPVOID lpReserved)
-{
-  switch (ul_reason_for_call)
-  {
-    case DLL_PROCESS_ATTACH:
-      gotoblas_init();
-      break;
-    case DLL_THREAD_ATTACH:
-      break;
-    case DLL_THREAD_DETACH:
-#if defined(SMP)
-      blas_thread_memory_cleanup();
-#endif
-      break;
-    case DLL_PROCESS_DETACH:
-      gotoblas_quit();
-      break;
-    default:
-      break;
-  }
-  return TRUE;
-}
-
-/*
-  This is to allow static linking.
-  Code adapted from Google performance tools:
-  https://gperftools.googlecode.com/git-history/perftools-1.0/src/windows/port.cc
-  Reference:
-  https://sourceware.org/ml/pthreads-win32/2008/msg00028.html
-  http://ci.boost.org/svn-trac/browser/trunk/libs/thread/src/win32/tss_pe.cpp
-*/
-static int on_process_term(void)
-{
-  gotoblas_quit();
-  return 0;
-}
 #ifdef _WIN64
 #pragma comment(linker, "/INCLUDE:_tls_used")
 #else
 #pragma comment(linker, "/INCLUDE:__tls_used")
 #endif
-
-#ifdef _WIN64
-#pragma const_seg(".CRT$XLB")
-#else
-#pragma data_seg(".CRT$XLB")
-#endif
-
-#ifdef _WIN64
-static const PIMAGE_TLS_CALLBACK dll_callback(HINSTANCE h, DWORD ul_reason_for_call, PVOID pv) = DllMain;
-#pragma const_seg()
-#else
-static void (APIENTRY *dll_callback)(HINSTANCE h, DWORD ul_reason_for_call, PVOID pv) = DllMain;
-#pragma data_seg()
-#endif
-
-#ifdef _WIN64
-#pragma const_seg(".CRT$XTU")
-#else
-#pragma data_seg(".CRT$XTU")
-#endif
-
-#ifdef _WIN64
-static const int(*p_process_term)(void) = on_process_term;
-#pragma const_seg()
-#else
-static int(*p_process_term)(void) = on_process_term;
-#pragma data_seg()
-#endif
 #endif
 
 #if (defined(C_PGI) || (!defined(C_SUN) && defined(F_INTERFACE_SUN))) && (defined(ARCH_X86) || defined(ARCH_X86_64))
@@ -3146,7 +3082,7 @@ void CONSTRUCTOR gotoblas_init(void) {
 
 }
 
-void DESTRUCTOR gotoblas_quit(void) {
+void gotoblas_quit(void) {
 
   if (gotoblas_initialized == 0) return;
 
@@ -3175,71 +3111,6 @@ void DESTRUCTOR gotoblas_quit(void) {
 #endif
 }
 
-#if defined(_MSC_VER) && !defined(__clang__)
-BOOL APIENTRY DllMain(HMODULE hModule, DWORD  ul_reason_for_call, LPVOID lpReserved)
-{
-  switch (ul_reason_for_call)
-  {
-    case DLL_PROCESS_ATTACH:
-      gotoblas_init();
-      break;
-    case DLL_THREAD_ATTACH:
-      break;
-    case DLL_THREAD_DETACH:
-      break;
-    case DLL_PROCESS_DETACH:
-      gotoblas_quit();
-      break;
-    default:
-      break;
-  }
-  return TRUE;
-}
-
-/*
-  This is to allow static linking.
-  Code adapted from Google performance tools:
-  https://gperftools.googlecode.com/git-history/perftools-1.0/src/windows/port.cc
-  Reference:
-  https://sourceware.org/ml/pthreads-win32/2008/msg00028.html
-  http://ci.boost.org/svn-trac/browser/trunk/libs/thread/src/win32/tss_pe.cpp
-*/
-static int on_process_term(void)
-{
-  gotoblas_quit();
-  return 0;
-}
-#ifdef _WIN64
-#pragma comment(linker, "/INCLUDE:_tls_used")
-#else
-#pragma comment(linker, "/INCLUDE:__tls_used")
-#endif
-
-#ifdef _WIN64
-#pragma const_seg(".CRT$XLB")
-#else
-#pragma data_seg(".CRT$XLB")
-#endif
-static void (APIENTRY *dll_callback)(HINSTANCE h, DWORD ul_reason_for_call, PVOID pv) = DllMain;
-#ifdef _WIN64
-#pragma const_seg()
-#else
-#pragma data_seg()
-#endif
-
-#ifdef _WIN64
-#pragma const_seg(".CRT$XTU")
-#else
-#pragma data_seg(".CRT$XTU")
-#endif
-static int(*p_process_term)(void) = on_process_term;
-#ifdef _WIN64
-#pragma const_seg()
-#else
-#pragma data_seg()
-#endif
-#endif
-
 #if (defined(C_PGI) || (!defined(C_SUN) && defined(F_INTERFACE_SUN))) && (defined(ARCH_X86) || defined(ARCH_X86_64))
 /* Don't call me; this is just work around for PGI / Sun bug */
 void gotoblas_dummy_for_PGI(void) {
back to top