[PATCH] Signal handling / register passing for NETBSD
Marcus Meissner
marcus at jet.franken.de
Sun Oct 22 14:13:58 CDT 2006
---
dlls/ntdll/signal_i386.c | 47 +++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 46 insertions(+), 1 deletions(-)
1cebf982b311c3fef1d6bd50ea3ec496943c1bb4
diff --git a/dlls/ntdll/signal_i386.c b/dlls/ntdll/signal_i386.c
index 8166124..ad952cf 100644
--- a/dlls/ntdll/signal_i386.c
+++ b/dlls/ntdll/signal_i386.c
@@ -163,7 +163,7 @@ typedef struct trapframe SIGCONTEXT;
#endif /* bsdi */
-#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__)
+#if (defined(__NetBSD__) && (__NetBSD_Version__ < 200000000)) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__)
typedef struct sigcontext SIGCONTEXT;
@@ -268,6 +268,43 @@ typedef ucontext_t SIGCONTEXT;
#endif /* __APPLE__ */
+#if defined(__NetBSD__) && (__NetBSD_Version__ >= 200000000)
+# include <sys/ucontext.h>
+# include <sys/types.h>
+# include <signal.h>
+
+typedef ucontext_t SIGCONTEXT;
+
+#define EAX_sig(context) ((context)->uc_mcontext.__gregs[_REG_EAX])
+#define EBX_sig(context) ((context)->uc_mcontext.__gregs[_REG_EBX])
+#define ECX_sig(context) ((context)->uc_mcontext.__gregs[_REG_ECX])
+#define EDX_sig(context) ((context)->uc_mcontext.__gregs[_REG_EDX])
+#define ESI_sig(context) ((context)->uc_mcontext.__gregs[_REG_ESI])
+#define EDI_sig(context) ((context)->uc_mcontext.__gregs[_REG_EDI])
+#define EBP_sig(context) ((context)->uc_mcontext.__gregs[_REG_EBP])
+
+#define CS_sig(context) ((context)->uc_mcontext.__gregs[_REG_CS])
+#define DS_sig(context) ((context)->uc_mcontext.__gregs[_REG_DS])
+#define ES_sig(context) ((context)->uc_mcontext.__gregs[_REG_ES])
+#define FS_sig(context) ((context)->uc_mcontext.__gregs[_REG_FS])
+#define GS_sig(context) ((context)->uc_mcontext.__gregs[_REG_GS])
+#define SS_sig(context) ((context)->uc_mcontext.__gregs[_REG_SS])
+
+#define EFL_sig(context) ((context)->uc_mcontext.__gregs[_REG_EFL])
+
+#define EIP_sig(context) (*((unsigned long*)&(context)->uc_mcontext.__gregs[_REG_EIP]))
+#define ESP_sig(context) (*((unsigned long*)&(context)->uc_mcontext.__gregs[_REG_ESP]))
+
+#define TRAP_sig(context) ((context)->uc_mcontext.__gregs[_REG_TRAPNO])
+#define ERROR_sig(context) ((context)->uc_mcontext.__gregs[_REG_ERR])
+
+#define FAULT_ADDRESS (__siginfo->si_addr)
+
+#define HANDLER_DEF(name) void name( int __signal, siginfo_t *__siginfo, SIGCONTEXT *__context )
+#define HANDLER_CONTEXT (__context)
+
+#endif /* __NetBSD__ */
+
#include "wine/exception.h"
#include "wine/debug.h"
@@ -303,8 +340,10 @@ enum i386_trap_code
TRAP_x86_PAGEFLT = T_PAGEFLT, /* Page fault */
TRAP_x86_ARITHTRAP = T_ARITHTRAP, /* Floating point exception */
TRAP_x86_ALIGNFLT = T_ALIGNFLT, /* Alignment check exception */
+#if !defined(__NetBSD__)
TRAP_x86_MCHK = T_MCHK, /* Machine check exception */
TRAP_x86_CACHEFLT = T_XMMFLT /* Cache flush exception */
+#endif
#else
TRAP_x86_DIVIDE = 0, /* Division by zero exception */
TRAP_x86_TRCTRAP = 1, /* Single-step exception */
@@ -1148,8 +1187,10 @@ static void segv_handler( int signal, si
case TRAP_x86_DNA: /* Device not available exception */
case TRAP_x86_DOUBLEFLT: /* Double fault exception */
case TRAP_x86_TSSFLT: /* Invalid TSS exception */
+#if !defined(__NetBSD__)
case TRAP_x86_MCHK: /* Machine check exception */
case TRAP_x86_CACHEFLT: /* Cache flush exception */
+#endif
rec->ExceptionCode = EXCEPTION_ILLEGAL_INSTRUCTION;
break;
}
@@ -1341,7 +1382,11 @@ BOOL SIGNAL_Init(void)
sigaddset( &sig_act.sa_mask, SIGINT );
sigaddset( &sig_act.sa_mask, SIGUSR1 );
sigaddset( &sig_act.sa_mask, SIGUSR2 );
+#if defined(__NetBSD__) && (__NetBSD_Version__ < 200000000)
+ sig_act.sa_flags = SA_RESTART;
+#else
sig_act.sa_flags = SA_SIGINFO | SA_RESTART;
+#endif
#ifdef SA_ONSTACK
sig_act.sa_flags |= SA_ONSTACK;
--
1.2.4
More information about the wine-patches
mailing list