Index: src/gc/darwin_stop_world.c =================================================================== RCS file: /project/ecl/cvsroot/ecl/src/gc/darwin_stop_world.c,v retrieving revision 1.4 diff -u -d -u -r1.4 darwin_stop_world.c --- src/gc/darwin_stop_world.c 27 Jun 2005 08:09:15 -0000 1.4 +++ src/gc/darwin_stop_world.c 16 Jun 2006 20:16:33 -0000 @@ -32,12 +32,19 @@ StackFrame *frame; if (stack_start == 0) { -# ifdef POWERPC +# if defined(POWERPC) # if CPP_WORDSZ == 32 __asm__ volatile("lwz %0,0(r1)" : "=r" (frame)); # else __asm__ volatile("ldz %0,0(r1)" : "=r" (frame)); # endif +# elif defined(I386) + /* p3-29 of SysV ABI says user code is responsible for marking + the deepest stack frame with a 0; if it gets the initial %esp + instead, that will be argc, which is not good. */ + __asm__ volatile("lea (%%ebp),%0" : "=r" (frame)); +# else +# error FIXME for non-x86 || ppc architectures # endif } else { frame = (StackFrame *)stack_start; @@ -52,11 +59,13 @@ frame = (StackFrame*)frame->savedSP; +#ifdef POWERPC /* we do these next two checks after going to the next frame because the LR for the first stack frame in the loop is not set up on purpose, so we shouldn't check it. */ if ((frame->savedLR & ~3) == 0) break; /* if the next LR is bogus, stop */ if ((~(frame->savedLR) & ~3) == 0) break; /* ditto */ +#endif } while (1); # ifdef DEBUG_THREADS @@ -73,7 +82,13 @@ GC_thread p; pthread_t me; ptr_t lo, hi; +#if defined(POWERPC) ppc_thread_state_t state; +#elif defined(I386) + i386_thread_state_t state; +#else +# error FIXME for non-x86 || ppc architectures +#endif mach_msg_type_number_t thread_state_count = MACHINE_THREAD_STATE_COUNT; me = pthread_self(); @@ -93,6 +108,17 @@ &thread_state_count); if(r != KERN_SUCCESS) ABORT("thread_get_state failed"); +#if defined(I386) + lo = state.esp; + + GC_push_one(state.eax); + GC_push_one(state.ebx); + GC_push_one(state.ecx); + GC_push_one(state.edx); + GC_push_one(state.edi); + GC_push_one(state.esi); + GC_push_one(state.ebp); +#elif defined(POWERPC) lo = (void*)(state.r1 - PPC_RED_ZONE_SIZE); GC_push_one(state.r0); @@ -126,6 +152,9 @@ GC_push_one(state.r29); GC_push_one(state.r30); GC_push_one(state.r31); +#else +# error FIXME for non-x86 || ppc architectures +#endif } /* p != me */ if(p->flags & MAIN_THREAD) hi = GC_stackbottom; @@ -209,7 +238,7 @@ GC_push_one(info.r29); GC_push_one(info.r30); GC_push_one(info.r31); -# else +# elif defined(I386) /* FIXME: Remove after testing: */ WARN("This is completely untested and likely will not work\n", 0); i386_thread_state_t info; @@ -236,7 +265,9 @@ GC_push_one(info.es); GC_push_one(info.fs); GC_push_one(info.gs); -# endif /* !POWERPC */ +# else +# error FIXME for non-x86 || ppc architectures +# endif /* !POWERPC */ } # if DEBUG_THREADS GC_printf3("Darwin: Stack for thread 0x%lx = [%lx,%lx)\n",