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