Fix C compiler warning.
[sbcl.git] / src / runtime / x86-64-bsd-os.h
blob4bff08baa4c51f813364ff5047fa9342510d689f
1 #ifndef _X86_64_BSD_OS_H
2 #define _X86_64_BSD_OS_H
4 #ifdef LISP_FEATURE_FREEBSD
5 #include <machine/fpu.h>
6 #endif
8 #ifdef LISP_FEATURE_DRAGONFLY
9 #include <machine/npx.h>
10 #endif
12 typedef register_t os_context_register_t;
14 static inline os_context_t *arch_os_get_context(void **void_context)
16 return (os_context_t *) *void_context;
19 /* The different BSD variants have diverged in exactly where they
20 * store signal context information, but at least they tend to use the
21 * same stems to name the structure fields, so by using this macro we
22 * can share a fair amount of code between different variants. */
23 #if defined LISP_FEATURE_FREEBSD || defined(__DragonFly__)
24 #define CONTEXT_ADDR_FROM_STEM(stem) &context->uc_mcontext.mc_ ## stem
25 #elif defined(__OpenBSD__)
26 #define CONTEXT_ADDR_FROM_STEM(stem) &context->sc_ ## stem
27 #elif defined __NetBSD__
28 #define CONTEXT_ADDR_FROM_STEM(stem) &((context)->uc_mcontext.__gregs[_REG_ ## stem])
29 #else
30 #error unsupported BSD variant
31 #endif
33 #if defined LISP_FEATURE_DRAGONFLY
34 /* I am not sure if following definition is needed after this:
35 http://gitweb.dragonflybsd.org/dragonfly.git/commit/e6e019a801e99ba7888ed009c5c3b3c7b047af1e
37 But It will not harm if I leave it here. */
38 #define RESTORE_FP_CONTROL_FROM_CONTEXT
39 void os_restore_fp_control(os_context_t *context);
41 #define X86_64_SIGFPE_FIXUP
43 static inline unsigned int *
44 arch_os_context_mxcsr_addr(os_context_t *context)
46 struct envxmm *ex = (struct envxmm *)(&context->uc_mcontext.mc_fpregs);
47 return &ex->en_mxcsr;
49 #endif
51 #if defined LISP_FEATURE_FREEBSD
52 #define RESTORE_FP_CONTROL_FROM_CONTEXT
53 void os_restore_fp_control(os_context_t *context);
55 /* FreeBSD does not setup si_code on XMM exception. */
56 #define X86_64_SIGFPE_FIXUP
58 static inline unsigned int *
59 arch_os_context_mxcsr_addr(os_context_t *context)
61 struct envxmm *ex = (struct envxmm *)(&context->uc_mcontext.mc_fpstate);
62 return &ex->en_mxcsr;
64 #endif
66 #if defined LISP_FEATURE_OPENBSD
67 #define RESTORE_FP_CONTROL_FROM_CONTEXT
68 void os_restore_fp_control(os_context_t *context);
69 #endif
71 #endif /* _X86_64_BSD_OS_H */