Raymond Toy pushed to branch issue-355-solaris-x86-fp-trap-handler at cmucl / cmucl

Commits:

2 changed files:

Changes:

  • src/code/float-trap.lisp
    ... ... @@ -481,6 +481,7 @@
    481 481
     	   (type system-area-pointer scp))
    
    482 482
       (let* ((modes (sigcontext-floating-point-modes
    
    483 483
     		 (alien:sap-alien scp (* unix:sigcontext)))))
    
    484
    +    (format t "Current modes:         ~32,'0b~%" modes)
    
    484 485
         (multiple-value-bind (fop operands)
    
    485 486
     	(let ((sym (find-symbol "GET-FP-OPERANDS" "VM")))
    
    486 487
     	  (if (fboundp sym)
    
    ... ... @@ -503,6 +504,7 @@
    503 504
     	;;
    
    504 505
     	;; Clear out the status for any enabled traps.  If we don't
    
    505 506
     	;; then when we return, the exception gets signaled again.
    
    507
    +	#+nil
    
    506 508
     	(let* ((trap-bit (third (assoc code +fpe-code-info-alist+)))
    
    507 509
     	       (current-x87-modes (vm::x87-floating-point-modes))
    
    508 510
     	       (current-sse2-modes (vm::sse2-floating-point-modes))
    
    ... ... @@ -525,7 +527,16 @@
    525 527
     	    (setf (vm::x87-floating-point-modes) new-x87-modes))
    
    526 528
     
    
    527 529
     	  (format t "new x87 modes:         ~32,'0b~%" (vm::x87-floating-point-modes))
    
    528
    -	  (format t "new sse2 modes:        ~32,'0b~%" (vm::sse2-floating-point-modes)))))))
    
    530
    +	  (format t "new sse2 modes:        ~32,'0b~%" (vm::sse2-floating-point-modes)))
    
    531
    +	(let* ((trap-bit (third (assoc code +fpe-code-info-alist+)))
    
    532
    +	       (new-modes
    
    533
    +		(dpb (logandc2 (ldb float-exceptions-byte modes)
    
    534
    +			       trap-bit)
    
    535
    +		     float-exceptions-byte modes)))
    
    536
    +	  (format t "New modes:             ~32,'0b~%" new-modes)
    
    537
    +	  (setf (sigcontext-floating-point-modes)
    
    538
    +		(alien:sap-alien scp (* unix:sigcontext))
    
    539
    +		new-modes))))))
    
    529 540
     
    
    530 541
     (macrolet
    
    531 542
         ((with-float-traps (name merge-traps docstring)
    

  • src/lisp/solaris-os.c
    ... ... @@ -637,6 +637,45 @@ os_sigcontext_fpu_modes(ucontext_t *scp)
    637 637
         return modes;
    
    638 638
     }
    
    639 639
     
    
    640
    +unsigned int
    
    641
    +os_set_sigcontext_fpu_modes(ucontext_t *scp, uint32_t modes)
    
    642
    +{
    
    643
    +    unsigned short cw, sw;
    
    644
    +    fpregset_t *fpr;
    
    645
    +    unsigned int state;
    
    646
    +        
    
    647
    +    fpr = &scp->uc_mcontext.fpregs;
    
    648
    +
    
    649
    +    cw = modes & 0x3f;
    
    650
    +    sw = (modes >> 7) &0x3f;
    
    651
    +
    
    652
    +    DPRINTF(1, (stderr, "modes = 0x%08x\n", modes));
    
    653
    +    DPRINTF(1, (stderr, "cw = 0x%04x\n", cw));
    
    654
    +    DPRINTF(1, (stderr, "sw = 0x%04x\n", sw));
    
    655
    +
    
    656
    +    fpr->fp_reg_set.fpchip_state.state[0] = cw;
    
    657
    +    fpr->fp_reg_set.fpchip_state.state[1] = sw;
    
    658
    +    
    
    659
    +#ifdef FEATURE_SSE2
    
    660
    +    /*
    
    661
    +     * Add in the SSE2 part, if we're running the sse2 core.
    
    662
    +     */
    
    663
    +    if (fpu_mode == SSE2) {
    
    664
    +	unsigned long mxcsr = modes & 0xffff;
    
    665
    +
    
    666
    +        DPRINTF(1, (stderr, "SSE2 modes = %08lx\n", mxcsr));
    
    667
    +        fpr->fp_reg_set.fpchip_state.mxcsr = mxcsr;
    
    668
    +
    
    669
    +	modes |= mxcsr;
    
    670
    +    }
    
    671
    +#endif
    
    672
    +
    
    673
    +    modes ^= (0x3f << 7);
    
    674
    +    return modes;
    
    675
    +}
    
    676
    +
    
    677
    +
    
    678
    +
    
    640 679
     boolean
    
    641 680
     os_support_sse2()
    
    642 681
     {