0.8.7.57:
authorWilliam Harold Newman <william.newman@airmail.net>
Fri, 20 Feb 2004 18:15:10 +0000 (18:15 +0000)
committerWilliam Harold Newman <william.newman@airmail.net>
Fri, 20 Feb 2004 18:15:10 +0000 (18:15 +0000)
merged Brian Mastenbrook's "SBCL-on-Darwin state" patch
(sbcl-devel 2004-02-18)

23 files changed:
contrib/asdf-install/installer.lisp
make-target-1.sh
src/runtime/Config.ppc-darwin
src/runtime/GNUmakefile
src/runtime/breakpoint.c
src/runtime/bsd-os.c
src/runtime/bsd-os.h
src/runtime/coreparse.c
src/runtime/globals.h
src/runtime/interr.c
src/runtime/interrupt.c
src/runtime/monitor.c
src/runtime/os-common.c
src/runtime/ppc-arch.c
src/runtime/ppc-assem.S
src/runtime/ppc-darwin-mkrospace.c [new file with mode: 0644]
src/runtime/ppc-darwin-os.c
src/runtime/ppc-lispregs.h
src/runtime/purify.c
src/runtime/save.c
src/runtime/validate.c
src/runtime/vars.c
version.lisp-expr

index c85e947..d17d7e1 100644 (file)
   (let* ((tar
          (with-output-to-string (o)
            (or
-            (sb-ext:run-program "tar"
+            (sb-ext:run-program #-darwin "tar"
+                                #+darwin "gnutar"
                                 (list "-C" (namestring source)
                                       "-xzvf" (namestring packagename))
                                 :output o
index d0bdbd0..8256384 100644 (file)
@@ -35,3 +35,9 @@ cd tools-for-build
 $GNUMAKE -I../src/runtime grovel-headers || exit 1
 cd ..
 tools-for-build/grovel-headers > output/stuff-groveled-from-headers.lisp
+
+# after-grovel-headers may not exist for all platforms (used for
+# Darwin hacks)
+cd src/runtime
+$GNUMAKE after-grovel-headers || true
+cd ..
index a208c5d..8f8cc2e 100644 (file)
@@ -1,9 +1,9 @@
 # -*- makefile -*-
-CFLAGS = -DDARWIN -Dppc -g -Wall -O3 -no-cpp-precomp
+CFLAGS = -Dppc -g -Wall -O3 -no-cpp-precomp
 OS_SRC = bsd-os.c os-common.c ppc-darwin-os.c ppc-darwin-dlshim.c
 OS_LIBS = -lSystem -lc -lm
 
-# Avoid the dreaded gcc 3.3 prerelease tarpit of death!
+# Avoid the gcc 3.3 prerelease tarpit of death!
 CC = gcc3
 
 ASSEM_SRC = ppc-assem.S ldso-stubs.S
@@ -11,7 +11,31 @@ ARCH_SRC = ppc-arch.c
 
 CPP = cpp -no-cpp-precomp
 
-OS_LINK_FLAGS = -dynamic -L$(HOME)/local/lib -L/sw/lib -L/opt/local/lib -L/usr/local/lib
+# FIXME - "-Wl,-segaddr,SBCLRO,0x1000000" is output from
+# ppc-darwin-mkrospace (it depends on READ_ONLY_SPACE I believe) but it
+# is hard-coded here!
+OS_LINK_FLAGS = -dynamic -L$(HOME)/local/lib -L/sw/lib -L/opt/local/lib -L/usr/local/lib -Wl,-segaddr,SBCLRO,0x1000000 -Wl,-seg1addr,0x5000000 $(if $(AFTER_GROVEL_HEADERS),ppc-darwin-rospace.o)
 
 GC_SRC= cheneygc.c
 
+CLEAN_FILES += ppc-darwin-mkrospace
+
+ppc-darwin-mkrospace: ppc-darwin-mkrospace.c
+       $(CC) -o $@ $<
+
+ppc-darwin-rospace.o: ppc-darwin-mkrospace
+       ./ppc-darwin-mkrospace
+
+.PHONY: after-grovel-headers
+
+# Rebuild the sbcl runtime to avoid Panther placing the heap where
+# it wants read only space (in the first 32 megabytes, where it
+# can be absolute-branched to with BA.)  Must be done after 
+# grovel-headers, because Apple's nm is broken.
+after-grovel-headers: ppc-darwin-rospace.o
+       rm -f sbcl
+       $(GNUMAKE) sbcl AFTER_GROVEL_HEADERS=1
+
+# Fortunatly make-target-1.sh does a make clean all the time.
+# Otherwise we would have to make sure that sbcl gets rebuilt without
+# the readonlyspace hack before groveling headers again.
index 1c5ae15..b147ca9 100644 (file)
@@ -55,7 +55,7 @@ sbcl: ${OBJS}
 
 .PHONY: clean all
 clean:
-       -rm -f depend *.o sbcl sbcl.nm core *.tmp
+       -rm -f depend *.o sbcl sbcl.nm core *.tmp $(CLEAN_FILES)
 
 TAGS: $(SRCS)
        etags $(SRCS)
index 878ada4..439354d 100644 (file)
@@ -12,9 +12,9 @@
 #include <stdio.h>
 #include <signal.h>
 
+#include "sbcl.h"
 #include "runtime.h"
 #include "os.h"
-#include "sbcl.h"
 #include "interrupt.h"
 #include "arch.h"
 #include "lispregs.h"
index f31f5fc..e758d2e 100644 (file)
@@ -21,6 +21,7 @@
 #include <stdio.h>
 #include <sys/param.h>
 #include <sys/file.h>
+#include "sbcl.h"
 #include "./signal.h"
 #include "os.h"
 #include "arch.h"
@@ -28,7 +29,6 @@
 #include "interrupt.h"
 #include "interr.h"
 #include "lispregs.h"
-#include "sbcl.h"
 #include "thread.h"
 
 #include <sys/types.h>
@@ -50,7 +50,7 @@ int *os_context_pc_addr(os_context_t *context)
     return CONTEXT_ADDR_FROM_STEM(eip);
 #elif defined __OpenBSD__
     return CONTEXT_ADDR_FROM_STEM(pc);
-#elif defined DARWIN
+#elif defined LISP_FEATURE_DARWIN
     return &context->uc_mcontext->ss.srr0;
 #else
 #error unsupported BSD variant
@@ -63,7 +63,7 @@ os_context_sigmask_addr(os_context_t *context)
     /* (Unlike most of the other context fields that we access, the
      * signal mask field is a field of the basic, outermost context
      * struct itself both in FreeBSD 4.0 and in OpenBSD 2.6.) */
-#if defined __FreeBSD__ || defined DARWIN
+#if defined __FreeBSD__ || defined LISP_FEATURE_DARWIN
     return &context->uc_sigmask;
 #elif defined __OpenBSD__
     return &context->sc_mask;
@@ -166,7 +166,7 @@ memory_fault_handler(int signal, siginfo_t *siginfo, void *void_context)
     void *fault_addr = siginfo->si_addr;
 #elif defined __OpenBSD__
     void *fault_addr = siginfo->si_addr;
-#elif defined DARWIN
+#elif defined LISP_FEATURE_DARWIN
     void *fault_addr = siginfo->si_addr;
 #else
 #error unsupported BSD variant
@@ -200,6 +200,8 @@ sigsegv_handler(int signal, siginfo_t *info, void* void_context)
     if(!interrupt_maybe_gc(signal, info, context))
        if(!handle_control_stack_guard_triggered(context,addr))
            interrupt_handle_now(signal, info, context);
+    /* Work around G5 bug; fix courtesy gbyers */
+    sigreturn(void_context);
 }
 
 void
index d95431d..f7c3e1c 100644 (file)
@@ -48,7 +48,7 @@ typedef ucontext_t os_context_t;
 #elif defined __OpenBSD__
 typedef struct sigcontext os_context_t;
 #define SIG_MEMORY_FAULT SIGSEGV
-#elif defined DARWIN
+#elif defined LISP_FEATURE_DARWIN
   /* man pages claim that the third argument is a sigcontext struct,
      but ucontext_t is defined, matches sigcontext where sensible,
      offers better access to mcontext, and is of course the SUSv2-
index 6ac74ba..e01bf33 100644 (file)
 #include <fcntl.h>
 #endif
 
+#include "sbcl.h"
 #include "os.h"
 #include "runtime.h"
 #include "globals.h"
 #include "core.h"
 #include "arch.h"
 #include "interr.h"
-#include "sbcl.h"
 #include "thread.h"
 
 unsigned char build_id[] =
index 2064f6f..8991729 100644 (file)
@@ -59,7 +59,7 @@ extern void globals_init(void);
 #endif
 #endif
 #ifdef ppc
-#ifdef DARWIN
+#ifdef LISP_FEATURE_DARWIN
 #define EXTERN(name,bytes) .globl _/**/name
 #else
 #define EXTERN(name,bytes) .globl name 
index 7de06f0..5734ac1 100644 (file)
 #include <stdarg.h>
 #include <stdlib.h>
 
+#include "sbcl.h"
 #include "arch.h"
 #include "signal.h"
 
 #include "runtime.h"
-#include "sbcl.h"
 #include "interr.h"
 #include "print.h"
 #include "lispregs.h"
index 9bc28ac..7f26e76 100644 (file)
@@ -48,9 +48,9 @@
 #include <sys/types.h>
 #include <sys/wait.h>
 
+#include "sbcl.h"
 #include "runtime.h"
 #include "arch.h"
-#include "sbcl.h"
 #include "os.h"
 #include "interrupt.h"
 #include "globals.h"
@@ -536,6 +536,10 @@ maybe_now_maybe_later(int signal, siginfo_t *info, void *void_context)
                           signal,info,context))
        return;
     interrupt_handle_now(signal, info, context);
+#ifdef LISP_FEATURE_DARWIN
+    /* Work around G5 bug */
+    sigreturn(void_context);
+#endif
 }
 
 #ifdef LISP_FEATURE_SB_THREAD
@@ -575,6 +579,9 @@ interrupt_handle_now_handler(int signal, siginfo_t *info, void *void_context)
 {
     os_context_t *context = arch_os_get_context(&void_context);
     interrupt_handle_now(signal, info, context);
+#ifdef LISP_FEATURE_DARWIN
+    sigreturn(void_context);
+#endif
 }
 
 /*
index 9bddfec..cae927b 100644 (file)
@@ -326,7 +326,7 @@ print_context(os_context_t *context)
        brief_print((lispobj)(*os_context_register_addr(context,i)));
 #endif
     }
-#ifdef DARWIN
+#ifdef LISP_FEATURE_DARWIN
     printf("DAR:\t\t 0x%08lx\n", (unsigned long)(*os_context_register_addr(context, 41)));
     printf("DSISR:\t\t 0x%08lx\n", (unsigned long)(*os_context_register_addr(context, 42)));
 #endif
index 3becd18..dce4613 100644 (file)
@@ -13,6 +13,7 @@
 #include <errno.h>
 #include <strings.h>
 
+#include "sbcl.h"
 #include "os.h"
 #include "interr.h"
 
index f62739e..aa8a522 100644 (file)
@@ -1,5 +1,6 @@
 #include <stdio.h>
 
+#include "sbcl.h"
 #include "arch.h"
 #include "sbcl.h"
 #include "globals.h"
@@ -185,14 +186,24 @@ sigtrap_handler(int signal, siginfo_t *siginfo, os_context_t *context)
            interrupt_handle_now(signal, code, context);
            break;
        }
+#ifdef LISP_FEATURE_DARWIN
+       sigreturn(context);
+#endif
        return;
     }
     if (((code >> 26) == 3) && (((code >> 21) & 31) == 24)) {
        interrupt_internal_error(signal, code, context, 0);
+#ifdef LISP_FEATURE_DARWIN
+       sigreturn(context);
+#endif
        return;
     }
     
     interrupt_handle_now(signal, code, context);
+#ifdef LISP_FEATURE_DARWIN
+    /* Work around G5 bug */
+    sigreturn(context);
+#endif
 }
 
 
index de36538..afd0b1c 100644 (file)
@@ -9,13 +9,13 @@
 #include "genesis/closure.h"
 #include "genesis/static-symbols.h"
 
-#ifdef DARWIN
+#ifdef LISP_FEATURE_DARWIN
 #define CSYMBOL(x) _ ## x
 #else
 #define CSYMBOL(x) x
 #endif
 
-#if defined DARWIN
+#if defined LISP_FEATURE_DARWIN
 #define FUNCDEF(x)     .text @ \
                        .align 3 @ \
 _##x:
@@ -32,7 +32,7 @@ x:
        FUNCDEF(x)
 #endif
 
-#if defined DARWIN
+#if defined LISP_FEATURE_DARWIN
 #define SET_SIZE(x)
 #else
 #define SET_SIZE(x) .size x,.-x
@@ -41,7 +41,7 @@ x:
 /* Load a register from a global, using the register as an intermediary */
 /* The register will be a fixnum for one instruction, so this is gc-safe */
 
-#if defined DARWIN
+#if defined LISP_FEATURE_DARWIN
 #define load(reg,global) \
        lis reg,ha16(global) @ \
        lwz reg,lo16(global)(reg) ; Comment
@@ -56,7 +56,7 @@ x:
 #endif
        
 #define        FIRST_SAVE_FPR  14      /* lowest-numbered non-volatile FPR */
-#ifdef DARWIN
+#ifdef LISP_FEATURE_DARWIN
 #define        FIRST_SAVE_GPR  13      /* lowest-numbered non-volatile GPR */
 #define NGPR_SAVE_BYTES(n) ((32-(n))*4)
 #define FRAME_ARG_BYTES(n)  (((((n)+6)*4)+15)&~15)
@@ -67,7 +67,7 @@ x:
 #endif
 #define        NFPR_SAVE_BYTES(n) ((32-(n))*8)
 
-#ifdef DARWIN
+#ifdef LISP_FEATURE_DARWIN
 #define FRAME_SIZE(first_g,first_f,out_arg_words,savecr) \
 (NFPR_SAVE_BYTES(first_f)+ NGPR_SAVE_BYTES(first_g)+ FRAME_ARG_BYTES(out_arg_words))
 #define SAVE_FPR(n) stfd f##n,-8*(32- n)(r11)
@@ -86,7 +86,7 @@ x:
 #define RESTORE_GPR(n) lwz n,-4*(32-(n))(11)
 #endif
 
-#ifdef DARWIN
+#ifdef LISP_FEATURE_DARWIN
 #define C_FULL_PROLOG \
        nop @\
        nop @ \
@@ -302,7 +302,7 @@ x:
        li reg_L1,0
        li reg_L2,0
        li reg_LIP,0
-#ifdef DARWIN  
+#ifdef LISP_FEATURE_DARWIN     
        lis reg_NULL,hi16(NIL)
        ori reg_NULL,reg_NULL,lo16(NIL)
 #else
@@ -334,7 +334,7 @@ x:
        lwz reg_A3,12(reg_CFP)
 
        /* Calculate LRA */
-#ifdef DARWIN
+#ifdef LISP_FEATURE_DARWIN
        lis reg_LRA,ha16(lra)
        addi reg_LRA,reg_LRA,lo16(lra)
 #else
@@ -436,7 +436,7 @@ lra:
        twlti reg_ALLOC,0
        mr reg_NL3,reg_NARGS
 
-#ifdef DARWIN
+#ifdef LISP_FEATURE_DARWIN
        /* PowerOpen (i.e. OS X) requires the callee address in r12
            (a.k.a. CFUNC), so move it back there, too. */
        mfctr reg_CFUNC
@@ -445,7 +445,7 @@ lra:
        bctrl
 
        /* Re-establish NIL */
-#ifdef DARWIN
+#ifdef LISP_FEATURE_DARWIN
        lis reg_NULL,hi16(NIL)
        ori reg_NULL,reg_NULL,lo16(NIL)
 #else
diff --git a/src/runtime/ppc-darwin-mkrospace.c b/src/runtime/ppc-darwin-mkrospace.c
new file mode 100644 (file)
index 0000000..8faf381
--- /dev/null
@@ -0,0 +1,58 @@
+/* ppc-darwin-mkrospace.c - write a .o which makes sure we get our desired address range */
+
+#include <stdlib.h>
+#include <string.h>
+#include <mach-o/loader.h>
+#include <sys/types.h>
+#include <sys/uio.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include "runtime.h"
+#include "sbcl.h"
+
+struct simple_object_file
+{
+  struct mach_header theheader;
+  struct segment_command thesegment;
+  struct section thesection;
+};
+
+int main(int argc, char** argv)
+{
+  struct simple_object_file *theobj;
+  int fd;
+  theobj = (struct simple_object_file*) malloc(sizeof(struct simple_object_file));
+  theobj->theheader.magic = MH_MAGIC;
+  theobj->theheader.cputype = CPU_TYPE_POWERPC;
+  theobj->theheader.cpusubtype = CPU_SUBTYPE_POWERPC_ALL;
+  theobj->theheader.filetype = MH_OBJECT;
+  theobj->theheader.ncmds = 1;
+  theobj->theheader.sizeofcmds = sizeof(struct segment_command) + sizeof(struct section);
+  theobj->theheader.flags = MH_NOUNDEFS;
+  theobj->thesegment.cmd = LC_SEGMENT;
+  theobj->thesegment.cmdsize = sizeof(struct segment_command) + sizeof(struct section);
+  memcpy(theobj->thesegment.segname, "", sizeof(char));
+  theobj->thesegment.fileoff = sizeof(struct mach_header);
+  theobj->thesegment.vmaddr = READ_ONLY_SPACE_START;
+  theobj->thesegment.vmsize = READ_ONLY_SPACE_END - READ_ONLY_SPACE_START;
+  theobj->thesegment.maxprot = VM_PROT_ALL;
+  theobj->thesegment.initprot = VM_PROT_ALL;
+  theobj->thesegment.nsects = 1;
+  theobj->thesegment.flags = 0;
+  memcpy(theobj->thesection.sectname, "core", 5);
+  memcpy(theobj->thesection.segname, "SBCLRO", 7);
+  theobj->thesection.addr = READ_ONLY_SPACE_START;
+  theobj->thesection.size = READ_ONLY_SPACE_END - READ_ONLY_SPACE_START;
+  theobj->thesection.offset = sizeof(struct mach_header) + sizeof(struct segment_command) + sizeof(struct section);
+  theobj->thesection.align = 0;
+  theobj->thesection.reloff = 0;
+  theobj->thesection.nreloc = 0;
+  theobj->thesection.flags = S_ZEROFILL | S_REGULAR | S_ATTR_SOME_INSTRUCTIONS;
+  theobj->thesection.reserved1 = 0;
+  theobj->thesection.reserved2 = 0;
+  fd = open("ppc-darwin-rospace.o", O_WRONLY | O_CREAT, 0644);
+  write(fd, theobj, sizeof(struct simple_object_file));
+  close(fd);
+  printf("-Wl,-segaddr,SBCLRO,0x%x\n",READ_ONLY_SPACE_START);
+  return 0;
+}
index ba1060f..7bf1346 100644 (file)
@@ -14,7 +14,7 @@
  * files for more information.
  */
 
-
+#include "sbcl.h"
 #include "globals.h"
 #include <signal.h>
 #include <ucontext.h>
index e47791b..817a9ae 100644 (file)
@@ -1,4 +1,4 @@
-#if defined DARWIN
+#if defined LISP_FEATURE_DARWIN
 #if defined LANGUAGE_ASSEMBLY
 #define REG(num) r##num
 #else
@@ -22,7 +22,7 @@
 #define reg_NL6       REG(9)   /* Last (7th) FF param */
 #define reg_FDEFN     REG(10)   /* was NL7 until recently -dan */
 #define reg_NARGS     REG(11)
-#ifdef DARWIN
+#ifdef LISP_FEATURE_DARWIN
 #define reg_CFUNC     REG(12)  /* Silly to blow a reg on FF-name */
 #define reg_NFP       REG(13)  /* Lisp may save around FF-call */
 #else
index 9e8159a..2d87694 100644 (file)
@@ -19,9 +19,9 @@
 #include <strings.h>
 #include <errno.h>
 
+#include "sbcl.h"
 #include "runtime.h"
 #include "os.h"
-#include "sbcl.h"
 #include "globals.h"
 #include "validate.h"
 #include "interrupt.h"
index c8c152f..e901d98 100644 (file)
@@ -14,9 +14,9 @@
 #include <signal.h>
 #include <sys/file.h>
 
+#include "sbcl.h"
 #include "runtime.h"
 #include "os.h"
-#include "sbcl.h"
 #include "core.h"
 #include "globals.h"
 #include "save.h"
index d88d17d..aa0890f 100644 (file)
 #include <stdio.h>
 #include <stdlib.h>
 
+#include "sbcl.h"
 #include "runtime.h"
 #include "os.h"
 #include "globals.h"
-#include "sbcl.h"
 #include "validate.h"
 
 static void
index 8786ee7..5f36ef1 100644 (file)
@@ -14,6 +14,7 @@
 #include <sys/types.h>
 #include <stdlib.h>
 
+#include "sbcl.h"
 #include "runtime.h"
 #include "vars.h"
 #include "os.h"
index f8bb7d6..c2a8ea3 100644 (file)
@@ -17,4 +17,4 @@
 ;;; checkins which aren't released. (And occasionally for internal
 ;;; versions, especially for internal versions off the main CVS
 ;;; branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".)
-"0.8.7.56"
+"0.8.7.57"