#include <asm/sigcontext.h>
#endif
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+#ifdef HAVE_SIGNAL_H
+#include <signal.h>
+#endif
+
#if defined(__i386__)
#if defined(__FreeBSD__) || defined(__APPLE__)
#define UCONTEXT_REG_EDI(ctx) (((ucontext_t*)(ctx))->uc_mcontext.__gregs [_REG_EDI])
#define UCONTEXT_REG_EIP(ctx) (((ucontext_t*)(ctx))->uc_mcontext.__gregs [_REG_EIP])
#elif defined(__OpenBSD__)
- #define UCONTEXT_REG_EAX(ctx) ((ctx)->sc_eax)
- #define UCONTEXT_REG_EBX(ctx) ((ctx)->sc_ebx)
- #define UCONTEXT_REG_ECX(ctx) ((ctx)->sc_ecx)
- #define UCONTEXT_REG_EDX(ctx) ((ctx)->sc_edx)
- #define UCONTEXT_REG_EBP(ctx) ((ctx)->sc_ebp)
- #define UCONTEXT_REG_ESP(ctx) ((ctx)->sc_esp)
- #define UCONTEXT_REG_ESI(ctx) ((ctx)->sc_esi)
- #define UCONTEXT_REG_EDI(ctx) ((ctx)->sc_edi)
- #define UCONTEXT_REG_EIP(ctx) ((ctx)->sc_eip)
+ #define UCONTEXT_REG_EAX(ctx) (((ucontext_t*)(ctx))->sc_eax)
+ #define UCONTEXT_REG_EBX(ctx) (((ucontext_t*)(ctx))->sc_ebx)
+ #define UCONTEXT_REG_ECX(ctx) (((ucontext_t*)(ctx))->sc_ecx)
+ #define UCONTEXT_REG_EDX(ctx) (((ucontext_t*)(ctx))->sc_edx)
+ #define UCONTEXT_REG_EBP(ctx) (((ucontext_t*)(ctx))->sc_ebp)
+ #define UCONTEXT_REG_ESP(ctx) (((ucontext_t*)(ctx))->sc_esp)
+ #define UCONTEXT_REG_ESI(ctx) (((ucontext_t*)(ctx))->sc_esi)
+ #define UCONTEXT_REG_EDI(ctx) (((ucontext_t*)(ctx))->sc_edi)
+ #define UCONTEXT_REG_EIP(ctx) (((ucontext_t*)(ctx))->sc_eip)
#else
#define UCONTEXT_REG_EAX(ctx) (((ucontext_t*)(ctx))->uc_mcontext.gregs [REG_EAX])
#define UCONTEXT_REG_EBX(ctx) (((ucontext_t*)(ctx))->uc_mcontext.gregs [REG_EBX])
#elif defined(__x86_64__)
+#if defined(__FreeBSD__)
+#include <ucontext.h>
+#endif
+
#if defined(__APPLE__)
#define UCONTEXT_REG_RAX(ctx) (((ucontext_t*)(ctx))->uc_mcontext->__ss.__rax)
#define UCONTEXT_REG_RBX(ctx) (((ucontext_t*)(ctx))->uc_mcontext->__ss.__rbx)
#define UCONTEXT_REG_R14(ctx) (((ucontext_t*)(ctx))->uc_mcontext->__ss.__r14)
#define UCONTEXT_REG_R15(ctx) (((ucontext_t*)(ctx))->uc_mcontext->__ss.__r15)
#elif defined(__FreeBSD__)
-#define UCONTEXT_GREGS(ctx) ((guint64*)&(((ucontext_t*)(ctx))->uc_mcontext))
+ #define UCONTEXT_REG_RAX(ctx) (((ucontext_t*)(ctx))->uc_mcontext.mc_rax)
+ #define UCONTEXT_REG_RBX(ctx) (((ucontext_t*)(ctx))->uc_mcontext.mc_rbx)
+ #define UCONTEXT_REG_RCX(ctx) (((ucontext_t*)(ctx))->uc_mcontext.mc_rcx)
+ #define UCONTEXT_REG_RDX(ctx) (((ucontext_t*)(ctx))->uc_mcontext.mc_rdx)
+ #define UCONTEXT_REG_RBP(ctx) (((ucontext_t*)(ctx))->uc_mcontext.mc_rbp)
+ #define UCONTEXT_REG_RSP(ctx) (((ucontext_t*)(ctx))->uc_mcontext.mc_rsp)
+ #define UCONTEXT_REG_RSI(ctx) (((ucontext_t*)(ctx))->uc_mcontext.mc_rsi)
+ #define UCONTEXT_REG_RDI(ctx) (((ucontext_t*)(ctx))->uc_mcontext.mc_rdi)
+ #define UCONTEXT_REG_RIP(ctx) (((ucontext_t*)(ctx))->uc_mcontext.mc_rip)
+ #define UCONTEXT_REG_R8(ctx) (((ucontext_t*)(ctx))->uc_mcontext.mc_r8)
+ #define UCONTEXT_REG_R9(ctx) (((ucontext_t*)(ctx))->uc_mcontext.mc_r9)
+ #define UCONTEXT_REG_R10(ctx) (((ucontext_t*)(ctx))->uc_mcontext.mc_r10)
+ #define UCONTEXT_REG_R11(ctx) (((ucontext_t*)(ctx))->uc_mcontext.mc_r11)
+ #define UCONTEXT_REG_R12(ctx) (((ucontext_t*)(ctx))->uc_mcontext.mc_r12)
+ #define UCONTEXT_REG_R13(ctx) (((ucontext_t*)(ctx))->uc_mcontext.mc_r13)
+ #define UCONTEXT_REG_R14(ctx) (((ucontext_t*)(ctx))->uc_mcontext.mc_r14)
+ #define UCONTEXT_REG_R15(ctx) (((ucontext_t*)(ctx))->uc_mcontext.mc_r15)
#elif defined(__OpenBSD__)
/* OpenBSD/amd64 has no gregs array, ucontext_t == sigcontext */
- #define UCONTEXT_REG_RAX(ctx) ((ctx)->sc_rax)
- #define UCONTEXT_REG_RBX(ctx) ((ctx)->sc_rbx)
- #define UCONTEXT_REG_RCX(ctx) ((ctx)->sc_rcx)
- #define UCONTEXT_REG_RDX(ctx) ((ctx)->sc_rdx)
- #define UCONTEXT_REG_RBP(ctx) ((ctx)->sc_rbp)
- #define UCONTEXT_REG_RSP(ctx) ((ctx)->sc_rsp)
- #define UCONTEXT_REG_RSI(ctx) ((ctx)->sc_rsi)
- #define UCONTEXT_REG_RDI(ctx) ((ctx)->sc_rdi)
- #define UCONTEXT_REG_RIP(ctx) ((ctx)->sc_rip)
- #define UCONTEXT_REG_R8(ctx) ((ctx)->sc_r8)
- #define UCONTEXT_REG_R9(ctx) ((ctx)->sc_r9)
- #define UCONTEXT_REG_R10(ctx) ((ctx)->sc_r10)
- #define UCONTEXT_REG_R11(ctx) ((ctx)->sc_r11)
- #define UCONTEXT_REG_R12(ctx) ((ctx)->sc_r12)
- #define UCONTEXT_REG_R13(ctx) ((ctx)->sc_r13)
- #define UCONTEXT_REG_R14(ctx) ((ctx)->sc_r14)
- #define UCONTEXT_REG_R15(ctx) ((ctx)->sc_r15)
+ #define UCONTEXT_REG_RAX(ctx) (((ucontext_t*)(ctx))->sc_rax)
+ #define UCONTEXT_REG_RBX(ctx) (((ucontext_t*)(ctx))->sc_rbx)
+ #define UCONTEXT_REG_RCX(ctx) (((ucontext_t*)(ctx))->sc_rcx)
+ #define UCONTEXT_REG_RDX(ctx) (((ucontext_t*)(ctx))->sc_rdx)
+ #define UCONTEXT_REG_RBP(ctx) (((ucontext_t*)(ctx))->sc_rbp)
+ #define UCONTEXT_REG_RSP(ctx) (((ucontext_t*)(ctx))->sc_rsp)
+ #define UCONTEXT_REG_RSI(ctx) (((ucontext_t*)(ctx))->sc_rsi)
+ #define UCONTEXT_REG_RDI(ctx) (((ucontext_t*)(ctx))->sc_rdi)
+ #define UCONTEXT_REG_RIP(ctx) (((ucontext_t*)(ctx))->sc_rip)
+ #define UCONTEXT_REG_R8(ctx) (((ucontext_t*)(ctx))->sc_r8)
+ #define UCONTEXT_REG_R9(ctx) (((ucontext_t*)(ctx))->sc_r9)
+ #define UCONTEXT_REG_R10(ctx) (((ucontext_t*)(ctx))->sc_r10)
+ #define UCONTEXT_REG_R11(ctx) (((ucontext_t*)(ctx))->sc_r11)
+ #define UCONTEXT_REG_R12(ctx) (((ucontext_t*)(ctx))->sc_r12)
+ #define UCONTEXT_REG_R13(ctx) (((ucontext_t*)(ctx))->sc_r13)
+ #define UCONTEXT_REG_R14(ctx) (((ucontext_t*)(ctx))->sc_r14)
+ #define UCONTEXT_REG_R15(ctx) (((ucontext_t*)(ctx))->sc_r15)
#else
#define UCONTEXT_GREGS(ctx) ((guint64*)&(((ucontext_t*)(ctx))->uc_mcontext.gregs))
#endif
#define UCONTEXT_REG_R10(ctx) (((ucontext_t*)(ctx))->uc_mcontext->__ss.__r[10])
#define UCONTEXT_REG_R11(ctx) (((ucontext_t*)(ctx))->uc_mcontext->__ss.__r[11])
#define UCONTEXT_REG_R12(ctx) (((ucontext_t*)(ctx))->uc_mcontext->__ss.__r[12])
+ #define UCONTEXT_REG_CPSR(ctx) (((ucontext_t*)(ctx))->uc_mcontext->__ss.__cpsr)
#elif defined(__linux__)
typedef struct arm_ucontext {
unsigned long uc_flags;
#define UCONTEXT_REG_R10(ctx) (((arm_ucontext*)(ctx))->sig_ctx.arm_r10)
#define UCONTEXT_REG_R11(ctx) (((arm_ucontext*)(ctx))->sig_ctx.arm_fp)
#define UCONTEXT_REG_R12(ctx) (((arm_ucontext*)(ctx))->sig_ctx.arm_ip)
+ #define UCONTEXT_REG_CPSR(ctx) (((arm_ucontext*)(ctx))->sig_ctx.arm_cpsr)
#endif
#elif defined(__s390x__)