winejoystick.drv: Use CP_UNIXCP instead of CP_ACP when converting a string that comes...
[wine] / dlls / ntdll / signal_x86_64.c
1 /*
2  * x86-64 signal handling routines
3  *
4  * Copyright 1999, 2005 Alexandre Julliard
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19  */
20
21 #ifdef __x86_64__
22
23 #include "config.h"
24 #include "wine/port.h"
25
26 #include <assert.h>
27 #include <signal.h>
28 #include <stdlib.h>
29 #include <stdarg.h>
30 #include <stdio.h>
31 #ifdef HAVE_UNISTD_H
32 # include <unistd.h>
33 #endif
34
35 #ifdef HAVE_SYS_PARAM_H
36 # include <sys/param.h>
37 #endif
38 #ifdef HAVE_SYS_SIGNAL_H
39 # include <sys/signal.h>
40 #endif
41
42 #define NONAMELESSUNION
43 #include "windef.h"
44 #include "winternl.h"
45 #include "wine/library.h"
46 #include "wine/exception.h"
47 #include "ntdll_misc.h"
48 #include "wine/debug.h"
49
50 WINE_DEFAULT_DEBUG_CHANNEL(seh);
51
52
53 /***********************************************************************
54  * signal context platform-specific definitions
55  */
56 #ifdef linux
57
58 #include <asm/prctl.h>
59 extern int arch_prctl(int func, void *ptr);
60
61 typedef struct ucontext SIGCONTEXT;
62
63 # define HANDLER_DEF(name) void name( int __signal, struct siginfo *__siginfo, SIGCONTEXT *__context )
64 # define HANDLER_CONTEXT (__context)
65
66 #define RAX_sig(context)     ((context)->uc_mcontext.gregs[REG_RAX])
67 #define RBX_sig(context)     ((context)->uc_mcontext.gregs[REG_RBX])
68 #define RCX_sig(context)     ((context)->uc_mcontext.gregs[REG_RCX])
69 #define RDX_sig(context)     ((context)->uc_mcontext.gregs[REG_RDX])
70 #define RSI_sig(context)     ((context)->uc_mcontext.gregs[REG_RSI])
71 #define RDI_sig(context)     ((context)->uc_mcontext.gregs[REG_RDI])
72 #define RBP_sig(context)     ((context)->uc_mcontext.gregs[REG_RBP])
73 #define R8_sig(context)      ((context)->uc_mcontext.gregs[REG_R8])
74 #define R9_sig(context)      ((context)->uc_mcontext.gregs[REG_R9])
75 #define R10_sig(context)     ((context)->uc_mcontext.gregs[REG_R10])
76 #define R11_sig(context)     ((context)->uc_mcontext.gregs[REG_R11])
77 #define R12_sig(context)     ((context)->uc_mcontext.gregs[REG_R12])
78 #define R13_sig(context)     ((context)->uc_mcontext.gregs[REG_R13])
79 #define R14_sig(context)     ((context)->uc_mcontext.gregs[REG_R14])
80 #define R15_sig(context)     ((context)->uc_mcontext.gregs[REG_R15])
81
82 #define CS_sig(context)      (*((WORD *)&(context)->uc_mcontext.gregs[REG_CSGSFS] + 0))
83 #define GS_sig(context)      (*((WORD *)&(context)->uc_mcontext.gregs[REG_CSGSFS] + 1))
84 #define FS_sig(context)      (*((WORD *)&(context)->uc_mcontext.gregs[REG_CSGSFS] + 2))
85
86 #define RSP_sig(context)     ((context)->uc_mcontext.gregs[REG_RSP])
87 #define RIP_sig(context)     ((context)->uc_mcontext.gregs[REG_RIP])
88 #define EFL_sig(context)     ((context)->uc_mcontext.gregs[REG_EFL])
89 #define TRAP_sig(context)    ((context)->uc_mcontext.gregs[REG_TRAPNO])
90 #define ERROR_sig(context)   ((context)->uc_mcontext.gregs[REG_ERR])
91
92 #define FPU_sig(context)     ((XMM_SAVE_AREA32 *)((context)->uc_mcontext.fpregs))
93
94 #define FAULT_CODE     (__siginfo->si_code)
95 #define FAULT_ADDRESS  (__siginfo->si_addr)
96
97 #endif /* linux */
98
99 #if defined(__NetBSD__)
100 # include <sys/ucontext.h>
101 # include <sys/types.h>
102 # include <signal.h>
103
104 typedef ucontext_t SIGCONTEXT;
105
106 #define RAX_sig(context)    ((context)->uc_mcontext.__gregs[_REG_RAX])
107 #define RBX_sig(context)    ((context)->uc_mcontext.__gregs[_REG_RBX])
108 #define RCX_sig(context)    ((context)->uc_mcontext.__gregs[_REG_RCX])
109 #define RDX_sig(context)    ((context)->uc_mcontext.__gregs[_REG_RDX])
110 #define RSI_sig(context)    ((context)->uc_mcontext.__gregs[_REG_RSI])
111 #define RDI_sig(context)    ((context)->uc_mcontext.__gregs[_REG_RDI])
112 #define RBP_sig(context)    ((context)->uc_mcontext.__gregs[_REG_RBP])
113 #define R8_sig(context)     ((context)->uc_mcontext.__gregs[_REG_R8])
114 #define R9_sig(context)     ((context)->uc_mcontext.__gregs[_REG_R9])
115 #define R10_sig(context)    ((context)->uc_mcontext.__gregs[_REG_R10])
116 #define R11_sig(context)    ((context)->uc_mcontext.__gregs[_REG_R11])
117 #define R12_sig(context)    ((context)->uc_mcontext.__gregs[_REG_R12])
118 #define R13_sig(context)    ((context)->uc_mcontext.__gregs[_REG_R13])
119 #define R14_sig(context)    ((context)->uc_mcontext.__gregs[_REG_R14])
120 #define R15_sig(context)    ((context)->uc_mcontext.__gregs[_REG_R15])
121
122 #define CS_sig(context)     ((context)->uc_mcontext.__gregs[_REG_CS])
123 #define DS_sig(context)     ((context)->uc_mcontext.__gregs[_REG_DS])
124 #define ES_sig(context)     ((context)->uc_mcontext.__gregs[_REG_ES])
125 #define FS_sig(context)     ((context)->uc_mcontext.__gregs[_REG_FS])
126 #define GS_sig(context)     ((context)->uc_mcontext.__gregs[_REG_GS])
127 #define SS_sig(context)     ((context)->uc_mcontext.__gregs[_REG_SS])
128
129 #define EFL_sig(context)    ((context)->uc_mcontext.__gregs[_REG_RFL])
130
131 #define RIP_sig(context)    (*((unsigned long*)&(context)->uc_mcontext.__gregs[_REG_RIP]))
132 #define RSP_sig(context)    (*((unsigned long*)&(context)->uc_mcontext.__gregs[_REG_URSP]))
133
134 #define TRAP_sig(context)   ((context)->uc_mcontext.__gregs[_REG_TRAPNO])
135 #define ERROR_sig(context)  ((context)->uc_mcontext.__gregs[_REG_ERR])
136
137 #define FAULT_CODE          (__siginfo->si_code)
138 #define FAULT_ADDRESS       (__siginfo->si_addr)
139
140 #define HANDLER_DEF(name) void name( int __signal, siginfo_t *__siginfo, SIGCONTEXT *__context )
141 #define HANDLER_CONTEXT (__context)
142
143 #define FPU_sig(context)   ((XMM_SAVE_AREA32 *)((context)->uc_mcontext.__fpregs))
144 #endif /* __NetBSD__ */
145
146 enum i386_trap_code
147 {
148     TRAP_x86_UNKNOWN    = -1,  /* Unknown fault (TRAP_sig not defined) */
149     TRAP_x86_DIVIDE     = 0,   /* Division by zero exception */
150     TRAP_x86_TRCTRAP    = 1,   /* Single-step exception */
151     TRAP_x86_NMI        = 2,   /* NMI interrupt */
152     TRAP_x86_BPTFLT     = 3,   /* Breakpoint exception */
153     TRAP_x86_OFLOW      = 4,   /* Overflow exception */
154     TRAP_x86_BOUND      = 5,   /* Bound range exception */
155     TRAP_x86_PRIVINFLT  = 6,   /* Invalid opcode exception */
156     TRAP_x86_DNA        = 7,   /* Device not available exception */
157     TRAP_x86_DOUBLEFLT  = 8,   /* Double fault exception */
158     TRAP_x86_FPOPFLT    = 9,   /* Coprocessor segment overrun */
159     TRAP_x86_TSSFLT     = 10,  /* Invalid TSS exception */
160     TRAP_x86_SEGNPFLT   = 11,  /* Segment not present exception */
161     TRAP_x86_STKFLT     = 12,  /* Stack fault */
162     TRAP_x86_PROTFLT    = 13,  /* General protection fault */
163     TRAP_x86_PAGEFLT    = 14,  /* Page fault */
164     TRAP_x86_ARITHTRAP  = 16,  /* Floating point exception */
165     TRAP_x86_ALIGNFLT   = 17,  /* Alignment check exception */
166     TRAP_x86_MCHK       = 18,  /* Machine check exception */
167     TRAP_x86_CACHEFLT   = 19   /* Cache flush exception */
168 };
169
170 typedef int (*wine_signal_handler)(unsigned int sig);
171
172 static wine_signal_handler handlers[256];
173
174 /***********************************************************************
175  *           dispatch_signal
176  */
177 static inline int dispatch_signal(unsigned int sig)
178 {
179     if (handlers[sig] == NULL) return 0;
180     return handlers[sig](sig);
181 }
182
183 /***********************************************************************
184  *           save_context
185  *
186  * Set the register values from a sigcontext.
187  */
188 static void save_context( CONTEXT *context, const SIGCONTEXT *sigcontext )
189 {
190     context->Rax    = RAX_sig(sigcontext);
191     context->Rcx    = RCX_sig(sigcontext);
192     context->Rdx    = RDX_sig(sigcontext);
193     context->Rbx    = RBX_sig(sigcontext);
194     context->Rsp    = RSP_sig(sigcontext);
195     context->Rbp    = RBP_sig(sigcontext);
196     context->Rsi    = RSI_sig(sigcontext);
197     context->Rdi    = RDI_sig(sigcontext);
198     context->R8     = R8_sig(sigcontext);
199     context->R9     = R9_sig(sigcontext);
200     context->R10    = R10_sig(sigcontext);
201     context->R11    = R11_sig(sigcontext);
202     context->R12    = R12_sig(sigcontext);
203     context->R13    = R13_sig(sigcontext);
204     context->R14    = R14_sig(sigcontext);
205     context->R15    = R15_sig(sigcontext);
206     context->Rip    = RIP_sig(sigcontext);
207     context->SegCs  = CS_sig(sigcontext);
208     context->SegFs  = FS_sig(sigcontext);
209     context->SegGs  = GS_sig(sigcontext);
210     context->EFlags = EFL_sig(sigcontext);
211     context->SegDs  = 0;  /* FIXME */
212     context->SegEs  = 0;  /* FIXME */
213     context->SegSs  = 0;  /* FIXME */
214     context->MxCsr  = 0;  /* FIXME */
215     if (FPU_sig(sigcontext)) context->u.FltSave = *FPU_sig(sigcontext);
216 }
217
218
219 /***********************************************************************
220  *           restore_context
221  *
222  * Build a sigcontext from the register values.
223  */
224 static void restore_context( const CONTEXT *context, SIGCONTEXT *sigcontext )
225 {
226     RAX_sig(sigcontext) = context->Rax;
227     RCX_sig(sigcontext) = context->Rcx;
228     RDX_sig(sigcontext) = context->Rdx;
229     RBX_sig(sigcontext) = context->Rbx;
230     RSP_sig(sigcontext) = context->Rsp;
231     RBP_sig(sigcontext) = context->Rbp;
232     RSI_sig(sigcontext) = context->Rsi;
233     RDI_sig(sigcontext) = context->Rdi;
234     R8_sig(sigcontext)  = context->R8;
235     R9_sig(sigcontext)  = context->R9;
236     R10_sig(sigcontext) = context->R10;
237     R11_sig(sigcontext) = context->R11;
238     R12_sig(sigcontext) = context->R12;
239     R13_sig(sigcontext) = context->R13;
240     R14_sig(sigcontext) = context->R14;
241     R15_sig(sigcontext) = context->R15;
242     RIP_sig(sigcontext) = context->Rip;
243     CS_sig(sigcontext)  = context->SegCs;
244     FS_sig(sigcontext)  = context->SegFs;
245     GS_sig(sigcontext)  = context->SegGs;
246     EFL_sig(sigcontext) = context->EFlags;
247     if (FPU_sig(sigcontext)) *FPU_sig(sigcontext) = context->u.FltSave;
248 }
249
250
251 /***********************************************************************
252  *              RtlCaptureContext (NTDLL.@)
253  */
254 void WINAPI __regs_RtlCaptureContext( CONTEXT *context, CONTEXT *regs )
255 {
256     *context = *regs;
257 }
258 DEFINE_REGS_ENTRYPOINT( RtlCaptureContext, 1 )
259
260
261 /***********************************************************************
262  *           set_cpu_context
263  *
264  * Set the new CPU context.
265  */
266 void set_cpu_context( const CONTEXT *context )
267 {
268     FIXME("not implemented\n");
269 }
270
271
272 /**********************************************************************
273  *              segv_handler
274  *
275  * Handler for SIGSEGV and related errors.
276  */
277 static HANDLER_DEF(segv_handler)
278 {
279     EXCEPTION_RECORD rec;
280     CONTEXT context;
281
282     save_context( &context, HANDLER_CONTEXT );
283
284     rec.ExceptionRecord  = NULL;
285     rec.ExceptionFlags   = EXCEPTION_CONTINUABLE;
286     rec.ExceptionAddress = (LPVOID)context.Rip;
287     rec.NumberParameters = 0;
288
289     switch(TRAP_sig(HANDLER_CONTEXT))
290     {
291     case TRAP_x86_OFLOW:   /* Overflow exception */
292         rec.ExceptionCode = EXCEPTION_INT_OVERFLOW;
293         break;
294     case TRAP_x86_BOUND:   /* Bound range exception */
295         rec.ExceptionCode = EXCEPTION_ARRAY_BOUNDS_EXCEEDED;
296         break;
297     case TRAP_x86_PRIVINFLT:   /* Invalid opcode exception */
298         rec.ExceptionCode = EXCEPTION_ILLEGAL_INSTRUCTION;
299         break;
300     case TRAP_x86_STKFLT:  /* Stack fault */
301         rec.ExceptionCode = EXCEPTION_STACK_OVERFLOW;
302         break;
303     case TRAP_x86_SEGNPFLT:  /* Segment not present exception */
304     case TRAP_x86_PROTFLT:   /* General protection fault */
305     case TRAP_x86_UNKNOWN:   /* Unknown fault code */
306         rec.ExceptionCode = ERROR_sig(HANDLER_CONTEXT) ? EXCEPTION_ACCESS_VIOLATION
307                                                        : EXCEPTION_PRIV_INSTRUCTION;
308         break;
309     case TRAP_x86_PAGEFLT:  /* Page fault */
310         rec.ExceptionCode = EXCEPTION_ACCESS_VIOLATION;
311 #ifdef FAULT_ADDRESS
312         rec.NumberParameters = 2;
313         rec.ExceptionInformation[0] = (ERROR_sig(HANDLER_CONTEXT) & 2) != 0;
314         rec.ExceptionInformation[1] = (ULONG_PTR)FAULT_ADDRESS;
315         if (!(rec.ExceptionCode = virtual_handle_fault( FAULT_ADDRESS, rec.ExceptionInformation[0] )))
316             goto done;
317 #endif
318         break;
319     case TRAP_x86_ALIGNFLT:  /* Alignment check exception */
320         rec.ExceptionCode = EXCEPTION_DATATYPE_MISALIGNMENT;
321         break;
322     default:
323         ERR( "Got unexpected trap %ld\n", TRAP_sig(HANDLER_CONTEXT) );
324         /* fall through */
325     case TRAP_x86_NMI:       /* NMI interrupt */
326     case TRAP_x86_DNA:       /* Device not available exception */
327     case TRAP_x86_DOUBLEFLT: /* Double fault exception */
328     case TRAP_x86_TSSFLT:    /* Invalid TSS exception */
329     case TRAP_x86_MCHK:      /* Machine check exception */
330     case TRAP_x86_CACHEFLT:  /* Cache flush exception */
331         rec.ExceptionCode = EXCEPTION_ILLEGAL_INSTRUCTION;
332         break;
333     }
334
335     __regs_RtlRaiseException( &rec, &context );
336 done:
337     restore_context( &context, HANDLER_CONTEXT );
338 }
339
340 /**********************************************************************
341  *              trap_handler
342  *
343  * Handler for SIGTRAP.
344  */
345 static HANDLER_DEF(trap_handler)
346 {
347     EXCEPTION_RECORD rec;
348     CONTEXT context;
349
350     save_context( &context, HANDLER_CONTEXT );
351     rec.ExceptionFlags   = EXCEPTION_CONTINUABLE;
352     rec.ExceptionRecord  = NULL;
353     rec.ExceptionAddress = (LPVOID)context.Rip;
354     rec.NumberParameters = 0;
355
356     switch(FAULT_CODE)
357     {
358     case TRAP_TRACE:  /* Single-step exception */
359         rec.ExceptionCode = EXCEPTION_SINGLE_STEP;
360         EFL_sig(HANDLER_CONTEXT) &= ~0x100;  /* clear single-step flag */
361         break;
362     case TRAP_BRKPT:   /* Breakpoint exception */
363         rec.ExceptionAddress = (char *)rec.ExceptionAddress - 1;  /* back up over the int3 instruction */
364         /* fall through */
365     default:
366         rec.ExceptionCode = EXCEPTION_BREAKPOINT;
367         break;
368     }
369
370     __regs_RtlRaiseException( &rec, &context );
371     restore_context( &context, HANDLER_CONTEXT );
372 }
373
374 /**********************************************************************
375  *              fpe_handler
376  *
377  * Handler for SIGFPE.
378  */
379 static HANDLER_DEF(fpe_handler)
380 {
381     EXCEPTION_RECORD rec;
382     CONTEXT context;
383
384     save_context( &context, HANDLER_CONTEXT );
385     rec.ExceptionFlags   = EXCEPTION_CONTINUABLE;
386     rec.ExceptionRecord  = NULL;
387     rec.ExceptionAddress = (LPVOID)context.Rip;
388     rec.NumberParameters = 0;
389
390     switch (FAULT_CODE)
391     {
392     case FPE_FLTSUB:
393         rec.ExceptionCode = EXCEPTION_ARRAY_BOUNDS_EXCEEDED;
394         break;
395     case FPE_INTDIV:
396         rec.ExceptionCode = EXCEPTION_INT_DIVIDE_BY_ZERO;
397         break;
398     case FPE_INTOVF:
399         rec.ExceptionCode = EXCEPTION_INT_OVERFLOW;
400         break;
401     case FPE_FLTDIV:
402         rec.ExceptionCode = EXCEPTION_FLT_DIVIDE_BY_ZERO;
403         break;
404     case FPE_FLTOVF:
405         rec.ExceptionCode = EXCEPTION_FLT_OVERFLOW;
406         break;
407     case FPE_FLTUND:
408         rec.ExceptionCode = EXCEPTION_FLT_UNDERFLOW;
409         break;
410     case FPE_FLTRES:
411         rec.ExceptionCode = EXCEPTION_FLT_INEXACT_RESULT;
412         break;
413     case FPE_FLTINV:
414     default:
415         rec.ExceptionCode = EXCEPTION_FLT_INVALID_OPERATION;
416         break;
417     }
418
419     __regs_RtlRaiseException( &rec, &context );
420     restore_context( &context, HANDLER_CONTEXT );
421 }
422
423 /**********************************************************************
424  *              int_handler
425  *
426  * Handler for SIGINT.
427  */
428 static HANDLER_DEF(int_handler)
429 {
430     if (!dispatch_signal(SIGINT))
431     {
432         EXCEPTION_RECORD rec;
433         CONTEXT context;
434
435         save_context( &context, HANDLER_CONTEXT );
436         rec.ExceptionCode    = CONTROL_C_EXIT;
437         rec.ExceptionFlags   = EXCEPTION_CONTINUABLE;
438         rec.ExceptionRecord  = NULL;
439         rec.ExceptionAddress = (LPVOID)context.Rip;
440         rec.NumberParameters = 0;
441         __regs_RtlRaiseException( &rec, &context );
442         restore_context( &context, HANDLER_CONTEXT );
443     }
444 }
445
446
447 /**********************************************************************
448  *              abrt_handler
449  *
450  * Handler for SIGABRT.
451  */
452 static HANDLER_DEF(abrt_handler)
453 {
454     EXCEPTION_RECORD rec;
455     CONTEXT context;
456
457     save_context( &context, HANDLER_CONTEXT );
458     rec.ExceptionCode    = EXCEPTION_WINE_ASSERTION;
459     rec.ExceptionFlags   = EH_NONCONTINUABLE;
460     rec.ExceptionRecord  = NULL;
461     rec.ExceptionAddress = (LPVOID)context.Rip;
462     rec.NumberParameters = 0;
463     __regs_RtlRaiseException( &rec, &context ); /* Should never return.. */
464     restore_context( &context, HANDLER_CONTEXT );
465 }
466
467
468 /**********************************************************************
469  *              quit_handler
470  *
471  * Handler for SIGQUIT.
472  */
473 static HANDLER_DEF(quit_handler)
474 {
475     server_abort_thread(0);
476 }
477
478
479 /**********************************************************************
480  *              usr1_handler
481  *
482  * Handler for SIGUSR1, used to signal a thread that it got suspended.
483  */
484 static HANDLER_DEF(usr1_handler)
485 {
486     CONTEXT context;
487
488     save_context( &context, HANDLER_CONTEXT );
489     wait_suspend( &context );
490     restore_context( &context, HANDLER_CONTEXT );
491 }
492
493
494 /**********************************************************************
495  *              get_signal_stack_total_size
496  *
497  * Retrieve the size to allocate for the signal stack, including the TEB at the bottom.
498  * Must be a power of two.
499  */
500 size_t get_signal_stack_total_size(void)
501 {
502     assert( sizeof(TEB) <= 2*getpagesize() );
503     return 2*getpagesize();  /* this is just for the TEB, we don't need a signal stack */
504 }
505
506
507 /***********************************************************************
508  *           set_handler
509  *
510  * Set a signal handler
511  */
512 static int set_handler( int sig, void (*func)() )
513 {
514     struct sigaction sig_act;
515
516     sig_act.sa_sigaction = func;
517     sig_act.sa_mask = server_block_set;
518     sig_act.sa_flags = SA_RESTART | SA_SIGINFO | SA_ONSTACK;
519     return sigaction( sig, &sig_act, NULL );
520 }
521
522
523 /***********************************************************************
524  *           __wine_set_signal_handler   (NTDLL.@)
525  */
526 int CDECL __wine_set_signal_handler(unsigned int sig, wine_signal_handler wsh)
527 {
528     if (sig > sizeof(handlers) / sizeof(handlers[0])) return -1;
529     if (handlers[sig] != NULL) return -2;
530     handlers[sig] = wsh;
531     return 0;
532 }
533
534
535 /**********************************************************************
536  *              signal_init_thread
537  */
538 void signal_init_thread( TEB *teb )
539 {
540 #ifdef __linux__
541     arch_prctl( ARCH_SET_GS, teb );
542 #else
543 # error Please define setting %gs for your architecture
544 #endif
545 }
546
547 /**********************************************************************
548  *              signal_init_process
549  */
550 void signal_init_process(void)
551 {
552     if (set_handler( SIGINT,  (void (*)())int_handler ) == -1) goto error;
553     if (set_handler( SIGFPE,  (void (*)())fpe_handler ) == -1) goto error;
554     if (set_handler( SIGSEGV, (void (*)())segv_handler ) == -1) goto error;
555     if (set_handler( SIGILL,  (void (*)())segv_handler ) == -1) goto error;
556     if (set_handler( SIGABRT, (void (*)())abrt_handler ) == -1) goto error;
557     if (set_handler( SIGQUIT, (void (*)())quit_handler ) == -1) goto error;
558     if (set_handler( SIGUSR1, (void (*)())usr1_handler ) == -1) goto error;
559 #ifdef SIGBUS
560     if (set_handler( SIGBUS,  (void (*)())segv_handler ) == -1) goto error;
561 #endif
562 #ifdef SIGTRAP
563     if (set_handler( SIGTRAP, (void (*)())trap_handler ) == -1) goto error;
564 #endif
565     return;
566
567  error:
568     perror("sigaction");
569     exit(1);
570 }
571
572
573 /**********************************************************************
574  *              RtlLookupFunctionEntry   (NTDLL.@)
575  */
576 PRUNTIME_FUNCTION WINAPI RtlLookupFunctionEntry( ULONG64 pc, ULONG64 *base,
577                                                  UNWIND_HISTORY_TABLE *table )
578 {
579     FIXME("stub\n");
580     return NULL;
581 }
582
583
584 /**********************************************************************
585  *              RtlVirtualUnwind   (NTDLL.@)
586  */
587 PVOID WINAPI RtlVirtualUnwind ( ULONG type, ULONG64 base, ULONG64 pc,
588                                 RUNTIME_FUNCTION *function, CONTEXT *context,
589                                 PVOID *data, ULONG64 *frame,
590                                 KNONVOLATILE_CONTEXT_POINTERS *ctx_ptr )
591 {
592     FIXME("stub\n");
593     return NULL;
594 }
595
596
597 /**********************************************************************
598  *              __wine_enter_vm86   (NTDLL.@)
599  */
600 void __wine_enter_vm86( CONTEXT *context )
601 {
602     MESSAGE("vm86 mode not supported on this platform\n");
603 }
604
605 /**********************************************************************
606  *              DbgBreakPoint   (NTDLL.@)
607  */
608 __ASM_GLOBAL_FUNC( DbgBreakPoint, "int $3; ret")
609
610 /**********************************************************************
611  *              DbgUserBreakPoint   (NTDLL.@)
612  */
613 __ASM_GLOBAL_FUNC( DbgUserBreakPoint, "int $3; ret")
614
615 #endif  /* __x86_64__ */