]> gitweb.factorcode.org Git - factor.git/blob - vm/os-linux-ppc.64.hpp
VM: Refactor os-* to Factor style
[factor.git] / vm / os-linux-ppc.64.hpp
1 #include <ucontext.h>
2
3 namespace factor {
4
5 #define FRAME_RETURN_ADDRESS(frame, vm) \
6   *((void**)(vm->frame_successor(frame) + 1) + 2)
7 #define UAP_STACK_POINTER(ucontext) \
8   ((ucontext_t*)ucontext)->uc_mcontext.gp_regs[1]
9 #define UAP_PROGRAM_COUNTER(ucontext) \
10   (((ucontext_t*)ucontext)->uc_mcontext.gp_regs[32])
11 #define UAP_SET_TOC_POINTER(uap, ptr) (void) 0
12
13 #define FACTOR_PPC_TOC 1
14
15 #define CODE_TO_FUNCTION_POINTER(code) \
16   void* desc[3];                       \
17   code = fill_function_descriptor(desc, code)
18
19 #define CODE_TO_FUNCTION_POINTER_CALLBACK(vm, code)     \
20   code = fill_function_descriptor(new void* [3], code); \
21   vm->function_descriptors.push_back((void**)code)
22
23 #define FUNCTION_CODE_POINTER(ptr) (function_descriptor_field((void*)ptr, 0))
24
25 #define FUNCTION_TOC_POINTER(ptr) (function_descriptor_field((void*)ptr, 1))
26
27 #define UAP_STACK_POINTER_TYPE unsigned long
28
29 inline static unsigned int uap_fpu_status(void* uap) {
30   union {
31     double as_double;
32     unsigned int as_uint[2];
33   } tmp;
34   tmp.as_double = ((ucontext_t*)uap)->uc_mcontext.fp_regs[32];
35   return tmp.as_uint[1];
36 }
37
38 inline static void uap_clear_fpu_status(void* uap) {
39   union {
40     double as_double;
41     unsigned int as_uint[2];
42   } tmp;
43   tmp.as_double = ((ucontext_t*)uap)->uc_mcontext.fp_regs[32];
44   tmp.as_uint[1] &= 0x0007f8ff;
45   ((ucontext_t*)uap)->uc_mcontext.fp_regs[32] = tmp.as_double;
46 }
47
48 }