[MLton-commit] r6269

Matthew Fluet fluet at mlton.org
Fri Dec 14 15:40:04 PST 2007


Patch from Wesley Terpstra to compile runtime on Mac OS X (10.5, Leopard)
----------------------------------------------------------------------

U   mlton/trunk/runtime/platform/darwin.c

----------------------------------------------------------------------

Modified: mlton/trunk/runtime/platform/darwin.c
===================================================================
--- mlton/trunk/runtime/platform/darwin.c	2007-12-14 22:58:54 UTC (rev 6268)
+++ mlton/trunk/runtime/platform/darwin.c	2007-12-14 23:40:03 UTC (rev 6269)
@@ -1,5 +1,5 @@
-#include <mach-o/dyld.h>
 #include <mach-o/getsect.h>  // for get_etext()
+#include <dlfcn.h>
 #include <stdio.h>
 
 #include "platform.h"
@@ -16,12 +16,13 @@
 }
 
 code_pointer GC_getTextStart (void) {
-        void *address;
-        const struct mach_header *mh;
-
-        _dyld_lookup_and_bind ("_main", &address, NULL);
-        mh = _dyld_get_image_header_containing_address (address);
-        return (code_pointer)mh;
+        void* address;
+        Dl_info info;
+        
+        address = dlsym(RTLD_DEFAULT, "main");
+        dladdr(address, &info);
+        
+        return (code_pointer)info.dli_fbase;
 }
 
 void GC_displayMem (void) {
@@ -35,10 +36,18 @@
                      __attribute__ ((unused)) siginfo_t *sip, 
                      ucontext_t *ucp) {
 #if (defined(__powerpc__) || defined(__ppc__))
+#if __DARWIN_UNIX03
+        GC_handleSigProf ((code_pointer) ucp->uc_mcontext->__ss.__srr0);
+#else
         GC_handleSigProf ((code_pointer) ucp->uc_mcontext->ss.srr0);
+#endif
 #elif (defined(__i386__))
+#if __DARWIN_UNIX03
+        GC_handleSigProf ((code_pointer) ucp->uc_mcontext->__ss.__eip);
+#else
         GC_handleSigProf ((code_pointer) ucp->uc_mcontext->ss.eip);
 #endif
+#endif
 }
 
 void GC_setSigProfHandler (struct sigaction *sa) {




More information about the MLton-commit mailing list