Update the address of the Free Software Foundation.
[wine] / dlls / ntdll / signal_powerpc.c
1 /*
2  * PowerPC signal handling routines
3  *
4  * Copyright 2002 Marcus Meissner, SuSE Linux AG
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 __powerpc__
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_SYSCALL_H
39 # include <syscall.h>
40 #else
41 # ifdef HAVE_SYS_SYSCALL_H
42 #  include <sys/syscall.h>
43 # endif
44 #endif
45
46 #ifdef HAVE_SYS_VM86_H
47 # include <sys/vm86.h>
48 #endif
49
50 #ifdef HAVE_SYS_SIGNAL_H
51 # include <sys/signal.h>
52 #endif
53
54 #include "windef.h"
55 #include "winternl.h"
56 #include "wine/library.h"
57 #include "wine/exception.h"
58 #include "ntdll_misc.h"
59 #include "wine/debug.h"
60
61 WINE_DEFAULT_DEBUG_CHANNEL(seh);
62
63
64 /***********************************************************************
65  * signal context platform-specific definitions
66  */
67 #ifdef linux
68
69 typedef struct ucontext SIGCONTEXT;
70
71 # define HANDLER_DEF(name) void name( int __signal, struct siginfo *__siginfo, SIGCONTEXT *__context )
72 # define HANDLER_CONTEXT (__context)
73
74 /* All Registers access - only for local access */
75 # define REG_sig(reg_name, context)             ((context)->uc_mcontext.regs->reg_name)
76
77
78 /* Gpr Registers access  */
79 # define GPR_sig(reg_num, context)              REG_sig(gpr[reg_num], context)
80
81 # define IAR_sig(context)                       REG_sig(nip, context)   /* Program counter */
82 # define MSR_sig(context)                       REG_sig(msr, context)   /* Machine State Register (Supervisor) */
83 # define CTR_sig(context)                       REG_sig(ctr, context)   /* Count register */
84
85 # define XER_sig(context)                       REG_sig(xer, context) /* User's integer exception register */
86 # define LR_sig(context)                        REG_sig(link, context) /* Link register */
87 # define CR_sig(context)                        REG_sig(ccr, context) /* Condition register */
88
89 /* Float Registers access  */
90 # define FLOAT_sig(reg_num, context)            (((double*)((char*)((context)->uc_mcontext.regs+48*4)))[reg_num])
91
92 # define FPSCR_sig(context)                     (*(int*)((char*)((context)->uc_mcontext.regs+(48+32*2)*4)))
93
94 /* Exception Registers access */
95 # define DAR_sig(context)                       REG_sig(dar, context)
96 # define DSISR_sig(context)                     REG_sig(dsisr, context)
97 # define TRAP_sig(context)                      REG_sig(trap, context)
98
99 #endif /* linux */
100
101 #ifdef __APPLE__
102
103 # include <sys/ucontext.h>
104
105 # include <sys/types.h>
106 # include <signal.h>
107 typedef siginfo_t siginfo;
108
109 typedef struct ucontext SIGCONTEXT;
110
111
112 # define HANDLER_DEF(name) void name( int __signal, siginfo *__siginfo, SIGCONTEXT *__context )
113 # define HANDLER_CONTEXT (__context)
114
115 /* All Registers access - only for local access */
116 # define REG_sig(reg_name, context)             ((context)->uc_mcontext->ss.reg_name)
117 # define FLOATREG_sig(reg_name, context)        ((context)->uc_mcontext->fs.reg_name)
118 # define EXCEPREG_sig(reg_name, context)        ((context)->uc_mcontext->es.reg_name)
119 # define VECREG_sig(reg_name, context)          ((context)->uc_mcontext->vs.reg_name)
120
121 /* Gpr Registers access */
122 # define GPR_sig(reg_num, context)              REG_sig(r##reg_num, context)
123
124 # define IAR_sig(context)                       REG_sig(srr0, context)  /* Program counter */
125 # define MSR_sig(context)                       REG_sig(srr1, context)  /* Machine State Register (Supervisor) */
126 # define CTR_sig(context)                       REG_sig(ctr, context)
127
128 # define XER_sig(context)                       REG_sig(xer, context) /* Link register */
129 # define LR_sig(context)                        REG_sig(lr, context)  /* User's integer exception register */
130 # define CR_sig(context)                        REG_sig(cr, context)  /* Condition register */
131
132 /* Float Registers access */
133 # define FLOAT_sig(reg_num, context)            FLOATREG_sig(fpregs[reg_num], context)
134
135 # define FPSCR_sig(context)                     FLOATREG_sig(fpscr, context)
136
137 /* Exception Registers access */
138 # define DAR_sig(context)                       EXCEPREG_sig(dar, context)     /* Fault registers for coredump */
139 # define DSISR_sig(context)                     EXCEPREG_sig(dsisr, context)
140 # define TRAP_sig(context)                      EXCEPREG_sig(exception, context) /* number of powerpc exception taken */
141
142 /* Signal defs : Those are undefined on darwin
143 SIGBUS
144 #undef BUS_ADRERR
145 #undef BUS_OBJERR
146 SIGILL
147 #undef ILL_ILLOPN
148 #undef ILL_ILLTRP
149 #undef ILL_ILLADR
150 #undef ILL_COPROC
151 #undef ILL_PRVREG
152 #undef ILL_BADSTK
153 SIGTRAP
154 #undef TRAP_BRKPT
155 #undef TRAP_TRACE
156 SIGFPE
157 */
158
159 #endif /* __APPLE__ */
160
161
162
163 typedef int (*wine_signal_handler)(unsigned int sig);
164
165 static wine_signal_handler handlers[256];
166
167 /***********************************************************************
168  *           dispatch_signal
169  */
170 inline static int dispatch_signal(unsigned int sig)
171 {
172     if (handlers[sig] == NULL) return 0;
173     return handlers[sig](sig);
174 }
175
176 /***********************************************************************
177  *           save_context
178  *
179  * Set the register values from a sigcontext.
180  */
181 static void save_context( CONTEXT *context, const SIGCONTEXT *sigcontext )
182 {
183
184 #define C(x) context->Gpr##x = GPR_sig(x,sigcontext)
185         /* Save Gpr registers */
186         C(0); C(1); C(2); C(3); C(4); C(5); C(6); C(7); C(8); C(9); C(10);
187         C(11); C(12); C(13); C(14); C(15); C(16); C(17); C(18); C(19); C(20);
188         C(21); C(22); C(23); C(24); C(25); C(26); C(27); C(28); C(29); C(30);
189         C(31);
190 #undef C
191
192         context->Iar = IAR_sig(sigcontext);  /* Program Counter */
193         context->Msr = MSR_sig(sigcontext);  /* Machine State Register (Supervisor) */
194         context->Ctr = CTR_sig(sigcontext);
195         
196         context->Xer = XER_sig(sigcontext);
197         context->Lr  = LR_sig(sigcontext);
198         context->Cr  = CR_sig(sigcontext);
199         
200         /* Saving Exception regs */
201         context->Dar   = DAR_sig(sigcontext);
202         context->Dsisr = DSISR_sig(sigcontext);
203         context->Trap  = TRAP_sig(sigcontext);
204 }
205
206
207 /***********************************************************************
208  *           restore_context
209  *
210  * Build a sigcontext from the register values.
211  */
212 static void restore_context( const CONTEXT *context, SIGCONTEXT *sigcontext )
213 {
214
215 #define C(x)  GPR_sig(x,sigcontext) = context->Gpr##x
216         C(0); C(1); C(2); C(3); C(4); C(5); C(6); C(7); C(8); C(9); C(10);
217         C(11); C(12); C(13); C(14); C(15); C(16); C(17); C(18); C(19); C(20);
218         C(21); C(22); C(23); C(24); C(25); C(26); C(27); C(28); C(29); C(30);
219         C(31);
220 #undef C
221
222         IAR_sig(sigcontext) = context->Iar;  /* Program Counter */
223         MSR_sig(sigcontext) = context->Msr;  /* Machine State Register (Supervisor) */
224         CTR_sig(sigcontext) = context->Ctr;
225         
226         XER_sig(sigcontext) = context->Xer;
227         LR_sig(sigcontext) = context->Lr;
228         CR_sig(sigcontext) = context->Cr;
229         
230         /* Setting Exception regs */
231         DAR_sig(sigcontext) = context->Dar;
232         DSISR_sig(sigcontext) = context->Dsisr;
233         TRAP_sig(sigcontext) = context->Trap;
234 }
235
236
237 /***********************************************************************
238  *           save_fpu
239  *
240  * Set the FPU context from a sigcontext.
241  */
242 inline static void save_fpu( CONTEXT *context, const SIGCONTEXT *sigcontext )
243 {
244 #define C(x)   context->Fpr##x = FLOAT_sig(x,sigcontext)
245         C(0); C(1); C(2); C(3); C(4); C(5); C(6); C(7); C(8); C(9); C(10);
246         C(11); C(12); C(13); C(14); C(15); C(16); C(17); C(18); C(19); C(20);
247         C(21); C(22); C(23); C(24); C(25); C(26); C(27); C(28); C(29); C(30);
248         C(31);
249 #undef C
250         context->Fpscr = FPSCR_sig(sigcontext);
251 }
252
253
254 /***********************************************************************
255  *           restore_fpu
256  *
257  * Restore the FPU context to a sigcontext.
258  */
259 inline static void restore_fpu( CONTEXT *context, const SIGCONTEXT *sigcontext )
260 {
261 #define C(x)  FLOAT_sig(x,sigcontext) = context->Fpr##x
262         C(0); C(1); C(2); C(3); C(4); C(5); C(6); C(7); C(8); C(9); C(10);
263         C(11); C(12); C(13); C(14); C(15); C(16); C(17); C(18); C(19); C(20);
264         C(21); C(22); C(23); C(24); C(25); C(26); C(27); C(28); C(29); C(30);
265         C(31);
266 #undef C
267         FPSCR_sig(sigcontext) = context->Fpscr;
268 }
269
270
271 /***********************************************************************
272  *              get_cpu_context
273  *
274  * Get the context of the current thread.
275  */
276 void get_cpu_context( CONTEXT *context )
277 {
278     FIXME("not implemented\n");
279 }
280
281
282 /***********************************************************************
283  *           set_cpu_context
284  *
285  * Set the new CPU context.
286  */
287 void set_cpu_context( const CONTEXT *context )
288 {
289     FIXME("not implemented\n");
290 }
291
292
293 /**********************************************************************
294  *              get_fpu_code
295  *
296  * Get the FPU exception code from the FPU status.
297  */
298 static inline DWORD get_fpu_code( const CONTEXT *context )
299 {
300     DWORD status  = context->Fpscr;
301
302     if (status & 0x01)  /* IE */
303     {
304         if (status & 0x40)  /* SF */
305             return EXCEPTION_FLT_STACK_CHECK;
306         else
307             return EXCEPTION_FLT_INVALID_OPERATION;
308     }
309     if (status & 0x02) return EXCEPTION_FLT_DENORMAL_OPERAND;  /* DE flag */
310     if (status & 0x04) return EXCEPTION_FLT_DIVIDE_BY_ZERO;    /* ZE flag */
311     if (status & 0x08) return EXCEPTION_FLT_OVERFLOW;          /* OE flag */
312     if (status & 0x10) return EXCEPTION_FLT_UNDERFLOW;         /* UE flag */
313     if (status & 0x20) return EXCEPTION_FLT_INEXACT_RESULT;    /* PE flag */
314     return EXCEPTION_FLT_INVALID_OPERATION;  /* generic error */
315 }
316
317 /**********************************************************************
318  *              do_segv
319  *
320  * Implementation of SIGSEGV handler.
321  */
322 static void do_segv( CONTEXT *context, int trap, int err, int code, void * addr )
323 {
324     EXCEPTION_RECORD rec;
325     DWORD page_fault_code = EXCEPTION_ACCESS_VIOLATION;
326
327     rec.ExceptionRecord  = NULL;
328     rec.ExceptionFlags   = EXCEPTION_CONTINUABLE;
329     rec.ExceptionAddress = addr;
330     rec.NumberParameters = 0;
331     
332     switch (trap) {
333     case SIGSEGV:
334         switch ( code & 0xffff ) {
335         case SEGV_MAPERR:
336         case SEGV_ACCERR:
337                 rec.NumberParameters = 2;
338                 rec.ExceptionInformation[0] = 0; /* FIXME ? */
339                 rec.ExceptionInformation[1] = (ULONG_PTR)addr;
340                 if (!(page_fault_code=VIRTUAL_HandleFault(addr)))
341                         return;
342                 rec.ExceptionCode = page_fault_code;
343                 break;
344         default:FIXME("Unhandled SIGSEGV/%x\n",code);
345                 break;
346         }
347         break;
348     case SIGBUS:
349         switch ( code & 0xffff ) {
350         case BUS_ADRALN:
351                 rec.ExceptionCode = EXCEPTION_DATATYPE_MISALIGNMENT;
352                 break;
353 #ifdef BUS_ADRERR
354         case BUS_ADRERR:
355 #endif
356 #ifdef BUS_OBJERR
357         case BUS_OBJERR:
358                 /* FIXME: correct for all cases ? */
359                 rec.NumberParameters = 2;
360                 rec.ExceptionInformation[0] = 0; /* FIXME ? */
361                 rec.ExceptionInformation[1] = (ULONG_PTR)addr;
362                 if (!(page_fault_code=VIRTUAL_HandleFault(addr)))
363                         return;
364                 rec.ExceptionCode = page_fault_code;
365                 break;
366 #endif
367         default:FIXME("Unhandled SIGBUS/%x\n",code);
368                 break;
369         }
370         break;
371     case SIGILL:
372         switch ( code & 0xffff ) {
373         case ILL_ILLOPC: /* illegal opcode */
374 #ifdef ILL_ILLOPN
375         case ILL_ILLOPN: /* illegal operand */
376 #endif
377 #ifdef ILL_ILLADR
378         case ILL_ILLADR: /* illegal addressing mode */
379 #endif
380 #ifdef ILL_ILLTRP
381         case ILL_ILLTRP: /* illegal trap */
382 #endif
383 #ifdef ILL_COPROC
384         case ILL_COPROC: /* coprocessor error */
385 #endif
386                 rec.ExceptionCode = EXCEPTION_ILLEGAL_INSTRUCTION;
387                 break;
388         case ILL_PRVOPC: /* privileged opcode */
389 #ifdef ILL_PRVREG
390         case ILL_PRVREG: /* privileged register */
391 #endif
392                 rec.ExceptionCode = EXCEPTION_PRIV_INSTRUCTION;
393                 break;
394 #ifdef ILL_BADSTK
395         case ILL_BADSTK: /* internal stack error */
396                 rec.ExceptionCode = EXCEPTION_STACK_OVERFLOW;
397                 break;
398 #endif
399         default:FIXME("Unhandled SIGILL/%x\n", code);
400                 break;
401         }
402         break;
403     }
404     __regs_RtlRaiseException( &rec, context );
405 }
406
407 /**********************************************************************
408  *              do_trap
409  *
410  * Implementation of SIGTRAP handler.
411  */
412 static void do_trap( CONTEXT *context, int code, void * addr )
413 {
414     EXCEPTION_RECORD rec;
415
416     rec.ExceptionFlags   = EXCEPTION_CONTINUABLE;
417     rec.ExceptionRecord  = NULL;
418     rec.ExceptionAddress = addr;
419     rec.NumberParameters = 0;
420
421     /* FIXME: check if we might need to modify PC */
422     switch (code & 0xffff) {
423 #ifdef TRAP_BRKPT
424     case TRAP_BRKPT:
425         rec.ExceptionCode = EXCEPTION_BREAKPOINT;
426         break;
427 #endif
428 #ifdef TRAP_TRACE
429     case TRAP_TRACE:
430         rec.ExceptionCode = EXCEPTION_SINGLE_STEP;
431         break;
432 #endif
433     default:FIXME("Unhandled SIGTRAP/%x\n", code);
434                 break;
435     }
436     __regs_RtlRaiseException( &rec, context );
437 }
438
439 /**********************************************************************
440  *              do_trap
441  *
442  * Implementation of SIGFPE handler.
443  */
444 static void do_fpe( CONTEXT *context, int code, void * addr )
445 {
446     EXCEPTION_RECORD rec;
447
448     switch ( code  & 0xffff ) {
449 #ifdef FPE_FLTSUB
450     case FPE_FLTSUB:
451         rec.ExceptionCode = EXCEPTION_ARRAY_BOUNDS_EXCEEDED;
452         break;
453 #endif
454 #ifdef FPE_INTDIV
455     case FPE_INTDIV:
456         rec.ExceptionCode = EXCEPTION_INT_DIVIDE_BY_ZERO;
457         break;
458 #endif
459 #ifdef FPE_INTOVF
460     case FPE_INTOVF:
461         rec.ExceptionCode = EXCEPTION_INT_OVERFLOW;
462         break;
463 #endif
464 #ifdef FPE_FLTDIV
465     case FPE_FLTDIV:
466         rec.ExceptionCode = EXCEPTION_FLT_DIVIDE_BY_ZERO;
467         break;
468 #endif
469 #ifdef FPE_FLTOVF
470     case FPE_FLTOVF:
471         rec.ExceptionCode = EXCEPTION_FLT_OVERFLOW;
472         break;
473 #endif
474 #ifdef FPE_FLTUND
475     case FPE_FLTUND:
476         rec.ExceptionCode = EXCEPTION_FLT_UNDERFLOW;
477         break;
478 #endif
479 #ifdef FPE_FLTRES
480     case FPE_FLTRES:
481         rec.ExceptionCode = EXCEPTION_FLT_INEXACT_RESULT;
482         break;
483 #endif
484 #ifdef FPE_FLTINV
485     case FPE_FLTINV:
486 #endif
487     default:
488         rec.ExceptionCode = EXCEPTION_FLT_INVALID_OPERATION;
489         break;
490     }
491     rec.ExceptionFlags   = EXCEPTION_CONTINUABLE;
492     rec.ExceptionRecord  = NULL;
493     rec.ExceptionAddress = addr;
494     rec.NumberParameters = 0;
495     __regs_RtlRaiseException( &rec, context );
496 }
497
498 /**********************************************************************
499  *              segv_handler
500  *
501  * Handler for SIGSEGV and related errors.
502  */
503 static HANDLER_DEF(segv_handler)
504 {
505     CONTEXT context;
506     save_context( &context, HANDLER_CONTEXT );
507     do_segv( &context, __siginfo->si_signo, __siginfo->si_errno, __siginfo->si_code, __siginfo->si_addr );
508     restore_context( &context, HANDLER_CONTEXT );
509 }
510
511 /**********************************************************************
512  *              trap_handler
513  *
514  * Handler for SIGTRAP.
515  */
516 static HANDLER_DEF(trap_handler)
517 {
518     CONTEXT context;
519     save_context( &context, HANDLER_CONTEXT );
520     do_trap( &context, __siginfo->si_code, __siginfo->si_addr );
521     restore_context( &context, HANDLER_CONTEXT );
522 }
523
524 /**********************************************************************
525  *              fpe_handler
526  *
527  * Handler for SIGFPE.
528  */
529 static HANDLER_DEF(fpe_handler)
530 {
531     CONTEXT context;
532     save_fpu( &context, HANDLER_CONTEXT );
533     save_context( &context, HANDLER_CONTEXT );
534     do_fpe( &context,  __siginfo->si_code, __siginfo->si_addr );
535     restore_context( &context, HANDLER_CONTEXT );
536     restore_fpu( &context, HANDLER_CONTEXT );
537 }
538
539 /**********************************************************************
540  *              int_handler
541  *
542  * Handler for SIGINT.
543  */
544 static HANDLER_DEF(int_handler)
545 {
546     if (!dispatch_signal(SIGINT))
547     {
548         EXCEPTION_RECORD rec;
549         CONTEXT context;
550
551         save_context( &context, HANDLER_CONTEXT );
552         rec.ExceptionCode    = CONTROL_C_EXIT;
553         rec.ExceptionFlags   = EXCEPTION_CONTINUABLE;
554         rec.ExceptionRecord  = NULL;
555         rec.ExceptionAddress = (LPVOID)context.Iar;
556         rec.NumberParameters = 0;
557         __regs_RtlRaiseException( &rec, &context );
558         restore_context( &context, HANDLER_CONTEXT );
559     }
560 }
561
562
563 /**********************************************************************
564  *              abrt_handler
565  *
566  * Handler for SIGABRT.
567  */
568 static HANDLER_DEF(abrt_handler)
569 {
570     EXCEPTION_RECORD rec;
571     CONTEXT context;
572
573     save_context( &context, HANDLER_CONTEXT );
574     rec.ExceptionCode    = EXCEPTION_WINE_ASSERTION;
575     rec.ExceptionFlags   = EH_NONCONTINUABLE;
576     rec.ExceptionRecord  = NULL;
577     rec.ExceptionAddress = (LPVOID)context.Iar;
578     rec.NumberParameters = 0;
579     __regs_RtlRaiseException( &rec, &context ); /* Should never return.. */
580     restore_context( &context, HANDLER_CONTEXT );
581 }
582
583
584 /**********************************************************************
585  *              term_handler
586  *
587  * Handler for SIGTERM.
588  */
589 static HANDLER_DEF(term_handler)
590 {
591     server_abort_thread(0);
592 }
593
594
595 /**********************************************************************
596  *              usr1_handler
597  *
598  * Handler for SIGUSR1, used to signal a thread that it got suspended.
599  */
600 static HANDLER_DEF(usr1_handler)
601 {
602     CONTEXT context;
603
604     save_context( &context, HANDLER_CONTEXT );
605     wait_suspend( &context );
606     restore_context( &context, HANDLER_CONTEXT );
607 }
608
609
610 /**********************************************************************
611  *              get_signal_stack_total_size
612  *
613  * Retrieve the size to allocate for the signal stack, including the TEB at the bottom.
614  * Must be a power of two.
615  */
616 size_t get_signal_stack_total_size(void)
617 {
618     assert( sizeof(TEB) <= getpagesize() );
619     return getpagesize();  /* this is just for the TEB, we don't need a signal stack */
620 }
621
622
623 /***********************************************************************
624  *           set_handler
625  *
626  * Set a signal handler
627  */
628 static int set_handler( int sig, void (*func)() )
629 {
630     struct sigaction sig_act;
631
632     sig_act.sa_sigaction = func;
633     sigemptyset( &sig_act.sa_mask );
634     sigaddset( &sig_act.sa_mask, SIGINT );
635     sigaddset( &sig_act.sa_mask, SIGALRM );
636
637     sig_act.sa_flags = SA_RESTART | SA_SIGINFO;
638     return sigaction( sig, &sig_act, NULL );
639 }
640
641
642 /***********************************************************************
643  *           __wine_set_signal_handler   (NTDLL.@)
644  */
645 int __wine_set_signal_handler(unsigned int sig, wine_signal_handler wsh)
646 {
647     if (sig > sizeof(handlers) / sizeof(handlers[0])) return -1;
648     if (handlers[sig] != NULL) return -2;
649     handlers[sig] = wsh;
650     return 0;
651 }
652
653
654 /**********************************************************************
655  *              SIGNAL_Init
656  */
657 BOOL SIGNAL_Init(void)
658 {
659     if (set_handler( SIGINT,  (void (*)())int_handler ) == -1) goto error;
660     if (set_handler( SIGFPE,  (void (*)())fpe_handler ) == -1) goto error;
661     if (set_handler( SIGSEGV, (void (*)())segv_handler ) == -1) goto error;
662     if (set_handler( SIGILL,  (void (*)())segv_handler ) == -1) goto error;
663     if (set_handler( SIGABRT, (void (*)())abrt_handler ) == -1) goto error;
664     if (set_handler( SIGTERM, (void (*)())term_handler ) == -1) goto error;
665     if (set_handler( SIGUSR1, (void (*)())usr1_handler ) == -1) goto error;
666 #ifdef SIGBUS
667     if (set_handler( SIGBUS,  (void (*)())segv_handler ) == -1) goto error;
668 #endif
669 #ifdef SIGTRAP
670     if (set_handler( SIGTRAP, (void (*)())trap_handler ) == -1) goto error;
671 #endif
672
673     return TRUE;
674
675  error:
676     perror("sigaction");
677     return FALSE;
678 }
679
680
681 /**********************************************************************
682  *              __wine_enter_vm86   (NTDLL.@)
683  */
684 void __wine_enter_vm86( CONTEXT *context )
685 {
686     MESSAGE("vm86 mode not supported on this platform\n");
687 }
688
689 /**********************************************************************
690  *              DbgBreakPoint   (NTDLL.@)
691  */
692 void WINAPI DbgBreakPoint(void)
693 {
694      kill(getpid(), SIGTRAP);
695 }
696
697 /**********************************************************************
698  *              DbgUserBreakPoint   (NTDLL.@)
699  */
700 void WINAPI DbgUserBreakPoint(void)
701 {
702      kill(getpid(), SIGTRAP);
703 }
704
705 #endif  /* __powerpc__ */