2 * i386 signal handling routines
4 * Copyright 1999 Alexandre Julliard
17 #ifdef HAVE_SYS_PARAM_H
18 # include <sys/param.h>
23 # ifdef HAVE_SYS_SYSCALL_H
24 # include <sys/syscall.h>
28 #include "selectors.h"
30 /***********************************************************************
31 * signal context platform-specific definitions
37 unsigned short sc_gs
, __gsh
;
38 unsigned short sc_fs
, __fsh
;
39 unsigned short sc_es
, __esh
;
40 unsigned short sc_ds
, __dsh
;
49 unsigned long sc_trapno
;
52 unsigned short sc_cs
, __csh
;
53 unsigned long sc_eflags
;
54 unsigned long esp_at_signal
;
55 unsigned short sc_ss
, __ssh
;
57 unsigned long oldmask
;
61 #define HANDLER_DEF(name) void name( int __signal, SIGCONTEXT __context )
62 #define HANDLER_CONTEXT (&__context)
64 /* this is the sigaction structure from the Linux 2.1.20 kernel. */
65 struct kernel_sigaction
67 void (*ksa_handler
)();
68 unsigned long ksa_mask
;
69 unsigned long ksa_flags
;
73 /* Similar to the sigaction function in libc, except it leaves alone the
74 restorer field, which is used to specify the signal stack address */
75 static inline int wine_sigaction( int sig
, struct kernel_sigaction
*new,
76 struct kernel_sigaction
*old
)
78 __asm__
__volatile__( "pushl %%ebx\n\t"
83 : "0" (SYS_sigaction
), "r" (sig
), "c" (new), "d" (old
) );
89 #ifdef HAVE_SIGALTSTACK
90 /* direct syscall for sigaltstack to work around glibc 2.0 brain-damage */
91 static inline int wine_sigaltstack( const struct sigaltstack
*new,
92 struct sigaltstack
*old
)
95 __asm__
__volatile__( "pushl %%ebx\n\t"
100 : "0" (SYS_sigaltstack
), "r" (new), "c" (old
) );
101 if (ret
>= 0) return 0;
111 #define EAX_sig(context) ((context)->tf_eax)
112 #define EBX_sig(context) ((context)->tf_ebx)
113 #define ECX_sig(context) ((context)->tf_ecx)
114 #define EDX_sig(context) ((context)->tf_edx)
115 #define ESI_sig(context) ((context)->tf_esi)
116 #define EDI_sig(context) ((context)->tf_edi)
117 #define EBP_sig(context) ((context)->tf_ebp)
119 #define CS_sig(context) ((context)->tf_cs)
120 #define DS_sig(context) ((context)->tf_ds)
121 #define ES_sig(context) ((context)->tf_es)
122 #define SS_sig(context) ((context)->tf_ss)
124 #include <machine/frame.h>
125 typedef struct trapframe SIGCONTEXT
;
127 #define HANDLER_DEF(name) void name( int __signal, int code, SIGCONTEXT *__context )
128 #define HANDLER_CONTEXT __context
130 #define EFL_sig(context) ((context)->tf_eflags)
132 #define EIP_sig(context) (*((unsigned long*)&(context)->tf_eip))
133 #define ESP_sig(context) (*((unsigned long*)&(context)->tf_esp))
137 #if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__)
139 typedef struct sigcontext SIGCONTEXT
;
141 #define HANDLER_DEF(name) void name( int __signal, int code, SIGCONTEXT *__context )
142 #define HANDLER_CONTEXT __context
146 #if defined(__svr4__) || defined(_SCO_DS) || defined(__sun)
149 #include <sys/regset.h>
153 #include <sys/ucontext.h>
155 typedef struct ucontext SIGCONTEXT
;
157 #define HANDLER_DEF(name) void name( int __signal, void *__siginfo, SIGCONTEXT *__context )
158 #define HANDLER_CONTEXT __context
160 #endif /* svr4 || SCO_DS */
166 unsigned long ContextFlags
;
167 FLOATING_SAVE_AREA sc_float
;
172 unsigned long sc_edi
;
173 unsigned long sc_esi
;
174 unsigned long sc_eax
;
175 unsigned long sc_ebx
;
176 unsigned long sc_ecx
;
177 unsigned long sc_edx
;
178 unsigned long sc_ebp
;
179 unsigned long sc_eip
;
181 unsigned long sc_eflags
;
182 unsigned long sc_esp
;
189 #if defined(linux) || defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__EMX__)
191 #define EAX_sig(context) ((context)->sc_eax)
192 #define EBX_sig(context) ((context)->sc_ebx)
193 #define ECX_sig(context) ((context)->sc_ecx)
194 #define EDX_sig(context) ((context)->sc_edx)
195 #define ESI_sig(context) ((context)->sc_esi)
196 #define EDI_sig(context) ((context)->sc_edi)
197 #define EBP_sig(context) ((context)->sc_ebp)
199 #define CS_sig(context) ((context)->sc_cs)
200 #define DS_sig(context) ((context)->sc_ds)
201 #define ES_sig(context) ((context)->sc_es)
202 #define SS_sig(context) ((context)->sc_ss)
204 /* FS and GS are now in the sigcontext struct of FreeBSD, but not
205 * saved by the exception handling. duh.
206 * Actually they are in -current (have been for a while), and that
207 * patch now finally has been MFC'd to -stable too (Nov 15 1999).
208 * If you're running a system from the -stable branch older than that,
209 * like a 3.3-RELEASE, grab the patch from the ports tree:
210 * ftp://ftp.freebsd.org/pub/FreeBSD/FreeBSD-current/ports/emulators/wine/files/patch-3.3-sys-fsgs
211 * (If its not yet there when you look, go here:
212 * http://www.jelal.kn-bremen.de/freebsd/ports/emulators/wine/files/ )
215 #define FS_sig(context) ((context)->sc_fs)
216 #define GS_sig(context) ((context)->sc_gs)
220 #define FS_sig(context) ((context)->sc_fs)
221 #define GS_sig(context) ((context)->sc_gs)
222 #define CR2_sig(context) ((context)->cr2)
223 #define TRAP_sig(context) ((context)->sc_trapno)
224 #define ERROR_sig(context) ((context)->sc_err)
225 #define FPU_sig(context) ((FLOATING_SAVE_AREA*)((context)->i387))
229 #define EFL_sig(context) ((context)->sc_eflags)
231 #define EFL_sig(context) ((context)->sc_efl)
232 /* FreeBSD, see i386/i386/traps.c::trap_pfault va->err kludge */
233 #define CR2_sig(context) ((context)->sc_err)
234 #define TRAP_sig(context) ((context)->sc_trapno)
237 #define EIP_sig(context) (*((unsigned long*)&(context)->sc_eip))
238 #define ESP_sig(context) (*((unsigned long*)&(context)->sc_esp))
240 #endif /* linux || __NetBSD__ || __FreeBSD__ || __OpenBSD__ */
242 #if defined(__svr4__) || defined(_SCO_DS) || defined(__sun)
248 #define EAX_sig(context) ((context)->uc_mcontext.gregs[EAX])
249 #define EBX_sig(context) ((context)->uc_mcontext.gregs[EBX])
250 #define ECX_sig(context) ((context)->uc_mcontext.gregs[ECX])
251 #define EDX_sig(context) ((context)->uc_mcontext.gregs[EDX])
252 #define ESI_sig(context) ((context)->uc_mcontext.gregs[ESI])
253 #define EDI_sig(context) ((context)->uc_mcontext.gregs[EDI])
254 #define EBP_sig(context) ((context)->uc_mcontext.gregs[EBP])
256 #define CS_sig(context) ((context)->uc_mcontext.gregs[CS])
257 #define DS_sig(context) ((context)->uc_mcontext.gregs[DS])
258 #define ES_sig(context) ((context)->uc_mcontext.gregs[ES])
259 #define SS_sig(context) ((context)->uc_mcontext.gregs[SS])
261 #define FS_sig(context) ((context)->uc_mcontext.gregs[FS])
262 #define GS_sig(context) ((context)->uc_mcontext.gregs[GS])
264 #define EFL_sig(context) ((context)->uc_mcontext.gregs[EFL])
266 #define EIP_sig(context) ((context)->uc_mcontext.gregs[EIP])
268 #define ESP_sig(context) ((context)->uc_mcontext.gregs[R_ESP])
270 #define ESP_sig(context) ((context)->uc_mcontext.gregs[ESP])
273 #define TRAP_sig(context) ((context)->uc_mcontext.gregs[TRAPNO])
276 #endif /* svr4 || SCO_DS */
279 /* exception code definitions (already defined by FreeBSD) */
280 #ifndef __FreeBSD__ /* FIXME: other BSDs? */
281 #define T_DIVIDE 0 /* Division by zero exception */
282 #define T_TRCTRAP 1 /* Single-step exception */
283 #define T_NMI 2 /* NMI interrupt */
284 #define T_BPTFLT 3 /* Breakpoint exception */
285 #define T_OFLOW 4 /* Overflow exception */
286 #define T_BOUND 5 /* Bound range exception */
287 #define T_PRIVINFLT 6 /* Invalid opcode exception */
288 #define T_DNA 7 /* Device not available exception */
289 #define T_DOUBLEFLT 8 /* Double fault exception */
290 #define T_FPOPFLT 9 /* Coprocessor segment overrun */
291 #define T_TSSFLT 10 /* Invalid TSS exception */
292 #define T_SEGNPFLT 11 /* Segment not present exception */
293 #define T_STKFLT 12 /* Stack fault */
294 #define T_PROTFLT 13 /* General protection fault */
295 #define T_PAGEFLT 14 /* Page fault */
296 #define T_RESERVED 15 /* Unknown exception */
297 #define T_ARITHTRAP 16 /* Floating point exception */
298 #define T_ALIGNFLT 17 /* Alignment check exception */
299 #define T_MCHK 18 /* Machine check exception */
300 #define T_CACHEFLT 19 /* Cache flush exception */
303 #define T_UNKNOWN (-1) /* Unknown fault (TRAP_sig not defined) */
305 #include "wine/exception.h"
307 #include "stackframe.h"
311 #include "syslevel.h"
312 #include "debugtools.h"
314 DEFAULT_DEBUG_CHANNEL(seh
)
318 /***********************************************************************
321 * Initialization code for a signal handler.
322 * Restores the proper %fs value for the current thread.
324 static inline void handler_init( CONTEXT
*context
, const SIGCONTEXT
*sigcontext
)
327 /* get %fs at time of the fault */
329 fs
= FS_sig(sigcontext
);
334 /* now restore a proper %fs for the fault handler */
335 if (!IS_SELECTOR_SYSTEM(CS_sig(sigcontext
))) fs
= SYSLEVEL_Win16CurrentTeb
;
336 if (!fs
) fs
= SYSLEVEL_EmergencyTeb
;
340 /***********************************************************************
343 * Get the trap code for a signal.
345 static inline int get_trap_code( const SIGCONTEXT
*sigcontext
)
348 return TRAP_sig(sigcontext
);
350 return T_UNKNOWN
; /* unknown trap code */
354 /***********************************************************************
357 * Set the register values from a sigcontext.
359 static void save_context( CONTEXT
*context
, const SIGCONTEXT
*sigcontext
)
361 context
->Eax
= EAX_sig(sigcontext
);
362 context
->Ebx
= EBX_sig(sigcontext
);
363 context
->Ecx
= ECX_sig(sigcontext
);
364 context
->Edx
= EDX_sig(sigcontext
);
365 context
->Esi
= ESI_sig(sigcontext
);
366 context
->Edi
= EDI_sig(sigcontext
);
367 context
->Ebp
= EBP_sig(sigcontext
);
368 context
->EFlags
= EFL_sig(sigcontext
);
369 context
->Eip
= EIP_sig(sigcontext
);
370 context
->Esp
= ESP_sig(sigcontext
);
371 context
->SegCs
= LOWORD(CS_sig(sigcontext
));
372 context
->SegDs
= LOWORD(DS_sig(sigcontext
));
373 context
->SegEs
= LOWORD(ES_sig(sigcontext
));
374 context
->SegSs
= LOWORD(SS_sig(sigcontext
));
375 /* %fs already handled in handler_init */
377 context
->SegGs
= LOWORD(GS_sig(sigcontext
));
379 context
->SegGs
= __get_gs();
381 if (ISV86(context
)) V86BASE(context
) = (DWORD
)DOSMEM_MemoryBase(0);
385 /***********************************************************************
388 * Build a sigcontext from the register values.
390 static void restore_context( const CONTEXT
*context
, SIGCONTEXT
*sigcontext
)
392 EAX_sig(sigcontext
) = context
->Eax
;
393 EBX_sig(sigcontext
) = context
->Ebx
;
394 ECX_sig(sigcontext
) = context
->Ecx
;
395 EDX_sig(sigcontext
) = context
->Edx
;
396 ESI_sig(sigcontext
) = context
->Esi
;
397 EDI_sig(sigcontext
) = context
->Edi
;
398 EBP_sig(sigcontext
) = context
->Ebp
;
399 EFL_sig(sigcontext
) = context
->EFlags
;
400 EIP_sig(sigcontext
) = context
->Eip
;
401 ESP_sig(sigcontext
) = context
->Esp
;
402 CS_sig(sigcontext
) = context
->SegCs
;
403 DS_sig(sigcontext
) = context
->SegDs
;
404 ES_sig(sigcontext
) = context
->SegEs
;
405 SS_sig(sigcontext
) = context
->SegSs
;
407 FS_sig(sigcontext
) = context
->SegFs
;
409 __set_fs( context
->SegFs
);
412 GS_sig(sigcontext
) = context
->SegGs
;
414 __set_gs( context
->SegGs
);
419 /***********************************************************************
422 * Set the FPU context from a sigcontext.
424 static void inline save_fpu( CONTEXT
*context
, const SIGCONTEXT
*sigcontext
)
427 if (FPU_sig(sigcontext
))
429 context
->FloatSave
= *FPU_sig(sigcontext
);
434 __asm__
__volatile__( "fnsave %0; fwait" : "=m" (context
->FloatSave
) );
435 #endif /* __GNUC__ */
439 /***********************************************************************
442 * Restore the FPU context to a sigcontext.
444 static void inline restore_fpu( CONTEXT
*context
, const SIGCONTEXT
*sigcontext
)
446 /* reset the current interrupt status */
447 context
->FloatSave
.StatusWord
&= context
->FloatSave
.ControlWord
| 0xffffff80;
449 if (FPU_sig(sigcontext
))
451 *FPU_sig(sigcontext
) = context
->FloatSave
;
456 /* avoid nested exceptions */
457 __asm__
__volatile__( "frstor %0; fwait" : : "m" (context
->FloatSave
) );
458 #endif /* __GNUC__ */
462 /**********************************************************************
465 * Get the FPU exception code from the FPU status.
467 static inline DWORD
get_fpu_code( const CONTEXT
*context
)
469 DWORD status
= context
->FloatSave
.StatusWord
;
471 if (status
& 0x01) /* IE */
473 if (status
& 0x40) /* SF */
474 return EXCEPTION_FLT_STACK_CHECK
;
476 return EXCEPTION_FLT_INVALID_OPERATION
;
478 if (status
& 0x02) return EXCEPTION_FLT_DENORMAL_OPERAND
; /* DE flag */
479 if (status
& 0x04) return EXCEPTION_FLT_DIVIDE_BY_ZERO
; /* ZE flag */
480 if (status
& 0x08) return EXCEPTION_FLT_OVERFLOW
; /* OE flag */
481 if (status
& 0x10) return EXCEPTION_FLT_UNDERFLOW
; /* UE flag */
482 if (status
& 0x20) return EXCEPTION_FLT_INEXACT_RESULT
; /* PE flag */
483 return EXCEPTION_FLT_INVALID_OPERATION
; /* generic error */
487 /**********************************************************************
490 * Handler for SIGSEGV and related errors.
492 static HANDLER_DEF(segv_handler
)
494 EXCEPTION_RECORD rec
;
496 DWORD page_fault_code
= EXCEPTION_ACCESS_VIOLATION
;
498 handler_init( &context
, HANDLER_CONTEXT
);
501 /* we want the page-fault case to be fast */
502 if (get_trap_code(HANDLER_CONTEXT
) == T_PAGEFLT
)
503 if (!(page_fault_code
= VIRTUAL_HandleFault( (LPVOID
)CR2_sig(HANDLER_CONTEXT
) ))) return;
506 save_context( &context
, HANDLER_CONTEXT
);
507 rec
.ExceptionRecord
= NULL
;
508 rec
.ExceptionFlags
= EXCEPTION_CONTINUABLE
;
509 rec
.ExceptionAddress
= (LPVOID
)context
.Eip
;
510 rec
.NumberParameters
= 0;
512 switch(get_trap_code(HANDLER_CONTEXT
))
514 case T_OFLOW
: /* Overflow exception */
515 rec
.ExceptionCode
= EXCEPTION_INT_OVERFLOW
;
517 case T_BOUND
: /* Bound range exception */
518 rec
.ExceptionCode
= EXCEPTION_ARRAY_BOUNDS_EXCEEDED
;
520 case T_PRIVINFLT
: /* Invalid opcode exception */
521 rec
.ExceptionCode
= EXCEPTION_ILLEGAL_INSTRUCTION
;
523 case T_STKFLT
: /* Stack fault */
524 rec
.ExceptionCode
= EXCEPTION_STACK_OVERFLOW
;
526 case T_SEGNPFLT
: /* Segment not present exception */
527 case T_PROTFLT
: /* General protection fault */
528 case T_UNKNOWN
: /* Unknown fault code */
529 if (INSTR_EmulateInstruction( &context
)) goto restore
;
530 rec
.ExceptionCode
= EXCEPTION_PRIV_INSTRUCTION
;
532 case T_PAGEFLT
: /* Page fault */
534 rec
.NumberParameters
= 2;
536 rec
.ExceptionInformation
[0] = (ERROR_sig(HANDLER_CONTEXT
) & 2) != 0;
538 rec
.ExceptionInformation
[0] = 0;
539 #endif /* ERROR_sig */
540 rec
.ExceptionInformation
[1] = CR2_sig(HANDLER_CONTEXT
);
542 rec
.ExceptionCode
= page_fault_code
;
544 case T_ALIGNFLT
: /* Alignment check exception */
545 /* FIXME: pass through exception handler first? */
546 if (context
.EFlags
& 0x00040000)
548 /* Disable AC flag, return */
549 context
.EFlags
&= ~0x00040000;
552 rec
.ExceptionCode
= EXCEPTION_DATATYPE_MISALIGNMENT
;
555 ERR( "Got unexpected trap %d\n", get_trap_code(HANDLER_CONTEXT
) );
557 case T_NMI
: /* NMI interrupt */
558 case T_DNA
: /* Device not available exception */
559 case T_DOUBLEFLT
: /* Double fault exception */
560 case T_TSSFLT
: /* Invalid TSS exception */
561 case T_RESERVED
: /* Unknown exception */
562 case T_MCHK
: /* Machine check exception */
564 case T_CACHEFLT
: /* Cache flush exception */
566 rec
.ExceptionCode
= EXCEPTION_ILLEGAL_INSTRUCTION
;
570 EXC_RtlRaiseException( &rec
, &context
);
572 restore_context( &context
, HANDLER_CONTEXT
);
576 /**********************************************************************
579 * Handler for SIGTRAP.
581 static HANDLER_DEF(trap_handler
)
583 EXCEPTION_RECORD rec
;
586 handler_init( &context
, HANDLER_CONTEXT
);
588 save_context( &context
, HANDLER_CONTEXT
);
589 rec
.ExceptionFlags
= EXCEPTION_CONTINUABLE
;
590 rec
.ExceptionRecord
= NULL
;
591 rec
.ExceptionAddress
= (LPVOID
)context
.Eip
;
592 rec
.NumberParameters
= 0;
594 switch(get_trap_code(HANDLER_CONTEXT
))
596 case T_TRCTRAP
: /* Single-step exception */
597 rec
.ExceptionCode
= EXCEPTION_SINGLE_STEP
;
598 context
.EFlags
&= ~0x100; /* clear single-step flag */
600 case T_BPTFLT
: /* Breakpoint exception */
601 rec
.ExceptionAddress
= (char *) rec
.ExceptionAddress
- 1; /* back up over the int3 instruction */
604 rec
.ExceptionCode
= EXCEPTION_BREAKPOINT
;
607 EXC_RtlRaiseException( &rec
, &context
);
608 restore_context( &context
, HANDLER_CONTEXT
);
612 /**********************************************************************
615 * Handler for SIGFPE.
617 static HANDLER_DEF(fpe_handler
)
619 EXCEPTION_RECORD rec
;
622 handler_init( &context
, HANDLER_CONTEXT
);
624 save_fpu( &context
, HANDLER_CONTEXT
);
626 switch(get_trap_code(HANDLER_CONTEXT
))
628 case T_DIVIDE
: /* Division by zero exception */
629 rec
.ExceptionCode
= EXCEPTION_INT_DIVIDE_BY_ZERO
;
631 case T_FPOPFLT
: /* Coprocessor segment overrun */
632 rec
.ExceptionCode
= EXCEPTION_FLT_INVALID_OPERATION
;
634 case T_ARITHTRAP
: /* Floating point exception */
635 case T_UNKNOWN
: /* Unknown fault code */
636 rec
.ExceptionCode
= get_fpu_code( &context
);
639 ERR( "Got unexpected trap %d\n", get_trap_code(HANDLER_CONTEXT
) );
640 rec
.ExceptionCode
= EXCEPTION_FLT_INVALID_OPERATION
;
643 save_context( &context
, HANDLER_CONTEXT
);
644 rec
.ExceptionFlags
= EXCEPTION_CONTINUABLE
;
645 rec
.ExceptionRecord
= NULL
;
646 rec
.ExceptionAddress
= (LPVOID
)context
.Eip
;
647 rec
.NumberParameters
= 0;
648 EXC_RtlRaiseException( &rec
, &context
);
649 restore_context( &context
, HANDLER_CONTEXT
);
650 restore_fpu( &context
, HANDLER_CONTEXT
);
654 /**********************************************************************
657 * Handler for SIGINT.
659 static HANDLER_DEF(int_handler
)
661 EXCEPTION_RECORD rec
;
664 handler_init( &context
, HANDLER_CONTEXT
);
665 save_context( &context
, HANDLER_CONTEXT
);
666 rec
.ExceptionCode
= CONTROL_C_EXIT
;
667 rec
.ExceptionFlags
= EXCEPTION_CONTINUABLE
;
668 rec
.ExceptionRecord
= NULL
;
669 rec
.ExceptionAddress
= (LPVOID
)context
.Eip
;
670 rec
.NumberParameters
= 0;
671 EXC_RtlRaiseException( &rec
, &context
);
672 restore_context( &context
, HANDLER_CONTEXT
);
676 /***********************************************************************
679 * Set a signal handler
681 static int set_handler( int sig
, int have_sigaltstack
, void (*func
)() )
683 struct sigaction sig_act
;
686 if (!have_sigaltstack
&& NtCurrentTeb()->signal_stack
)
688 struct kernel_sigaction sig_act
;
689 sig_act
.ksa_handler
= func
;
690 sig_act
.ksa_flags
= SA_RESTART
| SA_NOMASK
;
691 sig_act
.ksa_mask
= 0;
692 /* point to the top of the stack */
693 sig_act
.ksa_restorer
= (char *)NtCurrentTeb()->signal_stack
+ SIGNAL_STACK_SIZE
;
694 return wine_sigaction( sig
, &sig_act
, NULL
);
697 sig_act
.sa_handler
= func
;
698 sigemptyset( &sig_act
.sa_mask
);
701 sig_act
.sa_flags
= SA_RESTART
| SA_NOMASK
;
702 #elif defined (__svr4__) || defined(_SCO_DS)
703 sig_act
.sa_flags
= SA_SIGINFO
| SA_RESTART
;
705 sig_act
.sa_flags
= 0;
709 if (have_sigaltstack
) sig_act
.sa_flags
|= SA_ONSTACK
;
711 return sigaction( sig
, &sig_act
, NULL
);
715 /**********************************************************************
718 BOOL
SIGNAL_Init(void)
720 int have_sigaltstack
= 0;
722 #ifdef HAVE_SIGALTSTACK
723 struct sigaltstack ss
;
724 if ((ss
.ss_sp
= NtCurrentTeb()->signal_stack
))
726 ss
.ss_size
= SIGNAL_STACK_SIZE
;
728 if (!sigaltstack(&ss
, NULL
)) have_sigaltstack
= 1;
730 /* sigaltstack may fail because the kernel is too old, or
731 because glibc is brain-dead. In the latter case a
732 direct system call should succeed. */
733 else if (!wine_sigaltstack(&ss
, NULL
)) have_sigaltstack
= 1;
736 #endif /* HAVE_SIGALTSTACK */
738 /* automatic child reaping to avoid zombies */
739 signal( SIGCHLD
, SIG_IGN
);
741 if (set_handler( SIGINT
, have_sigaltstack
, (void (*)())int_handler
) == -1) goto error
;
742 if (set_handler( SIGFPE
, have_sigaltstack
, (void (*)())fpe_handler
) == -1) goto error
;
743 if (set_handler( SIGSEGV
, have_sigaltstack
, (void (*)())segv_handler
) == -1) goto error
;
744 if (set_handler( SIGILL
, have_sigaltstack
, (void (*)())segv_handler
) == -1) goto error
;
746 if (set_handler( SIGBUS
, have_sigaltstack
, (void (*)())segv_handler
) == -1) goto error
;
749 if (set_handler( SIGTRAP
, have_sigaltstack
, (void (*)())trap_handler
) == -1) goto error
;
758 /**********************************************************************
759 * DbgBreakPoint (NTDLL)
761 void WINAPI
DbgBreakPoint(void);
762 __ASM_GLOBAL_FUNC( DbgBreakPoint
, "int $3; ret");
764 /**********************************************************************
765 * DbgUserBreakPoint (NTDLL)
767 void WINAPI
DbgUserBreakPoint(void);
768 __ASM_GLOBAL_FUNC( DbgUserBreakPoint
, "int $3; ret");
770 #endif /* __i386__ */