Permalink
Browse files

0.9.3.63:

	Merge Solaris/x86 support, mostly as in sbcl-devel 2005-06-07
	... one or two minor fixups
	... log the major problems remaining in BUGS
  • Loading branch information...
1 parent 891f4de commit 40e3ba03d0e1b824e4d1ae75d74246b975b70964 @csrhodes csrhodes committed Aug 19, 2005
View
5 BUGS
@@ -2111,3 +2111,8 @@ WORKAROUND:
385:
(format nil "~4,1F" 0.001) => "0.00" (should be " 0.0");
(format nil "~4,1@F" 0.001) => "+.00" (should be "+0.0").
+
+386: SunOS/x86 stack exhaustion handling broken
+ According to <http://alfa.s145.xrea.com/sbcl/solaris-x86.html>, the
+ stack exhaustion checking (implemented with a write-protected guard
+ page) does not work on SunOS/x86.
View
@@ -583,6 +583,9 @@ Bruno Haible:
Matthias Hoelzl:
He reported and fixed COMPILE's misbehavior on macros.
+Daisuke Homma:
+ He added support for SunOS on x86 processors.
+
Espen S Johnsen:
He provided an ANSI-compliant version of CHANGE-CLASS for PCL.
View
3 NEWS
@@ -1,5 +1,8 @@
;;;; -*- coding: utf-8; -*-
changes in sbcl-0.9.4 relative to sbcl-0.9.3:
+ * new port: the Solaris operating system on x86 processors is now
+ mostly supported, though some rough edges in the environment
+ remain. (thanks to Daisuke Homma)
* enhancement: SBCL on MIPS platforms now has a much larger dynamic
space for its heap. (thanks to Thiemo Seufer)
* minor incompatible change: eof selects abort in the debugger.
View
@@ -31,6 +31,7 @@ printf '(' >> $ltf
echo //guessing default target CPU architecture from host architecture
case `uname -m` in
*86) guessed_sbcl_arch=x86 ;;
+ i86pc) guessed_sbcl_arch=x86 ;;
*x86_64) guessed_sbcl_arch=x86-64 ;;
[Aa]lpha) guessed_sbcl_arch=alpha ;;
sparc*) guessed_sbcl_arch=sparc ;;
@@ -55,6 +55,9 @@
(inst rep)
(inst movs :dword)
+ ;; solaris requires DF being zero.
+ #!+sunos (inst cld)
+
;; Restore the count.
(inst mov ecx edx)
@@ -147,6 +150,9 @@
(inst rep)
(inst movs :dword)
+ ;; solaris requires DF being zero.
+ #!+sunos (inst cld)
+
;; Load the register arguments carefully.
(loadw edx ebp-tn -1)
View
@@ -62,4 +62,5 @@
;; FIXME: Or we could just get rid of this, since the uses of it look
;; disposable.
;; FIXME II: this could well be wrong
- 8192)
+ #!+sparc 8192
+ #!+x86 4096)
View
@@ -305,6 +305,8 @@
(inst mov eax-tn nil-value)
(inst std)
(inst mov ecx-tn (- nvals register-arg-count))
+ ;; solaris requires DF being zero.
+ #!+sunos (inst cld)
;; Jump into the default loop.
(inst jmp default-stack-vals)
@@ -339,6 +341,8 @@
(inst std)
(inst rep)
(inst movs :dword)
+ ;; solaris requires DF being zero.
+ #!+sunos (inst cld)
;; Restore ESI.
(loadw esi-tn ebx-tn (- (1+ 2)))
;; Now we have to default the remaining args. Find out how many.
@@ -354,6 +358,8 @@
(emit-label default-stack-vals)
(inst rep)
(inst stos eax-tn)
+ ;; solaris requires DF being zero.
+ #!+sunos (inst cld)
;; Restore EDI, and reset the stack.
(emit-label restore-edi)
(loadw edi-tn ebx-tn (- (1+ 1)))
@@ -1312,7 +1318,9 @@
(inst loop loop)
;; NIL out the last cons.
(storew nil-value dst 1 list-pointer-lowtag))
- (emit-label done))))
+ (emit-label done)
+ ;; solaris requires DF being zero.
+ #!+sunos (inst cld))))
;;; Return the location and size of the &MORE arg glob created by
;;; COPY-MORE-ARG. SUPPLIED is the total number of arguments supplied
@@ -214,6 +214,8 @@
(inst movs :dword)
DONE
+ ;; solaris requires DF being zero.
+ #!+sunos (inst cld)
;; Reset the CSP at last moved arg.
(inst lea esp-tn (make-ea :dword :base edi :disp n-word-bytes))))
@@ -161,6 +161,20 @@
(def!constant linkage-table-space-start #x70000000)
(def!constant linkage-table-space-end #x7ffff000))
+#!+sunos
+(progn
+ (def!constant read-only-space-start #x20000000)
+ (def!constant read-only-space-end #x2ffff000)
+
+ (def!constant static-space-start #x40000000)
+ (def!constant static-space-end #x42fff000)
+
+ (def!constant dynamic-space-start #x48000000)
+ (def!constant dynamic-space-end #xA0000000)
+
+ (def!constant linkage-table-space-start #xA2000000)
+ (def!constant linkage-table-space-end #xA3000000))
+
#!+freebsd
(progn
(def!constant read-only-space-start #x10000000)
@@ -39,6 +39,8 @@
(inst cmp esp-tn esi)
(inst jmp :be loop)
DONE
+ ;; solaris requires DF being zero.
+ #!+sunos (inst cld)
(inst lea esp-tn (make-ea :dword :base edi :disp n-word-bytes))
(inst sub edi esi)
(loop for moved = moved-ptrs then (tn-ref-across moved)
@@ -147,5 +149,7 @@
(inst push temp)
(inst loop loop)
- DONE))
+ DONE
+ ;; solaris requires DF being zero.
+ #!+sunos (inst cld)))
@@ -0,0 +1,15 @@
+CC=gcc
+CFLAGS = -O2 -Wall -DSVR4
+ASFLAGS = -Wall -DSVR4
+LD = ld
+NM = nm -xgp
+GREP = ggrep
+
+ASSEM_SRC = x86-assem.S ldso-stubs.S
+ARCH_SRC = x86-arch.c
+
+OS_SRC = sunos-os.c x86-sunos-os.c os-common.c
+OS_LIBS= -ldl -lsocket -lnsl -lrt
+
+GC_SRC= gencgc.c
+
View
@@ -20,6 +20,7 @@ LD = ld
LINKFLAGS = -g
NM = nm -gp
DEPEND_FLAGS = -MM
+GREP = grep
CFLAGS = -g -Wall -O3
ASFLAGS = $(CFLAGS)
@@ -52,7 +53,7 @@ sbcl: $(OBJS)
$(CC) ${LINKFLAGS} -o $@ $^ $(LIBS)
sbcl.nm: sbcl
- $(NM) sbcl | grep -v " F \| U " > ,$@
+ $(NM) sbcl | $(GREP) -v " F \| U " > ,$@
mv -f ,$@ $@
sbcl.h: $(wildcard genesis/*.h)
View
@@ -65,14 +65,16 @@ static void gencgc_pickup_dynamic(void);
boolean enable_page_protection = 1;
/* Should we unmap a page and re-mmap it to have it zero filled? */
-#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__)
+#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__sun)
/* comment from cmucl-2.4.8: This can waste a lot of swap on FreeBSD
* so don't unmap there.
*
* The CMU CL comment didn't specify a version, but was probably an
* old version of FreeBSD (pre-4.0), so this might no longer be true.
* OTOH, if it is true, this behavior might exist on OpenBSD too, so
* for now we don't unmap there either. -- WHN 2001-04-07 */
+/* Apparently this flag is required to be 0 for SunOS/x86, as there
+ * are reports of heap corruption otherwise. */
boolean gencgc_unmap_zero = 0;
#else
boolean gencgc_unmap_zero = 1;
View
@@ -17,7 +17,22 @@
#include "validate.h"
#include "target-arch-os.h"
+#ifdef LISP_FEATURE_X86
+#include "genesis/static-symbols.h"
+#include "genesis/fdefn.h"
+#endif
+
+#ifdef LISP_FEATURE_GENCGC
+#include "gencgc-internal.h"
+#endif
+
+#if defined LISP_FEATURE_SPARC
#define OS_VM_DEFAULT_PAGESIZE 8192
+#elif defined LISP_FEATURE_X86
+#define OS_VM_DEFAULT_PAGESIZE 4096
+#else
+#error "Don't know OS_VM_DEFAULT_PAGESIZE"
+#endif
long os_vm_page_size=(-1);
static long os_real_page_size=(-1);
@@ -161,8 +176,13 @@ boolean is_valid_lisp_addr(os_vm_address_t addr)
struct thread *th;
if(in_range_p(addr, READ_ONLY_SPACE_START, READ_ONLY_SPACE_SIZE) ||
in_range_p(addr, STATIC_SPACE_START , STATIC_SPACE_SIZE) ||
+#ifdef LISP_FEATURE_GENCGC
+ in_range_p(addr, DYNAMIC_SPACE_START, DYNAMIC_SPACE_SIZE)
+#else
in_range_p(addr, DYNAMIC_0_SPACE_START, DYNAMIC_SPACE_SIZE) ||
- in_range_p(addr, DYNAMIC_1_SPACE_START, DYNAMIC_SPACE_SIZE))
+ in_range_p(addr, DYNAMIC_1_SPACE_START, DYNAMIC_SPACE_SIZE)
+#endif
+ )
return 1;
for_each_thread(th) {
if((th->control_stack_start <= addr) && (addr < th->control_stack_end))
@@ -174,6 +194,30 @@ boolean is_valid_lisp_addr(os_vm_address_t addr)
}
+#if defined LISP_FEATURE_GENCGC
+
+void
+sigsegv_handler(int signal, siginfo_t *info, void* void_context)
+{
+ os_context_t *context = arch_os_get_context(&void_context);
+ void* fault_addr = (void*)info->si_addr;
+ if(info->si_code == 1)
+ {
+ perror("error: SEGV_MAPERR\n");
+ exit(1);
+ }
+
+ if (!gencgc_handle_wp_violation(fault_addr))
+ if(!handle_guard_page_triggered(context, fault_addr))
+#ifdef LISP_FEATURE_C_STACK_IS_CONTROL_STACK
+ arrange_return_to_lisp_function(context,
+ SymbolFunction(MEMORY_FAULT_ERROR));
+#else
+ interrupt_handle_now(signal, info, context);
+#endif
+}
+
+#else
static void
sigsegv_handler(int signal, siginfo_t *info, void* void_context)
@@ -188,6 +232,8 @@ sigsegv_handler(int signal, siginfo_t *info, void* void_context)
}
}
+#endif
+
void
os_install_interrupt_handlers()
{
View
@@ -46,7 +46,7 @@ void arch_init(void)
int *
context_eflags_addr(os_context_t *context)
{
-#if defined __linux__
+#if defined __linux__ || defined __sun
/* KLUDGE: As of kernel 2.2.14 on Red Hat 6.2, there's code in the
* <sys/ucontext.h> file to define symbolic names for offsets into
* gregs[], but it's conditional on __USE_GNU and not defined, so
View
@@ -29,7 +29,7 @@
* turns out not to matter, perhaps it's just clutter we could get
* rid of? -- WHN 2004-04-18)
*/
-#if defined __linux__ || defined __FreeBSD__ || defined __NetBSD__ || defined __OpenBSD__
+#if defined __linux__ || defined __FreeBSD__ || defined __NetBSD__ || defined __OpenBSD__ || defined __sun
#define GNAME(var) var
#else
#define GNAME(var) _##var
@@ -44,7 +44,7 @@
* matter any more, perhaps it's just clutter we could get
* rid of? -- WHN 2004-04-18)
*/
-#if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
+#if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__sun)
#define align_4byte 4
#define align_8byte 8
#define align_16byte 16
View
@@ -0,0 +1,80 @@
+#include <stdio.h>
+#include <sys/param.h>
+#include <sys/file.h>
+#include "sbcl.h"
+#include "./signal.h"
+#include "os.h"
+#include "arch.h"
+#include "globals.h"
+#include "interrupt.h"
+#include "interr.h"
+#include "lispregs.h"
+#include <sys/socket.h>
+#include <sys/utsname.h>
+
+#include <sys/types.h>
+#include <signal.h>
+#include <sys/time.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
+#include "validate.h"
+#ifdef LISP_FEATURE_SB_THREAD
+#error "Define threading support functions"
+#else
+int arch_os_thread_init(struct thread *thread) {
+ stack_t sigstack;
+#ifdef LISP_FEATURE_C_STACK_IS_CONTROL_STACK
+ /* Signal handlers are run on the control stack, so if it is exhausted
+ * we had better use an alternate stack for whatever signal tells us
+ * we've exhausted it */
+ sigstack.ss_sp=((void *) thread)+dynamic_values_bytes;
+ sigstack.ss_flags=0;
+ sigstack.ss_size = 32*SIGSTKSZ;
+ sigaltstack(&sigstack,0);
+#endif
+ return 1; /* success */
+}
+int arch_os_thread_cleanup(struct thread *thread) {
+ return 1; /* success */
+}
+#endif
+
+os_context_register_t *
+os_context_register_addr(os_context_t *context, int offset)
+{
+ switch(offset) {
+ case reg_EAX: return &context->uc_mcontext.gregs[11];
+ case reg_ECX: return &context->uc_mcontext.gregs[10];
+ case reg_EDX: return &context->uc_mcontext.gregs[9];
+ case reg_EBX: return &context->uc_mcontext.gregs[8];
+ case reg_ESP: return &context->uc_mcontext.gregs[7];
+ case reg_EBP: return &context->uc_mcontext.gregs[6];
+ case reg_ESI: return &context->uc_mcontext.gregs[5];
+ case reg_EDI: return &context->uc_mcontext.gregs[4];
+ default: return 0;
+ }
+ return &context->uc_mcontext.gregs[offset];
+}
+
+os_context_register_t *
+os_context_pc_addr(os_context_t *context)
+{
+ return &(context->uc_mcontext.gregs[14]); /* REG_EIP */
+}
+
+os_context_register_t *
+os_context_sp_addr(os_context_t *context)
+{
+ return &(context->uc_mcontext.gregs[17]); /* REG_UESP */
+}
+
+sigset_t *
+os_context_sigmask_addr(os_context_t *context)
+{
+ return &(context->uc_sigmask);
+}
+
+void os_flush_icache(os_vm_address_t address, os_vm_size_t length)
+{
+}
View
@@ -0,0 +1,10 @@
+#ifndef _X86_SOLARIS_OS_H
+#define _X86_SOLARIS_OS_H
+
+typedef ucontext_t os_context_t;
+
+static inline os_context_t *arch_os_get_context(void **void_context) {
+ return (os_context_t *) *void_context;
+}
+
+#endif /* _X86_SOLARIS_OS_H */
Oops, something went wrong.

0 comments on commit 40e3ba0

Please sign in to comment.