2007-10-25 Jb Evain <jbevain@novell.com>
[mono.git] / libgc / darwin_stop_world.c
index 00a25cf62d24bda6185917df2c755d27fac807cd..6dcc0680831b1140d2166b6c9351d6064cc15af6 100644 (file)
@@ -75,12 +75,14 @@ void GC_push_all_stacks() {
   ptr_t lo, hi;
 #if defined(POWERPC)
   ppc_thread_state_t state;
+  mach_msg_type_number_t thread_state_count = PPC_THREAD_STATE_COUNT;
 #elif defined(I386)
   i386_thread_state_t state;
+  mach_msg_type_number_t thread_state_count = i386_THREAD_STATE_COUNT;
 #else
 # error FIXME for non-x86 || ppc architectures
-#endif
   mach_msg_type_number_t thread_state_count = MACHINE_THREAD_STATE_COUNT;
+#endif
   
   me = pthread_self();
   if (!GC_thr_initialized) GC_thr_init();
@@ -94,7 +96,7 @@ void GC_push_all_stacks() {
        /* Get the thread state (registers, etc) */
        r = thread_get_state(
                             p->stop_info.mach_thread,
-                            MACHINE_THREAD_STATE,
+                            GC_MACH_THREAD_STATE_FLAVOR,
                             (natural_t*)&state,
                             &thread_state_count);
        if(r != KERN_SUCCESS) ABORT("thread_get_state failed");
@@ -193,7 +195,7 @@ void GC_push_all_stacks() {
        ppc_thread_state64_t info;
 #      endif
        mach_msg_type_number_t outCount = THREAD_STATE_MAX;
-       r = thread_get_state(thread, MACHINE_THREAD_STATE,
+       r = thread_get_state(thread, GC_MACH_THREAD_STATE_FLAVOR,
                             (natural_t *)&info, &outCount);
        if(r != KERN_SUCCESS) continue;
 
@@ -236,7 +238,7 @@ void GC_push_all_stacks() {
        WARN("This is completely untested and likely will not work\n", 0);
        i386_thread_state_t info;
        mach_msg_type_number_t outCount = THREAD_STATE_MAX;
-       r = thread_get_state(thread, MACHINE_THREAD_STATE,
+       r = thread_get_state(thread, GC_MACH_THREAD_STATE_FLAVOR,
                             (natural_t *)&info, &outCount);
        if(r != KERN_SUCCESS) continue;
 
@@ -278,13 +280,14 @@ void GC_push_all_stacks() {
 static mach_port_t GC_mach_handler_thread;
 static int GC_use_mach_handler_thread = 0;
 
-static struct GC_mach_thread GC_mach_threads[THREAD_TABLE_SZ];
+#define SUSPEND_THREADS_SIZE 2048
+static struct GC_mach_thread GC_mach_threads[SUSPEND_THREADS_SIZE];
 static int GC_mach_threads_count;
 
 void GC_stop_init() {
   int i;
 
-  for (i = 0; i < THREAD_TABLE_SZ; i++) {
+  for (i = 0; i < SUSPEND_THREADS_SIZE; i++) {
     GC_mach_threads[i].thread = 0;
     GC_mach_threads[i].already_suspended = 0;
   }