]> gitweb.factorcode.org Git - factor.git/blob - vm/os-linux-arm.64.hpp
alien.c-types: not necessary to import `short` differently anymore
[factor.git] / vm / os-linux-arm.64.hpp
1 #include <ucontext.h>
2 #include <asm/unistd.h>
3 #include <sys/syscall.h>
4
5 namespace factor {
6
7 #define CALLSTACK_BOTTOM(ctx) \
8   (ctx->callstack_seg->end - sizeof(cell) * 5)
9
10 static const fixnum xt_tail_pic_offset = 4 + 1;
11
12 #define UAP_STACK_POINTER(ucontext) \
13   (((ucontext_t*)ucontext)->uc_mcontext.sp)
14 #define UAP_PROGRAM_COUNTER(ucontext) \
15   (((ucontext_t*)ucontext)->uc_mcontext.pc)
16
17 // #define CODE_TO_FUNCTION_POINTER(code) (void)0
18 // #define CODE_TO_FUNCTION_POINTER_CALLBACK(vm, code) (void)0
19 // #define FUNCTION_CODE_POINTER(ptr) ptr
20 // #define FUNCTION_TOC_POINTER(ptr) ptr
21
22 inline static unsigned int uap_fpu_status(void* uap) {
23   // ucontext_t* ucontext = (ucontext_t*)uap;
24   // return ucontext->uc_mcontext.fpregs->swd |
25   //        ucontext->uc_mcontext.fpregs->mxcsr;
26   return 0;
27 }
28
29 inline static void uap_clear_fpu_status(void* uap) {
30   // ucontext_t* ucontext = (ucontext_t*)uap;
31   // ucontext->uc_mcontext.fpregs->swd = 0;
32   // ucontext->uc_mcontext.fpregs->mxcsr &= 0xffffffc0;
33 }
34
35 inline static unsigned int fpu_status(unsigned int status) {
36   unsigned int r = 0;
37
38   if (status & 0x01)
39     r |= FP_TRAP_INVALID_OPERATION;
40   if (status & 0x04)
41     r |= FP_TRAP_ZERO_DIVIDE;
42   if (status & 0x08)
43     r |= FP_TRAP_OVERFLOW;
44   if (status & 0x10)
45     r |= FP_TRAP_UNDERFLOW;
46   if (status & 0x20)
47     r |= FP_TRAP_INEXACT;
48
49   return r;
50 }
51   // FP_TRAP_INVALID_OPERATION = 1 << 0,
52   // FP_TRAP_OVERFLOW = 1 << 1,
53   // FP_TRAP_UNDERFLOW = 1 << 2,
54   // FP_TRAP_ZERO_DIVIDE = 1 << 3,
55   // FP_TRAP_INEXACT = 1 << 4,
56
57
58 // #define UAP_STACK_POINTER(ucontext) \
59 //   (((ucontext_t*)ucontext)->uc_mcontext.regs[15])
60 // #define UAP_PROGRAM_COUNTER(ucontext) \
61 //   (((ucontext_t*)ucontext)->uc_mcontext.regs[16])
62
63 #define CODE_TO_FUNCTION_POINTER(code) (void)0
64 #define CODE_TO_FUNCTION_POINTER_CALLBACK(vm, code) (void)0
65 #define FUNCTION_CODE_POINTER(ptr) ptr
66 #define FUNCTION_TOC_POINTER(ptr) ptr
67
68 // Must match the stack-frame-size constant in
69 // bootstrap/assembler/x86.64.unix.factor
70 static const unsigned JIT_FRAME_SIZE = 32;
71
72
73 static const unsigned char call_opcode = 0xe8;
74 static const unsigned char jmp_opcode = 0xe9;
75
76
77 static const unsigned SIGNAL_HANDLER_STACK_FRAME_SIZE = 192;
78
79 }