Raymond Toy pushed to branch issue-355-solaris-x86-fp-trap-handler at cmucl / cmucl
Commits:
-
959faae1
by Raymond Toy at 2024-08-29T20:47:11-07:00
3 changed files:
Changes:
... | ... | @@ -482,6 +482,13 @@ |
482 | 482 | (let* ((modes (sigcontext-floating-point-modes
|
483 | 483 | (alien:sap-alien scp (* unix:sigcontext)))))
|
484 | 484 | (format t "Current modes: ~32,'0b~%" modes)
|
485 | + (format t "sigcontext x87: ~32,'0b~%"
|
|
486 | + (sigcontext-floating-point-modes-x87
|
|
487 | + (alien:sap-alien scp (* unix:sigcontext))))
|
|
488 | + (format t "sigcontext sse2: ~32,'0b~%"
|
|
489 | + (sigcontext-floating-point-modes-sse2
|
|
490 | + (alien:sap-alien scp (* unix:sigcontext))))
|
|
491 | + |
|
485 | 492 | (multiple-value-bind (fop operands)
|
486 | 493 | (let ((sym (find-symbol "GET-FP-OPERANDS" "VM")))
|
487 | 494 | (if (fboundp sym)
|
... | ... | @@ -529,14 +536,19 @@ |
529 | 536 | (format t "new x87 modes: ~32,'0b~%" (vm::x87-floating-point-modes))
|
530 | 537 | (format t "new sse2 modes: ~32,'0b~%" (vm::sse2-floating-point-modes)))
|
531 | 538 | (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))))))
|
|
539 | + (x87-modes (sigcontext-floating-point-modes-x87
|
|
540 | + (alien:sap-alien scp (* unix:sigcontext))))
|
|
541 | + (sse2-modes (sigcontext-floating-point-modes-sse2
|
|
542 | + (alien:sap-alien scp (* unix:sigcontext)))))
|
|
543 | + (format t "Trap bit: ~D~%" trap-bit)
|
|
544 | + (format t "New sigcontext x87: ~32,'0b~%" (logandc2 x87-modes trap-bit))
|
|
545 | + (format t "New sigcontext sse2: ~32,'0b~%" (logandc2 sse2-modes trap-bit))
|
|
546 | + (%set-sigcontext-floating-point-modes-x87
|
|
547 | + (alien:sap-alien scp (* unix:sigcontext))
|
|
548 | + (logandc2 x87-modes trap-bit))
|
|
549 | + (%set-sigcontext-floating-point-modes-sse2
|
|
550 | + (alien:sap-alien scp (* unix:sigcontext))
|
|
551 | + (logandc2 sse2-modes trap-bit)))))))
|
|
540 | 552 | |
541 | 553 | (macrolet
|
542 | 554 | ((with-float-traps (name merge-traps docstring)
|
... | ... | @@ -378,6 +378,41 @@ |
378 | 378 | |
379 | 379 | (defsetf sigcontext-floating-point-modes %set-sigcontext-floating-point-modes)
|
380 | 380 | |
381 | +#+solaris
|
|
382 | +(progn
|
|
383 | +(defun sigcontext-floating-point-modes-x87 (scp)
|
|
384 | + (declare (type (alien (* unix:sigcontext)) scp))
|
|
385 | + (let ((fn (extern-alien "os_sigcontext_x87_modes"
|
|
386 | + (function (integer 32)
|
|
387 | + (* unix:sigcontext)))))
|
|
388 | + (alien-funcall fn scp)))
|
|
389 | + |
|
390 | +(defun %set-sigcontext-floating-point-modes-x87 (scp new-modes)
|
|
391 | + (declare (type (alien (* unix:sigcontext)) scp))
|
|
392 | + (let ((fn (extern-alien "os_set_sigcontext_x87_modes"
|
|
393 | + (function c-call:void
|
|
394 | + (* unix:sigcontext)
|
|
395 | + c-call:unsigned-int))))
|
|
396 | + (alien-funcall fn scp new-modes)
|
|
397 | + new-modes))
|
|
398 | +
|
|
399 | +(defun sigcontext-floating-point-modes-sse2 (scp)
|
|
400 | + (declare (type (alien (* unix:sigcontext)) scp))
|
|
401 | + (let ((fn (extern-alien "os_sigcontext_sse2_modes"
|
|
402 | + (function (integer 32)
|
|
403 | + (* unix:sigcontext)))))
|
|
404 | + (alien-funcall fn scp)))
|
|
405 | + |
|
406 | +(defun %set-sigcontext-floating-point-modes-sse2 (scp new-modes)
|
|
407 | + (declare (type (alien (* unix:sigcontext)) scp))
|
|
408 | + (let ((fn (extern-alien "os_set_sigcontext_sse2_modes"
|
|
409 | + (function c-call:void
|
|
410 | + (* unix:sigcontext)
|
|
411 | + c-call:unsigned-int))))
|
|
412 | + (alien-funcall fn scp new-modes)
|
|
413 | + new-modes))
|
|
414 | +)
|
|
415 | + |
|
381 | 416 | |
382 | 417 | ;;; EXTERN-ALIEN-NAME -- interface.
|
383 | 418 | ;;;
|
... | ... | @@ -615,9 +615,9 @@ os_sigcontext_fpu_modes(ucontext_t *scp) |
615 | 615 | |
616 | 616 | modes = ((cw & 0x3f) << 7) | (sw & 0x3f);
|
617 | 617 | |
618 | - DPRINTF(0, (stderr, "cw = 0x%04x\n", cw));
|
|
619 | - DPRINTF(0, (stderr, "sw = 0x%04x\n", sw));
|
|
620 | - DPRINTF(0, (stderr, "modes = 0x%08x\n", modes));
|
|
618 | + DPRINTF(0, (stderr, "os_sigcontext_fpu cw = 0x%04x\n", cw));
|
|
619 | + DPRINTF(0, (stderr, "os_sigcontext_fpu sw = 0x%04x\n", sw));
|
|
620 | + DPRINTF(0, (stderr, "os_sigcontext_fpu modes = 0x%08x\n", modes));
|
|
621 | 621 |
|
622 | 622 | #ifdef FEATURE_SSE2
|
623 | 623 | /*
|
... | ... | @@ -627,7 +627,7 @@ os_sigcontext_fpu_modes(ucontext_t *scp) |
627 | 627 | unsigned long mxcsr;
|
628 | 628 | |
629 | 629 | mxcsr = fpr->fp_reg_set.fpchip_state.mxcsr;
|
630 | - DPRINTF(0, (stderr, "SSE2 modes = %08lx\n", mxcsr));
|
|
630 | + DPRINTF(0, (stderr, "os_sigcontext_fpu SSE2 modes = %08lx\n", mxcsr));
|
|
631 | 631 | |
632 | 632 | modes |= mxcsr;
|
633 | 633 | }
|
... | ... | @@ -637,6 +637,65 @@ os_sigcontext_fpu_modes(ucontext_t *scp) |
637 | 637 | return modes;
|
638 | 638 | }
|
639 | 639 | |
640 | +unsigned int
|
|
641 | +os_sigcontext_x87_modes(ucontext_t *scp)
|
|
642 | +{
|
|
643 | + unsigned short cw, sw;
|
|
644 | + fpregset_t *fpr;
|
|
645 | + fpr = &scp->uc_mcontext.fpregs;
|
|
646 | + |
|
647 | + cw = fpr->fp_reg_set.fpchip_state.state[0] & 0xffff;
|
|
648 | + sw = fpr->fp_reg_set.fpchip_state.state[1] & 0xffff;
|
|
649 | + |
|
650 | + DPRINTF(1, (stderr, "os_sigcontext_x87 cw, sw = #x%04x #x%04x\n", cw, sw));
|
|
651 | + |
|
652 | + return (cw << 16) | sw;
|
|
653 | +}
|
|
654 | + |
|
655 | +void
|
|
656 | +os_set_sigcontext_x87_modes(ucontext_t *scp, unsigned int modes)
|
|
657 | +{
|
|
658 | + unsigned short cw, sw;
|
|
659 | + fpregset_t *fpr;
|
|
660 | + fpr = &scp->uc_mcontext.fpregs;
|
|
661 | + |
|
662 | + sw = modes & 0xffff;
|
|
663 | + cw = (modes >> 16) & 0xffff;
|
|
664 | +
|
|
665 | + fpr->fp_reg_set.fpchip_state.state[0] = cw;
|
|
666 | + fpr->fp_reg_set.fpchip_state.state[1] = sw;
|
|
667 | + |
|
668 | + DPRINTF(1, (stderr, "os_set_sigcontext_x87 modes = #x%08x\n", modes));
|
|
669 | + DPRINTF(1, (stderr, "os_set_sigcontext_x87 cw, sw = #x%04x #x%04x\n", cw, sw));
|
|
670 | +}
|
|
671 | + |
|
672 | + |
|
673 | +#ifdef FEATURE_SSE2
|
|
674 | +unsigned int
|
|
675 | +os_sigcontext_sse2_modes(ucontext_t *scp)
|
|
676 | +{
|
|
677 | + unsigned long mxcsr;
|
|
678 | + fpregset_t *fpr;
|
|
679 | + |
|
680 | + fpr = &scp->uc_mcontext.fpregs;
|
|
681 | + mxcsr = fpr->fp_reg_set.fpchip_state.mxcsr;
|
|
682 | + DPRINTF(1, (stderr, "os_sigcontext_sse2 mxcsr = #x%08lx\n", mxcsr));
|
|
683 | + |
|
684 | + return mxcsr;
|
|
685 | +}
|
|
686 | + |
|
687 | +void
|
|
688 | +os_set_sigcontext_sse2_modes(ucontext_t *scp, unsigned int modes)
|
|
689 | +{
|
|
690 | + fpregset_t *fpr;
|
|
691 | + fpr = &scp->uc_mcontext.fpregs;
|
|
692 | + |
|
693 | + fpr->fp_reg_set.fpchip_state.mxcsr = modes;
|
|
694 | + |
|
695 | + DPRINTF(1, (stderr, "os_set_sigcontext_sse2 mxcsr = #x%08x\n", modes));
|
|
696 | +}
|
|
697 | +#endif
|
|
698 | + |
|
640 | 699 | unsigned int
|
641 | 700 | os_set_sigcontext_fpu_modes(ucontext_t *scp, uint32_t modes)
|
642 | 701 | {
|