From: Ivan Maidanski Date: Sun, 17 May 2015 14:37:51 +0000 (+0300) Subject: Fix logic/compile errors in "event callbacks" code (Darwin, Pthreads) X-Git-Tag: gc7_6_0~194^2~1 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7cd987a1656fb2c9e38adc79027c1f0ef080f5df;p=gc Fix logic/compile errors in "event callbacks" code (Darwin, Pthreads) * 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. --- diff --git a/darwin_stop_world.c b/darwin_stop_world.c index 35a4ba7d..32b1ea64 100644 --- a/darwin_stop_world.c +++ b/darwin_stop_world.c @@ -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); } } } diff --git a/pthread_stop_world.c b/pthread_stop_world.c index 9bce8741..9ad51e3a 100644 --- a/pthread_stop_world.c +++ b/pthread_stop_world.c @@ -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 }