0.pre8.39:
authorChristophe Rhodes <csr21@cam.ac.uk>
Sat, 5 Apr 2003 13:04:14 +0000 (13:04 +0000)
committerChristophe Rhodes <csr21@cam.ac.uk>
Sat, 5 Apr 2003 13:04:14 +0000 (13:04 +0000)
          === 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).

13 files changed:
src/code/target-unithread.lisp
src/compiler/sparc/parms.lisp
src/compiler/sparc/system.lisp
src/runtime/Config.sparc-sunos
src/runtime/ppc-linux-os.c
src/runtime/purify.c
src/runtime/sparc-arch.c
src/runtime/sparc-sunos-os.c
src/runtime/sunos-os.c
src/runtime/thread.c
src/runtime/thread.h
src/runtime/x86-linux-os.h
version.lisp-expr

index e7a1917..bd57e74 100644 (file)
@@ -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))) 
index f66386a..0b7ae33 100644 (file)
   (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))  
 
 \f
 ;;;; other random constants.
     *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*
index 0ef87f4..18c377e 100644 (file)
   (:generator 1
     (inst unimp pending-interrupt-trap)))
 
+#!+sb-thread
+(error "write a VOP for CURRENT-THREAD-OFFSET-SAP")
 
 (define-vop (halt)
   (:generator 1
index 335abd8..ffe4ec5 100644 (file)
@@ -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
index 188fbb6..443c733 100644 (file)
@@ -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 */
 }
 
index 0111857..843b821 100644 (file)
 #include <sys/types.h>
 #include <stdlib.h>
 #include <strings.h>
+#if (defined(LISP_FEATURE_SB_THREAD) && defined(LISP_FEATURE_LINUX))
 #include <sys/ptrace.h>
 #include <linux/user.h>
+#endif
 #include <errno.h>
 
 #include "runtime.h"
index 114c81f..5c825ad 100644 (file)
@@ -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;
+}
+
 \f
 extern lispobj call_into_lisp(lispobj fun, lispobj *args, int nargs);
 
index 469c5a0..73440fb 100644 (file)
 
 #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)
index a6ab92f..8c1d9b4 100644 (file)
@@ -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;
 }
-
 \f
 
 
index 7d4520d..45086eb 100644 (file)
@@ -1,6 +1,7 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <sched.h>
+#include <signal.h>
 #include <stddef.h>
 #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);
 }
-
index 737153e..cf0a26e 100644 (file)
@@ -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_ */
index a233223..90b34c0 100644 (file)
@@ -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 */
index b4b6ca1..53c1e2c 100644 (file)
@@ -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"