commit f3a9add00e2062f31358c66296dd6f845e785072
Author: Alastair Bridgewater <nyef_sbcl@lisphacker.com>
Date:   Fri May 21 18:28:50 2010 -0400

    Support for building on OpenBSD/PPC (patch by Josh Elsasser).
    
      * Dynamic space assignments.
    
      * New Config.* makefile fragment.
    
      * OpenBSD-specific support in ppc-arch.c and ppc-bsd-os.c
    
      * Fixed one of two known OpenBSD/PPC-specific test suite issues.
    
      * It turns out that os_context_sp_addr() in ppc-bsd-os.c is only used
    when ARCH_HAS_STACK_POINTER is set, which only occurs on x86oid systems
    at the present time.

diff --git a/src/compiler/ppc/parms.lisp b/src/compiler/ppc/parms.lisp
index 1e443b4..f03c325 100644
--- a/src/compiler/ppc/parms.lisp
+++ b/src/compiler/ppc/parms.lisp
@@ -137,6 +137,26 @@
     (def!constant dynamic-1-space-start #x67000000)
     (def!constant dynamic-1-space-end   #x7efff000)))
 
+;;; Text and data segments start at #x01800000.  Range for randomized
+;;; malloc() starts #x20000000 (MAXDSIZ) after end of data seg and
+;;; extends 256 MB.  Use 512 - 64 MB for dynamic space so we can run
+;;; under default resource limits.
+;;; FIXME: MAXDSIZ is a kernel parameter, and can vary as high as 1GB.
+;;; These parameters should probably be tested under such a configuration,
+;;; as rare as it might or might not be.
+#!+openbsd
+(progn
+  #!+gencgc
+  (progn
+    (def!constant dynamic-space-start #x4f000000)
+    (def!constant dynamic-space-end   #x6afff000))
+  #!-gencgc
+  (progn
+    (def!constant dynamic-0-space-start #x4f000000)
+    (def!constant dynamic-0-space-end   #x5cfff000)
+    (def!constant dynamic-1-space-start #x5f000000)
+    (def!constant dynamic-1-space-end   #x6cfff000)))
+
 #!+darwin
 (progn
   #!+gencgc
diff --git a/src/runtime/Config.ppc-openbsd b/src/runtime/Config.ppc-openbsd
new file mode 100644
index 0000000..1f100f3
--- /dev/null
+++ b/src/runtime/Config.ppc-openbsd
@@ -0,0 +1,29 @@
+# -*- makefile -*- for the C-level run-time support for SBCL
+
+# This software is part of the SBCL system. See the README file for
+# more information.
+#
+# This software is derived from the CMU CL system, which was
+# written at Carnegie Mellon University and released into the
+# public domain. The software is in the public domain and is
+# provided with absolutely no warranty. See the COPYING and CREDITS
+# files for more information.
+
+# XXX why do all the other Configs set LINKFLAGS instead of LDFLAGS?
+# LINKFLAGS is only used in src/runtime/GNUmakefile, this causes the
+# dladdr test in tools-for-build/ to fail.
+
+LINKFLAGS += -export-dynamic
+LDFLAGS += -export-dynamic
+
+ASSEM_SRC = ppc-assem.S ldso-stubs.S
+ARCH_SRC = ppc-arch.c
+
+OS_SRC = bsd-os.c ppc-bsd-os.c
+OS_LIBS = -lutil
+
+GC_SRC = gencgc.c
+
+# Nothing to do for after-grovel-headers.
+.PHONY: after-grovel-headers
+after-grovel-headers:
diff --git a/src/runtime/ppc-arch.c b/src/runtime/ppc-arch.c
index 92516e5..7fb7b6c 100644
--- a/src/runtime/ppc-arch.c
+++ b/src/runtime/ppc-arch.c
@@ -59,7 +59,7 @@ arch_get_bad_addr(int sig, siginfo_t *code, os_context_t *context)
 {
     os_vm_address_t addr;
 
-#if defined(LISP_FEATURE_NETBSD)
+#if defined(LISP_FEATURE_NETBSD) || defined(LISP_FEATURE_OPENBSD)
     addr = (os_vm_address_t) (code->si_addr);
 #else
     addr = (os_vm_address_t) (*os_context_register_addr(context,PT_DAR));
diff --git a/src/runtime/ppc-bsd-os.c b/src/runtime/ppc-bsd-os.c
index e77590c..a9f0ce5 100644
--- a/src/runtime/ppc-bsd-os.c
+++ b/src/runtime/ppc-bsd-os.c
@@ -8,26 +8,42 @@
 int *
 os_context_register_addr(os_context_t *context, int offset)
 {
+#if defined(LISP_FEATURE_NETBSD)
     return &context->uc_mcontext.__gregs[offset];
+#elif defined(LISP_FEATURE_OPENBSD)
+    return &context->sc_frame.fixreg[offset];
+#endif
 }
 
+#if defined(ARCH_HAS_STACK_POINTER) /* It's not defined on PPC. */
 int *
 os_context_sp_addr(os_context_t *context)
 {
+#if defined(LISP_FEATURE_NETBSD)
     return &(_UC_MACHINE_SP(context));
+#endif
 }
+#endif
 
 
 int *
 os_context_pc_addr(os_context_t *context)
 {
+#if defined(LISP_FEATURE_NETBSD)
     return &(_UC_MACHINE_PC(context));
+#elif defined(LISP_FEATURE_OPENBSD)
+    return &context->sc_frame.srr0;
+#endif
 }
 
 int *
 os_context_lr_addr(os_context_t *context)
 {
+#if defined(LISP_FEATURE_NETBSD)
     return &context->uc_mcontext.__gregs[_REG_LR];
+#elif defined(LISP_FEATURE_OPENBSD)
+    return &context->sc_frame.lr;
+#endif
 }
 
 /* FIXME: If this can be a no-op on BSD/x86, then it
diff --git a/tests/foreign-stack-alignment.impure.lisp b/tests/foreign-stack-alignment.impure.lisp
index 4bc683c..4ca957d 100644
--- a/tests/foreign-stack-alignment.impure.lisp
+++ b/tests/foreign-stack-alignment.impure.lisp
@@ -32,12 +32,12 @@
 
 (defvar *required-alignment*
   #+(and ppc darwin) 16
-  #+(and ppc linux) 8
+  #+(and ppc (not darwin)) 8
   #+x86-64 16
   #+mips 8
   #+(and x86 (not darwin)) 4
   #+(and x86 darwin) 16
-  #-(or x86 x86-64 mips (and ppc (or darwin linux))) (error "Unknown platform"))
+  #-(or x86 x86-64 mips ppc) (error "Unknown platform"))
 
 ;;;; Build the offset-tool as regular excutable, and run it with
 ;;;; fork/exec, so that no lisp is on the stack. This is our known-good
