factor/vm/os-linux-ppc.64.hpp

44 lines
1.2 KiB
C++
Raw Permalink Normal View History

2011-05-20 18:11:50 -04:00
#include <ucontext.h>
2013-05-11 22:24:31 -04:00
namespace factor {
2011-05-20 18:11:50 -04:00
2013-05-11 22:24:31 -04:00
#define UAP_STACK_POINTER(ucontext) \
((ucontext_t*)ucontext)->uc_mcontext.gp_regs[1]
#define UAP_PROGRAM_COUNTER(ucontext) \
(((ucontext_t*)ucontext)->uc_mcontext.gp_regs[32])
2011-05-20 18:11:50 -04:00
#define FACTOR_PPC_TOC 1
#define CODE_TO_FUNCTION_POINTER(code) \
2013-05-11 22:24:31 -04:00
void* desc[3]; \
code = fill_function_descriptor(desc, code)
2011-05-20 18:11:50 -04:00
2013-05-11 22:24:31 -04:00
#define CODE_TO_FUNCTION_POINTER_CALLBACK(vm, code) \
code = fill_function_descriptor(new void* [3], code); \
vm->function_descriptors.push_back((void**)code)
2011-05-20 18:11:50 -04:00
2013-05-11 22:24:31 -04:00
#define FUNCTION_CODE_POINTER(ptr) (function_descriptor_field((void*)ptr, 0))
2011-05-20 18:11:50 -04:00
2013-05-11 22:24:31 -04:00
#define FUNCTION_TOC_POINTER(ptr) (function_descriptor_field((void*)ptr, 1))
2011-05-20 18:11:50 -04:00
2013-05-11 22:24:31 -04:00
inline static unsigned int uap_fpu_status(void* uap) {
union {
double as_double;
unsigned int as_uint[2];
} tmp;
tmp.as_double = ((ucontext_t*)uap)->uc_mcontext.fp_regs[32];
return tmp.as_uint[1];
2011-05-20 18:11:50 -04:00
}
2013-05-11 22:24:31 -04:00
inline static void uap_clear_fpu_status(void* uap) {
union {
double as_double;
unsigned int as_uint[2];
} tmp;
tmp.as_double = ((ucontext_t*)uap)->uc_mcontext.fp_regs[32];
tmp.as_uint[1] &= 0x0007f8ff;
((ucontext_t*)uap)->uc_mcontext.fp_regs[32] = tmp.as_double;
2011-05-20 18:11:50 -04:00
}
}