NaCl runtime fixes
[mono.git] / libgc / pthread_stop_world.c
index 05e897fb739ba5a4468ccd54c99f51f7771118c3..8b25376b54ab6d691176ba61f0d7345c6b5c1ab6 100644 (file)
@@ -24,7 +24,7 @@
 #endif
 
 #ifdef NACL
-int nacl_park_threads_now = 0;
+volatile int __nacl_thread_suspension_needed = 0;
 pthread_t nacl_thread_parker = -1;
 
 volatile int nacl_thread_parked[MAX_NACL_GC_THREADS];
@@ -471,7 +471,7 @@ static void pthread_stop_world()
     GC_printf1("pthread_stop_world: num_threads %d\n", nacl_num_gc_threads - 1);
     #endif
     nacl_thread_parker = pthread_self();
-    nacl_park_threads_now = 1;
+    __nacl_thread_suspension_needed = 1;
     
     while (1) {
        #define NACL_PARK_WAIT_NANOSECONDS 100000
@@ -549,6 +549,8 @@ void nacl_pre_syscall_hook()
     }
 }
 
+void __nacl_suspend_thread_if_needed();
+
 void nacl_post_syscall_hook()
 {
     /* Calling __nacl_suspend_thread_if_needed() right away should guarantee we don't mutate the GC set. */
@@ -559,7 +561,7 @@ void nacl_post_syscall_hook()
 }
 
 void __nacl_suspend_thread_if_needed() {
-    if (nacl_park_threads_now) {
+    if (__nacl_thread_suspension_needed) {
         pthread_t self = pthread_self();
         int local_dummy = 0;
         /* Don't try to park the thread parker. */
@@ -578,7 +580,7 @@ void __nacl_suspend_thread_if_needed() {
             nacl_gc_thread_self->stop_info.stack_ptr = (ptr_t)(&local_dummy);
         }
         nacl_thread_parked[nacl_thread_idx] = 1;
-        while (nacl_park_threads_now)
+        while (__nacl_thread_suspension_needed)
             ; /* spin */
         nacl_thread_parked[nacl_thread_idx] = 0;
 
@@ -688,7 +690,7 @@ static void pthread_start_world()
 #   if DEBUG_THREADS
     GC_printf0("World starting\n");
 #   endif
-    nacl_park_threads_now = 0;
+    __nacl_thread_suspension_needed = 0;
     if (GC_notify_event)
         GC_notify_event (GC_EVENT_POST_START_WORLD);
 #endif /* NACL */