Revert "Revert "Merge branch 'master' of https://github.com/mono/mono""
[mono.git] / mono / metadata / sgen-archdep.h
old mode 100644 (file)
new mode 100755 (executable)
index c41e738..b86ec31
 #ifdef MONO_ARCH_HAS_MONO_CONTEXT
 #define USE_MONO_CTX
 #else
-#ifdef _MSC_VER
-#define ARCH_STORE_REGS(ptr) __asm {   \
-               __asm mov [ptr], edi \
-               __asm mov [ptr+4], esi \
-               __asm mov [ptr+8], ebx \
-               __asm mov [ptr+12], edx \
-               __asm mov [ptr+16], ecx \
-               __asm mov [ptr+20], eax \
-               __asm mov [ptr+24], ebp \
-               __asm mov [ptr+28], esp \
-       }
-#else
-#define ARCH_STORE_REGS(ptr)   \
-       __asm__ __volatile__(   \
-               "mov %%edi,0(%0)\n"     \
-               "mov %%esi,4(%0)\n"     \
-               "mov %%ebx,8(%0)\n"     \
-               "mov %%edx,12(%0)\n"    \
-               "mov %%ecx,16(%0)\n"    \
-               "mov %%eax,20(%0)\n"    \
-               "mov %%ebp,24(%0)\n"    \
-               "mov %%esp,28(%0)\n"    \
-               :                       \
-               : "r" (ptr)     \
-       )
-#endif
+#error 0
 #endif
 
 /*FIXME, move this to mono-sigcontext as this is generaly useful.*/
@@ -89,7 +64,7 @@
 #define ARCH_SIGCTX_SP(ctx)    (UCONTEXT_REG_RSP (ctx))
 #define ARCH_SIGCTX_IP(ctx)    (UCONTEXT_REG_RIP (ctx))
 
-#elif defined(TARGET_PPC)
+#elif defined(TARGET_POWERPC)
 
 #define REDZONE_SIZE   224
 
 #define ARCH_COPY_SIGCTX_REGS(a,ctx) do {      \
        int __i;        \
        for (__i = 0; __i < 32; ++__i)  \
-               ((a)[__i]) = UCONTEXT_REG_Rn((ctx), __i);       \
+               ((a)[__i]) = (gpointer) UCONTEXT_REG_Rn((ctx), __i);    \
        } while (0)
 
 #elif defined(TARGET_ARM)
        ((a)[13]) = (gpointer) (UCONTEXT_REG_LR((ctx)));        \
        } while (0)
 
+#elif defined(TARGET_ARM64)
+
+#include <mono/utils/mono-sigcontext.h>
+
+#ifdef __linux__
+#define REDZONE_SIZE    0
+#elif defined(__APPLE__)
+#define REDZONE_SIZE   128
+#else
+#error "Not implemented."
+#endif
+#define USE_MONO_CTX
+#define ARCH_NUM_REGS 31
+
+#define ARCH_STORE_REGS(ptr) do { g_assert_not_reached (); } while (0)
+
+#define ARCH_SIGCTX_SP(ctx)    UCONTEXT_REG_SP (ctx)
+#define ARCH_SIGCTX_IP(ctx)    UCONTEXT_REG_PC (ctx)
+#define ARCH_COPY_SIGCTX_REGS(a,ctx) do { g_assert_not_reached (); } while (0)
+
 #elif defined(__mips__)
 
 #define REDZONE_SIZE   0
 #define USE_MONO_CTX
 #define ARCH_NUM_REGS 32
 
-#define ARCH_SIGCTX_SP(ctx)    (UCONTEXT_GREGS((ctx))[29])
-#define ARCH_SIGCTX_IP(ctx)    (UCONTEXT_REG_PC((ctx)))
+/*
+ * These casts are necessary since glibc always makes the
+ * gregs 64-bit values in userland.
+ */
+#define ARCH_SIGCTX_SP(ctx)    ((gsize) UCONTEXT_GREGS((ctx))[29])
+#define ARCH_SIGCTX_IP(ctx)    ((gsize) UCONTEXT_REG_PC((ctx)))
 
 #elif defined(__s390x__)
 
        )
 #endif
 
+#ifndef REG_SP
+#define REG_SP REG_O6
+#endif
+
 #define ARCH_SIGCTX_SP(ctx)    (((ucontext_t *)(ctx))->uc_mcontext.gregs [REG_SP])
 #define ARCH_SIGCTX_IP(ctx)    (((ucontext_t *)(ctx))->uc_mcontext.gregs [REG_PC])
 #define ARCH_COPY_SIGCTX_REGS(a,ctx) do {      \