PageRenderTime 43ms CodeModel.GetById 33ms app.highlight 8ms RepoModel.GetById 1ms app.codeStats 0ms

/vm/os-freebsd-x86.32.hpp

http://github.com/abeaumont/factor
C++ Header | 44 lines | 38 code | 6 blank | 0 comment | 10 complexity | 11666c2d33ac4143994f869bd7ca3415 MD5 | raw file
 1#include <ucontext.h>
 2#include <machine/npx.h>
 3
 4namespace factor
 5{
 6
 7inline static unsigned int uap_fpu_status(void *uap)
 8{
 9	ucontext_t *ucontext = (ucontext_t *)uap;
10	if (ucontext->uc_mcontext.mc_fpformat == _MC_FPFMT_387)
11	{
12		struct save87 *x87 = (struct save87 *)(&ucontext->uc_mcontext.mc_fpstate);
13		return x87->sv_env.en_sw;
14	}
15	else if (ucontext->uc_mcontext.mc_fpformat == _MC_FPFMT_XMM)
16	{
17		struct savexmm *xmm = (struct savexmm *)(&ucontext->uc_mcontext.mc_fpstate);
18		return xmm->sv_env.en_sw | xmm->sv_env.en_mxcsr;
19	}
20	else
21		return 0;
22}
23
24inline static void uap_clear_fpu_status(void *uap)
25{
26	ucontext_t *ucontext = (ucontext_t *)uap;
27	if (ucontext->uc_mcontext.mc_fpformat == _MC_FPFMT_387)
28	{
29		struct save87 *x87 = (struct save87 *)(&ucontext->uc_mcontext.mc_fpstate);
30		x87->sv_env.en_sw = 0;
31	}
32	else if (ucontext->uc_mcontext.mc_fpformat == _MC_FPFMT_XMM)
33	{
34		struct savexmm *xmm = (struct savexmm *)(&ucontext->uc_mcontext.mc_fpstate);
35		xmm->sv_env.en_sw = 0;
36		xmm->sv_env.en_mxcsr &= 0xffffffc0;
37	}
38}
39
40
41#define UAP_STACK_POINTER(ucontext) (((ucontext_t *)ucontext)->uc_mcontext.mc_esp)
42#define UAP_PROGRAM_COUNTER(ucontext) (((ucontext_t *)ucontext)->uc_mcontext.mc_eip)
43
44}