From: Juho Snellman Date: Sun, 22 Mar 2009 20:07:50 +0000 (+0000) Subject: 1.0.26.13: OpenBSD x86-64 support X-Git-Url: http://repo.macrolet.net/gitweb/?a=commitdiff_plain;h=d63d80e637e9058ff5db7a10c267796ff7970ba1;p=sbcl.git 1.0.26.13: OpenBSD x86-64 support * Patch by Josh Elsasser --- diff --git a/NEWS b/NEWS index fedb224..6728d45 100644 --- 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) diff --git a/src/code/unix.lisp b/src/code/unix.lisp index 0983f27..c3c97a3 100644 --- a/src/code/unix.lisp +++ b/src/code/unix.lisp @@ -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 diff --git a/src/compiler/x86-64/parms.lisp b/src/compiler/x86-64/parms.lisp index 6913f59..648a7fa 100644 --- a/src/compiler/x86-64/parms.lisp +++ b/src/compiler/x86-64/parms.lisp @@ -111,7 +111,12 @@ (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 index 0000000..e893ee0 --- /dev/null +++ b/src/runtime/Config.x86-64-openbsd @@ -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 diff --git a/src/runtime/bsd-os.c b/src/runtime/bsd-os.c index 0d221f5..8848492 100644 --- a/src/runtime/bsd-os.c +++ b/src/runtime/bsd-os.c @@ -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 diff --git a/src/runtime/x86-64-arch.c b/src/runtime/x86-64-arch.c index 75432d0..72148fd 100644 --- a/src/runtime/x86-64-arch.c +++ b/src/runtime/x86-64-arch.c @@ -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 diff --git a/src/runtime/x86-64-assem.S b/src/runtime/x86-64-assem.S index 8878f04..6466859 100644 --- a/src/runtime/x86-64-assem.S +++ b/src/runtime/x86-64-assem.S @@ -25,15 +25,15 @@ #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 diff --git a/src/runtime/x86-64-bsd-os.c b/src/runtime/x86-64-bsd-os.c index 5c29b22..3b45bc5 100644 --- a/src/runtime/x86-64-bsd-os.c +++ b/src/runtime/x86-64-bsd-os.c @@ -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) { diff --git a/tests/debug.impure.lisp b/tests/debug.impure.lisp index aae3111..7a2d913 100644 --- a/tests/debug.impure.lisp +++ b/tests/debug.impure.lisp @@ -213,6 +213,7 @@ (and :x86 :linux) (and :x86-64 :darwin) (and :x86-64 :linux) + (and :x86-64 :openbsd) (and :sparc :linux) :alpha :mips)) diff --git a/tests/float.pure.lisp b/tests/float.pure.lisp index 1b983b7..e1aabae 100644 --- a/tests/float.pure.lisp +++ b/tests/float.pure.lisp @@ -125,7 +125,8 @@ (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 diff --git a/tests/foreign-stack-alignment.impure.lisp b/tests/foreign-stack-alignment.impure.lisp index 128d21f..4bc683c 100644 --- a/tests/foreign-stack-alignment.impure.lisp +++ b/tests/foreign-stack-alignment.impure.lisp @@ -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") diff --git a/tools-for-build/os-provides-dladdr-test.c b/tools-for-build/os-provides-dladdr-test.c index ba899a2..bc1a05c 100644 --- a/tools-for-build/os-provides-dladdr-test.c +++ b/tools-for-build/os-provides-dladdr-test.c @@ -1,6 +1,8 @@ /* test to build and run so that we know if we have dladdr */ +#include + /* bloody FSF dlcfn.h won't give us dladdr without this */ #define _GNU_SOURCE diff --git a/version.lisp-expr b/version.lisp-expr index e8eefd7..76f2ec0 100644 --- a/version.lisp-expr +++ b/version.lisp-expr @@ -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"