summaryrefslogtreecommitdiff
path: root/emulators/wine/patches/patch-af
blob: a7fa184bd633e87683e3cb5285bc8f172c2b43aa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
$NetBSD: patch-af,v 1.22 2007/03/17 23:07:58 adam Exp $

--- dlls/ntdll/signal_i386.c.orig	2007-03-16 17:40:46.000000000 +0100
+++ dlls/ntdll/signal_i386.c
@@ -167,7 +167,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;
 
@@ -290,6 +290,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__ */
+
 WINE_DEFAULT_DEBUG_CHANNEL(seh);
 
 typedef int (*wine_signal_handler)(unsigned int sig);
@@ -322,8 +359,13 @@ 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_MCA,        /* Machine check exception */
+    TRAP_x86_CACHEFLT   = T_XMM         /* Cache flush exception */
+#else
     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 */
@@ -1376,7 +1418,11 @@ BOOL SIGNAL_Init(void)
 #endif  /* HAVE_SIGALTSTACK */
 
     sig_act.sa_mask = server_block_set;
+#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;
 #endif