3 * plat independent machine state definitions
6 * Copyright (c) 2011 Novell, Inc (http://www.novell.com)
7 * Licensed under the MIT license. See LICENSE file in the project root for full license information.
11 #ifndef __MONO_MONO_CONTEXT_H__
12 #define __MONO_MONO_CONTEXT_H__
14 #include "mono-compiler.h"
15 #include "mono-sigcontext.h"
16 #include "mono-machine.h"
22 #define MONO_CONTEXT_OFFSET(field, index, field_type) \
23 "i" (offsetof (MonoContext, field) + (index) * sizeof (field_type))
25 #if defined(TARGET_X86)
26 #if defined(__APPLE__)
27 #define MONO_HAVE_SIMD_REG
28 typedef struct __darwin_xmm_reg MonoContextSimdReg
;
30 #elif defined(TARGET_AMD64)
31 #if defined(__APPLE__)
32 #define MONO_HAVE_SIMD_REG
33 typedef struct __darwin_xmm_reg MonoContextSimdReg
;
34 #elif defined(__linux__) && defined(__GLIBC__)
35 #define MONO_HAVE_SIMD_REG
36 typedef struct _libc_xmmreg MonoContextSimdReg
;
37 #elif defined(HOST_WIN32)
38 #define MONO_HAVE_SIMD_REG
39 #include <emmintrin.h>
40 typedef __m128d MonoContextSimdReg
;
41 #elif defined(HOST_ANDROID)
42 #define MONO_HAVE_SIMD_REG
43 typedef struct _libc_xmmreg MonoContextSimdReg
;
44 #elif defined(__linux__) || defined(__OpenBSD__)
45 #define MONO_HAVE_SIMD_REG
46 #include <emmintrin.h>
47 typedef __m128d MonoContextSimdReg
;
49 #elif defined(TARGET_ARM64)
50 #define MONO_HAVE_SIMD_REG
51 typedef __uint128_t MonoContextSimdReg
;
55 * General notes about mono-context.
56 * Each arch defines a MonoContext struct with all GPR regs + IP/PC.
57 * IP/PC should be the last element of the struct (this is a mild sgen constraint we could drop if needed)
58 * Macros to get/set BP, SP and IP are defined too.
59 * MONO_CONTEXT_GET_CURRENT captures the current context as close as possible. One reg might be clobbered
60 * to hold the address of the target MonoContext. It will be a caller save one, so should not be a problem.
62 #if defined (TARGET_WASM)
67 host_mgreg_t llvm_exc_reg
;
72 #define MONO_CONTEXT_SET_IP(ctx,ip) do { (ctx)->wasm_ip = (host_mgreg_t)(gsize)(ip); } while (0);
73 #define MONO_CONTEXT_SET_BP(ctx,bp) do { (ctx)->wasm_bp = (host_mgreg_t)(gsize)(bp); } while (0);
74 #define MONO_CONTEXT_SET_SP(ctx,sp) do { (ctx)->wasm_sp = (host_mgreg_t)(gsize)(sp); } while (0);
76 #define MONO_CONTEXT_GET_IP(ctx) ((gpointer)(gsize)((ctx)->wasm_ip))
77 #define MONO_CONTEXT_GET_BP(ctx) ((gpointer)(gsize)((ctx)->wasm_bp))
78 #define MONO_CONTEXT_GET_SP(ctx) ((gpointer)(gsize)((ctx)->wasm_sp))
80 #elif (defined(__i386__) && !defined(MONO_CROSS_COMPILE)) || (defined(TARGET_X86))
82 /*HACK, move this to an eventual mono-signal.c*/
83 #if defined( __linux__) || defined(__sun) || defined(__APPLE__) || defined(__NetBSD__) || \
84 defined(__FreeBSD__) || defined(__OpenBSD__)
85 #if defined(HAVE_SIGACTION) || defined(__APPLE__) // the __APPLE__ check is required for the tvos simulator, which has ucontext_t but not sigaction
86 #define MONO_SIGNAL_USE_UCONTEXT_T 1
91 /* sigcontext surrogate */
98 /* sigcontext surrogate */
112 #if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__APPLE__)
113 # define SC_EAX sc_eax
114 # define SC_EBX sc_ebx
115 # define SC_ECX sc_ecx
116 # define SC_EDX sc_edx
117 # define SC_EBP sc_ebp
118 # define SC_EIP sc_eip
119 # define SC_ESP sc_esp
120 # define SC_EDI sc_edi
121 # define SC_ESI sc_esi
122 #elif defined(__HAIKU__)
123 # define SC_EAX regs.eax
124 # define SC_EBX regs.ebx
125 # define SC_ECX regs.ecx
126 # define SC_EDX regs.edx
127 # define SC_EBP regs.ebp
128 # define SC_EIP regs.eip
129 # define SC_ESP regs.esp
130 # define SC_EDI regs.edi
131 # define SC_ESI regs.esi
144 #include <mono/arch/x86/x86-codegen.h>
157 MonoContextSimdReg fregs
[X86_XMM_NREG
];
161 #define MONO_CONTEXT_SET_IP(ctx,ip) do { (ctx)->eip = (host_mgreg_t)(gsize)(ip); } while (0);
162 #define MONO_CONTEXT_SET_BP(ctx,bp) do { (ctx)->ebp = (host_mgreg_t)(gsize)(bp); } while (0);
163 #define MONO_CONTEXT_SET_SP(ctx,sp) do { (ctx)->esp = (host_mgreg_t)(gsize)(sp); } while (0);
165 #define MONO_CONTEXT_GET_IP(ctx) ((gpointer)(gsize)((ctx)->eip))
166 #define MONO_CONTEXT_GET_BP(ctx) ((gpointer)(gsize)((ctx)->ebp))
167 #define MONO_CONTEXT_GET_SP(ctx) ((gpointer)(gsize)((ctx)->esp))
169 /*We set EAX to zero since we are clobering it anyway*/
171 #define MONO_CONTEXT_GET_CURRENT(ctx) do { \
172 void *_ptr = &(ctx); \
174 __asm mov eax, _ptr \
175 __asm mov [eax+0x00], eax \
176 __asm mov [eax+0x04], ebx \
177 __asm mov [eax+0x08], ecx \
178 __asm mov [eax+0x0c], edx \
179 __asm mov [eax+0x10], ebp \
180 __asm mov [eax+0x14], esp \
181 __asm mov [eax+0x18], esi \
182 __asm mov [eax+0x1c], edi \
183 __asm call __mono_context_get_ip \
184 __asm __mono_context_get_ip: \
185 __asm pop dword ptr [eax+0x20] \
190 #define MONO_CONTEXT_GET_CURRENT_GREGS(ctx) \
191 __asm__ __volatile__( \
192 "movl $0x0, %c[eax](%0)\n" \
193 "mov %%ebx, %c[ebx](%0)\n" \
194 "mov %%ecx, %c[ecx](%0)\n" \
195 "mov %%edx, %c[edx](%0)\n" \
196 "mov %%ebp, %c[ebp](%0)\n" \
197 "mov %%esp, %c[esp](%0)\n" \
198 "mov %%esi, %c[esi](%0)\n" \
199 "mov %%edi, %c[edi](%0)\n" \
201 "1: pop 0x20(%0)\n" \
204 [eax] MONO_CONTEXT_OFFSET (eax, 0, host_mgreg_t), \
205 [ebx] MONO_CONTEXT_OFFSET (ebx, 0, host_mgreg_t), \
206 [ecx] MONO_CONTEXT_OFFSET (ecx, 0, host_mgreg_t), \
207 [edx] MONO_CONTEXT_OFFSET (edx, 0, host_mgreg_t), \
208 [ebp] MONO_CONTEXT_OFFSET (ebp, 0, host_mgreg_t), \
209 [esp] MONO_CONTEXT_OFFSET (esp, 0, host_mgreg_t), \
210 [esi] MONO_CONTEXT_OFFSET (esi, 0, host_mgreg_t), \
211 [edi] MONO_CONTEXT_OFFSET (edi, 0, host_mgreg_t) \
214 #ifdef UCONTEXT_REG_XMM
215 #define MONO_CONTEXT_GET_CURRENT_FREGS(ctx) \
217 __asm__ __volatile__ ( \
218 "movups %%xmm0, %c[xmm0](%0)\n" \
219 "movups %%xmm1, %c[xmm1](%0)\n" \
220 "movups %%xmm2, %c[xmm2](%0)\n" \
221 "movups %%xmm3, %c[xmm3](%0)\n" \
222 "movups %%xmm4, %c[xmm4](%0)\n" \
223 "movups %%xmm5, %c[xmm5](%0)\n" \
224 "movups %%xmm6, %c[xmm6](%0)\n" \
225 "movups %%xmm7, %c[xmm7](%0)\n" \
228 [xmm0] MONO_CONTEXT_OFFSET (fregs, X86_XMM0, MonoContextSimdReg), \
229 [xmm1] MONO_CONTEXT_OFFSET (fregs, X86_XMM1, MonoContextSimdReg), \
230 [xmm2] MONO_CONTEXT_OFFSET (fregs, X86_XMM2, MonoContextSimdReg), \
231 [xmm3] MONO_CONTEXT_OFFSET (fregs, X86_XMM3, MonoContextSimdReg), \
232 [xmm4] MONO_CONTEXT_OFFSET (fregs, X86_XMM4, MonoContextSimdReg), \
233 [xmm5] MONO_CONTEXT_OFFSET (fregs, X86_XMM5, MonoContextSimdReg), \
234 [xmm6] MONO_CONTEXT_OFFSET (fregs, X86_XMM6, MonoContextSimdReg), \
235 [xmm7] MONO_CONTEXT_OFFSET (fregs, X86_XMM7, MonoContextSimdReg)); \
238 #define MONO_CONTEXT_GET_CURRENT_FREGS(ctx)
241 #define MONO_CONTEXT_GET_CURRENT(ctx) \
243 MONO_CONTEXT_GET_CURRENT_GREGS(ctx); \
244 MONO_CONTEXT_GET_CURRENT_FREGS(ctx); \
249 #define MONO_ARCH_HAS_MONO_CONTEXT 1
251 #elif (defined(__x86_64__) && !defined(MONO_CROSS_COMPILE)) || (defined(TARGET_AMD64)) /* defined(__i386__) */
253 #include <mono/arch/amd64/amd64-codegen.h>
255 #if !defined( HOST_WIN32 )
257 // the __APPLE__ check is required for the tvos simulator, which has ucontext_t but not sigaction
258 #if defined(HAVE_SIGACTION) || defined(__APPLE__)
259 #define MONO_SIGNAL_USE_UCONTEXT_T 1
265 /* sigcontext surrogate */
270 // Haiku doesn't support this
271 #undef MONO_SIGNAL_USE_UCONTEXT_T
274 MONO_DISABLE_WARNING(4324) // 'struct_name' : structure was padded due to __declspec(align())
277 host_mgreg_t gregs
[AMD64_NREG
];
278 #if defined(MONO_HAVE_SIMD_REG)
279 MonoContextSimdReg fregs
[AMD64_XMM_NREG
];
281 double fregs
[AMD64_XMM_NREG
];
287 #define MONO_CONTEXT_SET_IP(ctx,ip) do { (ctx)->gregs [AMD64_RIP] = (host_mgreg_t)(gsize)(ip); } while (0);
288 #define MONO_CONTEXT_SET_BP(ctx,bp) do { (ctx)->gregs [AMD64_RBP] = (host_mgreg_t)(gsize)(bp); } while (0);
289 #define MONO_CONTEXT_SET_SP(ctx,esp) do { (ctx)->gregs [AMD64_RSP] = (host_mgreg_t)(gsize)(esp); } while (0);
291 #define MONO_CONTEXT_GET_IP(ctx) ((gpointer)(gsize)((ctx)->gregs [AMD64_RIP]))
292 #define MONO_CONTEXT_GET_BP(ctx) ((gpointer)(gsize)((ctx)->gregs [AMD64_RBP]))
293 #define MONO_CONTEXT_GET_SP(ctx) ((gpointer)(gsize)((ctx)->gregs [AMD64_RSP]))
295 #if defined (HOST_WIN32) && !defined(__GNUC__)
296 /* msvc doesn't support inline assembly, so have to use a separate .asm file */
297 // G_EXTERN_C due to being written in assembly.
298 G_EXTERN_C
void mono_context_get_current (void *);
299 #define MONO_CONTEXT_GET_CURRENT(ctx) do { mono_context_get_current((void*)&(ctx)); } while (0)
303 #define MONO_CONTEXT_GET_CURRENT_GREGS(ctx) \
305 __asm__ __volatile__( \
306 "movq $0x0, %c[rax](%0)\n" \
307 "movq %%rcx, %c[rcx](%0)\n" \
308 "movq %%rdx, %c[rdx](%0)\n" \
309 "movq %%rbx, %c[rbx](%0)\n" \
310 "movq %%rsp, %c[rsp](%0)\n" \
311 "movq %%rbp, %c[rbp](%0)\n" \
312 "movq %%rsi, %c[rsi](%0)\n" \
313 "movq %%rdi, %c[rdi](%0)\n" \
314 "movq %%r8, %c[r8](%0)\n" \
315 "movq %%r9, %c[r9](%0)\n" \
316 "movq %%r10, %c[r10](%0)\n" \
317 "movq %%r11, %c[r11](%0)\n" \
318 "movq %%r12, %c[r12](%0)\n" \
319 "movq %%r13, %c[r13](%0)\n" \
320 "movq %%r14, %c[r14](%0)\n" \
321 "movq %%r15, %c[r15](%0)\n" \
322 /* "leaq (%%rip), %%rdx\n" is not understood by icc */ \
323 ".byte 0x48, 0x8d, 0x15, 0x00, 0x00, 0x00, 0x00\n" \
324 "movq %%rdx, %c[rip](%0)\n" \
327 [rax] MONO_CONTEXT_OFFSET (gregs, AMD64_RAX, host_mgreg_t), \
328 [rcx] MONO_CONTEXT_OFFSET (gregs, AMD64_RCX, host_mgreg_t), \
329 [rdx] MONO_CONTEXT_OFFSET (gregs, AMD64_RDX, host_mgreg_t), \
330 [rbx] MONO_CONTEXT_OFFSET (gregs, AMD64_RBX, host_mgreg_t), \
331 [rsp] MONO_CONTEXT_OFFSET (gregs, AMD64_RSP, host_mgreg_t), \
332 [rbp] MONO_CONTEXT_OFFSET (gregs, AMD64_RBP, host_mgreg_t), \
333 [rsi] MONO_CONTEXT_OFFSET (gregs, AMD64_RSI, host_mgreg_t), \
334 [rdi] MONO_CONTEXT_OFFSET (gregs, AMD64_RDI, host_mgreg_t), \
335 [r8] MONO_CONTEXT_OFFSET (gregs, AMD64_R8, host_mgreg_t), \
336 [r9] MONO_CONTEXT_OFFSET (gregs, AMD64_R9, host_mgreg_t), \
337 [r10] MONO_CONTEXT_OFFSET (gregs, AMD64_R10, host_mgreg_t), \
338 [r11] MONO_CONTEXT_OFFSET (gregs, AMD64_R11, host_mgreg_t), \
339 [r12] MONO_CONTEXT_OFFSET (gregs, AMD64_R12, host_mgreg_t), \
340 [r13] MONO_CONTEXT_OFFSET (gregs, AMD64_R13, host_mgreg_t), \
341 [r14] MONO_CONTEXT_OFFSET (gregs, AMD64_R14, host_mgreg_t), \
342 [r15] MONO_CONTEXT_OFFSET (gregs, AMD64_R15, host_mgreg_t), \
343 [rip] MONO_CONTEXT_OFFSET (gregs, AMD64_RIP, host_mgreg_t) \
344 : "rdx", "memory"); \
347 #ifdef UCONTEXT_REG_XMM
348 #define MONO_CONTEXT_GET_CURRENT_FREGS(ctx) \
350 __asm__ __volatile__ ( \
351 "movups %%xmm0, %c[xmm0](%0)\n" \
352 "movups %%xmm1, %c[xmm1](%0)\n" \
353 "movups %%xmm2, %c[xmm2](%0)\n" \
354 "movups %%xmm3, %c[xmm3](%0)\n" \
355 "movups %%xmm4, %c[xmm4](%0)\n" \
356 "movups %%xmm5, %c[xmm5](%0)\n" \
357 "movups %%xmm6, %c[xmm6](%0)\n" \
358 "movups %%xmm7, %c[xmm7](%0)\n" \
359 "movups %%xmm8, %c[xmm8](%0)\n" \
360 "movups %%xmm9, %c[xmm9](%0)\n" \
361 "movups %%xmm10, %c[xmm10](%0)\n" \
362 "movups %%xmm11, %c[xmm11](%0)\n" \
363 "movups %%xmm12, %c[xmm12](%0)\n" \
364 "movups %%xmm12, %c[xmm12](%0)\n" \
365 "movups %%xmm14, %c[xmm14](%0)\n" \
366 "movups %%xmm15, %c[xmm15](%0)\n" \
369 [xmm0] MONO_CONTEXT_OFFSET (fregs, AMD64_XMM0, MonoContextSimdReg), \
370 [xmm1] MONO_CONTEXT_OFFSET (fregs, AMD64_XMM1, MonoContextSimdReg), \
371 [xmm2] MONO_CONTEXT_OFFSET (fregs, AMD64_XMM2, MonoContextSimdReg), \
372 [xmm3] MONO_CONTEXT_OFFSET (fregs, AMD64_XMM3, MonoContextSimdReg), \
373 [xmm4] MONO_CONTEXT_OFFSET (fregs, AMD64_XMM4, MonoContextSimdReg), \
374 [xmm5] MONO_CONTEXT_OFFSET (fregs, AMD64_XMM5, MonoContextSimdReg), \
375 [xmm6] MONO_CONTEXT_OFFSET (fregs, AMD64_XMM6, MonoContextSimdReg), \
376 [xmm7] MONO_CONTEXT_OFFSET (fregs, AMD64_XMM7, MonoContextSimdReg), \
377 [xmm8] MONO_CONTEXT_OFFSET (fregs, AMD64_XMM8, MonoContextSimdReg), \
378 [xmm9] MONO_CONTEXT_OFFSET (fregs, AMD64_XMM9, MonoContextSimdReg), \
379 [xmm10] MONO_CONTEXT_OFFSET (fregs, AMD64_XMM10, MonoContextSimdReg), \
380 [xmm11] MONO_CONTEXT_OFFSET (fregs, AMD64_XMM11, MonoContextSimdReg), \
381 [xmm12] MONO_CONTEXT_OFFSET (fregs, AMD64_XMM12, MonoContextSimdReg), \
382 [xmm13] MONO_CONTEXT_OFFSET (fregs, AMD64_XMM13, MonoContextSimdReg), \
383 [xmm14] MONO_CONTEXT_OFFSET (fregs, AMD64_XMM14, MonoContextSimdReg), \
384 [xmm15] MONO_CONTEXT_OFFSET (fregs, AMD64_XMM15, MonoContextSimdReg)); \
387 #define MONO_CONTEXT_GET_CURRENT_FREGS(ctx)
390 #define MONO_CONTEXT_GET_CURRENT(ctx) \
392 MONO_CONTEXT_GET_CURRENT_GREGS(ctx); \
393 MONO_CONTEXT_GET_CURRENT_FREGS(ctx); \
397 #define MONO_ARCH_HAS_MONO_CONTEXT 1
399 #elif (defined(__arm__) && !defined(MONO_CROSS_COMPILE)) || (defined(TARGET_ARM)) /* defined(__x86_64__) */
401 #include <mono/arch/arm/arm-codegen.h>
405 host_mgreg_t regs
[16];
410 /* we have the stack pointer, not the base pointer in sigcontext */
411 #define MONO_CONTEXT_SET_IP(ctx,ip) do { (ctx)->pc = (host_mgreg_t)(gsize)ip; } while (0);
412 #define MONO_CONTEXT_SET_BP(ctx,bp) do { (ctx)->regs [ARMREG_FP] = (host_mgreg_t)(gsize)bp; } while (0);
413 #define MONO_CONTEXT_SET_SP(ctx,bp) do { (ctx)->regs [ARMREG_SP] = (host_mgreg_t)(gsize)bp; } while (0);
415 #define MONO_CONTEXT_GET_IP(ctx) ((gpointer)(gsize)((ctx)->pc))
416 #define MONO_CONTEXT_GET_BP(ctx) ((gpointer)(gsize)((ctx)->regs [ARMREG_FP]))
417 #define MONO_CONTEXT_GET_SP(ctx) ((gpointer)(gsize)((ctx)->regs [ARMREG_SP]))
419 #if defined(HOST_WATCHOS)
421 #define MONO_CONTEXT_GET_CURRENT(ctx) do { \
423 ctx.regs [ARMREG_SP] = (host_mgreg_t)(gsize)&_dummy; \
428 #define MONO_CONTEXT_GET_CURRENT(ctx) do { \
429 __asm__ __volatile__( \
433 "ldr r1, [sp, #4]\n" \
434 "str r1, [r0], #4\n" \
435 "ldr r1, [sp, #0]\n" \
436 "str r1, [r0], #4\n" \
437 "stmia r0!, {r2-r12}\n" \
438 "str sp, [r0], #4\n" \
439 "str lr, [r0], #4\n" \
441 "str r1, [r0], #4\n" \
448 ctx.pc = ctx.regs [15]; \
453 #define MONO_ARCH_HAS_MONO_CONTEXT 1
455 #elif (defined(__aarch64__) && !defined(MONO_CROSS_COMPILE)) || (defined(TARGET_ARM64))
457 #include <mono/arch/arm64/arm64-codegen.h>
460 host_mgreg_t regs
[32];
461 /* FIXME not fully saved in trampolines */
462 MonoContextSimdReg fregs
[32];
465 * fregs might not be initialized if this context was created from a
468 host_mgreg_t has_fregs
;
471 #define MONO_CONTEXT_SET_IP(ctx,ip) do { (ctx)->pc = (host_mgreg_t)(gsize)ip; } while (0)
472 #define MONO_CONTEXT_SET_BP(ctx,bp) do { (ctx)->regs [ARMREG_FP] = (host_mgreg_t)(gsize)bp; } while (0);
473 #define MONO_CONTEXT_SET_SP(ctx,bp) do { (ctx)->regs [ARMREG_SP] = (host_mgreg_t)(gsize)bp; } while (0);
475 #define MONO_CONTEXT_GET_IP(ctx) (gpointer)(gsize)((ctx)->pc)
476 #define MONO_CONTEXT_GET_BP(ctx) (gpointer)(gsize)((ctx)->regs [ARMREG_FP])
477 #define MONO_CONTEXT_GET_SP(ctx) (gpointer)(gsize)((ctx)->regs [ARMREG_SP])
479 #if defined (HOST_TVOS)
481 #define MONO_CONTEXT_GET_CURRENT(ctx) do { \
482 arm_unified_thread_state_t thread_state; \
483 arm_neon_state64_t thread_fpstate; \
484 int state_flavor = ARM_UNIFIED_THREAD_STATE; \
485 int fpstate_flavor = ARM_NEON_STATE64; \
486 unsigned state_count = ARM_UNIFIED_THREAD_STATE_COUNT; \
487 unsigned fpstate_count = ARM_NEON_STATE64_COUNT; \
488 thread_port_t self = mach_thread_self (); \
489 kern_return_t ret = thread_get_state (self, state_flavor, (thread_state_t) &thread_state, &state_count); \
490 g_assert (ret == 0); \
491 ret = thread_get_state (self, fpstate_flavor, (thread_state_t) &thread_fpstate, &fpstate_count); \
492 g_assert (ret == 0); \
493 mono_mach_arch_thread_states_to_mono_context ((thread_state_t) &thread_state, (thread_state_t) &thread_fpstate, &ctx); \
494 mach_port_deallocate (current_task (), self); \
497 #elif defined(HOST_WATCHOS)
499 #define MONO_CONTEXT_GET_CURRENT(ctx) do { \
501 ctx.regs [ARMREG_SP] = (host_mgreg_t)(gsize)&_dummy; \
506 #define MONO_CONTEXT_GET_CURRENT(ctx) do { \
507 __asm__ __volatile__( \
509 "stp x0, x1, [x16], #16\n" \
510 "stp x2, x3, [x16], #16\n" \
511 "stp x4, x5, [x16], #16\n" \
512 "stp x6, x7, [x16], #16\n" \
513 "stp x8, x9, [x16], #16\n" \
514 "stp x10, x11, [x16], #16\n" \
515 "stp x12, x13, [x16], #16\n" \
516 "stp x14, x15, [x16], #16\n" \
517 "stp xzr, x17, [x16], #16\n" \
518 "stp x18, x19, [x16], #16\n" \
519 "stp x20, x21, [x16], #16\n" \
520 "stp x22, x23, [x16], #16\n" \
521 "stp x24, x25, [x16], #16\n" \
522 "stp x26, x27, [x16], #16\n" \
523 "stp x28, x29, [x16], #16\n" \
524 "stp x30, xzr, [x16], #8\n" \
526 "str x30, [x16], #8\n" \
527 "stp q0, q1, [x16], #32\n" \
528 "stp q2, q3, [x16], #32\n" \
529 "stp q4, q5, [x16], #32\n" \
530 "stp q6, q7, [x16], #32\n" \
531 "stp q8, q9, [x16], #32\n" \
532 "stp q10, q11, [x16], #32\n" \
533 "stp q12, q13, [x16], #32\n" \
534 "stp q14, q15, [x16], #32\n" \
535 "stp q16, q17, [x16], #32\n" \
536 "stp q18, q19, [x16], #32\n" \
537 "stp q20, q21, [x16], #32\n" \
538 "stp q22, q23, [x16], #32\n" \
539 "stp q24, q25, [x16], #32\n" \
540 "stp q26, q27, [x16], #32\n" \
541 "stp q28, q29, [x16], #32\n" \
542 "stp q30, q31, [x16], #32\n" \
545 : "x16", "x30", "memory" \
547 __asm__ __volatile__( \
558 #define MONO_ARCH_HAS_MONO_CONTEXT 1
560 #elif defined(__mono_ppc__) /* defined(__arm__) */
562 /* we define our own structure and we'll copy the data
563 * from sigcontext/ucontext/mach when we need it.
564 * This also makes us save stack space and time when copying
565 * We might also want to add an additional field to propagate
566 * the original context from the signal handler.
568 #ifdef __mono_ppc64__
573 host_mgreg_t regs
[32];
577 /* we have the stack pointer, not the base pointer in sigcontext */
578 #define MONO_CONTEXT_SET_IP(ctx,ip) do { (ctx)->sc_ir = (gulong)(gsize)ip; } while (0);
579 #define MONO_CONTEXT_SET_BP(ctx,bp) do { (ctx)->sc_sp = (gulong)(gsize)bp; } while (0);
580 #define MONO_CONTEXT_SET_SP(ctx,sp) do { (ctx)->sc_sp = (gulong)(gsize)sp; } while (0);
582 #define MONO_CONTEXT_GET_IP(ctx) ((gpointer)(gsize)((ctx)->sc_ir))
583 #define MONO_CONTEXT_GET_BP(ctx) ((gpointer)(gsize)((ctx)->regs [ppc_r31]))
584 #define MONO_CONTEXT_GET_SP(ctx) ((gpointer)(gsize)((ctx)->sc_sp))
586 #define MONO_CONTEXT_GET_CURRENT(ctx) \
587 __asm__ __volatile__( \
590 "std 0, 8*0+16(%0)\n" \
591 "std 1, 8*1+16(%0)\n" \
592 "std 2, 8*2+16(%0)\n" \
593 "std 3, 8*3+16(%0)\n" \
594 "std 4, 8*4+16(%0)\n" \
595 "std 5, 8*5+16(%0)\n" \
596 "std 6, 8*6+16(%0)\n" \
597 "std 7, 8*7+16(%0)\n" \
598 "std 8, 8*8+16(%0)\n" \
599 "std 9, 8*9+16(%0)\n" \
600 "std 10, 8*10+16(%0)\n" \
601 "std 11, 8*11+16(%0)\n" \
602 "std 12, 8*12+16(%0)\n" \
603 "std 13, 8*13+16(%0)\n" \
604 "std 14, 8*14+16(%0)\n" \
605 "std 15, 8*15+16(%0)\n" \
606 "std 16, 8*16+16(%0)\n" \
607 "std 17, 8*17+16(%0)\n" \
608 "std 18, 8*18+16(%0)\n" \
609 "std 19, 8*19+16(%0)\n" \
610 "std 20, 8*20+16(%0)\n" \
611 "std 21, 8*21+16(%0)\n" \
612 "std 22, 8*22+16(%0)\n" \
613 "std 23, 8*23+16(%0)\n" \
614 "std 24, 8*24+16(%0)\n" \
615 "std 25, 8*25+16(%0)\n" \
616 "std 26, 8*26+16(%0)\n" \
617 "std 27, 8*27+16(%0)\n" \
618 "std 28, 8*28+16(%0)\n" \
619 "std 29, 8*29+16(%0)\n" \
620 "std 30, 8*30+16(%0)\n" \
621 "std 31, 8*31+16(%0)\n" \
622 "stfd 0, 8*0+8*32+16(%0)\n" \
623 "stfd 1, 8*1+8*32+16(%0)\n" \
624 "stfd 2, 8*2+8*32+16(%0)\n" \
625 "stfd 3, 8*3+8*32+16(%0)\n" \
626 "stfd 4, 8*4+8*32+16(%0)\n" \
627 "stfd 5, 8*5+8*32+16(%0)\n" \
628 "stfd 6, 8*6+8*32+16(%0)\n" \
629 "stfd 7, 8*7+8*32+16(%0)\n" \
630 "stfd 8, 8*8+8*32+16(%0)\n" \
631 "stfd 9, 8*9+8*32+16(%0)\n" \
632 "stfd 10, 8*10+8*32+16(%0)\n" \
633 "stfd 11, 8*11+8*32+16(%0)\n" \
634 "stfd 12, 8*12+8*32+16(%0)\n" \
635 "stfd 13, 8*13+8*32+16(%0)\n" \
636 "stfd 14, 8*14+8*32+16(%0)\n" \
637 "stfd 15, 8*15+8*32+16(%0)\n" \
638 "stfd 16, 8*16+8*32+16(%0)\n" \
639 "stfd 17, 8*17+8*32+16(%0)\n" \
640 "stfd 18, 8*18+8*32+16(%0)\n" \
641 "stfd 19, 8*19+8*32+16(%0)\n" \
642 "stfd 20, 8*20+8*32+16(%0)\n" \
643 "stfd 21, 8*21+8*32+16(%0)\n" \
644 "stfd 22, 8*22+8*32+16(%0)\n" \
645 "stfd 23, 8*23+8*32+16(%0)\n" \
646 "stfd 24, 8*24+8*32+16(%0)\n" \
647 "stfd 25, 8*25+8*32+16(%0)\n" \
648 "stfd 26, 8*26+8*32+16(%0)\n" \
649 "stfd 27, 8*27+8*32+16(%0)\n" \
650 "stfd 28, 8*28+8*32+16(%0)\n" \
651 "stfd 29, 8*29+8*32+16(%0)\n" \
652 "stfd 30, 8*30+8*32+16(%0)\n" \
653 "stfd 31, 8*31+8*32+16(%0)\n" \
658 #else /* !defined(__mono_ppc64__) */
661 host_mgreg_t sc_ir
; // pc
662 host_mgreg_t sc_sp
; // r1
663 host_mgreg_t regs
[32];
667 /* we have the stack pointer, not the base pointer in sigcontext */
668 #define MONO_CONTEXT_SET_IP(ctx,ip) do { (ctx)->sc_ir = (host_mgreg_t)(gsize)ip; } while (0);
669 /* FIXME: should be called SET_SP */
670 #define MONO_CONTEXT_SET_BP(ctx,bp) do { (ctx)->sc_sp = (host_mgreg_t)(gsize)bp; } while (0);
671 #define MONO_CONTEXT_SET_SP(ctx,sp) do { (ctx)->sc_sp = (host_mgreg_t)(gsize)sp; } while (0);
673 #define MONO_CONTEXT_GET_IP(ctx) ((gpointer)(gsize)((ctx)->sc_ir))
674 #define MONO_CONTEXT_GET_BP(ctx) ((gpointer)(gsize)((ctx)->regs [ppc_r31]))
675 #define MONO_CONTEXT_GET_SP(ctx) ((gpointer)(gsize)((ctx)->sc_sp))
677 #define MONO_CONTEXT_GET_CURRENT(ctx) \
678 __asm__ __volatile__( \
681 "stw 0, 4*0+8(%0)\n" \
682 "stw 1, 4*1+8(%0)\n" \
683 "stw 2, 4*2+8(%0)\n" \
684 "stw 3, 4*3+8(%0)\n" \
685 "stw 4, 4*4+8(%0)\n" \
686 "stw 5, 4*5+8(%0)\n" \
687 "stw 6, 4*6+8(%0)\n" \
688 "stw 7, 4*7+8(%0)\n" \
689 "stw 8, 4*8+8(%0)\n" \
690 "stw 9, 4*9+8(%0)\n" \
691 "stw 10, 4*10+8(%0)\n" \
692 "stw 11, 4*11+8(%0)\n" \
693 "stw 12, 4*12+8(%0)\n" \
694 "stw 13, 4*13+8(%0)\n" \
695 "stw 14, 4*14+8(%0)\n" \
696 "stw 15, 4*15+8(%0)\n" \
697 "stw 16, 4*16+8(%0)\n" \
698 "stw 17, 4*17+8(%0)\n" \
699 "stw 18, 4*18+8(%0)\n" \
700 "stw 19, 4*19+8(%0)\n" \
701 "stw 20, 4*20+8(%0)\n" \
702 "stw 21, 4*21+8(%0)\n" \
703 "stw 22, 4*22+8(%0)\n" \
704 "stw 23, 4*23+8(%0)\n" \
705 "stw 24, 4*24+8(%0)\n" \
706 "stw 25, 4*25+8(%0)\n" \
707 "stw 26, 4*26+8(%0)\n" \
708 "stw 27, 4*27+8(%0)\n" \
709 "stw 28, 4*28+8(%0)\n" \
710 "stw 29, 4*29+8(%0)\n" \
711 "stw 30, 4*30+8(%0)\n" \
712 "stw 31, 4*31+8(%0)\n" \
713 "stfd 0, 8*0+4*32+8(%0)\n" \
714 "stfd 1, 8*1+4*32+8(%0)\n" \
715 "stfd 2, 8*2+4*32+8(%0)\n" \
716 "stfd 3, 8*3+4*32+8(%0)\n" \
717 "stfd 4, 8*4+4*32+8(%0)\n" \
718 "stfd 5, 8*5+4*32+8(%0)\n" \
719 "stfd 6, 8*6+4*32+8(%0)\n" \
720 "stfd 7, 8*7+4*32+8(%0)\n" \
721 "stfd 8, 8*8+4*32+8(%0)\n" \
722 "stfd 9, 8*9+4*32+8(%0)\n" \
723 "stfd 10, 8*10+4*32+8(%0)\n" \
724 "stfd 11, 8*11+4*32+8(%0)\n" \
725 "stfd 12, 8*12+4*32+8(%0)\n" \
726 "stfd 13, 8*13+4*32+8(%0)\n" \
727 "stfd 14, 8*14+4*32+8(%0)\n" \
728 "stfd 15, 8*15+4*32+8(%0)\n" \
729 "stfd 16, 8*16+4*32+8(%0)\n" \
730 "stfd 17, 8*17+4*32+8(%0)\n" \
731 "stfd 18, 8*18+4*32+8(%0)\n" \
732 "stfd 19, 8*19+4*32+8(%0)\n" \
733 "stfd 20, 8*20+4*32+8(%0)\n" \
734 "stfd 21, 8*21+4*32+8(%0)\n" \
735 "stfd 22, 8*22+4*32+8(%0)\n" \
736 "stfd 23, 8*23+4*32+8(%0)\n" \
737 "stfd 24, 8*24+4*32+8(%0)\n" \
738 "stfd 25, 8*25+4*32+8(%0)\n" \
739 "stfd 26, 8*26+4*32+8(%0)\n" \
740 "stfd 27, 8*27+4*32+8(%0)\n" \
741 "stfd 28, 8*28+4*32+8(%0)\n" \
742 "stfd 29, 8*29+4*32+8(%0)\n" \
743 "stfd 30, 8*30+4*32+8(%0)\n" \
744 "stfd 31, 8*31+4*32+8(%0)\n" \
751 #define MONO_ARCH_HAS_MONO_CONTEXT 1
753 #elif defined(__sparc__) || defined(sparc) /* defined(__mono_ppc__) */
755 typedef struct MonoContext
{
756 host_mgreg_t regs
[15];
762 #define MONO_CONTEXT_SET_IP(ctx,eip) do { (ctx)->ip = (gpointer)(eip); } while (0);
763 #define MONO_CONTEXT_SET_BP(ctx,ebp) do { (ctx)->fp = (gpointer*)(ebp); } while (0);
764 #define MONO_CONTEXT_SET_SP(ctx,esp) do { (ctx)->sp = (gpointer*)(esp); } while (0);
766 #define MONO_CONTEXT_GET_IP(ctx) ((gpointer)((ctx)->ip))
767 #define MONO_CONTEXT_GET_BP(ctx) ((gpointer)((ctx)->fp))
768 #define MONO_CONTEXT_GET_SP(ctx) ((gpointer)((ctx)->sp))
771 #define MONO_CONTEXT_GET_CURRENT(ctx) \
772 __asm__ __volatile__( \
774 "st %%g2,[%0+0x08]\n" \
775 "st %%g3,[%0+0x10]\n" \
776 "st %%g4,[%0+0x18]\n" \
777 "st %%g5,[%0+0x20]\n" \
778 "st %%g6,[%0+0x28]\n" \
779 "st %%g7,[%0+0x30]\n" \
780 "st %%o0,[%0+0x38]\n" \
781 "st %%o1,[%0+0x40]\n" \
782 "st %%o2,[%0+0x48]\n" \
783 "st %%o3,[%0+0x50]\n" \
784 "st %%o4,[%0+0x58]\n" \
785 "st %%o5,[%0+0x60]\n" \
786 "st %%o6,[%0+0x68]\n" \
787 "st %%o7,[%0+0x70]\n" \
793 #define MONO_CONTEXT_GET_CURRENT(ctx) \
794 __asm__ __volatile__( \
796 "st %%g2,[%0+0x04]\n" \
797 "st %%g3,[%0+0x08]\n" \
798 "st %%g4,[%0+0x0c]\n" \
799 "st %%g5,[%0+0x10]\n" \
800 "st %%g6,[%0+0x14]\n" \
801 "st %%g7,[%0+0x18]\n" \
802 "st %%o0,[%0+0x1c]\n" \
803 "st %%o1,[%0+0x20]\n" \
804 "st %%o2,[%0+0x24]\n" \
805 "st %%o3,[%0+0x28]\n" \
806 "st %%o4,[%0+0x2c]\n" \
807 "st %%o5,[%0+0x30]\n" \
808 "st %%o6,[%0+0x34]\n" \
809 "st %%o7,[%0+0x38]\n" \
816 #define MONO_ARCH_HAS_MONO_CONTEXT 1
818 #elif ((defined(__mips__) && !defined(MONO_CROSS_COMPILE)) || (defined(TARGET_MIPS))) && SIZEOF_REGISTER == 4
820 #define MONO_ARCH_HAS_MONO_CONTEXT 1
822 #include <mono/arch/mips/mips-codegen.h>
826 host_mgreg_t sc_regs
[32];
827 gfloat sc_fpregs
[32];
830 #define MONO_CONTEXT_SET_IP(ctx,ip) do { (ctx)->sc_pc = (host_mgreg_t)(gsize)(ip); } while (0);
831 #define MONO_CONTEXT_SET_BP(ctx,bp) do { (ctx)->sc_regs[mips_fp] = (host_mgreg_t)(gsize)(bp); } while (0);
832 #define MONO_CONTEXT_SET_SP(ctx,sp) do { (ctx)->sc_regs[mips_sp] = (host_mgreg_t)(gsize)(sp); } while (0);
834 #define MONO_CONTEXT_GET_IP(ctx) ((gpointer)(gsize)((ctx)->sc_pc))
835 #define MONO_CONTEXT_GET_BP(ctx) ((gpointer)(gsize)((ctx)->sc_regs[mips_fp]))
836 #define MONO_CONTEXT_GET_SP(ctx) ((gpointer)(gsize)((ctx)->sc_regs[mips_sp]))
838 #define MONO_CONTEXT_GET_CURRENT(ctx) \
839 __asm__ __volatile__( \
850 "sw $10,40(%0)\n\t" \
851 "sw $11,44(%0)\n\t" \
852 "sw $12,48(%0)\n\t" \
853 "sw $13,52(%0)\n\t" \
854 "sw $14,56(%0)\n\t" \
855 "sw $15,60(%0)\n\t" \
856 "sw $16,64(%0)\n\t" \
857 "sw $17,68(%0)\n\t" \
858 "sw $18,72(%0)\n\t" \
859 "sw $19,76(%0)\n\t" \
860 "sw $20,80(%0)\n\t" \
861 "sw $21,84(%0)\n\t" \
862 "sw $22,88(%0)\n\t" \
863 "sw $23,92(%0)\n\t" \
864 "sw $24,96(%0)\n\t" \
865 "sw $25,100(%0)\n\t" \
866 "sw $26,104(%0)\n\t" \
867 "sw $27,108(%0)\n\t" \
868 "sw $28,112(%0)\n\t" \
869 "sw $29,116(%0)\n\t" \
870 "sw $30,120(%0)\n\t" \
871 "sw $31,124(%0)\n\t" \
872 : : "r" (&(ctx).sc_regs [0]) \
876 #elif defined(__s390x__)
878 #define MONO_ARCH_HAS_MONO_CONTEXT 1
880 #include <sys/ucontext.h>
882 #if __GLIBC_PREREQ(2, 27)
883 typedef ucontext_t MonoContext
;
885 typedef struct ucontext MonoContext
;
888 #define MONO_CONTEXT_SET_IP(ctx,ip) \
890 (ctx)->uc_mcontext.gregs[14] = (unsigned long)ip; \
891 (ctx)->uc_mcontext.psw.addr = (unsigned long)ip; \
894 #define MONO_CONTEXT_SET_SP(ctx,bp) MONO_CONTEXT_SET_BP((ctx),(bp))
895 #define MONO_CONTEXT_SET_BP(ctx,bp) \
897 (ctx)->uc_mcontext.gregs[15] = (unsigned long)bp; \
898 (ctx)->uc_stack.ss_sp = (void*)bp; \
901 #define MONO_CONTEXT_GET_IP(ctx) (gpointer) (ctx)->uc_mcontext.psw.addr
902 #define MONO_CONTEXT_GET_SP(ctx) ((gpointer)((ctx)->uc_mcontext.gregs[15]))
903 #define MONO_CONTEXT_GET_BP(ctx) ((gpointer)((ctx)->uc_mcontext.gregs[11]))
905 #define MONO_CONTEXT_GET_CURRENT(ctx) \
906 __asm__ __volatile__( \
907 "stmg %%r0,%%r15,0(%0)\n" \
910 "std %%f2,16(%1)\n" \
911 "std %%f3,24(%1)\n" \
912 "std %%f4,32(%1)\n" \
913 "std %%f5,40(%1)\n" \
914 "std %%f6,48(%1)\n" \
915 "std %%f7,56(%1)\n" \
916 "std %%f8,64(%1)\n" \
917 "std %%f9,72(%1)\n" \
918 "std %%f10,80(%1)\n" \
919 "std %%f11,88(%1)\n" \
920 "std %%f12,96(%1)\n" \
921 "std %%f13,104(%1)\n" \
922 "std %%f14,112(%1)\n" \
923 "std %%f15,120(%1)\n" \
924 : : "r" (&(ctx).uc_mcontext.gregs[0]), \
925 "r" (&(ctx).uc_mcontext.fpregs.fprs[0]) \
929 #elif (defined (HOST_RISCV) && !defined (MONO_CROSS_COMPILE)) || defined (TARGET_RISCV)
931 #include <mono/arch/riscv/riscv-codegen.h>
934 host_mgreg_t gregs
[RISCV_N_GREGS
]; // [0] contains pc since x0 is hard-wired to zero anyway.
935 double fregs
[RISCV_N_FREGS
* 2 + 2]; // [32] contains fcsr (32 bits), the rest is for quad-precision values (currently unused).
938 #define MONO_CONTEXT_SET_IP(ctx, ip) do { (ctx)->gregs [RISCV_ZERO] = (host_mgreg_t) (ip); } while (0)
939 #define MONO_CONTEXT_SET_BP(ctx, bp) do { (ctx)->gregs [RISCV_FP] = (host_mgreg_t) (bp); } while (0)
940 #define MONO_CONTEXT_SET_SP(ctx, sp) do { (ctx)->gregs [RISCV_SP] = (host_mgreg_t) (sp); } while (0)
942 #define MONO_CONTEXT_GET_IP(ctx) ((gpointer) ((ctx)->gregs [RISCV_ZERO]))
943 #define MONO_CONTEXT_GET_BP(ctx) ((gpointer) ((ctx)->gregs [RISCV_FP]))
944 #define MONO_CONTEXT_GET_SP(ctx) ((gpointer) ((ctx)->gregs [RISCV_SP]))
946 #ifdef TARGET_RISCV64
947 #define _RISCV_STR "sd"
948 #define _RISCV_SZ "8"
950 #define _RISCV_STR "sw"
951 #define _RISCV_SZ "4"
954 #define MONO_CONTEXT_GET_CURRENT(ctx) \
956 __asm__ __volatile__ ( \
957 _RISCV_STR " x1, " _RISCV_SZ "*1(%0)\n" \
958 _RISCV_STR " x2, " _RISCV_SZ "*2(%0)\n" \
959 _RISCV_STR " x3, " _RISCV_SZ "*3(%0)\n" \
960 _RISCV_STR " x4, " _RISCV_SZ "*4(%0)\n" \
961 _RISCV_STR " x5, " _RISCV_SZ "*5(%0)\n" \
962 _RISCV_STR " x6, " _RISCV_SZ "*6(%0)\n" \
963 _RISCV_STR " x7, " _RISCV_SZ "*7(%0)\n" \
964 _RISCV_STR " x8, " _RISCV_SZ "*8(%0)\n" \
965 _RISCV_STR " x9, " _RISCV_SZ "*9(%0)\n" \
966 _RISCV_STR " x10, " _RISCV_SZ "*10(%0)\n" \
967 _RISCV_STR " x11, " _RISCV_SZ "*11(%0)\n" \
968 _RISCV_STR " x12, " _RISCV_SZ "*12(%0)\n" \
969 _RISCV_STR " x13, " _RISCV_SZ "*13(%0)\n" \
970 _RISCV_STR " x14, " _RISCV_SZ "*14(%0)\n" \
971 _RISCV_STR " x15, " _RISCV_SZ "*15(%0)\n" \
972 _RISCV_STR " x16, " _RISCV_SZ "*16(%0)\n" \
973 _RISCV_STR " x17, " _RISCV_SZ "*17(%0)\n" \
974 _RISCV_STR " x18, " _RISCV_SZ "*18(%0)\n" \
975 _RISCV_STR " x19, " _RISCV_SZ "*19(%0)\n" \
976 _RISCV_STR " x20, " _RISCV_SZ "*20(%0)\n" \
977 _RISCV_STR " x21, " _RISCV_SZ "*21(%0)\n" \
978 _RISCV_STR " x22, " _RISCV_SZ "*22(%0)\n" \
979 _RISCV_STR " x23, " _RISCV_SZ "*23(%0)\n" \
980 _RISCV_STR " x24, " _RISCV_SZ "*24(%0)\n" \
981 _RISCV_STR " x25, " _RISCV_SZ "*25(%0)\n" \
982 _RISCV_STR " x26, " _RISCV_SZ "*26(%0)\n" \
983 _RISCV_STR " x27, " _RISCV_SZ "*27(%0)\n" \
984 _RISCV_STR " x28, " _RISCV_SZ "*28(%0)\n" \
985 _RISCV_STR " x29, " _RISCV_SZ "*29(%0)\n" \
986 _RISCV_STR " x30, " _RISCV_SZ "*30(%0)\n" \
987 _RISCV_STR " x31, " _RISCV_SZ "*31(%0)\n" \
989 : "r" (&(ctx).gregs) \
992 __asm__ __volatile__ ( \
994 "fsd f0, 8*0(%0)\n" \
995 "fsd f1, 8*1(%0)\n" \
996 "fsd f2, 8*2(%0)\n" \
997 "fsd f3, 8*3(%0)\n" \
998 "fsd f4, 8*4(%0)\n" \
999 "fsd f5, 8*5(%0)\n" \
1000 "fsd f6, 8*6(%0)\n" \
1001 "fsd f7, 8*7(%0)\n" \
1002 "fsd f8, 8*8(%0)\n" \
1003 "fsd f9, 8*9(%0)\n" \
1004 "fsd f10, 8*10(%0)\n" \
1005 "fsd f11, 8*11(%0)\n" \
1006 "fsd f12, 8*12(%0)\n" \
1007 "fsd f13, 8*13(%0)\n" \
1008 "fsd f14, 8*14(%0)\n" \
1009 "fsd f15, 8*15(%0)\n" \
1010 "fsd f16, 8*16(%0)\n" \
1011 "fsd f17, 8*17(%0)\n" \
1012 "fsd f18, 8*18(%0)\n" \
1013 "fsd f19, 8*19(%0)\n" \
1014 "fsd f20, 8*20(%0)\n" \
1015 "fsd f21, 8*21(%0)\n" \
1016 "fsd f22, 8*22(%0)\n" \
1017 "fsd f23, 8*23(%0)\n" \
1018 "fsd f24, 8*24(%0)\n" \
1019 "fsd f25, 8*25(%0)\n" \
1020 "fsd f26, 8*26(%0)\n" \
1021 "fsd f27, 8*27(%0)\n" \
1022 "fsd f28, 8*28(%0)\n" \
1023 "fsd f29, 8*29(%0)\n" \
1024 "fsd f30, 8*30(%0)\n" \
1025 "fsd f31, 8*31(%0)\n" \
1026 "sw t0, 8*32(%0)\n" \
1028 : "r" (&(ctx).fregs) \
1031 __asm__ __volatile__ ( \
1033 _RISCV_STR " t0, (%0)\n" \
1035 : "r" (&(ctx).gregs [0]) \
1040 #define MONO_ARCH_HAS_MONO_CONTEXT (1)
1044 #error "Implement mono-context for the current arch"
1049 * The naming is misleading, the SIGCTX argument should be the platform's context
1050 * structure (ucontext_c on posix, CONTEXT on windows).
1052 void mono_sigctx_to_monoctx (void *sigctx
, MonoContext
*mctx
);
1055 * This will not completely initialize SIGCTX since MonoContext contains less
1056 * information that the system context. The caller should obtain a SIGCTX from
1057 * the system, and use this function to override the parts of it which are
1058 * also in MonoContext.
1060 void mono_monoctx_to_sigctx (MonoContext
*mctx
, void *sigctx
);
1062 #endif /* __MONO_MONO_CONTEXT_H__ */