diff options
-rw-r--r-- | misc.c | 12 | ||||
-rw-r--r-- | os_dep.c | 33 | ||||
-rw-r--r-- | win32_threads.c | 6 |
3 files changed, 24 insertions, 27 deletions
@@ -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); @@ -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 |