From: Christophe R. <cr...@us...> - 2002-03-25 18:25:08
|
Update of /cvsroot/sbcl/sbcl/src/runtime In directory usw-pr-cvs1:/tmp/cvs-serv13651/src/runtime Modified Files: coreparse.c ldso-stubs.S purify.c sparc-arch.c undefineds.h Added Files: Config.sparc-sunos sparc-sunos-os.c sparc-sunos-os.h sunos-os.c sunos-os.h Log Message: 0.7.1.1: Merged support for SPARC/SunOS (aka Solaris) ... added relevant runtime and -os.lisp files; ... cleaned up sparc backend runtime, actually _using_ the abstractions that were written for the SPARC/Linux port; ... added some #includes for compilation (nothing breaks on Linux, but BSD has not yet been tested; ... removed some bash-/ksh-isms from build and test scripts; ... abstraced wait3() constants into grovel_headers and unix.lisp. --- NEW FILE: Config.sparc-sunos --- # 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. CC=gcc CFLAGS = -g -O3 -Wall -Dsparc -DSVR4 ASFLAGS = -g -Wall -Dsparc -DSVR4 LD = ld LINKFLAGS = -v -g NM = nm -p ASSEM_SRC = sparc-assem.S #ARCH_SRC = sparc-arch.c undefineds.c ARCH_SRC = sparc-arch.c ldso-stubs.S OS_SRC = sunos-os.c sparc-sunos-os.c os-common.c #LINKFLAGS+=-static LINKFLAGS+= OS_LIBS= -ldl -lsocket -lnsl GC_SRC= gc.c --- NEW FILE: sparc-sunos-os.c --- /* * This is the SPARC Linux incarnation of arch-dependent OS-dependent * routines. See also "linux-os.c". */ /* * 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 <stdio.h> #include <sys/param.h> #include <sys/file.h> #include "./signal.h" #include "os.h" #include "arch.h" #include "globals.h" #include "interrupt.h" #include "interr.h" #include "lispregs.h" #include "sbcl.h" #include <sys/socket.h> #include <sys/utsname.h> #include <sys/types.h> #include <signal.h> /* #include <sys/sysinfo.h> */ #include <sys/time.h> #include <sys/stat.h> #include <unistd.h> #include "validate.h" #if defined GENCGC /* unlikely ... */ #include "gencgc.h" #endif os_context_register_t * os_context_register_addr(os_context_t *context, int offset) { if (offset == 0) { static int zero; zero = 0; return &zero; } else if (offset < 16) { return &context->uc_mcontext.gregs[offset+3]; } else if (offset < 32) { /* FIXME: You know, this (int *) stuff looks decidedly dubious */ int *sp = (int*) context->uc_mcontext.gregs[REG_SP]; return &(sp[offset-16]); } else { return 0; } } os_context_register_t * os_context_pc_addr(os_context_t *context) { return &(context->uc_mcontext.gregs[REG_PC]); } os_context_register_t * os_context_npc_addr(os_context_t *context) { return &(context->uc_mcontext.gregs[REG_nPC]); } 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) { /* FIXME. There's a bit of stuff in the CMUCL version. It may or may not be needed */ } --- NEW FILE: sparc-sunos-os.h --- #ifndef _SPARC_SOLARIS_OS_H #define _SPARC_SOLARIS_OS_H typedef ucontext_t os_context_t; static inline os_context_t *arch_os_get_context(void **void_context) { asm volatile ("ta 0x03"); /* ta ST_FLUSH_WINDOWS */ return (os_context_t *) (*void_context); } #endif /* _SPARC_SOLARIS_OS_H */ --- NEW FILE: sunos-os.c --- #include <stdio.h> #include <signal.h> #include <sys/file.h> #include <unistd.h> #include <errno.h> #include <sys/param.h> #include "os.h" #include "arch.h" #include "interr.h" #include "interrupt.h" #include "globals.h" #include "validate.h" #include "sbcl.h" #include "target-arch-os.h" #define OS_VM_DEFAULT_PAGESIZE 8192 long os_vm_page_size=(-1); static long os_real_page_size=(-1); static os_vm_size_t real_page_size_difference=0; void os_init(void) { /* I do not understand this at all. FIXME. */ os_vm_page_size = os_real_page_size = sysconf(_SC_PAGESIZE); if(os_vm_page_size>OS_VM_DEFAULT_PAGESIZE){ fprintf(stderr,"os_init: Pagesize too large (%d > %d)\n", os_vm_page_size,OS_VM_DEFAULT_PAGESIZE); exit(1); }else{ /* * we do this because there are apparently dependencies on * the pagesize being OS_VM_DEFAULT_PAGESIZE somewhere... * but since the OS doesn't know we're using this restriction, * we have to grovel around a bit to enforce it, thus anything * that uses real_page_size_difference. */ /* FIXME: Is this still true? */ real_page_size_difference=OS_VM_DEFAULT_PAGESIZE-os_vm_page_size; os_vm_page_size=OS_VM_DEFAULT_PAGESIZE; } } os_vm_address_t os_validate(os_vm_address_t addr, os_vm_size_t len) { int flags = MAP_PRIVATE | MAP_NORESERVE | MAP_ANON; if (addr) flags |= MAP_FIXED; addr = mmap(addr, len, OS_VM_PROT_ALL, flags, -1, 0); if (addr == MAP_FAILED) { perror("mmap"); lose ("Error in mmap(..)"); } return addr; } void os_invalidate(os_vm_address_t addr, os_vm_size_t len) { if(munmap((void*) addr, len) == -1) perror("munmap"); } os_vm_address_t os_map(int fd, int offset, os_vm_address_t addr, os_vm_size_t len) { addr = mmap(addr, len, OS_VM_PROT_ALL, MAP_PRIVATE | MAP_FIXED, fd, (off_t) offset); if (addr == MAP_FAILED) { perror("mmap"); lose("Unexpedted mmap(..) failure"); } return addr; } void os_protect(os_vm_address_t address, os_vm_size_t length, os_vm_prot_t prot) { if(mprotect((void*)address, length, prot) == -1) { perror("mprotect"); } } static boolean in_range_p(os_vm_address_t a, lispobj sbeg, size_t slen) { char* beg = (char*) sbeg; char* end = (char*) sbeg + slen; char* adr = (char*) a; return (adr >= beg && adr < end); } boolean is_valid_lisp_addr(os_vm_address_t addr) { /* Just assume address is valid if it lies within one of the known spaces. (Unlike sunos-os which keeps track of every valid page.) */ return ( in_range_p(addr, READ_ONLY_SPACE_START, READ_ONLY_SPACE_SIZE) || in_range_p(addr, STATIC_SPACE_START , STATIC_SPACE_SIZE ) || 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, CONTROL_STACK_START , CONTROL_STACK_SIZE ) || in_range_p(addr, BINDING_STACK_START , BINDING_STACK_SIZE )); } #if defined GENCGC #error "GENCGC is not yet supported (presumably on x86 solaris?)" #else static void sigsegv_handler(int signal, siginfo_t *info, void* void_context) { os_context_t *context = arch_os_get_context(&void_context); os_vm_address_t addr; addr = arch_get_bad_addr(signal, info, context); /* There's some complicated recovery code in linux-os.c here that I'm currently too confused to understand. Fixme. */ if(!interrupt_maybe_gc(signal, info, context)) { interrupt_handle_now(signal, info, context); } } #endif void os_install_interrupt_handlers() { undoably_install_low_level_interrupt_handler(SIGSEGV,sigsegv_handler); } --- NEW FILE: sunos-os.h --- /* * 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 <signal.h> #include <unistd.h> #include <sys/fcntl.h> #include <sys/mman.h> #include <ucontext.h> #include "target-arch-os.h" #include "target-arch.h" /* FIXME: Stolen from CMUCL. Investigate. */ typedef unsigned long os_vm_address_t; typedef long os_vm_size_t; typedef off_t os_vm_offset_t; typedef int os_vm_prot_t; /* typedef struct ucontext os_context_t;*/ #define OS_VM_PROT_READ PROT_READ #define OS_VM_PROT_WRITE PROT_WRITE #define OS_VM_PROT_EXECUTE PROT_EXEC /* Yaargh?! */ typedef int os_context_register_t ; Index: coreparse.c =================================================================== RCS file: /cvsroot/sbcl/sbcl/src/runtime/coreparse.c,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** coreparse.c 30 Jul 2001 19:30:33 -0000 1.12 --- coreparse.c 25 Mar 2002 18:25:04 -0000 1.13 *************** *** 19,22 **** --- 19,24 ---- #include <sys/file.h> #include <sys/types.h> + #include <sys/stat.h> + #include <fcntl.h> #include <unistd.h> Index: ldso-stubs.S =================================================================== RCS file: /cvsroot/sbcl/sbcl/src/runtime/ldso-stubs.S,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** ldso-stubs.S 18 Mar 2002 19:08:02 -0000 1.13 --- ldso-stubs.S 25 Mar 2002 18:25:04 -0000 1.14 *************** *** 158,162 **** --- 158,164 ---- LDSO_STUBIFY(setitimer) LDSO_STUBIFY(setpgrp) + #if !defined(SVR4) LDSO_STUBIFY(sigsetmask) + #endif LDSO_STUBIFY(sinh) LDSO_STUBIFY(socket) Index: purify.c =================================================================== RCS file: /cvsroot/sbcl/sbcl/src/runtime/purify.c,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** purify.c 15 Feb 2002 17:10:02 -0000 1.18 --- purify.c 25 Mar 2002 18:25:04 -0000 1.19 *************** *** 17,20 **** --- 17,21 ---- #include <sys/types.h> #include <stdlib.h> + #include <strings.h> #include "runtime.h" Index: sparc-arch.c =================================================================== RCS file: /cvsroot/sbcl/sbcl/src/runtime/sparc-arch.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** sparc-arch.c 18 Mar 2002 19:08:02 -0000 1.2 --- sparc-arch.c 25 Mar 2002 18:25:04 -0000 1.3 *************** *** 87,91 **** { ((char *) *os_context_pc_addr(context)) = ((char *) *os_context_npc_addr(context)); ! context->si_regs.npc += 4; } --- 87,91 ---- { ((char *) *os_context_pc_addr(context)) = ((char *) *os_context_npc_addr(context)); ! ((char *) *os_context_npc_addr(context)) += 4; } *************** *** 129,133 **** unsigned long *pc = (unsigned long *)(*os_context_pc_addr(context)); /* FIXME */ ! unsigned long *npc = &context->si_regs.npc; /* orig_sigmask = context->sigmask; --- 129,133 ---- unsigned long *pc = (unsigned long *)(*os_context_pc_addr(context)); /* FIXME */ ! unsigned long *npc = (unsigned long *)(*os_context_npc_addr(context)); /* orig_sigmask = context->sigmask; *************** *** 143,148 **** os_flush_icache((os_vm_address_t) npc, sizeof(unsigned long)); - /* How much is this not going to work? */ - sigreturn(context); } --- 143,146 ---- *************** *** 188,192 **** os_context_t *context = arch_os_get_context(&void_context); ! sigprocmask(SIG_SETMASK, &context->si_mask, 0); if ((siginfo->si_code) == ILL_ILLOPC --- 186,190 ---- os_context_t *context = arch_os_get_context(&void_context); ! sigprocmask(SIG_SETMASK, os_context_sigmask_addr(context), 0); if ((siginfo->si_code) == ILL_ILLOPC *************** *** 223,227 **** case trap_FunEndBreakpoint: *os_context_pc_addr(context) = (int) handle_fun_end_breakpoint(signal, siginfo, context); ! context->si_regs.npc = *os_context_pc_addr(context) + 4; break; --- 221,225 ---- case trap_FunEndBreakpoint: *os_context_pc_addr(context) = (int) handle_fun_end_breakpoint(signal, siginfo, context); ! *os_context_npc_addr(context) = *os_context_pc_addr(context) + 4; break; Index: undefineds.h =================================================================== RCS file: /cvsroot/sbcl/sbcl/src/runtime/undefineds.h,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** undefineds.h 16 Jan 2002 20:31:50 -0000 1.11 --- undefineds.h 25 Mar 2002 18:25:04 -0000 1.12 *************** *** 149,153 **** --- 149,155 ---- F(sigreturn) #endif + #if !defined(SVR4) F(sigsetmask) + #endif #if !defined(SVR4) && !defined(__FreeBSD__) && !defined(__OpenBSD__) F(sigstack) |