Changeset 5017
- Timestamp:
- Aug 23, 2006, 9:59:35 PM (18 years ago)
- File:
-
- 1 edited
-
trunk/ccl/lisp-kernel/x86-exceptions.c (modified) (16 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ccl/lisp-kernel/x86-exceptions.c
r5007 r5017 571 571 572 572 573 #if def FREEBSD573 #if defined(FREEBSD) || defined(DARWIN) 574 574 static 575 575 char mxcsr_bit_to_fpe_code[] = { … … 583 583 584 584 void 585 freebsd_decode_vector_fp_exception(siginfo_t *info, ExceptionInformation *xp)585 decode_vector_fp_exception(siginfo_t *info, uint32_t mxcsr) 586 586 { 587 587 /* If the exception appears to be an XMM FP exception, try to 588 588 determine what it was by looking at bits in the mxcsr. 589 589 */ 590 int xbit, maskbit; 591 592 for (xbit = 0, maskbit = MXCSR_IM_BIT; xbit < 6; xbit++, maskbit++) { 593 if ((mxcsr & (1 << xbit)) && 594 !(mxcsr & (1 << maskbit))) { 595 info->si_code = mxcsr_bit_to_fpe_code[xbit]; 596 return; 597 } 598 } 599 } 600 601 #ifdef FREEBSD 602 void 603 freebsd_decode_vector_fp_exception(siginfo_t *info, ExceptionInformation *xp) 604 { 590 605 if (info->si_code == 0) { 591 606 struct savefpu *fpu = (struct savefpu *) &(xp->uc_mcontext.mc_fpstate); 592 607 uint32_t mxcsr = fpu->sv_env.en_mxcsr; 593 int xbit, maskbit; 594 595 for (xbit = 0, maskbit = MXCSR_IM_BIT; xbit < 6; xbit++, maskbit++) { 596 if ((mxcsr & (1 << xbit)) && 597 !(mxcsr & (1 << maskbit))) { 598 info->si_code = mxcsr_bit_to_fpe_code[xbit]; 599 return; 600 } 601 } 602 } 603 } 608 609 decode_vector_fp_exception(info, mxcsr); 610 } 611 } 612 #endif 613 614 #ifdef DARWIN 615 void 616 darwin_decode_vector_fp_exception(siginfo_t *info, ExceptionInformation *xp) 617 { 618 if (info->si_code == EXC_I386_SSEEXTERR) { 619 uint32_t mxcsr = UC_MCONTEXT(xp)->fs.fpu_mxcsr; 620 621 decode_vector_fp_exception(info, mxcsr); 622 } 623 } 624 625 #endif 626 604 627 #endif 605 628 … … 691 714 freebsd_decode_vector_fp_exception(info,context); 692 715 #endif 716 #ifdef DARWIN 717 /* Same general problem with Darwin as of 8.7.2 */ 718 darwin_decode_vector_fp_exception(info,context); 719 #endif 720 693 721 return handle_floating_point_exception(tcr, context, info); 694 722 … … 830 858 #endif 831 859 860 #ifdef DARWIN 861 LispObj * 862 copy_darwin_mcontext(struct mcontext64 *context, 863 LispObj *current, 864 struct mcontext64 **out) 865 { 866 struct mcontext64 *dest = ((struct mcontext64 *)current)-1; 867 dest = (struct mcontext64 *) (((LispObj)dest) & ~15); 868 869 *dest = *context; 870 *out = dest; 871 return (LispObj *)dest; 872 } 873 #endif 874 832 875 LispObj * 833 876 copy_siginfo(siginfo_t *info, LispObj *current) 834 877 { 835 878 siginfo_t *dest = ((siginfo_t *)current) - 1; 879 dest = (siginfo_t *) (((LispObj)dest)&~15); 836 880 *dest = *info; 837 881 return (LispObj *)dest; … … 954 998 altstack_interrupt_handler (int signum, siginfo_t *info, ExceptionInformation *context) 955 999 { 1000 #ifdef DARWIN_GS_HACK 1001 Boolean gs_was_tcr = ensure_gs_pthread(); 1002 #endif 956 1003 TCR *tcr = get_interrupt_tcr(false); 957 1004 LispObj *foreign_rsp = find_foreign_rsp(xpGPR(context,Isp), tcr->cs_area, tcr); … … 961 1008 void *fpregs = NULL; 962 1009 #endif 1010 #ifdef DARWIN 1011 struct mcontext64 *mcontextp = NULL; 1012 #endif 963 1013 siginfo_t *info_copy = NULL; 964 1014 ExceptionInformation *xp = NULL; … … 967 1017 #ifdef LINUX 968 1018 foreign_rsp = copy_fpregs(context, foreign_rsp, &fpregs); 1019 #endif 1020 #ifdef DARWIN 1021 foreign_rsp = copy_darwin_mcontext(UC_MCONTEXT(context), foreign_rsp, &mcontextp); 969 1022 #endif 970 1023 foreign_rsp = copy_siginfo(info, foreign_rsp); … … 972 1025 foreign_rsp = copy_ucontext(context, foreign_rsp, fpregs); 973 1026 xp = (ExceptionInformation *)foreign_rsp; 1027 #ifdef DARWIN 1028 UC_MCONTEXT(xp) = mcontextp; 1029 #endif 974 1030 *--foreign_rsp = (LispObj)__builtin_return_address(0); 1031 #ifdef DARWIN_GS_HACK 1032 if (gs_was_tcr) { 1033 set_gs_address(tcr); 1034 } 1035 #endif 975 1036 switch_to_foreign_stack(foreign_rsp,interrupt_handler,signum,info_copy,xp); 976 1037 } … … 997 1058 install_pmcl_exception_handlers() 998 1059 { 999 1060 #ifndef DARWIN 1000 1061 install_signal_handler(SIGILL, altstack_signal_handler); 1001 1062 … … 1003 1064 install_signal_handler(SIGSEGV,altstack_signal_handler); 1004 1065 install_signal_handler(SIGFPE, altstack_signal_handler); 1005 1066 #endif 1006 1067 1007 1068 install_signal_handler(SIGNAL_FOR_PROCESS_INTERRUPT, … … 1014 1075 altstack_suspend_resume_handler(int signum, siginfo_t *info, ExceptionInformation *context) 1015 1076 { 1077 #ifdef DARWIN_GS_HACK 1078 Boolean gs_was_tcr = ensure_gs_pthread(); 1079 #endif 1016 1080 TCR* tcr = get_tcr(true); 1017 1081 LispObj *foreign_rsp = find_foreign_rsp(xpGPR(context,Isp), tcr->cs_area, tcr); … … 1021 1085 void *fpregs = NULL; 1022 1086 #endif 1087 #ifdef DARWIN 1088 struct mcontext64 *mcontextp = NULL; 1089 #endif 1090 1023 1091 siginfo_t *info_copy = NULL; 1024 1092 ExceptionInformation *xp = NULL; … … 1027 1095 #ifdef LINUX 1028 1096 foreign_rsp = copy_fpregs(context, foreign_rsp, &fpregs); 1097 #endif 1098 #ifdef DARWIN 1099 foreign_rsp = copy_darwin_mcontext(UC_MCONTEXT(context), foreign_rsp, &mcontextp); 1029 1100 #endif 1030 1101 foreign_rsp = copy_siginfo(info, foreign_rsp); … … 1032 1103 foreign_rsp = copy_ucontext(context, foreign_rsp, fpregs); 1033 1104 xp = (ExceptionInformation *)foreign_rsp; 1105 #ifdef DARWIN 1106 UC_MCONTEXT(xp) = mcontextp; 1107 #endif 1034 1108 *--foreign_rsp = (LispObj)__builtin_return_address(0); 1109 #ifdef DARWIN_GS_HACK 1110 if (gs_was_tcr) { 1111 set_gs_address(tcr); 1112 } 1113 #endif 1035 1114 switch_to_foreign_stack(foreign_rsp,suspend_resume_handler,signum,info_copy,xp); 1036 1115 } … … 1573 1652 /* Set the thread's FP state from the pseudosigcontext */ 1574 1653 kret = thread_set_state(thread, 1575 x86_FLOAT_STATE ,1654 x86_FLOAT_STATE64, 1576 1655 (thread_state_t)&(mc->fs), 1577 x86_FLOAT_STATE _COUNT);1656 x86_FLOAT_STATE64_COUNT); 1578 1657 1579 1658 MACH_CHECK_ERROR("setting thread FP state", kret); … … 1673 1752 bcopy(ts,&(mc->ss),sizeof(*ts)); 1674 1753 1675 thread_state_count = x86_FLOAT_STATE _COUNT;1754 thread_state_count = x86_FLOAT_STATE64_COUNT; 1676 1755 thread_get_state(thread, 1677 x86_FLOAT_STATE ,1756 x86_FLOAT_STATE64, 1678 1757 (thread_state_t)&(mc->fs), 1679 1758 &thread_state_count);
Note:
See TracChangeset
for help on using the changeset viewer.
