Skip to content

Commit

Permalink
Add missing type casts in remap and register_my_thread_inner
Browse files Browse the repository at this point in the history
(fix of commit a825a2d)

Issue #206 (bdwgc).

* os_dep.c [USE_MUNMAP && USE_WINALLOC] (GC_remap): Cast result of
VirtualAlloc to ptr_t.
* win32_threads.c [!GC_NO_THREADS_DISCOVERY]
(GC_register_my_thread_inner): Cast the first argument of
InterlockedExchange() call to word* (instead of void*).
  • Loading branch information
ivmai committed Jun 20, 2018
1 parent 5f4ebc0 commit b66a887
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions os_dep.c
Original file line number Diff line number Diff line change
Expand Up @@ -2603,9 +2603,10 @@ GC_INNER void GC_remap(ptr_t start, size_t bytes)
!= sizeof(mem_info))
ABORT("Weird VirtualQuery result");
alloc_len = (len < mem_info.RegionSize) ? len : mem_info.RegionSize;
result = VirtualAlloc(start_addr, alloc_len, MEM_COMMIT,
GC_pages_executable ? PAGE_EXECUTE_READWRITE :
PAGE_READWRITE);
result = (ptr_t)VirtualAlloc(start_addr, alloc_len, MEM_COMMIT,
GC_pages_executable
? PAGE_EXECUTE_READWRITE
: PAGE_READWRITE);
if (result != start_addr) {
if (GetLastError() == ERROR_NOT_ENOUGH_MEMORY ||
GetLastError() == ERROR_OUTOFMEMORY) {
Expand Down
2 changes: 1 addition & 1 deletion win32_threads.c
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ STATIC GC_thread GC_register_my_thread_inner(const struct GC_stack_base *sb,
/* variants. */
/* cast away volatile qualifier */
for (i = 0;
InterlockedExchange((void*)&dll_thread_table[i].tm.in_use, 1) != 0;
InterlockedExchange((word*)&dll_thread_table[i].tm.in_use, 1) != 0;
i++) {
/* Compare-and-swap would make this cleaner, but that's not */
/* supported before Windows 98 and NT 4.0. In Windows 2000, */
Expand Down

0 comments on commit b66a887

Please sign in to comment.