]> granicus.if.org Git - gc/commitdiff
Fix logic/compile errors in "event callbacks" code (Darwin, Pthreads)
authorIvan Maidanski <ivmai@mail.ru>
Sun, 17 May 2015 14:37:51 +0000 (17:37 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Sun, 17 May 2015 15:06:01 +0000 (18:06 +0300)
* darwin_stop_world.c (GC_stop_world): Replace
GC_EVENT_THREAD_UNSUSPENDED to GC_EVENT_THREAD_SUSPENDED.
* pthread_stop_world.c (GC_on_collection_event): Declare.
* pthread_stop_world.c (GC_suspend_all): Change type of "thread_id"
local variable to pthread_t (or pid_t for Android) instead of int; fix
"threadid" parameter to "thread_id" in GC_on_collection_event call;
implement notification for NaCl target.
* pthread_stop_world.c (GC_start_world): Declare "thread_id" local
variable; implement notification for NaCl target.

darwin_stop_world.c
pthread_stop_world.c

index 35a4ba7d3e14a965919410529ebf83929f0c3147..32b1ea646d0b101fbe4e0b1f40f39b3b5dcf007e 100644 (file)
@@ -543,7 +543,8 @@ GC_INNER void GC_stop_world(void)
           if (kern_result != KERN_SUCCESS)
             ABORT("thread_suspend failed");
           if (GC_on_collection_event)
-              GC_on_collection_event(GC_EVENT_THREAD_UNSUSPENDED, (void *)p->stop_info.mach_thread);
+            GC_on_collection_event(GC_EVENT_THREAD_SUSPENDED,
+                                   (void *)p->stop_info.mach_thread);
         }
       }
     }
index 9bce8741dbcee66e317c2567c4a2ec53773c2849..9ad51e3a60a50ccc1e128ee75098b3d03b031ee8 100644 (file)
@@ -459,6 +459,8 @@ GC_INNER void GC_push_all_stacks(void)
   }
 #endif /* PLATFORM_ANDROID */
 
+extern GC_on_collection_event_proc GC_on_collection_event;
+
 /* We hold the allocation lock.  Suspend all threads that might */
 /* still be running.  Return the number of suspend signals that */
 /* were sent.                                                   */
@@ -466,8 +468,12 @@ STATIC int GC_suspend_all(void)
 {
   int n_live_threads = 0;
   int i;
-  int thread_id;
 # ifndef NACL
+#   ifndef PLATFORM_ANDROID
+      pthread_t thread_id;
+#   else
+      pid_t thread_id;
+#   endif
     GC_thread p;
 #   ifndef GC_OPENBSD_UTHREADS
       int result;
@@ -512,7 +518,8 @@ STATIC int GC_suspend_all(void)
                 result = android_thread_kill(thread_id, GC_sig_suspend);
 #             endif
               if (GC_on_collection_event)
-                GC_on_collection_event(GC_EVENT_THREAD_SUSPENDED, (void *)threadid);
+                GC_on_collection_event(GC_EVENT_THREAD_SUSPENDED,
+                                       (void *)thread_id);
               switch(result) {
                 case ESRCH:
                     /* Not really there anymore.  Possible? */
@@ -559,6 +566,9 @@ STATIC int GC_suspend_all(void)
           num_used++;
           if (GC_nacl_thread_parked[i] == 1) {
             num_threads_parked++;
+            if (GC_on_collection_event)
+              GC_on_collection_event(GC_EVENT_THREAD_SUSPENDED,
+                                     (void *)(word)i);
           }
         }
       }
@@ -804,6 +814,11 @@ GC_INNER void GC_start_world(void)
       register int n_live_threads = 0;
       register int result;
 #   endif
+#   ifndef PLATFORM_ANDROID
+      pthread_t thread_id;
+#   else
+      pid_t thread_id;
+#   endif
 #   ifdef GC_NETBSD_THREADS_WORKAROUND
       int code;
 #   endif
@@ -874,6 +889,9 @@ GC_INNER void GC_start_world(void)
       GC_log_printf("World starting...\n");
 #   endif
     GC_nacl_park_threads_now = 0;
+    if (GC_on_collection_event)
+      GC_on_collection_event(GC_EVENT_THREAD_UNSUSPENDED, NULL);
+      /* TODO: Send event for every unsuspended thread. */
 # endif
 }