Ticket #8358: patch-gc

File patch-gc, 3.5 KB (added by takuzo.ohara@…, 19 years ago)

Patch to fix gc compile error. Should be put under gauche/files/.

Line 
1Index: gc/darwin_stop_world.c
2===================================================================
3--- gc/darwin_stop_world.c      (revision 56697)
4+++ gc/darwin_stop_world.c      (working copy)
5@@ -73,7 +73,13 @@
6   GC_thread p;
7   pthread_t me;
8   ptr_t lo, hi;
9+#if defined(POWERPC)
10   ppc_thread_state_t state;
11+#elif defined(I386)
12+  i386_thread_state_t state;
13+#else
14+# error FIXME for non-x86 || ppc architectures
15+#endif
16   mach_msg_type_number_t thread_state_count = MACHINE_THREAD_STATE_COUNT;
17   
18   me = pthread_self();
19@@ -93,6 +99,17 @@
20                             &thread_state_count);
21        if(r != KERN_SUCCESS) ABORT("thread_get_state failed");
22       
23+#if defined(I386)
24+       lo = state.esp;
25+
26+       GC_push_one(state.eax);
27+       GC_push_one(state.ebx);
28+       GC_push_one(state.ecx);
29+       GC_push_one(state.edx);
30+       GC_push_one(state.edi);
31+       GC_push_one(state.esi);
32+       GC_push_one(state.ebp);
33+#elif defined(POWERPC)
34        lo = (void*)(state.r1 - PPC_RED_ZONE_SIZE);
35         
36        GC_push_one(state.r0);
37@@ -126,6 +143,9 @@
38        GC_push_one(state.r29);
39        GC_push_one(state.r30);
40        GC_push_one(state.r31);
41+#else
42+# error FIXME for non-x86 || ppc architectures
43+#endif
44       } /* p != me */
45       if(p->flags & MAIN_THREAD)
46        hi = GC_stackbottom;
47Index: include/private/gcconfig.h
48===================================================================
49--- gc/include/private/gcconfig.h       (revision 56697)
50+++ gc/include/private/gcconfig.h       (working copy)
51@@ -304,7 +304,28 @@
52 #    define mach_type_known
53 #   elif defined(__i386__)
54 #    define I386
55-     --> Not really supported, but at least we recognize it.
56+#    define mach_type_known
57+#    define DARWIN_DONT_PARSE_STACK
58+#    define OS_TYPE "DARWIN"
59+#    define DYNAMIC_LOADING
60+     /* XXX: see get_end(3), get_etext() and get_end() should not be used.
61+        These aren't used when dyld support is enabled (it is by default) */
62+#    define DATASTART ((ptr_t) get_etext())
63+#    define DATAEND    ((ptr_t) get_end())
64+#    define STACKBOTTOM ((ptr_t) 0xc0000000)
65+#    define USE_MMAP
66+#    define USE_MMAP_ANON
67+#    define USE_ASM_PUSH_REGS
68+     /* This is potentially buggy. It needs more testing. See the comments in
69+        os_dep.c.  It relies on threads to track writes. */
70+#    ifdef GC_DARWIN_THREADS
71+/* #       define MPROTECT_VDB -- diabled for now.  May work for some apps. */
72+#    endif
73+#    include <unistd.h>
74+#    define GETPAGESIZE() getpagesize()
75+      /* There seems to be some issues with trylock hanging on darwin. This
76+         should be looked into some more */
77+#     define NO_PTHREAD_TRYLOCK
78 #   endif
79 # endif
80 # if defined(NeXT) && defined(mc68000)
81Index: gc/os_dep.c
82===================================================================
83--- gc/os_dep.c (revision 56697)
84+++ gc/os_dep.c (working copy)
85@@ -3819,6 +3819,10 @@
86         mach_msg_type_number_t exc_state_count = PPC_EXCEPTION_STATE64_COUNT;
87         ppc_exception_state64_t exc_state;
88 #     endif
89+#   elif defined(I386)
90+        thread_state_flavor_t flavor = i386_EXCEPTION_STATE;
91+        mach_msg_type_number_t exc_state_count = i386_EXCEPTION_STATE_COUNT;
92+        i386_exception_state_t exc_state;
93 #   else
94 #      error FIXME for non-ppc darwin
95 #   endif
96@@ -3850,7 +3854,13 @@
97     }
98     
99     /* This is the address that caused the fault */
100+#if defined(POWERPC)
101     addr = (char*) exc_state.dar;
102+#elif defined (I386)
103+    addr = (char*) exc_state.faultvaddr;
104+#else
105+#   error FIXME for non POWERPC/I386
106+#endif
107         
108     if((HDR(addr)) == 0) {
109         /* Ugh... just like the SIGBUS problem above, it seems we get a bogus