summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2020-04-19 11:31:28 +0300
committerIvan Maidanski <ivmai@mail.ru>2020-04-19 11:40:33 +0300
commit95175f0db3daa9f79d08e097cd41b90a06138a4d (patch)
treec39140c1d52c8937ed4c3dcb85ece2fd83864f2a
parentb78dd64a2bfd18d64608f8592ab4f7ec9ab562de (diff)
downloadbdwgc-95175f0db3daa9f79d08e097cd41b90a06138a4d.tar.gz
Eliminate 'cast between incompatible func types' warnings for FARPROC vars
Direct conversion of GetProcAddress() result (of FARPROC type) to the required functional type is performed by casting the result to word type first. * misc.c [MSGBOX_ON_ERROR && DONT_USE_USER32_DLL] (GC_win32_MessageBoxA): Cast pfn to word type first. * win32_threads.c [WOW64_THREAD_CONTEXT_WORKAROUND] (GC_thr_init): Likewise. * misc.c [GC_WIN32_THREADS && !GC_PTHREADS && !MSWINRT_FLAVOR && !MSWINCE] (GC_init): Change pfn type to FARPROC; cast pfn to word type first and, then, to the required functional type. * os_dep.c [!OS2 && GWW_VDB] (GetWriteWatch_func): Change type to FARPROC. * os_dep.c [!OS2 && GWW_VDB] (GC_GWW_AVAILABLE): Compare GetWriteWatch_func to 0 instead of NULL. * os_dep.c [GWW_VDB] (detect_GetWriteWatch, GC_gww_read_dirty): Cast GetWriteWatch_func to word type first and, then, to the required functional type.
-rw-r--r--misc.c12
-rw-r--r--os_dep.c33
-rw-r--r--win32_threads.c6
3 files changed, 24 insertions, 27 deletions
diff --git a/misc.c b/misc.c
index d178790e..e60ea6c5 100644
--- a/misc.c
+++ b/misc.c
@@ -831,7 +831,7 @@ GC_API int GC_CALL GC_is_init_called(void)
if (hU32) {
FARPROC pfn = GetProcAddress(hU32, "MessageBoxA");
if (pfn)
- (void)(*(int (WINAPI *)(HWND, LPCSTR, LPCSTR, UINT))pfn)(
+ (void)(*(int (WINAPI *)(HWND, LPCSTR, LPCSTR, UINT))(word)pfn)(
NULL /* hWnd */, msg, caption, flags);
(void)FreeLibrary(hU32);
}
@@ -958,14 +958,14 @@ GC_API void GC_CALL GC_init(void)
# else
{
# ifndef MSWINCE
- BOOL (WINAPI *pfn)(LPCRITICAL_SECTION, DWORD) = 0;
+ FARPROC pfn = 0;
HMODULE hK32 = GetModuleHandle(TEXT("kernel32.dll"));
if (hK32)
- pfn = (BOOL (WINAPI *)(LPCRITICAL_SECTION, DWORD))
- GetProcAddress(hK32,
- "InitializeCriticalSectionAndSpinCount");
+ pfn = GetProcAddress(hK32,
+ "InitializeCriticalSectionAndSpinCount");
if (pfn) {
- pfn(&GC_allocate_ml, SPIN_COUNT);
+ (*(BOOL (WINAPI *)(LPCRITICAL_SECTION, DWORD))(word)pfn)(
+ &GC_allocate_ml, SPIN_COUNT);
} else
# endif /* !MSWINCE */
/* else */ InitializeCriticalSection(&GC_allocate_ml);
diff --git a/os_dep.c b/os_dep.c
index fb34d8d4..a74155e0 100644
--- a/os_dep.c
+++ b/os_dep.c
@@ -1636,10 +1636,10 @@ void GC_register_data_segments(void)
typedef UINT (WINAPI * GetWriteWatch_type)(
DWORD, PVOID, GC_ULONG_PTR /* SIZE_T */,
PVOID *, GC_ULONG_PTR *, PULONG);
- static GetWriteWatch_type GetWriteWatch_func;
+ static FARPROC GetWriteWatch_func;
static DWORD GetWriteWatch_alloc_flag;
-# define GC_GWW_AVAILABLE() (GetWriteWatch_func != NULL)
+# define GC_GWW_AVAILABLE() (GetWriteWatch_func != 0)
static void detect_GetWriteWatch(void)
{
@@ -1681,8 +1681,7 @@ void GC_register_data_segments(void)
hK32 = GetModuleHandle(TEXT("kernel32.dll"));
# endif
if (hK32 != (HMODULE)0 &&
- (GetWriteWatch_func = (GetWriteWatch_type)GetProcAddress(hK32,
- "GetWriteWatch")) != NULL) {
+ (GetWriteWatch_func = GetProcAddress(hK32, "GetWriteWatch")) != 0) {
/* Also check whether VirtualAlloc accepts MEM_WRITE_WATCH, */
/* as some versions of kernel32.dll have one but not the */
/* other, making the feature completely broken. */
@@ -1696,24 +1695,23 @@ void GC_register_data_segments(void)
/* Check that it actually works. In spite of some */
/* documentation it actually seems to exist on Win2K. */
/* This test may be unnecessary, but ... */
- if (GetWriteWatch_func(WRITE_WATCH_FLAG_RESET,
- page, GC_page_size,
- pages,
- &count,
- &page_size) != 0) {
+ if ((*(GetWriteWatch_type)(word)GetWriteWatch_func)(
+ WRITE_WATCH_FLAG_RESET, page,
+ GC_page_size, pages, &count,
+ &page_size) != 0) {
/* GetWriteWatch always fails. */
- GetWriteWatch_func = NULL;
+ GetWriteWatch_func = 0;
} else {
GetWriteWatch_alloc_flag = MEM_WRITE_WATCH;
}
VirtualFree(page, 0 /* dwSize */, MEM_RELEASE);
} else {
/* GetWriteWatch will be useless. */
- GetWriteWatch_func = NULL;
+ GetWriteWatch_func = 0;
}
}
# ifndef SMALL_CONFIG
- if (GetWriteWatch_func == NULL) {
+ if (!GetWriteWatch_func) {
GC_COND_LOG_PRINTF("Did not find a usable GetWriteWatch()\n");
} else {
GC_COND_LOG_PRINTF("Using GetWriteWatch()\n");
@@ -2935,12 +2933,11 @@ GC_API GC_push_other_roots_proc GC_CALL GC_get_push_other_roots(void)
/* loop condition. Since each partial call will reset the */
/* status of some pages, this should eventually terminate even */
/* in the overflow case. */
- if (GetWriteWatch_func(WRITE_WATCH_FLAG_RESET,
- GC_heap_sects[i].hs_start,
- GC_heap_sects[i].hs_bytes,
- pages,
- &count,
- &page_size) != 0) {
+ if ((*(GetWriteWatch_type)(word)GetWriteWatch_func)(
+ WRITE_WATCH_FLAG_RESET,
+ GC_heap_sects[i].hs_start,
+ GC_heap_sects[i].hs_bytes,
+ pages, &count, &page_size) != 0) {
static int warn_count = 0;
struct hblk * start = (struct hblk *)GC_heap_sects[i].hs_start;
static struct hblk *last_warned = 0;
diff --git a/win32_threads.c b/win32_threads.c
index 2db60f8a..f6edb431 100644
--- a/win32_threads.c
+++ b/win32_threads.c
@@ -2042,7 +2042,7 @@ GC_INNER void GC_get_next_stack(char *start, char *limit,
/* Invoke SetThreadDescription(). Cast the function pointer to word */
/* first to avoid "incompatible function types" compiler warning. */
- hr = ((HRESULT (WINAPI *)(HANDLE, const WCHAR *))
+ hr = (*(HRESULT (WINAPI *)(HANDLE, const WCHAR *))
(word)setThreadDescription_fn)(GetCurrentThread(), name_buf);
if (FAILED(hr))
WARN("SetThreadDescription failed\n", 0);
@@ -2775,8 +2775,8 @@ GC_INNER void GC_thr_init(void)
if (hK32) {
FARPROC pfn = GetProcAddress(hK32, "IsWow64Process");
if (pfn
- && !(*(BOOL (WINAPI*)(HANDLE, BOOL*))pfn)(GetCurrentProcess(),
- &isWow64))
+ && !(*(BOOL (WINAPI*)(HANDLE, BOOL*))(word)pfn)(
+ GetCurrentProcess(), &isWow64))
isWow64 = FALSE; /* IsWow64Process failed */
}
# endif