Revert "lists: Add list literal doc example."
[factor.git] / vm / os-macosx-x86.64.hpp
blobb7ab0b5983c64447d5076da6038ff8cb14d1dd3c
1 #include <sys/ucontext.h>
3 namespace factor {
5 // Fault handler information. MacOSX version.
6 // Copyright (C) 1993-1999, 2002-2003 Bruno Haible <clisp.org at bruno>
7 // Copyright (C) 2003 Paolo Bonzini <gnu.org at bonzini>
9 // Used under BSD license with permission from Paolo Bonzini and Bruno Haible,
10 // 2005-03-10:
12 // http://sourceforge.net/mailarchive/message.php?msg_name=200503102200.32002.bruno%40clisp.org
14 // Modified for Factor by Slava Pestov and Daniel Ehrenberg
15 #define MACH_EXC_STATE_TYPE x86_exception_state64_t
16 #define MACH_EXC_STATE_FLAVOR x86_EXCEPTION_STATE64
17 #define MACH_EXC_STATE_COUNT x86_EXCEPTION_STATE64_COUNT
19 #define MACH_EXC_INTEGER_DIV EXC_I386_DIV
21 #define MACH_THREAD_STATE_TYPE x86_thread_state64_t
22 #define MACH_THREAD_STATE_FLAVOR x86_THREAD_STATE64
23 #define MACH_THREAD_STATE_COUNT MACHINE_THREAD_STATE_COUNT
25 #define MACH_FLOAT_STATE_TYPE x86_float_state64_t
26 #define MACH_FLOAT_STATE_FLAVOR x86_FLOAT_STATE64
27 #define MACH_FLOAT_STATE_COUNT x86_FLOAT_STATE64_COUNT
29 #if __DARWIN_UNIX03
30 #define MACH_EXC_STATE_FAULT(exc_state) (exc_state)->__faultvaddr
31 #define MACH_STACK_POINTER(thr_state) (thr_state)->__rsp
32 #define MACH_PROGRAM_COUNTER(thr_state) (thr_state)->__rip
33 #define UAP_SS(ucontext) &(((ucontext_t*)(ucontext))->uc_mcontext->__ss)
34 #define UAP_FS(ucontext) &(((ucontext_t*)(ucontext))->uc_mcontext->__fs)
36 #define MXCSR(float_state) (float_state)->__fpu_mxcsr
37 #define X87SW(float_state) (float_state)->__fpu_fsw
38 #else
39 #define MACH_EXC_STATE_FAULT(exc_state) (exc_state)->faultvaddr
40 #define MACH_STACK_POINTER(thr_state) (thr_state)->rsp
41 #define MACH_PROGRAM_COUNTER(thr_state) (thr_state)->rip
42 #define UAP_SS(ucontext) &(((ucontext_t*)(ucontext))->uc_mcontext->ss)
43 #define UAP_FS(ucontext) &(((ucontext_t*)(ucontext))->uc_mcontext->fs)
45 #define MXCSR(float_state) (float_state)->fpu_mxcsr
46 #define X87SW(float_state) (float_state)->fpu_fsw
47 #endif
49 #define UAP_PROGRAM_COUNTER(ucontext) MACH_PROGRAM_COUNTER(UAP_SS(ucontext))
51 inline static unsigned int mach_fpu_status(x86_float_state64_t* float_state) {
52 unsigned short x87sw;
53 memcpy(&x87sw, &X87SW(float_state), sizeof(x87sw));
54 return MXCSR(float_state) | x87sw;
57 inline static unsigned int uap_fpu_status(void* uap) {
58 return mach_fpu_status(UAP_FS(uap));
61 inline static void mach_clear_fpu_status(x86_float_state64_t* float_state) {
62 MXCSR(float_state) &= 0xffffffc0;
63 memset(&X87SW(float_state), 0, sizeof(X87SW(float_state)));
66 inline static void uap_clear_fpu_status(void* uap) {
67 mach_clear_fpu_status(UAP_FS(uap));
70 // Must match the stack-frame-size constant in
71 // basis/bootstrap/assembler/x86.64.unix.factor
72 static const unsigned JIT_FRAME_SIZE = 32;