1 #ifndef _X86_64_BSD_OS_H
2 #define _X86_64_BSD_OS_H
4 #ifdef LISP_FEATURE_FREEBSD
5 #include <machine/fpu.h>
8 typedef register_t os_context_register_t;
10 static inline os_context_t *arch_os_get_context(void **void_context) {
11 return (os_context_t *) *void_context;
14 /* The different BSD variants have diverged in exactly where they
15 * store signal context information, but at least they tend to use the
16 * same stems to name the structure fields, so by using this macro we
17 * can share a fair amount of code between different variants. */
18 #if defined __FreeBSD__
19 #define CONTEXT_ADDR_FROM_STEM(stem) &context->uc_mcontext.mc_ ## stem
20 #elif defined(__OpenBSD__)
21 #define CONTEXT_ADDR_FROM_STEM(stem) &context->sc_ ## stem
22 #elif defined __NetBSD__
23 #define CONTEXT_ADDR_FROM_STEM(stem) &((context)->uc_mcontext.__gregs[_REG_ ## stem])
25 #error unsupported BSD variant
28 #if defined LISP_FEATURE_FREEBSD
29 #define RESTORE_FP_CONTROL_FROM_CONTEXT
30 void os_restore_fp_control(os_context_t *context);
32 /* FreeBSD does not setup si_code on XMM exception. */
33 #define X86_64_SIGFPE_FIXUP
35 static inline unsigned int *
36 arch_os_context_mxcsr_addr(os_context_t *context)
38 struct envxmm *ex = (struct envxmm *)(&context->uc_mcontext.mc_fpstate);
43 #endif /* _X86_64_BSD_OS_H */