]> granicus.if.org Git - gc/commitdiff
Fix GC_CreateThread 'dwStackSize' argument type for Win64
authorIvan Maidanski <ivmai@mail.ru>
Sun, 25 Nov 2012 18:35:06 +0000 (22:35 +0400)
committerIvan Maidanski <ivmai@mail.ru>
Sun, 25 Nov 2012 18:35:06 +0000 (22:35 +0400)
* 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).

include/gc.h
tests/test.c
win32_threads.c

index 0a56dce19c8cf5b443478054c65ca40807465892..4063e7945fd068ed24840036ef1e2ee588f305d3 100644 (file)
@@ -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 *),
index 189aee333b88f90ad15944c06ce3c02b9535518e..7309755b60913b7e78b642bd6d57f02b5a6f867b 100644 (file)
@@ -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());
index 83b2c420bfaff1a97d1f28f604963461260f42d3..92b34f6f5f1f1f560da0557bcdd5a24421c0ae02 100644 (file)
@@ -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)