Skip to content

Instantly share code, notes, and snippets.

@pocarist
Last active August 29, 2015 14:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pocarist/96aa47c4529131392355 to your computer and use it in GitHub Desktop.
Save pocarist/96aa47c4529131392355 to your computer and use it in GitHub Desktop.
Fix compile error for NetBSD/i386 (OCaml 4.02 or later)
--- ocaml-4.02.1/asmrun/signals_osdep.h 2014-09-29 04:46:24.000000000 +0900
+++ ocaml-4.02.1_fix/asmrun/signals_osdep.h 2014-10-05 15:22:24.000000000 +0900
@@ -163,14 +172,24 @@
#elif defined(TARGET_i386) && defined(SYS_bsd_elf)
- #define DECLARE_SIGNAL_HANDLER(name) \
- static void name(int sig, siginfo_t * info, struct sigcontext * context)
+ #if defined (__NetBSD__)
+ #include <ucontext.h>
+ #define DECLARE_SIGNAL_HANDLER(name) \
+ static void name(int sig, siginfo_t * info, ucontext_t * context)
+ #else
+ #define DECLARE_SIGNAL_HANDLER(name) \
+ static void name(int sig, siginfo_t * info, struct sigcontext * context)
+ #endif
#define SET_SIGACT(sigact,name) \
sigact.sa_sigaction = (void (*)(int,siginfo_t *,void *)) (name); \
sigact.sa_flags = SA_SIGINFO
- #define CONTEXT_PC (context->sc_eip)
+ #if defined (__NetBSD__)
+ #define CONTEXT_PC (_UC_MACHINE_PC(context))
+ #else
+ #define CONTEXT_PC (context->sc_eip)
+ #endif
#define CONTEXT_FAULTING_ADDRESS ((char *) info->si_addr)
/****************** I386, BSD */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment