$NetBSD: patch-aa,v 1.1.1.1 2002/05/04 01:10:03 jtb Exp $ --- /dev/null Tue Jan 2 02:09:36 2001 +++ fpe/netbsd1.5.c @@ -0,0 +1,40 @@ +#if HAVE_CONFIG_H +#include +#endif + +#include +#include +#include +#include +#include +#include + +#if !SKIP_LOCAL_INCLUDES +#include "exception.h" +#include "message.h" +#endif + +static void +catch_sigfpe (int sig, int code, struct sigcontext *scp) +{ + fail ("Floating point exception."); + raise_exception (); +} + +void +enable_fpe_traps () +{ + struct sigaction act; + + act.sa_handler = (void (*)(int)) catch_sigfpe; + sigemptyset (&act.sa_mask); + act.sa_flags = 0; + + if (sigaction (SIGFPE, &act, NULL)) + wipeout ("Bad sigaction call."); + + sigaddset (&act.sa_mask, SIGFPE); + sigprocmask (SIG_UNBLOCK, &act.sa_mask, NULL); + + fpsetmask (FP_X_INV | FP_X_DZ | FP_X_OFL); +}