Release 971116
[wine] / include / sig_context.h
1 /*
2  * Signal context definitions
3  *
4  * Copyright 1995 Alexandre Julliard
5  */
6
7 #ifndef __WINE_SIG_CONTEXT_H
8 #define __WINE_SIG_CONTEXT_H
9
10 #ifdef __i386__
11
12 #ifdef linux
13 typedef struct
14 {
15     unsigned short sc_gs, __gsh;
16     unsigned short sc_fs, __fsh;
17     unsigned short sc_es, __esh;
18     unsigned short sc_ds, __dsh;
19     unsigned long sc_edi;
20     unsigned long sc_esi;
21     unsigned long sc_ebp;
22     unsigned long sc_esp;
23     unsigned long sc_ebx;
24     unsigned long sc_edx;
25     unsigned long sc_ecx;
26     unsigned long sc_eax;
27     unsigned long sc_trapno;
28     unsigned long sc_err;
29     unsigned long sc_eip;
30     unsigned short sc_cs, __csh;
31     unsigned long sc_eflags;
32     unsigned long esp_at_signal;
33     unsigned short sc_ss, __ssh;
34     unsigned long i387;
35     unsigned long oldmask;
36     unsigned long cr2;
37 } SIGCONTEXT;
38
39 #define HANDLER_DEF(name) void name (int signal, SIGCONTEXT context)
40 #define HANDLER_CONTEXT (&context)
41
42 #endif  /* linux */
43
44 #if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__)
45
46 #include <signal.h>
47 typedef struct sigcontext SIGCONTEXT;
48
49 #define HANDLER_DEF(name) void name(int signal, int code, SIGCONTEXT *context)
50 #define HANDLER_CONTEXT context
51
52 #endif  /* FreeBSD */
53
54 #if defined(__svr4__) || defined(_SCO_DS)
55
56 #include <signal.h>
57 #ifdef _SCO_DS
58 #include <sys/regset.h>
59 #endif
60 #include <sys/ucontext.h>
61 typedef struct ucontext SIGCONTEXT;
62
63 #define HANDLER_DEF(name) void name(int signal, void *siginfo, SIGCONTEXT *context)
64 #define HANDLER_CONTEXT context
65
66 #endif  /* svr4 || SCO_DS */
67
68 #ifdef __EMX__
69 typedef unsigned long ULONG;
70 typedef unsigned short USHORT;
71 typedef struct _fpreg           /* Note 1 */
72 {
73   ULONG  losig;
74   ULONG  hisig;
75   USHORT signexp;
76 } FPREG;
77 typedef FPREG *PFPREG;
78
79 typedef struct _CONTEXT         /* Note 1 */
80 {
81   ULONG ContextFlags;
82   ULONG ctx_env[7];
83   FPREG ctx_stack[8];
84   ULONG ctx_SegGs;
85   ULONG ctx_SegFs;
86   ULONG ctx_SegEs;
87   ULONG ctx_SegDs;
88   ULONG ctx_RegEdi;
89   ULONG ctx_RegEsi;
90   ULONG ctx_RegEax;
91   ULONG ctx_RegEbx;
92   ULONG ctx_RegEcx;
93   ULONG ctx_RegEdx;
94   ULONG ctx_RegEbp;
95   ULONG ctx_RegEip;
96   ULONG ctx_SegCs;
97   ULONG ctx_EFlags;
98   ULONG ctx_RegEsp;
99   ULONG ctx_SegSs;
100 } SIGCONTEXT;
101 /*typedef CONTEXTRECORD *PCONTEXTRECORD;*/
102
103 #endif  /* __EMX__ */
104
105
106 #if defined(linux) || defined(__NetBSD__) || defined(__FreeBSD__) \
107  || defined(__OpenBSD__)
108
109 #define EAX_sig(context)     ((context)->sc_eax)
110 #define EBX_sig(context)     ((context)->sc_ebx)
111 #define ECX_sig(context)     ((context)->sc_ecx)
112 #define EDX_sig(context)     ((context)->sc_edx)
113 #define ESI_sig(context)     ((context)->sc_esi)
114 #define EDI_sig(context)     ((context)->sc_edi)
115 #define EBP_sig(context)     ((context)->sc_ebp)
116                             
117 #define CS_sig(context)      ((context)->sc_cs)
118 #define DS_sig(context)      ((context)->sc_ds)
119 #define ES_sig(context)      ((context)->sc_es)
120 #define SS_sig(context)      ((context)->sc_ss)
121                             
122 #ifdef linux
123 /* fs and gs are not supported on *BSD. Hopefully we won't need them. */
124 #define FS_sig(context)      ((context)->sc_fs)
125 #define GS_sig(context)      ((context)->sc_gs)
126 #endif
127                             
128 #ifndef __FreeBSD__         
129 #define EFL_sig(context)     ((context)->sc_eflags)
130 #else                       
131 #define EFL_sig(context)     ((context)->sc_efl)
132 #endif                      
133                             
134 #define EIP_sig(context)     (*((unsigned long*)&(context)->sc_eip))
135 #define ESP_sig(context)     (*((unsigned long*)&(context)->sc_esp))
136
137 #endif  /* linux || __NetBSD__ || __FreeBSD__ || __OpenBSD__ */
138
139 #if defined(__svr4__) || defined(_SCO_DS)
140
141 #ifdef _SCO_DS
142 #define gregs regs
143 #endif
144
145 #define EAX_sig(context)     ((context)->uc_mcontext.gregs[EAX])
146 #define EBX_sig(context)     ((context)->uc_mcontext.gregs[EBX])
147 #define ECX_sig(context)     ((context)->uc_mcontext.gregs[ECX])
148 #define EDX_sig(context)     ((context)->uc_mcontext.gregs[EDX])
149 #define ESI_sig(context)     ((context)->uc_mcontext.gregs[ESI])
150 #define EDI_sig(context)     ((context)->uc_mcontext.gregs[EDI])
151 #define EBP_sig(context)     ((context)->uc_mcontext.gregs[EBP])
152                             
153 #define CS_sig(context)      ((context)->uc_mcontext.gregs[CS])
154 #define DS_sig(context)      ((context)->uc_mcontext.gregs[DS])
155 #define ES_sig(context)      ((context)->uc_mcontext.gregs[ES])
156 #define SS_sig(context)      ((context)->uc_mcontext.gregs[SS])
157                             
158 #define FS_sig(context)      ((context)->uc_mcontext.gregs[FS])
159 #define GS_sig(context)      ((context)->uc_mcontext.gregs[GS])
160
161 #define EFL_sig(context)     ((context)->uc_mcontext.gregs[EFL])
162                             
163 #define EIP_sig(context)     ((context)->uc_mcontext.gregs[EIP])
164 #ifdef R_ESP
165 #define ESP_sig(context)     ((context)->uc_mcontext.gregs[R_ESP])
166 #else
167 #define ESP_sig(context)     ((context)->uc_mcontext.gregs[ESP])
168 #endif
169
170 #endif  /* svr4 || SCO_DS */
171                             
172 #ifdef __EMX__
173
174 #define EAX_sig(context)     ((context)->ctx_RegEax)
175 #define EBX_sig(context)     ((context)->ctx_RegEbx)
176 #define ECX_sig(context)     ((context)->ctx_RegEcx)
177 #define EDX_sig(context)     ((context)->ctx_RegEdx)
178 #define ESI_sig(context)     ((context)->ctx_RegEsi)
179 #define EDI_sig(context)     ((context)->ctx_RegEdi)
180 #define EBP_sig(context)     ((context)->ctx_RegEbp)
181 #define ESP_sig(context)     ((context)->ctx_RegEsp)
182 #define CS_sig(context)      ((context)->ctx_SegCs)
183 #define DS_sig(context)      ((context)->ctx_SegDs)
184 #define ES_sig(context)      ((context)->ctx_SegEs)
185 #define SS_sig(context)      ((context)->ctx_SegSs)
186 #define FS_sig(context)      ((context)->ctx_SegFs)
187 #define GS_sig(context)      ((context)->ctx_SegGs)
188 #define EFL_sig(context)     ((context)->ctx_EFlags)
189 #define EIP_sig(context)     ((context)->ctx_RegEip)
190
191 #endif  /* __EMX__ */
192
193 /* Generic definitions */
194
195 #define AX_sig(context)      (*(WORD*)&EAX_sig(context))
196 #define BX_sig(context)      (*(WORD*)&EBX_sig(context))
197 #define CX_sig(context)      (*(WORD*)&ECX_sig(context))
198 #define DX_sig(context)      (*(WORD*)&EDX_sig(context))
199 #define SI_sig(context)      (*(WORD*)&ESI_sig(context))
200 #define DI_sig(context)      (*(WORD*)&EDI_sig(context))
201 #define BP_sig(context)      (*(WORD*)&EBP_sig(context))
202
203 #define AL_sig(context)      (*(BYTE*)&EAX_sig(context))
204 #define AH_sig(context)      (*((BYTE*)&EAX_sig(context)+1))
205 #define BL_sig(context)      (*(BYTE*)&EBX_sig(context))
206 #define BH_sig(context)      (*((BYTE*)&EBX_sig(context)+1))
207 #define CL_sig(context)      (*(BYTE*)&ECX_sig(context))
208 #define CH_sig(context)      (*((BYTE*)&ECX_sig(context)+1))
209 #define DL_sig(context)      (*(BYTE*)&EDX_sig(context))
210 #define DH_sig(context)      (*((BYTE*)&EDX_sig(context)+1))
211                             
212 #define IP_sig(context)      (*(WORD*)&EIP_sig(context))
213 #define SP_sig(context)      (*(WORD*)&ESP_sig(context))
214                             
215 #define FL_sig(context)      (*(WORD*)&EFL_sig(context))
216
217 #endif /* __i386__ */
218
219 #endif /* __WINE_SIG_CONTEXT_H */