1.0.26.13: OpenBSD x86-64 support
authorJuho Snellman <jsnell@iki.fi>
Sun, 22 Mar 2009 20:07:50 +0000 (20:07 +0000)
committerJuho Snellman <jsnell@iki.fi>
Sun, 22 Mar 2009 20:07:50 +0000 (20:07 +0000)
        * Patch by Josh Elsasser

13 files changed:
NEWS
src/code/unix.lisp
src/compiler/x86-64/parms.lisp
src/runtime/Config.x86-64-openbsd [new file with mode: 0644]
src/runtime/bsd-os.c
src/runtime/x86-64-arch.c
src/runtime/x86-64-assem.S
src/runtime/x86-64-bsd-os.c
tests/debug.impure.lisp
tests/float.pure.lisp
tests/foreign-stack-alignment.impure.lisp
tools-for-build/os-provides-dladdr-test.c
version.lisp-expr

diff --git a/NEWS b/NEWS
index fedb224..6728d45 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,6 @@
 ;;;; -*- coding: utf-8; fill-column: 78 -*-
 changes in sbcl-1.0.27 relative to 1.0.26:
+  * new port: support added for x86-64 OpenBSD. (thanks to Josh Elsasser)
   * bug fix: a type error is signaled for attempts to use the LOOP
     keyword ACROSS for a NIL value. (thanks to Daniel Lowe)
 
index 0983f27..c3c97a3 100644 (file)
@@ -206,12 +206,21 @@ corresponds to NAME, or NIL if there is none."
 ;; microsecond but also has a range of years.
 ;; CLH: Note that tv-usec used to be a time-t, but that this seems
 ;; problematic on Darwin x86-64 (and wrong). Trying suseconds-t.
-#!-win32
+#!-(or win32 openbsd)
 (define-alien-type nil
   (struct timeval
           (tv-sec time-t)           ; seconds
           (tv-usec suseconds-t)))   ; and microseconds
 
+;; The above definition doesn't work on 64-bit OpenBSD platforms.
+;; Both tv_sec and tv_usec are declared as long instead of time_t, and
+;; time_t is a typedef for int.
+#!+openbsd
+(define-alien-type nil
+  (struct timeval
+          (tv-sec long)             ; seconds
+          (tv-usec long)))          ; and microseconds
+
 #!+win32
 (define-alien-type nil
   (struct timeval
@@ -772,11 +781,21 @@ corresponds to NAME, or NIL if there is none."
 
 ;; the POSIX.4 structure for a time value. This is like a "struct
 ;; timeval" but has nanoseconds instead of microseconds.
+#!-openbsd
 (define-alien-type nil
     (struct timespec
             (tv-sec long)   ; seconds
             (tv-nsec long))) ; nanoseconds
 
+;; Just as with struct timeval, 64-bit OpenBSD has problems with the
+;; above definition.  tv_sec is declared as time_t instead of long,
+;; and time_t is a typedef for int.
+#!+openbsd
+(define-alien-type nil
+    (struct timespec
+            (tv-sec time-t)  ; seconds
+            (tv-nsec long))) ; nanoseconds
+
 ;; used by other time functions
 (define-alien-type nil
     (struct tm
index 6913f59..648a7fa 100644 (file)
   (def!constant static-space-end          #x201ff000)
 
   (def!constant dynamic-space-start   #x1000000000)
+  #!-openbsd
   (def!constant dynamic-space-end     #x11ffff0000)
+  #!+openbsd
+  ;; This is lower on OpenBSD to allow SBCL to run under the default
+  ;; 512M data size limit.
+  (def!constant dynamic-space-end     #x101bcf0000)
 
   (def!constant linkage-table-space-start #x20200000)
   (def!constant linkage-table-space-end   #x202ff000)
diff --git a/src/runtime/Config.x86-64-openbsd b/src/runtime/Config.x86-64-openbsd
new file mode 100644 (file)
index 0000000..e893ee0
--- /dev/null
@@ -0,0 +1,22 @@
+# -*- 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.
+
+include Config.x86-64-bsd
+
+ASSEM_SRC += ldso-stubs.S
+OS_LIBS += -lutil
+
+# 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
index 0d221f5..8848492 100644 (file)
@@ -484,12 +484,22 @@ os_get_runtime_executable_path()
 void
 openbsd_init()
 {
+    /*
+     * Show a warning if it looks like the memory available after
+     * allocating the spaces won't be at least this much.
+     */
+#ifdef LISP_FEATURE_X86_64
+    const int wantfree = 64 * 1024 * 1024;
+#else
+    const int wantfree = 32 * 1024 * 1024;
+#endif
     struct rlimit rl;
 
     /* OpenBSD, like NetBSD, counts mmap()ed space against the
      * process's data size limit. If the soft limit is lower than the
      * hard limit then try to yank it up, this lets users in the
-     * "staff" login class run sbcl with a default /etc/login.conf
+     * "staff" or "daemon" login classes run sbcl with larger dynamic
+     * space sizes.
      */
     getrlimit (RLIMIT_DATA, &rl);
     if (rl.rlim_cur < rl.rlim_max) {
@@ -503,18 +513,17 @@ The system may fail to start.\n",
         }
     }
 
-    /* Display a (hopefully) helpful warning if it looks like we won't
-     * be able to allocate enough memory. In testing I found that on
-     * my system at least, a minimum of 25M on top of the three space
-     * sizes was needed to start SBCL. Show a warning below 32M so as
-     * to leave a little breathing room.
+    /*
+     * Display a (hopefully) helpful warning if it looks like we won't
+     * be able to allocate enough memory.
      */
     getrlimit (RLIMIT_DATA, &rl);
     if (dynamic_space_size + READ_ONLY_SPACE_SIZE + STATIC_SPACE_SIZE +
-        LINKAGE_TABLE_SPACE_SIZE + (32*1024*1024) > rl.rlim_cur)
+        LINKAGE_TABLE_SPACE_SIZE + wantfree > rl.rlim_cur)
         fprintf (stderr,
                  "RUNTIME WARNING: data size resource limit may be too low,\n"
-                 "  try decreasing the dynamic space size with --dynamic-space-size\n");
+                 "  try decreasing the dynamic space size with --dynamic-space-size\n"
+                 "  or raising the datasize or datasize-max limits in /etc/login.conf\n");
 }
 
 /* OpenBSD's dlsym() relies on the gcc bulitin
index 75432d0..72148fd 100644 (file)
@@ -66,7 +66,7 @@ context_eflags_addr(os_context_t *context)
 #elif defined LISP_FEATURE_DARWIN
     return CONTEXT_ADDR_FROM_STEM(rflags);
 #elif defined __OpenBSD__
-    return &context->sc_eflags;
+    return &context->sc_rflags;
 #else
 #error unsupported OS
 #endif
index 8878f04..6466859 100644 (file)
 #include "genesis/thread.h"
        
 /* Minimize conditionalization for different OS naming schemes. */
-#if defined __linux__  || defined __FreeBSD__ /* (but *not* OpenBSD) */
+#if defined __linux__  || defined __FreeBSD__ || defined __OpenBSD__
 #define GNAME(var) var
 #else
 #define GNAME(var) _##var
 #endif
 
-/* Get the right type of alignment. Linux and FreeBSD (but not OpenBSD)
+/* Get the right type of alignment. Linux, FreeBSD and OpenBSD
  * want alignment in bytes. */
-#if defined(__linux__) || defined(__FreeBSD__)
+#if defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__)
 #define align_4byte    4
 #define align_8byte    8
 #define align_16byte   16
index 5c29b22..3b45bc5 100644 (file)
@@ -25,7 +25,7 @@ kern_return_t mach_thread_init(mach_port_t thread_exception_port);
  * entails; unfortunately, currently the situation is worse, not
  * better, than in the above paragraph. */
 
-#if defined(LISP_FEATURE_FREEBSD) || defined(LISP_FEATURE_DARWIN)
+#if defined(LISP_FEATURE_FREEBSD) || defined(LISP_FEATURE_DARWIN) || defined(LISP_FEATURE_OPENBSD)
 os_context_register_t *
 os_context_register_addr(os_context_t *context, int offset)
 {
index aae3111..7a2d913 100644 (file)
                         (and :x86 :linux)
                         (and :x86-64 :darwin)
                         (and :x86-64 :linux)
+                        (and :x86-64 :openbsd)
                         (and :sparc :linux)
                         :alpha
                         :mips))
index 1b983b7..e1aabae 100644 (file)
 (funcall (compile nil '(lambda () (tan (tan (round 0))))))
 
 (with-test (:name (:addition-overflow :bug-372)
-            :fails-on '(or :ppc :darwin (and :x86 (or :netbsd :openbsd))))
+            :fails-on '(or :ppc :darwin (and (or :x86 :x86-64)
+                                             (or :netbsd :openbsd))))
   (assert (typep (nth-value
                   1
                   (ignore-errors
index 128d21f..4bc683c 100644 (file)
@@ -55,7 +55,7 @@
 ;;;; Build the tool again, this time as a shared object, and load it
 
 (run "cc" "stack-alignment-offset.c"
-     #+(and (or linux freebsd) (or x86-64 ppc mips)) "-fPIC"
+     #+(and (not darwin) (or x86-64 ppc mips)) "-fPIC"
      #+(and x86-64 darwin) "-arch" #+(and x86-64 darwin) "x86_64"
      #+darwin "-bundle" #-darwin "-shared"
      "-o" "stack-alignment-offset.so")
index ba899a2..bc1a05c 100644 (file)
@@ -1,6 +1,8 @@
 /* test to build and run so that we know if we have dladdr
  */
 
+#include <stdlib.h>
+
 /* bloody FSF dlcfn.h won't give us dladdr without this */
 #define _GNU_SOURCE
 
index e8eefd7..76f2ec0 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".)
-"1.0.26.12"
+"1.0.26.13"