1.0.32.32: add support for x86-64/NetBSD
authorChristophe Rhodes <csr21@cantab.net>
Thu, 19 Nov 2009 15:38:50 +0000 (15:38 +0000)
committerChristophe Rhodes <csr21@cantab.net>
Thu, 19 Nov 2009 15:38:50 +0000 (15:38 +0000)
Patch from Aymeric Vincent.

NEWS
src/code/unix.lisp
src/runtime/Config.x86-64-netbsd [new file with mode: 0644]
src/runtime/x86-64-arch.c
src/runtime/x86-64-assem.S
src/runtime/x86-64-bsd-os.c
version.lisp-expr

diff --git a/NEWS b/NEWS
index e3d2053..c51f304 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,6 @@
 ;;;; -*- coding: utf-8; fill-column: 78 -*-
 changes relative to sbcl-1.0.32:
+  * new port: support added for x86-64 NetBSD.  (thanks to Aymeric Vincent)
   * improvement: support O_LARGEFILE access to files larger than 2GB on
     x86-64/linux.  (thanks to Daniel Janus; launchpad bug #453080)
   * new feature: SB-INTROSPECT:WHO-SPECIALIZES-DIRECTLY to get a list of
index 5776803..f8ef69d 100644 (file)
@@ -202,7 +202,7 @@ 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.
-#!-(or win32 openbsd)
+#!-(or win32 openbsd netbsd)
 (define-alien-type nil
   (struct timeval
           (tv-sec time-t)           ; seconds
@@ -211,7 +211,7 @@ corresponds to NAME, or NIL if there is none."
 ;; 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
+#!+(or openbsd netbsd)
 (define-alien-type nil
   (struct timeval
           (tv-sec long)             ; seconds
@@ -777,7 +777,7 @@ 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
+#!-(or openbsd netbsd)
 (define-alien-type nil
     (struct timespec
             (tv-sec long)   ; seconds
@@ -786,7 +786,7 @@ corresponds to NAME, or NIL if there is none."
 ;; 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
+#!+(or openbsd netbsd)
 (define-alien-type nil
     (struct timespec
             (tv-sec time-t)  ; seconds
diff --git a/src/runtime/Config.x86-64-netbsd b/src/runtime/Config.x86-64-netbsd
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 a88435c..f3f414b 100644 (file)
@@ -67,6 +67,8 @@ context_eflags_addr(os_context_t *context)
     return CONTEXT_ADDR_FROM_STEM(rflags);
 #elif defined __OpenBSD__
     return &context->sc_rflags;
+#elif defined __NetBSD__
+    return CONTEXT_ADDR_FROM_STEM(RFLAGS);
 #else
 #error unsupported OS
 #endif
index 79140e0..ac42010 100644 (file)
@@ -25,7 +25,7 @@
 #include "genesis/thread.h"
        
 /* Minimize conditionalization for different OS naming schemes. */
-#if defined __linux__  || defined __FreeBSD__ || defined __OpenBSD__ || defined __sun
+#if defined __linux__  || defined __FreeBSD__ || defined __OpenBSD__ || defined __NetBSD__ || defined __sun
 #define GNAME(var) var
 #else
 #define GNAME(var) _##var
@@ -33,7 +33,7 @@
 
 /* Get the right type of alignment. Linux, FreeBSD and OpenBSD
  * want alignment in bytes. */
-#if defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__sun)
+#if defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined __NetBSD__ || defined(__sun)
 #define align_4byte    4
 #define align_8byte    8
 #define align_16byte   16
index 3b45bc5..93dec52 100644 (file)
@@ -79,6 +79,60 @@ os_context_pc_addr(os_context_t *context)
     return CONTEXT_ADDR_FROM_STEM(rip);
 }
 
+#elif defined(LISP_FEATURE_NETBSD)
+os_context_register_t *
+os_context_register_addr(os_context_t *context, int offset)
+{
+    switch(offset) {
+    case reg_RAX:
+        return CONTEXT_ADDR_FROM_STEM(RAX);
+    case reg_RCX:
+        return CONTEXT_ADDR_FROM_STEM(RCX);
+    case reg_RDX:
+        return CONTEXT_ADDR_FROM_STEM(RDX);
+    case reg_RBX:
+        return CONTEXT_ADDR_FROM_STEM(RBX);
+    case reg_RSP:
+        return CONTEXT_ADDR_FROM_STEM(RSP);
+    case reg_RBP:
+        return CONTEXT_ADDR_FROM_STEM(RBP);
+    case reg_RSI:
+        return CONTEXT_ADDR_FROM_STEM(RSI);
+    case reg_RDI:
+        return CONTEXT_ADDR_FROM_STEM(RDI);
+    case reg_R8:
+        return CONTEXT_ADDR_FROM_STEM(R8);
+    case reg_R9:
+        return CONTEXT_ADDR_FROM_STEM(R9);
+    case reg_R10:
+        return CONTEXT_ADDR_FROM_STEM(R10);
+    case reg_R11:
+        return CONTEXT_ADDR_FROM_STEM(R11);
+    case reg_R12:
+        return CONTEXT_ADDR_FROM_STEM(R12);
+    case reg_R13:
+        return CONTEXT_ADDR_FROM_STEM(R13);
+    case reg_R14:
+        return CONTEXT_ADDR_FROM_STEM(R14);
+    case reg_R15:
+        return CONTEXT_ADDR_FROM_STEM(R15);
+    default:
+        return 0;
+    }
+}
+
+os_context_register_t *
+os_context_sp_addr(os_context_t *context)
+{
+    return CONTEXT_ADDR_FROM_STEM(RSP);
+}
+
+os_context_register_t *
+os_context_pc_addr(os_context_t *context)
+{
+    return CONTEXT_ADDR_FROM_STEM(RIP);
+}
+
 #endif
 
 void
index 0745dea..967a726 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.32.31"
+"1.0.32.32"