He made a lot of progress toward getting SBCL to be bootstrappable
under CLISP.
+Perry E. Metzger:
+ He ported SBCL to NetBSD with newer signals, building on the
+ work of Valtteri Vuorikoski.
+
Gerd Moellman:
He has made many cleanups and improvements, small and large, in
CMU CL (mostly in PCL), which we have gratefully ported to SBCL. Of
SYSTEM-SPECIFIC HINTS
+for NetBSD:
+ NetBSD 2.0 and above are required because of the lack of needed
+ signal APIs in NetBSD 1.6 and earlier.
+
for OpenBSD:
OpenBSD 3.0 has stricter ulimit values, and/or enforces them more
strictly, than its predecessors. Therefore SBCL's initial mmap()
.SH SYSTEM REQUIREMENTS
-SBCL currently runs on X86 (Linux, FreeBSD, and OpenBSD), Alpha
+SBCL currently runs on X86 (Linux, FreeBSD, OpenBSD, and NetBSD), Alpha
(Linux, Tru64), PPC (Linux, Darwin/MacOS X), SPARC (Linux and Solaris
2.x), and MIPS (Linux). For information on other ongoing and possible
ports, see the sbcl-devel mailing list, and/or the web site.
;; FIXME: This list of modes should be defined in one place and
;; explicitly shared between here and REINIT.
- ;; Why was this marked #!+alpha? CMUCL does it here on all architectures
- (set-floating-point-modes :traps '(:overflow :invalid :divide-by-zero))
+ ;; FIXME: For some unknown reason, NetBSD/x86 won't run with the
+ ;; :invalid trap enabled. That should be fixed, but not today...
+ ;; PEM -- April 5, 2004
+ (set-floating-point-modes
+ :traps '(:overflow #!-netbsd :invalid :divide-by-zero))
(show-and-call !class-finalize)
;; LEAST-NEGATIVE-SINGLE-FLOAT, so the :UNDERFLOW exceptions are
;; disabled by default. Joe User can explicitly enable them if
;; desired.
- (set-floating-point-modes :traps '(:overflow :invalid :divide-by-zero))
+ ;;
+ ;; see also comment at the previous SET-FLOATING-POINT-MODES
+ ;; call site.
+ (set-floating-point-modes
+ :traps '(:overflow #!-netbsd :invalid :divide-by-zero))
(sb!thread::maybe-install-futex-functions)
;; Clear pseudo atomic in case this core wasn't compiled with
;;; use. (They want to use this address range even if we try to
;;; reserve it with a call to validate() as the first operation in
;;; main().)
+;;; * For NetBSD 2.0, the following ranges are used by normal
+;;; executables and mmap:
+;;; ** Executables are (by default) loaded at 0x08048000.
+;;; ** The break for the sbcl runtime seems to end around 0x08400000
+;;; We set read only space around 0x20000000, static
+;;; space around 0x30000000, all ending below 0x37fff000
+;;; ** ld.so and other mmap'ed stuff like shared libs start around
+;;; 0x48000000
+;;; We set dynamic space between 0x60000000 and 0x98000000
+;;; ** Bottom of the stack is typically not below 0xb0000000
+;;; FYI, this can be looked at with the "pmap" program, and if you
+;;; set the top-down mmap allocation option in the kernel (not yet
+;;; the default), all bets are totally off!
#!+linux
(progn
(def!constant dynamic-space-start #x09000000)
(def!constant dynamic-space-end #x29000000))
-#!+bsd
+#!+(or freebsd openbsd)
(progn
(def!constant read-only-space-start #x10000000)
#!+openbsd #x50000000)
(def!constant dynamic-space-end #x88000000))
+#!+netbsd
+(progn
+
+ (def!constant read-only-space-start #x20000000)
+ (def!constant read-only-space-end #x2ffff000)
+
+ (def!constant static-space-start #x30000000)
+ (def!constant static-space-end #x37fff000)
+
+ (def!constant dynamic-space-start #x60000000)
+ (def!constant dynamic-space-end #x98000000))
+
+
;;; Given that NIL is the first thing allocated in static space, we
;;; know its value at compile time:
(def!constant nil-value (+ static-space-start #xb))
--- /dev/null
+# -*- makefile -*-
+include Config.x86-bsd
+
+ASSEM_SRC += ldso-stubs.S
+OS_LINK_FLAGS = -dynamic -export-dynamic
+
+CFLAGS = -g -Wall -O2
# Config file
CFLAGS = -g -Wall -O3
ASFLAGS = $(CFLAGS)
-DEPEND_FLAGS =
CPPFLAGS = -I.
# Some of these things might be Config-dependent in future versions,
#include <stdio.h>
#include <sys/param.h>
#include <sys/file.h>
+#include <unistd.h>
+#include <assert.h>
#include "sbcl.h"
#include "./signal.h"
#include "os.h"
#include "validate.h"
\f
-vm_size_t os_vm_page_size;
+os_vm_size_t os_vm_page_size;
+#ifdef __NetBSD__
+#include <sys/resource.h>
+#include <string.h>
+
+static void netbsd_init();
+#endif /* __NetBSD__ */
+
void os_init(void)
{
os_vm_page_size = getpagesize();
+
+#ifdef __NetBSD__
+ netbsd_init();
+#endif /* __NetBSD__ */
}
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 __NetBSD__
+ return CONTEXT_ADDR_FROM_STEM(EIP);
#elif defined LISP_FEATURE_DARWIN
return &context->uc_mcontext->ss.srr0;
#else
/* (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 LISP_FEATURE_DARWIN
+#if defined __FreeBSD__ || __NetBSD__ || defined LISP_FEATURE_DARWIN
return &context->uc_sigmask;
#elif defined __OpenBSD__
return &context->sc_mask;
{
/* The way that we extract low level information like the fault
* address is not specified by POSIX. */
-#if defined __FreeBSD__
- void *fault_addr = siginfo->si_addr;
-#elif defined __OpenBSD__
+#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__)
void *fault_addr = siginfo->si_addr;
#elif defined LISP_FEATURE_DARWIN
void *fault_addr = siginfo->si_addr;
#else
#error unsupported BSD variant
#endif
+
os_context_t *context = arch_os_get_context(&void_context);
if (!gencgc_handle_wp_violation(fault_addr))
if(!handle_control_stack_guard_triggered(context,fault_addr))
}
#endif /* defined GENCGC */
+
+#ifdef __NetBSD__
+static void netbsd_init()
+{
+ struct rlimit rl;
+
+ /* NetBSD counts mmap()ed space against the process's data size limit,
+ * so yank it up. This might be a nasty thing to do? */
+ getrlimit (RLIMIT_DATA, &rl);
+ rl.rlim_cur = 1073741824;
+ if (setrlimit (RLIMIT_DATA, &rl) < 0) {
+ fprintf (stderr, "RUNTIME WARNING: unable to raise process data size limit to 1GB (%s). The system may fail to start.\n",
+ strerror(errno));
+ }
+}
+#endif /* __NetBSD__ */
\f
/* threads */
* so we need to implement single stepping in a more roundabout way. */
#define CANNOT_GET_TO_SINGLE_STEP_FLAG
#define SIG_MEMORY_FAULT SIGBUS
+
#elif defined __OpenBSD__
+
typedef struct sigcontext os_context_t;
#define SIG_MEMORY_FAULT SIGSEGV
+
+#elif defined __NetBSD__
+
+#include <ucontext.h>
+typedef ucontext_t os_context_t;
+#define SIG_MEMORY_FAULT SIGSEGV
+
#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,
#include <ucontext.h>
typedef ucontext_t os_context_t;
#define SIG_MEMORY_FAULT SIGBUS
+
#else
#error unsupported BSD variant
#endif
}
#ifndef LISP_FEATURE_GENCGC
-/* This function gets called from the SIGSEGV (for e.g. Linux or
+/* This function gets called from the SIGSEGV (for e.g. Linux, NetBSD, &
* OpenBSD) or SIGBUS (for e.g. FreeBSD) handler. Here we check
* whether the signal was due to treading on the mprotect()ed zone -
* and if so, arrange for a GC to happen. */
F(gethostbyaddr)
/* other miscellaneous things */
+/* FIXME: NetBSD needs to get fixed here too PEM 2004-03-27 */
#if defined(SVR4) || defined(__FreeBSD__)
F(setpgid)
F(getpgid)
return &context->uc_mcontext.mc_eflags;
#elif defined __OpenBSD__ || defined __NetBSD__
return &context->sc_eflags;
+#elif defined __NetBSD__
+ return &(context->uc_mcontext.__gregs[_REG_EFL]);
#else
#error unsupported OS
#endif
* flavour, with the cross-architecture complications that this
* entails; unfortunately, currently the situation is worse, not
* better, than in the above paragraph. */
-
+
+#if defined(__FreeBSD__) || defined(__OpenBSD__)
int *
os_context_register_addr(os_context_t *context, int offset)
{
return CONTEXT_ADDR_FROM_STEM(esp);
}
+#endif /* __FreeBSD__ || __OpenBSD__ */
+
+#ifdef __NetBSD__
+int *
+os_context_register_addr(os_context_t *context, int offset)
+{
+ switch(offset) {
+ case 0:
+ return CONTEXT_ADDR_FROM_STEM(EAX);
+ case 2:
+ return CONTEXT_ADDR_FROM_STEM(ECX);
+ case 4:
+ return CONTEXT_ADDR_FROM_STEM(EDX);
+ case 6:
+ return CONTEXT_ADDR_FROM_STEM(EBX);
+ case 8:
+ return CONTEXT_ADDR_FROM_STEM(ESP);
+ case 10:
+ return CONTEXT_ADDR_FROM_STEM(EBP);
+ case 12:
+ return CONTEXT_ADDR_FROM_STEM(ESI);
+ case 14:
+ return CONTEXT_ADDR_FROM_STEM(EDI);
+ default:
+ return 0;
+ }
+}
+
+int *
+os_context_sp_addr(os_context_t *context)
+{
+ return &(_UC_MACHINE_SP(context));
+}
+
+#endif /* __NetBSD__ */
+
+
/* FIXME: If this can be a no-op on BSD/x86, then it
* deserves a more precise name.
#define CONTEXT_ADDR_FROM_STEM(stem) &context->uc_mcontext.mc_ ## stem
#elif defined __OpenBSD__
#define CONTEXT_ADDR_FROM_STEM(stem) &context->sc_ ## stem
+#elif defined __NetBSD__
+#define CONTEXT_ADDR_FROM_STEM(stem) &((context)->uc_mcontext.__gregs[_REG_ ## stem])
#else
#error unsupported BSD variant
#endif
;;; 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.9.6.netbsd.1"
+"0.8.9.6.netbsd.2"