X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mono%2Futils%2Fmono-context.h;h=2704c8662a8d1e2919a99fb3afb91361a551bb1d;hb=59448e9b7a6382e768f7418430bf278410555447;hp=2661e657636dde188bb897b51a5284f77f254c3f;hpb=12b712c8917ac1411c3f85436845ec53d8c33a18;p=mono.git diff --git a/mono/utils/mono-context.h b/mono/utils/mono-context.h index 2661e657636..2704c8662a8 100644 --- a/mono/utils/mono-context.h +++ b/mono/utils/mono-context.h @@ -3,6 +3,7 @@ * * * Copyright (c) 2011 Novell, Inc (http://www.novell.com) + * Licensed under the MIT license. See LICENSE file in the project root for full license information. */ @@ -30,7 +31,7 @@ /*HACK, move this to an eventual mono-signal.c*/ #if defined( __linux__) || defined(__sun) || defined(__APPLE__) || defined(__NetBSD__) || \ defined(__FreeBSD__) || defined(__OpenBSD__) -#ifdef HAVE_SIGACTION +#if defined(HAVE_SIGACTION) || defined(__APPLE__) // the __APPLE__ check is required for the tvos simulator, which has ucontext_t but not sigaction #define MONO_SIGNAL_USE_UCONTEXT_T 1 #endif #endif @@ -151,7 +152,7 @@ typedef struct { #if !defined( HOST_WIN32 ) && !defined(__native_client__) && !defined(__native_client_codegen__) -#ifdef HAVE_SIGACTION +#if defined(HAVE_SIGACTION) || defined(__APPLE__) // the __APPLE__ check is required for the tvos simulator, which has ucontext_t but not sigaction #define MONO_SIGNAL_USE_UCONTEXT_T 1 #endif @@ -252,6 +253,8 @@ typedef struct { #if defined(HOST_WATCHOS) #define MONO_CONTEXT_GET_CURRENT(ctx) do { \ + gpointer _dummy; \ + ctx.regs [ARMREG_SP] = &_dummy; \ } while (0); #else @@ -452,31 +455,105 @@ typedef struct { : "memory" \ ) -#define MONO_ARCH_HAS_MONO_CONTEXT 1 - -#else +#else /* !defined(__mono_ppc64__) */ typedef struct { - gulong sc_ir; // pc - gulong sc_sp; // r1 - mgreg_t regs [19]; /*FIXME, this must be changed to 32 for sgen*/ - double fregs [18]; + mgreg_t sc_ir; // pc + mgreg_t sc_sp; // r1 + mgreg_t regs [32]; + double fregs [32]; } MonoContext; /* we have the stack pointer, not the base pointer in sigcontext */ -#define MONO_CONTEXT_SET_IP(ctx,ip) do { (ctx)->sc_ir = (gulong)ip; } while (0); +#define MONO_CONTEXT_SET_IP(ctx,ip) do { (ctx)->sc_ir = (mgreg_t)ip; } while (0); /* FIXME: should be called SET_SP */ -#define MONO_CONTEXT_SET_BP(ctx,bp) do { (ctx)->sc_sp = (gulong)bp; } while (0); -#define MONO_CONTEXT_SET_SP(ctx,sp) do { (ctx)->sc_sp = (gulong)sp; } while (0); +#define MONO_CONTEXT_SET_BP(ctx,bp) do { (ctx)->sc_sp = (mgreg_t)bp; } while (0); +#define MONO_CONTEXT_SET_SP(ctx,sp) do { (ctx)->sc_sp = (mgreg_t)sp; } while (0); #define MONO_CONTEXT_GET_IP(ctx) ((gpointer)((ctx)->sc_ir)) #define MONO_CONTEXT_GET_BP(ctx) ((gpointer)((ctx)->regs [ppc_r31-13])) #define MONO_CONTEXT_GET_SP(ctx) ((gpointer)((ctx)->sc_sp)) + +#define MONO_CONTEXT_GET_CURRENT(ctx) \ + __asm__ __volatile__( \ + "std 0, 0(%0)\n" \ + "std 1, 4(%0)\n" \ + "std 0, 4*0+8(%0)\n" \ + "std 1, 4*1+8(%0)\n" \ + "std 2, 4*2+8(%0)\n" \ + "std 3, 4*3+8(%0)\n" \ + "std 4, 4*4+8(%0)\n" \ + "std 5, 4*5+8(%0)\n" \ + "std 6, 4*6+8(%0)\n" \ + "std 7, 4*7+8(%0)\n" \ + "std 8, 4*8+8(%0)\n" \ + "std 9, 4*9+8(%0)\n" \ + "std 10, 4*10+8(%0)\n" \ + "std 11, 4*11+8(%0)\n" \ + "std 12, 4*12+8(%0)\n" \ + "std 13, 4*13+8(%0)\n" \ + "std 14, 4*14+8(%0)\n" \ + "std 15, 4*15+8(%0)\n" \ + "std 16, 4*16+8(%0)\n" \ + "std 17, 4*17+8(%0)\n" \ + "std 18, 4*18+8(%0)\n" \ + "std 19, 4*19+8(%0)\n" \ + "std 20, 4*20+8(%0)\n" \ + "std 21, 4*21+8(%0)\n" \ + "std 22, 4*22+8(%0)\n" \ + "std 23, 4*23+8(%0)\n" \ + "std 24, 4*24+8(%0)\n" \ + "std 25, 4*25+8(%0)\n" \ + "std 26, 4*26+8(%0)\n" \ + "std 27, 4*27+8(%0)\n" \ + "std 28, 4*28+8(%0)\n" \ + "std 29, 4*29+8(%0)\n" \ + "std 30, 4*30+8(%0)\n" \ + "std 31, 4*31+8(%0)\n" \ + "stfd 0, 8*0+4*32+8(%0)\n" \ + "stfd 1, 8*1+4*32+8(%0)\n" \ + "stfd 2, 8*2+4*32+8(%0)\n" \ + "stfd 3, 8*3+4*32+8(%0)\n" \ + "stfd 4, 8*4+4*32+8(%0)\n" \ + "stfd 5, 8*5+4*32+8(%0)\n" \ + "stfd 6, 8*6+4*32+8(%0)\n" \ + "stfd 7, 8*7+4*32+8(%0)\n" \ + "stfd 8, 8*8+4*32+8(%0)\n" \ + "stfd 9, 8*9+4*32+8(%0)\n" \ + "stfd 10, 8*10+4*32+8(%0)\n" \ + "stfd 11, 8*11+4*32+8(%0)\n" \ + "stfd 12, 8*12+4*32+8(%0)\n" \ + "stfd 13, 8*13+4*32+8(%0)\n" \ + "stfd 14, 8*14+4*32+8(%0)\n" \ + "stfd 15, 8*15+4*32+8(%0)\n" \ + "stfd 16, 8*16+4*32+8(%0)\n" \ + "stfd 17, 8*17+4*32+8(%0)\n" \ + "stfd 18, 8*18+4*32+8(%0)\n" \ + "stfd 19, 8*19+4*32+8(%0)\n" \ + "stfd 20, 8*20+4*32+8(%0)\n" \ + "stfd 21, 8*21+4*32+8(%0)\n" \ + "stfd 22, 8*22+4*32+8(%0)\n" \ + "stfd 23, 8*23+4*32+8(%0)\n" \ + "stfd 24, 8*24+4*32+8(%0)\n" \ + "stfd 25, 8*25+4*32+8(%0)\n" \ + "stfd 26, 8*26+4*32+8(%0)\n" \ + "stfd 27, 8*27+4*32+8(%0)\n" \ + "stfd 28, 8*28+4*32+8(%0)\n" \ + "stfd 29, 8*29+4*32+8(%0)\n" \ + "stfd 30, 8*30+4*32+8(%0)\n" \ + "stfd 31, 8*31+4*32+8(%0)\n" \ + : : "r" (&(ctx)) \ + : "memory" \ + ) + #endif +#define MONO_ARCH_HAS_MONO_CONTEXT 1 + #elif defined(__sparc__) || defined(sparc) /* defined(__mono_ppc__) */ typedef struct MonoContext { + mgreg_t regs [15]; guint8 *ip; gpointer *sp; gpointer *fp; @@ -490,6 +567,54 @@ typedef struct MonoContext { #define MONO_CONTEXT_GET_BP(ctx) ((gpointer)((ctx)->fp)) #define MONO_CONTEXT_GET_SP(ctx) ((gpointer)((ctx)->sp)) +#ifdef __sparcv9 +#define MONO_CONTEXT_GET_CURRENT(ctx) \ + __asm__ __volatile__( \ + "st %%g1,[%0]\n" \ + "st %%g2,[%0+0x08]\n" \ + "st %%g3,[%0+0x10]\n" \ + "st %%g4,[%0+0x18]\n" \ + "st %%g5,[%0+0x20]\n" \ + "st %%g6,[%0+0x28]\n" \ + "st %%g7,[%0+0x30]\n" \ + "st %%o0,[%0+0x38]\n" \ + "st %%o1,[%0+0x40]\n" \ + "st %%o2,[%0+0x48]\n" \ + "st %%o3,[%0+0x50]\n" \ + "st %%o4,[%0+0x58]\n" \ + "st %%o5,[%0+0x60]\n" \ + "st %%o6,[%0+0x68]\n" \ + "st %%o7,[%0+0x70]\n" \ + : \ + : "r" (&(ctx)) \ + : "memory" \ + ) +#else +#define MONO_CONTEXT_GET_CURRENT(ctx) \ + __asm__ __volatile__( \ + "st %%g1,[%0]\n" \ + "st %%g2,[%0+0x04]\n" \ + "st %%g3,[%0+0x08]\n" \ + "st %%g4,[%0+0x0c]\n" \ + "st %%g5,[%0+0x10]\n" \ + "st %%g6,[%0+0x14]\n" \ + "st %%g7,[%0+0x18]\n" \ + "st %%o0,[%0+0x1c]\n" \ + "st %%o1,[%0+0x20]\n" \ + "st %%o2,[%0+0x24]\n" \ + "st %%o3,[%0+0x28]\n" \ + "st %%o4,[%0+0x2c]\n" \ + "st %%o5,[%0+0x30]\n" \ + "st %%o6,[%0+0x34]\n" \ + "st %%o7,[%0+0x38]\n" \ + : \ + : "r" (&(ctx)) \ + : "memory" \ + ) +#endif + +#define MONO_ARCH_HAS_MONO_CONTEXT 1 + #elif defined(__ia64__) /*defined(__sparc__) || defined(sparc) */ #ifndef UNW_LOCAL_ONLY