@@ -31,7 +31,12 @@ void context_segfault(rei_host_context_t* reictx, void* segfault_ctx, bool to_se
3131
3232#if !defined(TARGET_NO_EXCEPTIONS)
3333#if HOST_CPU == CPU_ARM
34- #if HOST_OS == OS_LINUX
34+ #if defined(__FreeBSD__)
35+ bicopy (reictx->pc , MCTX (.__gregs [_REG_PC]), to_segfault);
36+
37+ for (int i = 0 ; i < 15 ; i++)
38+ bicopy (reictx->r [i], MCTX (.__gregs [i]), to_segfault);
39+ #elif HOST_OS == OS_LINUX
3540 bicopy (reictx->pc , MCTX (.arm_pc ), to_segfault);
3641 u32 * r =(u32 *) &MCTX (.arm_r0 );
3742
@@ -47,7 +52,12 @@ void context_segfault(rei_host_context_t* reictx, void* segfault_ctx, bool to_se
4752 #error HOST_OS
4853 #endif
4954#elif HOST_CPU == CPU_X86
50- #if HOST_OS == OS_LINUX
55+ #if defined(__FreeBSD__)
56+ bicopy (reictx->pc , MCTX (.mc_eip ), to_segfault);
57+ bicopy (reictx->esp , MCTX (.mc_esp ), to_segfault);
58+ bicopy (reictx->eax , MCTX (.mc_eax ), to_segfault);
59+ bicopy (reictx->ecx , MCTX (.mc_ecx ), to_segfault);
60+ #elif HOST_OS == OS_LINUX
5161 bicopy (reictx->pc , MCTX (.gregs [REG_EIP]), to_segfault);
5262 bicopy (reictx->esp , MCTX (.gregs [REG_ESP]), to_segfault);
5363 bicopy (reictx->eax , MCTX (.gregs [REG_EAX]), to_segfault);
@@ -61,11 +71,15 @@ void context_segfault(rei_host_context_t* reictx, void* segfault_ctx, bool to_se
6171 #error HOST_OS
6272 #endif
6373#elif HOST_CPU == CPU_X64
64- #if HOST_OS == OS_LINUX
65- bicopy (reictx->pc , MCTX (.gregs [REG_RIP]), to_segfault);
66- #elif HOST_OS == OS_DARWIN
67- bicopy (reictx->pc , MCTX (->__ss .__rip ), to_segfault);
68- #endif
74+ #if defined(__FreeBSD__) || defined(__DragonFly__)
75+ bicopy (reictx->pc , MCTX (.mc_rip ), to_segfault);
76+ #elif defined(__NetBSD__)
77+ bicopy (reictx->pc , MCTX (.__gregs [_REG_RIP]), to_segfault);
78+ #elif HOST_OS == OS_LINUX
79+ bicopy (reictx->pc , MCTX (.gregs [REG_RIP]), to_segfault);
80+ #else
81+ #error HOST_OS
82+ #endif
6983#elif HOST_CPU == CPU_MIPS
7084 bicopy (reictx->pc , MCTX (.pc ), to_segfault);
7185#elif HOST_CPU == CPU_GENERIC
0 commit comments