From 53ab0266f9a92943cc93f675cc727d01cfa55474 Mon Sep 17 00:00:00 2001 From: Juho Snellman Date: Sun, 22 Mar 2009 22:34:58 +0000 Subject: [PATCH] 1.0.26.18: Solaris x86-64 support * Patch by Alex Viskovatoff --- NEWS | 1 + contrib/sb-grovel/def-to-lisp.lisp | 1 + contrib/sb-posix/posix-tests.lisp | 10 ++-- make-config.sh | 7 ++- src/code/sunos-os.lisp | 2 +- src/runtime/Config.x86-64-sunos | 23 +++++++++ src/runtime/sparc-sunos-os.h | 1 + src/runtime/sunos-os.c | 2 +- src/runtime/sunos-os.h | 4 -- src/runtime/x86-64-arch.c | 2 +- src/runtime/x86-64-assem.S | 4 +- src/runtime/x86-64-sunos-os.c | 93 ++++++++++++++++++++++++++++++++++++ src/runtime/x86-64-sunos-os.h | 12 +++++ src/runtime/x86-sunos-os.h | 1 + version.lisp-expr | 2 +- 15 files changed, 150 insertions(+), 15 deletions(-) create mode 100644 src/runtime/Config.x86-64-sunos create mode 100644 src/runtime/x86-64-sunos-os.c create mode 100644 src/runtime/x86-64-sunos-os.h diff --git a/NEWS b/NEWS index 3ef75e6..4ab6d1b 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,7 @@ ;;;; -*- 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) + * new port: support added for x86-64 Solaris. (thanks to Alex Viskovatoff) * bug fix: a type error is signaled for attempts to use the LOOP keyword ACROSS for a NIL value. (thanks to Daniel Lowe) * bug fix: fix gc related interrupt handling bug on ppc (regression from diff --git a/contrib/sb-grovel/def-to-lisp.lisp b/contrib/sb-grovel/def-to-lisp.lisp index 585a84a..4c6cad4 100644 --- a/contrib/sb-grovel/def-to-lisp.lisp +++ b/contrib/sb-grovel/def-to-lisp.lisp @@ -207,6 +207,7 @@ code: "-D_FILE_OFFSET_BITS=64") #+(and x86-64 darwin) '("-arch" "x86_64") + #+(and x86-64 sunos) '("-m64") (list "-o" (namestring tmp-a-dot-out) (namestring tmp-c-source))) diff --git a/contrib/sb-posix/posix-tests.lisp b/contrib/sb-posix/posix-tests.lisp index bbd6dd5..b3ce8a2 100644 --- a/contrib/sb-posix/posix-tests.lisp +++ b/contrib/sb-posix/posix-tests.lisp @@ -415,14 +415,14 @@ #+win32 #.sb-posix:eacces) -#-(or (and x86-64 linux) win32) +#-(or (and x86-64 (or linux sunos)) win32) (deftest fcntl.1 (let ((fd (sb-posix:open "/dev/null" sb-posix::o-nonblock))) (= (sb-posix:fcntl fd sb-posix::f-getfl) sb-posix::o-nonblock)) t) ;; On AMD64/Linux O_LARGEFILE is always set, even though the whole ;; flag makes no sense. -#+(and x86-64 linux) +#+(and x86-64 (or linux sunos)) (deftest fcntl.1 (let ((fd (sb-posix:open "/dev/null" sb-posix::o-nonblock))) (/= 0 (logand (sb-posix:fcntl fd sb-posix::f-getfl) @@ -767,8 +767,10 @@ (delete-file temp)))) t "mkstemp-1") -#-(or win32 sunos hpux) -;;; mkdtemp is unimplemented on at least Solaris 10 +;#-(or win32 sunos hpux) +;;;; mkdtemp is unimplemented on at least Solaris 10 +#-(or win32 hpux) +;;; But it is implemented on OpenSolaris 2008.11 (deftest mkdtemp.1 (let ((pathname (sb-ext:parse-native-namestring diff --git a/make-config.sh b/make-config.sh index 2a70efe..0554600 100644 --- a/make-config.sh +++ b/make-config.sh @@ -123,6 +123,11 @@ case `uname -m` in ;; esac +# Under Solaris, uname -m returns "i86pc" even if CPU is amd64. +if [ "$sbcl_os" = "sunos" ] && [ `isainfo -k` = "amd64" ]; then + guessed_sbcl_arch=x86-64 +fi + echo //setting up CPU-architecture-dependent information sbcl_arch=${SBCL_ARCH:-$guessed_sbcl_arch} echo sbcl_arch=\"$sbcl_arch\" @@ -250,7 +255,7 @@ case "$sbcl_os" in printf ' :unix' >> $ltf printf ' :elf' >> $ltf printf ' :sunos' >> $ltf - if [ $sbcl_arch = "x86" ]; then + if [ $sbcl_arch = "x86" ] || [ $sbcl_arch = "amd64" ]; then printf ' :sb-lutex' >> $ltf fi link_or_copy Config.$sbcl_arch-sunos Config diff --git a/src/code/sunos-os.lisp b/src/code/sunos-os.lisp index 2a419a6..07a53f2 100644 --- a/src/code/sunos-os.lisp +++ b/src/code/sunos-os.lisp @@ -48,4 +48,4 @@ ;; disposable. ;; FIXME II: this could well be wrong #!+sparc 8192 - #!+x86 4096) + #!+(or x86 x86-64) 4096) diff --git a/src/runtime/Config.x86-64-sunos b/src/runtime/Config.x86-64-sunos new file mode 100644 index 0000000..8441cef --- /dev/null +++ b/src/runtime/Config.x86-64-sunos @@ -0,0 +1,23 @@ +CC=gcc +CFLAGS = -m64 -g -O2 -Wall -D__EXTENSIONS__ -D_POSIX_C_SOURCE=199506L -DSVR4 -D_REENTRANT -fno-omit-frame-pointer +ASFLAGS = -m64 -Wall +LD = ld +LINKFLAGS = -m64 -g +NM = nm -xgp +GREP = ggrep + +#CC=/opt/SunStudioExpress/bin/cc +#CFLAGS = -xarch=generic64 -g -O2 -Wall -D__EXTENSIONS__ -D_POSIX_C_SOURCE=199506L -DSVR4 -D_REENTRANT -fno-omit-frame-pointer +#ASFLAGS = -xarch=generic64 -Wall + +ASSEM_SRC = x86-64-assem.S ldso-stubs.S +ARCH_SRC = x86-64-arch.c + +OS_SRC = sunos-os.c x86-64-sunos-os.c os-common.c +OS_LIBS= -ldl -lsocket -lnsl -lrt + +GC_SRC= gencgc.c + +# Nothing to do for after-grovel-headers. +.PHONY: after-grovel-headers +after-grovel-headers: diff --git a/src/runtime/sparc-sunos-os.h b/src/runtime/sparc-sunos-os.h index b1dc334..3c72cb3 100644 --- a/src/runtime/sparc-sunos-os.h +++ b/src/runtime/sparc-sunos-os.h @@ -2,6 +2,7 @@ #define _SPARC_SOLARIS_OS_H typedef ucontext_t os_context_t; +typedef int os_context_register_t ; static inline os_context_t *arch_os_get_context(void **void_context) { diff --git a/src/runtime/sunos-os.c b/src/runtime/sunos-os.c index e42e4cb..89c0d71 100644 --- a/src/runtime/sunos-os.c +++ b/src/runtime/sunos-os.c @@ -28,7 +28,7 @@ #if defined LISP_FEATURE_SPARC #define OS_VM_DEFAULT_PAGESIZE 8192 -#elif defined LISP_FEATURE_X86 +#elif defined LISP_FEATURE_X86 || defined LISP_FEATURE_X86_64 #define OS_VM_DEFAULT_PAGESIZE 4096 #else #error "Don't know OS_VM_DEFAULT_PAGESIZE" diff --git a/src/runtime/sunos-os.h b/src/runtime/sunos-os.h index 7ca04b9..95726d0 100644 --- a/src/runtime/sunos-os.h +++ b/src/runtime/sunos-os.h @@ -33,7 +33,3 @@ typedef int os_vm_prot_t; #define SIG_MEMORY_FAULT SIGSEGV #define SIG_STOP_FOR_GC (SIGUSR2) - -/* Yaargh?! */ -typedef int os_context_register_t ; - diff --git a/src/runtime/x86-64-arch.c b/src/runtime/x86-64-arch.c index 72148fd..a88435c 100644 --- a/src/runtime/x86-64-arch.c +++ b/src/runtime/x86-64-arch.c @@ -54,7 +54,7 @@ arch_get_bad_addr(int sig, siginfo_t *code, os_context_t *context) os_context_register_t * 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 * file to define symbolic names for offsets into * gregs[], but it's conditional on __USE_GNU and not defined, so diff --git a/src/runtime/x86-64-assem.S b/src/runtime/x86-64-assem.S index 6466859..1b4ac54 100644 --- a/src/runtime/x86-64-assem.S +++ b/src/runtime/x86-64-assem.S @@ -25,7 +25,7 @@ #include "genesis/thread.h" /* Minimize conditionalization for different OS naming schemes. */ -#if defined __linux__ || defined __FreeBSD__ || defined __OpenBSD__ +#if defined __linux__ || defined __FreeBSD__ || defined __OpenBSD__ || 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__) +#if defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__sun) #define align_4byte 4 #define align_8byte 8 #define align_16byte 16 diff --git a/src/runtime/x86-64-sunos-os.c b/src/runtime/x86-64-sunos-os.c new file mode 100644 index 0000000..2b3e374 --- /dev/null +++ b/src/runtime/x86-64-sunos-os.c @@ -0,0 +1,93 @@ +#include +#include +#include +#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 +#include + +#include +#include +#include +#include +#include + +#ifdef LISP_FEATURE_SB_THREAD +#error "Threading is not supported for Solaris running on x86-64." +#endif + +#include "validate.h" + + +int arch_os_thread_init(struct thread *thread) { + stack_t sigstack; + return 1; +} + +int arch_os_thread_cleanup(struct thread *thread) { + return 1; +} + + +os_context_register_t * +os_context_register_addr(os_context_t *context, int offset) +{ +#define RCASE(name) case reg_ ## name: return &context->uc_mcontext.gregs[REG_ ## name]; + switch(offset) { + RCASE(RAX) + RCASE(RCX) + RCASE(RDX) + RCASE(RBX) + RCASE(RSP) + RCASE(RBP) + RCASE(RSI) + RCASE(RDI) + RCASE(R8) + RCASE(R9) + RCASE(R10) + RCASE(R11) + RCASE(R12) + RCASE(R13) + RCASE(R14) + RCASE(R15) + default: + if(offsetuc_mcontext.gregs[offset/2+4]; + else 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[REG_RIP]; +} + +os_context_register_t * +os_context_sp_addr(os_context_t *context) +{ + return &context->uc_mcontext.gregs[REG_RSP]; +} + +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) +{ +} + +unsigned long +os_context_fp_control(os_context_t *context) +{ + return context->uc_mcontext.fpregs.fp_reg_set.fpchip_state.cw; +} diff --git a/src/runtime/x86-64-sunos-os.h b/src/runtime/x86-64-sunos-os.h new file mode 100644 index 0000000..aac5505 --- /dev/null +++ b/src/runtime/x86-64-sunos-os.h @@ -0,0 +1,12 @@ +#ifndef _X86_64_SOLARIS_OS_H +#define _X86_64_SOLARIS_OS_H + +typedef struct ucontext os_context_t; +typedef long os_context_register_t; + +static inline os_context_t *arch_os_get_context(void **void_context) +{ + return (os_context_t *) *void_context; +} + +#endif /* _X86_64_SOLARIS_OS_H */ diff --git a/src/runtime/x86-sunos-os.h b/src/runtime/x86-sunos-os.h index dffcc33..bb7753a 100644 --- a/src/runtime/x86-sunos-os.h +++ b/src/runtime/x86-sunos-os.h @@ -2,6 +2,7 @@ #define _X86_SOLARIS_OS_H typedef ucontext_t os_context_t; +typedef int os_context_register_t; static inline os_context_t *arch_os_get_context(void **void_context) { diff --git a/version.lisp-expr b/version.lisp-expr index 01dab68..068097a 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.17" +"1.0.26.18" -- 1.7.10.4