From d767105094f5836327f9389b061f83a44240a279 Mon Sep 17 00:00:00 2001 From: Christophe Rhodes Date: Sat, 5 Apr 2003 13:04:14 +0000 Subject: [PATCH] 0.pre8.39: === Threads merge, 0.78125 metres === Merge patch (CSR sbcl-devel 2003-04-04) supporting SPARC/SunOS. This version builds on SPARC/SunOS and x86/Linux in #!-sb-thread mode; it has not been tested on x86/Linux with threads enabled (and will obviously not run on SPARC/SunOS with threads, because of the minor matter of various implementation details such as a garbage collector and multiprocessing primitives). --- src/code/target-unithread.lisp | 2 +- src/compiler/sparc/parms.lisp | 12 +++++------- src/compiler/sparc/system.lisp | 2 ++ src/runtime/Config.sparc-sunos | 2 +- src/runtime/ppc-linux-os.c | 4 ++-- src/runtime/purify.c | 2 ++ src/runtime/sparc-arch.c | 5 +++++ src/runtime/sparc-sunos-os.c | 13 +++++++++++++ src/runtime/sunos-os.c | 26 +++++++++++++++++++------- src/runtime/thread.c | 9 ++++++--- src/runtime/thread.h | 3 ++- src/runtime/x86-linux-os.h | 2 -- version.lisp-expr | 2 +- 13 files changed, 59 insertions(+), 25 deletions(-) diff --git a/src/code/target-unithread.lisp b/src/code/target-unithread.lisp index e7a1917..bd57e74 100644 --- a/src/code/target-unithread.lisp +++ b/src/code/target-unithread.lisp @@ -1,6 +1,6 @@ (in-package "SB!THREAD") -#-sb-fluid (declaim (inline sb!vm::current-thread-offset-sap)) +#!-sb-fluid (declaim (inline sb!vm::current-thread-offset-sap)) (defun sb!vm::current-thread-offset-sap (n) (declare (type (unsigned-byte 27) n)) (sb!sys:sap-ref-sap (alien-sap (extern-alien "all_threads" (* t))) diff --git a/src/compiler/sparc/parms.lisp b/src/compiler/sparc/parms.lisp index f66386a..0b7ae33 100644 --- a/src/compiler/sparc/parms.lisp +++ b/src/compiler/sparc/parms.lisp @@ -159,13 +159,7 @@ (def!constant dynamic-0-space-end #x38000000) (def!constant dynamic-1-space-start #x40000000) - (def!constant dynamic-1-space-end #x48000000) - - (def!constant control-stack-start #x50000000) - (def!constant control-stack-end #x51000000) - - (def!constant binding-stack-start #x60000000) - (def!constant binding-stack-end #x61000000)) + (def!constant dynamic-1-space-end #x48000000)) ;;;; other random constants. @@ -222,6 +216,10 @@ *current-catch-block* *current-unwind-protect-block* + *binding-stack-start* + *control-stack-start* + *control-stack-end* + ;; interrupt handling *free-interrupt-context-index* sb!unix::*interrupts-enabled* diff --git a/src/compiler/sparc/system.lisp b/src/compiler/sparc/system.lisp index 0ef87f4..18c377e 100644 --- a/src/compiler/sparc/system.lisp +++ b/src/compiler/sparc/system.lisp @@ -222,6 +222,8 @@ (:generator 1 (inst unimp pending-interrupt-trap))) +#!+sb-thread +(error "write a VOP for CURRENT-THREAD-OFFSET-SAP") (define-vop (halt) (:generator 1 diff --git a/src/runtime/Config.sparc-sunos b/src/runtime/Config.sparc-sunos index 335abd8..ffe4ec5 100644 --- a/src/runtime/Config.sparc-sunos +++ b/src/runtime/Config.sparc-sunos @@ -22,6 +22,6 @@ 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 +OS_LIBS= -ldl -lsocket -lnsl -lrt GC_SRC= cheneygc.c diff --git a/src/runtime/ppc-linux-os.c b/src/runtime/ppc-linux-os.c index 188fbb6..443c733 100644 --- a/src/runtime/ppc-linux-os.c +++ b/src/runtime/ppc-linux-os.c @@ -41,10 +41,10 @@ size_t os_vm_page_size; struct thread *arch_os_get_current_thread() { return all_threads; } -struct thread *arch_os_thread_init() { +int arch_os_thread_init(struct thread *thread) { return 1; /* success */ } -struct thread *arch_os_thread_cleanup() { +int arch_os_thread_cleanup(struct thread *thread) { return 1; /* success */ } diff --git a/src/runtime/purify.c b/src/runtime/purify.c index 0111857..843b821 100644 --- a/src/runtime/purify.c +++ b/src/runtime/purify.c @@ -17,8 +17,10 @@ #include #include #include +#if (defined(LISP_FEATURE_SB_THREAD) && defined(LISP_FEATURE_LINUX)) #include #include +#endif #include #include "runtime.h" diff --git a/src/runtime/sparc-arch.c b/src/runtime/sparc-arch.c index 114c81f..5c825ad 100644 --- a/src/runtime/sparc-arch.c +++ b/src/runtime/sparc-arch.c @@ -351,6 +351,11 @@ void arch_install_interrupt_handlers() undoably_install_low_level_interrupt_handler(SIGEMT, sigemt_handler); } +void get_spinlock(lispobj *word, int value) { + /* FIXME: dummy definition */ + *word = value; +} + extern lispobj call_into_lisp(lispobj fun, lispobj *args, int nargs); diff --git a/src/runtime/sparc-sunos-os.c b/src/runtime/sparc-sunos-os.c index 469c5a0..73440fb 100644 --- a/src/runtime/sparc-sunos-os.c +++ b/src/runtime/sparc-sunos-os.c @@ -36,6 +36,19 @@ #include "validate.h" +#ifdef LISP_FEATURE_SB_THREAD +#error "Define threading support functions" +#else +struct thread *arch_os_get_current_thread() { + return all_threads; +} +int arch_os_thread_init(struct thread *thread) { + 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) diff --git a/src/runtime/sunos-os.c b/src/runtime/sunos-os.c index a6ab92f..8c1d9b4 100644 --- a/src/runtime/sunos-os.c +++ b/src/runtime/sunos-os.c @@ -150,14 +150,26 @@ 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 )); + + /* FIXME: this looks like a valid definition for all targets with + cheney-gc; it may not be impressively smart (witness the + comment above) but maybe associating these functions with the + GC rather than the OS would be a maintainability win. -- CSR, + 2003-04-04 */ + 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) || + in_range_p(addr, DYNAMIC_0_SPACE_START, DYNAMIC_SPACE_SIZE) || + in_range_p(addr, DYNAMIC_1_SPACE_START, DYNAMIC_SPACE_SIZE)) + return 1; + for_each_thread(th) { + if((th->control_stack_start <= addr) && (addr < th->control_stack_end)) + return 1; + if(in_range_p(addr, th->binding_stack_start, BINDING_STACK_SIZE)) + return 1; + } + return 0; } - diff --git a/src/runtime/thread.c b/src/runtime/thread.c index 7d4520d..45086eb 100644 --- a/src/runtime/thread.c +++ b/src/runtime/thread.c @@ -1,6 +1,7 @@ #include #include #include +#include #include #ifndef CLONE_PARENT /* lameass glibc 2.2 doesn't define this */ #define CLONE_PARENT 0x00008000 /* even though the manpage documents it */ @@ -50,8 +51,13 @@ new_thread_trampoline(struct thread *th) fprintf(stderr, "/continue\n"); } th->unbound_marker = UNBOUND_MARKER_WIDETAG; +#ifdef LISP_FEATURE_SB_THREAD /* wait here until our thread is linked into all_threads: see below */ while(th->pid<1) sched_yield(); +#else + if(th->pid < 1) + lose("th->pid not set up right"); +#endif if(arch_os_thread_init(th)==0) return 1; /* failure. no, really */ @@ -249,8 +255,6 @@ struct thread *find_thread_by_pid(pid_t pid) return 0; } - - void block_sigcont(void) { /* don't allow ourselves to receive SIGCONT while we're in the @@ -270,4 +274,3 @@ void unblock_sigcont_and_sleep(void) sigwaitinfo(&set,0); sigprocmask(SIG_UNBLOCK,&set,0); } - diff --git a/src/runtime/thread.h b/src/runtime/thread.h index 737153e..cf0a26e 100644 --- a/src/runtime/thread.h +++ b/src/runtime/thread.h @@ -88,6 +88,7 @@ static inline void SetTlSymbolValue(u32 tagged_symbol_pointer,lispobj val, void #endif } - +int arch_os_thread_init(struct thread *thread); +extern struct thread *arch_os_get_current_thread(); #endif /* _INCLUDE_THREAD_H_ */ diff --git a/src/runtime/x86-linux-os.h b/src/runtime/x86-linux-os.h index a233223..90b34c0 100644 --- a/src/runtime/x86-linux-os.h +++ b/src/runtime/x86-linux-os.h @@ -8,9 +8,7 @@ static inline os_context_t *arch_os_get_context(void **void_context) { return (os_context_t *) *void_context; } -extern struct thread *arch_os_get_current_thread(); unsigned long os_context_fp_control(os_context_t *context); void os_restore_fp_control(os_context_t *context); -int arch_os_thread_init(struct thread *thread); #endif /* _X86_LINUX_OS_H */ diff --git a/version.lisp-expr b/version.lisp-expr index b4b6ca1..53c1e2c 100644 --- a/version.lisp-expr +++ b/version.lisp-expr @@ -18,4 +18,4 @@ ;;; versions, especially for internal versions off the main CVS ;;; branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".) -"0.pre8.38" +"0.pre8.39" -- 1.7.10.4