LoadLibrary needs cleaning after, and we do link to kernel32.dll anyway.
--
O.S.
From d835bc5e2b141e596ca38cb193c311d80163c2e6 Mon Sep 17 00:00:00 2001
From: Ozkan Sezer <[email protected]>
Date: Tue, 24 Oct 2023 17:11:04 +0300
Subject: [PATCH] winpthreads: change LoadLibrary calls to GetModuleHandle after
cb7f42e.
---
mingw-w64-libraries/winpthreads/src/misc.c | 5 +----
mingw-w64-libraries/winpthreads/src/thread.c | 4 +---
2 files changed, 2 insertions(+), 7 deletions(-)
diff --git a/mingw-w64-libraries/winpthreads/src/misc.c
b/mingw-w64-libraries/winpthreads/src/misc.c
index 0b5e493..79c01f2 100644
--- a/mingw-w64-libraries/winpthreads/src/misc.c
+++ b/mingw-w64-libraries/winpthreads/src/misc.c
@@ -28,10 +28,7 @@ static ULONGLONG (*GetTickCount64FuncPtr) (VOID);
static void __attribute__((constructor)) ctor (void)
{
- HMODULE module = LoadLibrary("kernel32.dll");
- if (module == NULL) return;
-
- GetTickCount64FuncPtr = (__typeof__(GetTickCount64FuncPtr))
GetProcAddress(module, "GetTickCount64");
+ GetTickCount64FuncPtr = (__typeof__(GetTickCount64FuncPtr))
GetProcAddress(GetModuleHandle("kernel32.dll"), "GetTickCount64");
}
unsigned long long _pthread_time_in_ms(void)
diff --git a/mingw-w64-libraries/winpthreads/src/thread.c
b/mingw-w64-libraries/winpthreads/src/thread.c
index e2eeaaf..2eb76db 100644
--- a/mingw-w64-libraries/winpthreads/src/thread.c
+++ b/mingw-w64-libraries/winpthreads/src/thread.c
@@ -81,9 +81,7 @@ static ULONG (*RemoveVectoredExceptionHandlerFuncPtr) (PVOID);
static void __attribute__((constructor))
ctor (void)
{
- HMODULE module = LoadLibrary("kernel32.dll");
- if (module == NULL) return;
-
+ HMODULE module = GetModuleHandle("kernel32.dll");
AddVectoredExceptionHandlerFuncPtr =
(__typeof__(AddVectoredExceptionHandlerFuncPtr)) GetProcAddress(module,
"AddVectoredExceptionHandler");
RemoveVectoredExceptionHandlerFuncPtr =
(__typeof__(RemoveVectoredExceptionHandlerFuncPtr)) GetProcAddress(module,
"RemoveVectoredExceptionHandler");
}
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public