[Mono-dev] [PATCH 04/12] mini: Add support for BeOS-style signal handlers

Andreas Färber andreas.faerber at web.de
Fri Mar 26 09:29:57 EDT 2010


Haiku does not support SA_SIGINFO-style signal handlers but supports
a BeOS extension to signal handlers.

This commit is licensed under the MIT X11 license.
---
 mono/mini/ChangeLog  |    7 +++++++
 mono/mini/mini-x86.h |   18 ++++++++++++++++++
 mono/mini/mini.h     |    6 ++++++
 3 files changed, 31 insertions(+), 0 deletions(-)

diff --git a/mono/mini/ChangeLog b/mono/mini/ChangeLog
index 19f7ff6..0624c69 100755
--- a/mono/mini/ChangeLog
+++ b/mono/mini/ChangeLog
@@ -1,5 +1,12 @@
 2010-03-26  Andreas Faerber  <andreas.faerber at web.de>
 
+	* mini.h, mini-x86.h: Suppress sigaction for Haiku, add support for
+	BeOS-style signal handlers.
+
+	Code is contributed under MIT/X11 license.
+
+2010-03-26  Andreas Faerber  <andreas.faerber at web.de>
+
 	* Makefile.am (version.h): Check for pure .git directory only,
 	fixes SVN revision when using git without git-svn.
 
diff --git a/mono/mini/mini-x86.h b/mono/mini/mini-x86.h
index bc7e0df..ab892d6 100644
--- a/mono/mini/mini-x86.h
+++ b/mono/mini/mini-x86.h
@@ -44,6 +44,12 @@ LONG CALLBACK seh_handler(EXCEPTION_POINTERS* ep);
 
 #endif /* HOST_WIN32 */
 
+#ifdef __HAIKU__
+struct sigcontext {
+	vregs regs;
+};
+#endif /* __HAIKU__ */
+
 #if defined( __linux__) || defined(__sun) || defined(__APPLE__) || defined(__NetBSD__) || \
        defined(__FreeBSD__) || defined(__OpenBSD__)
 #define MONO_ARCH_USE_SIGACTION
@@ -59,7 +65,9 @@ LONG CALLBACK seh_handler(EXCEPTION_POINTERS* ep);
 #ifndef __sun
 #define MONO_ARCH_SIGSEGV_ON_ALTSTACK
 #endif
+#ifndef __HAIKU__
 #define MONO_ARCH_USE_SIGACTION
+#endif /* __HAIKU__ */
 
 #endif /* HAVE_WORKING_SIGALTSTACK */
 #endif /* !HOST_WIN32 */
@@ -161,6 +169,16 @@ typedef struct {
 # define SC_ESP sc_esp
 # define SC_EDI sc_edi
 # define SC_ESI sc_esi
+#elif defined(__HAIKU__)
+# define SC_EAX regs.eax
+# define SC_EBX regs._reserved_2[2]
+# define SC_ECX regs.ecx
+# define SC_EDX regs.edx
+# define SC_EBP regs.ebp
+# define SC_EIP regs.eip
+# define SC_ESP regs.esp
+# define SC_EDI regs._reserved_2[0]
+# define SC_ESI regs._reserved_2[1]
 #else
 # define SC_EAX eax
 # define SC_EBX ebx
diff --git a/mono/mini/mini.h b/mono/mini/mini.h
index a97bfdf..8942bd2 100644
--- a/mono/mini/mini.h
+++ b/mono/mini/mini.h
@@ -2092,6 +2092,9 @@ gboolean mono_gdb_render_native_backtraces (void) MONO_INTERNAL;
 #ifdef MONO_ARCH_USE_SIGACTION
 #define GET_CONTEXT \
     void *ctx = context;
+#elif defined(__HAIKU__)
+#define GET_CONTEXT \
+	void *ctx = &regs;
 #else
 #define GET_CONTEXT \
 	void **_p = (void **)&_dummy; \
@@ -2106,6 +2109,9 @@ gboolean mono_gdb_render_native_backtraces (void) MONO_INTERNAL;
 #elif defined(HOST_WIN32)
 #define SIG_HANDLER_SIGNATURE(ftn) ftn (int _dummy, EXCEPTION_RECORD *info, void *context)
 #define SIG_HANDLER_PARAMS _dummy, info, context
+#elif defined(__HAIKU__)
+#define SIG_HANDLER_SIGNATURE(ftn) ftn (int _dummy, void *userData, vregs regs)
+#define SIG_HANDLER_PARAMS _dummy, userData, regs
 #else
 #define SIG_HANDLER_SIGNATURE(ftn) ftn (int _dummy)
 #define SIG_HANDLER_PARAMS _dummy
-- 
1.6.5.3



More information about the Mono-devel-list mailing list