]> gitweb.factorcode.org Git - factor.git/blob - vm/os-freebsd-x86.64.hpp
save the FP status out of the signal context and use it as part of the fp trap factor...
[factor.git] / vm / os-freebsd-x86.64.hpp
1 #include <ucontext.h>
2 #include <machine/fpu.h>
3
4 namespace factor
5 {
6
7 inline static void *ucontext_stack_pointer(void *uap)
8 {
9         ucontext_t *ucontext = (ucontext_t *)uap;
10         return (void *)ucontext->uc_mcontext.mc_rsp;
11 }
12
13 inline static unsigned int uap_fpu_status(void *uap)
14 {
15         ucontext_t *ucontext = (ucontext_t *)uap;
16         if (uap->uc_mcontext.mc_fpformat == _MC_FPFMT_XMM) {
17             struct savexmm *xmm = (struct savexmm *)(&ucontext->uc_mcontext.mc_fpstate);
18             return xmm->en_sw | xmm->en_mxcsr;
19         } else
20             return 0;
21 }
22
23 inline static void uap_clear_fpu_status(void *uap)
24 {
25         ucontext_t *ucontext = (ucontext_t *)uap;
26         if (uap->uc_mcontext.mc_fpformat == _MC_FPFMT_XMM) {
27             struct savexmm *xmm = (struct savexmm *)(&ucontext->uc_mcontext.mc_fpstate);
28             xmm->en_sw = 0;
29             xmm->en_mxcsr &= 0xffffffc0;
30         }
31 }
32
33 #define UAP_PROGRAM_COUNTER(ucontext) (((ucontext_t *)(ucontext))->uc_mcontext.mc_rip)
34
35 }