summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2012-11-25 22:35:06 +0400
committerIvan Maidanski <ivmai@mail.ru>2012-11-25 22:35:06 +0400
commitb9260aa98074770c042ccb654e806e3d17d9cf3d (patch)
tree654a87fcfe3b26d1d8e454be7d4d01abc1cda88e
parent37d8fb73e7210509bdc5f3e69b1ec5f8dcc6bda0 (diff)
downloadbdwgc-b9260aa98074770c042ccb654e806e3d17d9cf3d.tar.gz
Fix GC_CreateThread 'dwStackSize' argument type for Win64
* include/gc.h (GC_uintptr_t): Define (for Win32/CE) even if GC_NO_THREAD_DECLS; move definition upper than GC_CreateThread. * include/gc.h (GC_WIN32_SIZE_T): New macro (defined as GC_uintptr_t, Win32 threads only). * include/gc.h (GC_CreateThread): Use GC_WIN32_SIZE_T instead of DWORD type for "dwStackSize" argument (Win32 threads only). * win32_threads.c (GC_CreateThread): Likewise. * tests/test.c (fork_a_thread): Verify types of GC_CreateThread arguments by explicit casts (only if GC_WIN32_THREADS).
-rw-r--r--include/gc.h19
-rw-r--r--tests/test.c5
-rw-r--r--win32_threads.c2
3 files changed, 15 insertions, 11 deletions
diff --git a/include/gc.h b/include/gc.h
index 0a56dce1..4063e794 100644
--- a/include/gc.h
+++ b/include/gc.h
@@ -1447,7 +1447,7 @@ GC_API void GC_CALL GC_register_has_static_roots_callback(
/* Note: for Cygwin and win32-pthread, this is skipped */
/* unless windows.h is included before gc.h. */
-# ifndef GC_NO_THREAD_DECLS
+# if !defined(GC_NO_THREAD_DECLS) || defined(GC_BUILD)
# ifdef __cplusplus
} /* Including windows.h in an extern "C" context no longer works. */
@@ -1479,6 +1479,14 @@ GC_API void GC_CALL GC_register_has_static_roots_callback(
LPVOID /* reserved */);
# endif /* GC_INSIDE_DLL */
+# if !defined(_UINTPTR_T) && !defined(_UINTPTR_T_DEFINED) \
+ && !defined(UINTPTR_MAX)
+ typedef GC_word GC_uintptr_t;
+# else
+ typedef uintptr_t GC_uintptr_t;
+# endif
+# define GC_WIN32_SIZE_T GC_uintptr_t
+
/* All threads must be created using GC_CreateThread or */
/* GC_beginthreadex, or must explicitly call GC_register_my_thread */
/* (and call GC_unregister_my_thread before thread termination), so */
@@ -1491,7 +1499,7 @@ GC_API void GC_CALL GC_register_has_static_roots_callback(
/* so that the thread is properly unregistered. */
GC_API HANDLE WINAPI GC_CreateThread(
LPSECURITY_ATTRIBUTES /* lpThreadAttributes */,
- DWORD /* dwStackSize */,
+ GC_WIN32_SIZE_T /* dwStackSize */,
LPTHREAD_START_ROUTINE /* lpStartAddress */,
LPVOID /* lpParameter */, DWORD /* dwCreationFlags */,
LPDWORD /* lpThreadId */);
@@ -1505,13 +1513,6 @@ GC_API void GC_CALL GC_register_has_static_roots_callback(
DWORD /* dwExitCode */);
# if !defined(_WIN32_WCE) && !defined(__CEGCC__)
-# if !defined(_UINTPTR_T) && !defined(_UINTPTR_T_DEFINED) \
- && !defined(UINTPTR_MAX)
- typedef GC_word GC_uintptr_t;
-# else
- typedef uintptr_t GC_uintptr_t;
-# endif
-
GC_API GC_uintptr_t GC_CALL GC_beginthreadex(
void * /* security */, unsigned /* stack_size */,
unsigned (__stdcall *)(void *),
diff --git a/tests/test.c b/tests/test.c
index 189aee33..7309755b 100644
--- a/tests/test.c
+++ b/tests/test.c
@@ -532,7 +532,10 @@ void check_marks_int_list(sexpr x)
{
DWORD thread_id;
HANDLE h;
- h = GC_CreateThread(NULL, 0, tiny_reverse_test, 0, 0, &thread_id);
+ h = GC_CreateThread((SECURITY_ATTRIBUTES *)NULL, (word)0,
+ tiny_reverse_test, NULL, (DWORD)0, &thread_id);
+ /* Explicitly specify types of the */
+ /* arguments to test the prototype. */
if (h == (HANDLE)NULL) {
GC_printf("Small thread creation failed %d\n",
(int)GetLastError());
diff --git a/win32_threads.c b/win32_threads.c
index 83b2c420..92b34f6f 100644
--- a/win32_threads.c
+++ b/win32_threads.c
@@ -2227,7 +2227,7 @@ GC_INNER void GC_get_next_stack(char *start, char *limit,
GC_API HANDLE WINAPI GC_CreateThread(
LPSECURITY_ATTRIBUTES lpThreadAttributes,
- DWORD dwStackSize,
+ GC_WIN32_SIZE_T dwStackSize,
LPTHREAD_START_ROUTINE lpStartAddress,
LPVOID lpParameter, DWORD dwCreationFlags,
LPDWORD lpThreadId)