Eliminate 'pointer targets differ in signedness' compiler warning (Win32)
authorIvan Maidanski <ivmai@mail.ru>
Tue, 9 Oct 2018 07:59:39 +0000 (10:59 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Tue, 9 Oct 2018 09:01:21 +0000 (12:01 +0300)
(fix of commit b66a887d7)

* win32_threads.c [!GC_NO_THREADS_DISCOVERY] (GC_Thread_Rep.tm): Add
long_in_use field to union; add comment.
* win32_threads.c [!GC_NO_THREADS_DISCOVERY]
(GC_register_my_thread_inner): Pass pointer to long_in_use field
instead of a pointer to in_use one casted to word*; remove outdated
comment.

win32_threads.c

index 225d8e0..bf3f655 100644 (file)
@@ -179,6 +179,11 @@ struct GC_Thread_Rep {
                         /* entries have invalid ids of          */
                         /* zero and zero stack fields.          */
                         /* Used only with GC_win32_dll_threads. */
+      LONG long_in_use; /* The same but of the type that        */
+                        /* matches the first argument of        */
+                        /* InterlockedExchange(); volatile is   */
+                        /* omitted because the ancient version  */
+                        /* of the prototype lacks the qualifier.*/
 #   endif
     struct GC_Thread_Rep * next;
                         /* Hash table link without              */
@@ -415,9 +420,8 @@ STATIC GC_thread GC_register_my_thread_inner(const struct GC_stack_base *sb,
       /* around code that doesn't call back into the system libraries   */
       /* might be OK.  But this hasn't been tested across all win32     */
       /* variants.                                                      */
-                  /* cast away volatile qualifier */
       for (i = 0;
-           InterlockedExchange((word*)&dll_thread_table[i].tm.in_use, 1) != 0;
+           InterlockedExchange(&dll_thread_table[i].tm.long_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,    */