5 // glibc lies about the contents of the fpstate the kernel provides, hiding the
9 // Regular FPU environment
15 unsigned long dataoff;
16 unsigned long datasel;
18 unsigned short status;
19 unsigned short magic; // 0xffff = regular FPU data only
21 // FXSR FPU environment
22 unsigned long _fxsr_env[6]; // FXSR FPU env is ignored
24 unsigned long reserved;
25 struct _fpxreg _fxsr_st[8]; // FXSR FPU reg data is ignored
26 struct _xmmreg _xmm[8];
27 unsigned long padding[56];
30 #define X86_FXSR_MAGIC 0x0000
32 inline static unsigned int uap_fpu_status(void* uap) {
33 ucontext_t* ucontext = (ucontext_t*)uap;
34 struct _fpstate* fpregs = (struct _fpstate*)ucontext->uc_mcontext.fpregs;
35 if (fpregs->magic == X86_FXSR_MAGIC)
36 return fpregs->sw | fpregs->mxcsr;
41 inline static void uap_clear_fpu_status(void* uap) {
42 ucontext_t* ucontext = (ucontext_t*)uap;
43 struct _fpstate* fpregs = (struct _fpstate*)ucontext->uc_mcontext.fpregs;
45 if (fpregs->magic == X86_FXSR_MAGIC)
46 fpregs->mxcsr &= 0xffffffc0;
49 #define UAP_STACK_POINTER(ucontext) \
50 (((ucontext_t*)ucontext)->uc_mcontext.gregs[7])
51 #define UAP_PROGRAM_COUNTER(ucontext) \
52 (((ucontext_t*)ucontext)->uc_mcontext.gregs[14])
54 #define CODE_TO_FUNCTION_POINTER(code) (void)0
55 #define CODE_TO_FUNCTION_POINTER_CALLBACK(vm, code) (void)0
56 #define FUNCTION_CODE_POINTER(ptr) ptr
57 #define FUNCTION_TOC_POINTER(ptr) ptr