Add support for OpenBSD/arm64 (#53233)
authormonojenkins <jo.shields+jenkins@xamarin.com>
Tue, 25 May 2021 21:24:40 +0000 (17:24 -0400)
committerGitHub <noreply@github.com>
Tue, 25 May 2021 21:24:40 +0000 (17:24 -0400)
There are three changes required to build mono on OpenBSD/arm64.

- The first one is to provide the UCONTEXT macros, which for OpenBSD simply map to sigcontext.
- Furthermore as stated in issue mono/mono#21005, https://github.com/mono/boringssl/compare/mono...bluerise:obsd is necessary for boringssl so that it can be built.
- And last, bdwgc needs to be patches as well: https://github.com/Unity-Technologies/bdwgc/pull/62

Co-authored-by: bluerise <bluerise@users.noreply.github.com>
src/mono/mono/utils/mono-sigcontext.h

index f9885a9..a385b0e 100644 (file)
@@ -488,6 +488,12 @@ typedef struct ucontext {
        #define UCONTEXT_REG_SP(ctx) (((ucontext_t*)(ctx))->uc_mcontext.mc_gpregs.gp_sp)
        #define UCONTEXT_REG_R0(ctx) (((ucontext_t*)(ctx))->uc_mcontext.mc_gpregs.gp_x [ARMREG_R0])
        #define UCONTEXT_GREGS(ctx) (&(((ucontext_t*)(ctx))->uc_mcontext.mc_gpregs.gp_x))
+#elif defined(__OpenBSD__)
+       /* ucontext_t == sigcontext */
+       #define UCONTEXT_REG_PC(ctx) (((ucontext_t*)(ctx))->sc_elr)
+       #define UCONTEXT_REG_SP(ctx) (((ucontext_t*)(ctx))->sc_sp)
+       #define UCONTEXT_REG_R0(ctx) (((ucontext_t*)(ctx))->sc_x [ARMREG_R0])
+       #define UCONTEXT_GREGS(ctx) (&(((ucontext_t*)(ctx))->sc_x))
 #elif !defined(HOST_WIN32)
 #include <ucontext.h>
        #define UCONTEXT_REG_PC(ctx) (((ucontext_t*)(ctx))->uc_mcontext.pc)