From 43fd499e094bd6078dd13471f6cae71687326378 Mon Sep 17 00:00:00 2001 From: Richard Lowe Date: Mon, 22 Jul 2019 02:14:30 +0000 Subject: [PATCH] Enable threading for SunOS on x86-64 - Add arch_os_thread_init, in the same manner as BSD and Linux - Enable threading if --fancy - Mark wait-on-sempahore semaphore-notification :lp-1038034 as not failing - Mark exhaustion tests as not failing It seems like they failed because without threads, we didn't sigaltstack(2) --- make-config.sh | 3 +-- src/runtime/x86-64-sunos-os.c | 27 ++++++++++++++++++++++----- tests/exhaust.impure.lisp | 4 +--- tests/traceroot.impure.lisp | 6 ++++-- 4 files changed, 28 insertions(+), 12 deletions(-) diff --git a/make-config.sh b/make-config.sh index a2a5e062e..42ad55ae8 100755 --- a/make-config.sh +++ b/make-config.sh @@ -403,8 +403,7 @@ then # If --fancy, enable threads on platforms where they can be built. case $sbcl_arch in x86|x86-64|ppc|arm64) - if ([ "$sbcl_os" = "sunos" ] && [ "$sbcl_arch" = "x86-64" ]) || \ - [ "$sbcl_os" = "dragonfly" ] + if [ "$sbcl_os" = "dragonfly" ] then echo "No threads on this platform." else diff --git a/src/runtime/x86-64-sunos-os.c b/src/runtime/x86-64-sunos-os.c index 04c905287..90a6d72f2 100644 --- a/src/runtime/x86-64-sunos-os.c +++ b/src/runtime/x86-64-sunos-os.c @@ -14,22 +14,39 @@ #include #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; +#ifdef LISP_FEATURE_SB_THREAD +#ifdef LISP_FEATURE_GCC_TLS + current_thread = thread; +#else + pthread_setspecific(specials,thread); +#endif +#endif + +#if defined(LISP_FEATURE_C_STACK_IS_CONTROL_STACK) + /* Signal handlers are run on the control stack, so if it is exhausted + * we had better use an alternate stack for whatever signal tells us + * we've exhausted it */ + stack_t sigstack; + sigstack.ss_sp = calc_altstack_base(thread); + sigstack.ss_flags = 0; + sigstack.ss_size = calc_altstack_size(thread); + if (sigaltstack(&sigstack,0) < 0) { + lose("Cannot sigaltstack: %s\n",strerror(errno)); + } +#endif + return 1; /* success */ } int arch_os_thread_cleanup(struct thread *thread) { diff --git a/tests/exhaust.impure.lisp b/tests/exhaust.impure.lisp index 478c5d92f..55266f7ba 100644 --- a/tests/exhaust.impure.lisp +++ b/tests/exhaust.impure.lisp @@ -31,7 +31,7 @@ (defvar *count* 100) ;;; Base-case: detecting exhaustion -(with-test (:name (:exhaust :basic) :broken-on (and :sunos :x86-64)) +(with-test (:name (:exhaust :basic)) (assert (eq :exhausted (handler-case (recurse) @@ -43,7 +43,6 @@ ;;; exhaustion checking after unwinding -- and that previous test ;;; didn't break it. (with-test (:name (:exhaust :non-local-control) - :broken-on (and :sunos :x86-64) :skipped-on :win32) (let ((exhaust-count 0) (recurse-count 0)) @@ -62,7 +61,6 @@ ;;; Check that we can safely use user-provided restarts to ;;; unwind. (with-test (:name (:exhaust :restarts) - :broken-on (and :sunos :x86-64) :skipped-on :win32) (let ((exhaust-count 0) (recurse-count 0)) diff --git a/tests/traceroot.impure.lisp b/tests/traceroot.impure.lisp index 070e8e9fc..4ff800a64 100644 --- a/tests/traceroot.impure.lisp +++ b/tests/traceroot.impure.lisp @@ -55,7 +55,8 @@ (:bindings (assert (typep (cdr path) '(cons (eql *fred*) (cons nil)))))))))) -(with-test (:name (sb-ext:search-roots :stack-indirect)) +(with-test (:name (sb-ext:search-roots :stack-indirect) + :fails-on :sunos) (let ((wp (make-weak-pointer (list 1 2 3 4)))) (test1 wp (weak-pointer-value wp) :stack) (test1 wp (weak-pointer-value wp) :tls) @@ -72,5 +73,6 @@ (assert (and (sb-int:singleton-p nodes) (string= "main thread" (caar nodes)))))) c)) -(with-test (:name (sb-ext:search-roots :stack-direct)) +(with-test (:name (sb-ext:search-roots :stack-direct) + :fails-on :sunos) (f0)) -- 2.23.0