1.0.26.18: Solaris x86-64 support
authorJuho Snellman <jsnell@iki.fi>
Sun, 22 Mar 2009 22:34:58 +0000 (22:34 +0000)
committerJuho Snellman <jsnell@iki.fi>
Sun, 22 Mar 2009 22:34:58 +0000 (22:34 +0000)
        * Patch by Alex Viskovatoff

15 files changed:
NEWS
contrib/sb-grovel/def-to-lisp.lisp
contrib/sb-posix/posix-tests.lisp
make-config.sh
src/code/sunos-os.lisp
src/runtime/Config.x86-64-sunos [new file with mode: 0644]
src/runtime/sparc-sunos-os.h
src/runtime/sunos-os.c
src/runtime/sunos-os.h
src/runtime/x86-64-arch.c
src/runtime/x86-64-assem.S
src/runtime/x86-64-sunos-os.c [new file with mode: 0644]
src/runtime/x86-64-sunos-os.h [new file with mode: 0644]
src/runtime/x86-sunos-os.h
version.lisp-expr

diff --git a/NEWS b/NEWS
index 3ef75e6..4ab6d1b 100644 (file)
--- 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
index 585a84a..4c6cad4 100644 (file)
@@ -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)))
index bbd6dd5..b3ce8a2 100644 (file)
   #+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)
           (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
index 2a70efe..0554600 100644 (file)
@@ -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
index 2a419a6..07a53f2 100644 (file)
@@ -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 (file)
index 0000000..8441cef
--- /dev/null
@@ -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:
index b1dc334..3c72cb3 100644 (file)
@@ -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)
 {
index e42e4cb..89c0d71 100644 (file)
@@ -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"
index 7ca04b9..95726d0 100644 (file)
@@ -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 ;
-
index 72148fd..a88435c 100644 (file)
@@ -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
      * <sys/ucontext.h> file to define symbolic names for offsets into
      * gregs[], but it's conditional on __USE_GNU and not defined, so
index 6466859..1b4ac54 100644 (file)
@@ -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 (file)
index 0000000..2b3e374
--- /dev/null
@@ -0,0 +1,93 @@
+#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>
+
+#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(offset<NGREG)
+            return &context->uc_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 (file)
index 0000000..aac5505
--- /dev/null
@@ -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 */
index dffcc33..bb7753a 100644 (file)
@@ -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)
 {
index 01dab68..068097a 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.26.17"
+"1.0.26.18"