[Mono-dev] [PATCH] use offsetof in powerpc mono_arch_handle_altstack_exception

Olaf Hering olh at novell.com
Tue Jul 15 08:34:49 EDT 2008


Use offsetof() instead of own logic for regs offset in
mono_arch_handle_altstack_exception()

---
 mono/mini/exceptions-ppc.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

--- a/mono/mini/exceptions-ppc.c
+++ b/mono/mini/exceptions-ppc.c
@@ -12,6 +12,7 @@
 #include <glib.h>
 #include <signal.h>
 #include <string.h>
+#include <stddef.h>
 #include <ucontext.h>
 
 #include <mono/arch/ppc/ppc-codegen.h>
@@ -790,7 +791,7 @@ mono_arch_handle_altstack_exception (voi
 	uc_copy = (ucontext_t*)(sp + 16);
 	memcpy (uc_copy, uc, sizeof (os_ucontext));
 #ifdef __linux__
-	uc_copy->uc_mcontext.uc_regs = (char*)uc_copy + ((char*)uc->uc_mcontext.uc_regs - (char*)uc);
+	uc_copy->uc_mcontext.uc_regs = (char*)uc_copy + offsetof(ucontext_t, uc_mcontext.uc_regs);
 #endif
 	/* at the return form the signal handler execution starts in altstack_handle_and_restore() */
 	UCONTEXT_REG_LNK(uc) = UCONTEXT_REG_NIP(uc);


More information about the Mono-devel-list mailing list