diff --git a/IexMath/IexMathFpu.cpp b/IexMath/IexMathFpu.cpp index bff948c..c45737f 100644 --- a/IexMath/IexMathFpu.cpp +++ b/IexMath/IexMathFpu.cpp @@ -264,6 +264,18 @@ restoreControlRegs (const ucontext_t & ucon, bool clearExceptions) setMxcsr (ucon.uc_mcontext.fpregs->mxcsr, clearExceptions); } +#elif defined(__FreeBSD_kernel__) + +#include + +inline void +restoreControlRegs (const ucontext_t & ucon, bool clearExceptions) +{ + struct envxmm *ex = (struct envxmm *)(ucon.uc_mcontext.mc_fpstate); + setCw ((ex->en_cw & cwRestoreMask) | cwRestoreVal); + setMxcsr (ex->en_mxcsr, clearExceptions); +} + #else // @@ -463,8 +475,9 @@ setFpExceptionHandler (FpExceptionHandler handler) sigemptyset (&action.sa_mask); action.sa_flags = SA_SIGINFO | SA_NOMASK; action.sa_sigaction = (void (*) (int, siginfo_t *, void *)) catchSigFpe; +#ifndef __FreeBSD_kernel__ action.sa_restorer = 0; - +#endif sigaction (SIGFPE, &action, 0); }