[Gc] Fix for theaded test.c

Ivan Maidanski ivmai at mail.ru
Mon Oct 27 10:05:43 PST 2008


Hi!

This small patch for test.c does:
- replaces locking on GC_allocate_ml (for just doing "n_tests++") with atomic inc operation (this is needed on Win32+GC_DLL where "GC_lock_holder" is not exported);
- disables "implicit thread registration" if thread local allocation or parallel marking are turned on.

Bye.

-------------- next part --------------
diff -ru bdwgc/tests/test.c updated/bdwgc/tests/test.c
--- bdwgc/tests/test.c	2008-10-25 20:06:36.000000000 +0400
+++ updated/bdwgc/tests/test.c	2008-10-27 16:17:50.000000000 +0300
@@ -1019,7 +1019,6 @@
     CLOCK_TYPE reverse_time;
     CLOCK_TYPE tree_time;
     unsigned long time_diff;
-    DCL_LOCK_STATE;
     
 #   ifdef FIND_LEAK
 	GC_printf(
@@ -1184,9 +1183,11 @@
       GC_log_printf("-------------Finished tree_test at time %u (%p)\n",
 	  	      (unsigned) time_diff, &start_time);
     }
-    LOCK();
-    n_tests++;
-    UNLOCK();
+#   ifdef THREADS
+      (void)AO_fetch_and_add1_full(&n_tests);
+#   else
+      n_tests++;
+#   endif
 #   if defined(THREADS) && defined(HANDLE_FORK)
       if (fork() == 0) {
 	GC_gcollect();
@@ -1490,7 +1491,7 @@
 # endif
   DWORD thread_id;
 
-# ifdef GC_DLL
+# if defined(GC_DLL) && !defined(THREAD_LOCAL_ALLOC) && !defined(PARALLEL_MARK)
     GC_use_DllMain();  /* Test with implicit thread registration if possible. */
     GC_printf("Using DllMain to track threads\n");
 # endif


More information about the Gc mailing list