1.0.4.31: remove *internal-error-context*
[sbcl.git] / src / runtime / x86-64-bsd-os.h
1 #ifndef _X86_64_BSD_OS_H
2 #define _X86_64_BSD_OS_H
3
4 #ifdef LISP_FEATURE_FREEBSD
5 #include <machine/fpu.h>
6 #endif
7
8 typedef register_t os_context_register_t;
9
10 static inline os_context_t *arch_os_get_context(void **void_context) {
11     return (os_context_t *) *void_context;
12 }
13
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])
24 #else
25 #error unsupported BSD variant
26 #endif
27
28 #if defined LISP_FEATURE_FREEBSD
29 #define RESTORE_FP_CONTROL_FROM_CONTEXT
30 void os_restore_fp_control(os_context_t *context);
31
32 /* FreeBSD does not setup si_code on XMM exception. */
33 #define X86_64_SIGFPE_FIXUP
34
35 static inline unsigned int *
36 arch_os_context_mxcsr_addr(os_context_t *context)
37 {
38     struct envxmm *ex = (struct envxmm *)(&context->uc_mcontext.mc_fpstate);
39     return &ex->en_mxcsr;
40 }
41 #endif
42
43 #endif /* _X86_64_BSD_OS_H */