Newly created threads have all the traps cleared, while on other
platforms they are inherited from the parent thread.
(arguments (if (listp arguments)
arguments
(list arguments)))
+ #!+win32
+ (fp-modes (dpb 0 sb!vm::float-sticky-bits ;; clear accrued bits
+ (sb!vm:floating-point-modes)))
(initial-function
(named-lambda initial-thread-function ()
+ ;; Win32 doesn't inherit parent thread's FP modes,
+ ;; while it seems to happen everywhere else
+ #!+win32
+ (setf (sb!vm:floating-point-modes) fp-modes)
;; As it is, this lambda must not cons until we are
;; ready to run GC. Be very careful.
(initial-thread-function-trampoline
(sb-thread:make-thread
(lambda ()
(alien-funcall (extern-alien "alloca_test" (function void)))))))
+
+(with-test (:name :fp-mode-inheritance-threads)
+ (flet ((test ()
+ (let ((thread-fp-mode)
+ (fp-mode (dpb 0 sb-vm::float-sticky-bits (sb-vm:floating-point-modes))))
+ (sb-thread:join-thread
+ (sb-thread:make-thread
+ (lambda ()
+ (setf thread-fp-mode
+ (dpb 0 sb-vm::float-sticky-bits (sb-vm:floating-point-modes))))))
+ (assert (= fp-mode thread-fp-mode)))))
+ (test)
+ (sb-int:with-float-traps-masked (:divide-by-zero)
+ (test))
+ (setf (sb-vm:floating-point-modes)
+ (dpb sb-vm:float-divide-by-zero-trap-bit
+ sb-vm::float-traps-byte
+ (sb-vm:floating-point-modes)))
+ (test)))