summaryrefslogtreecommitdiff
path: root/math/algae/patches/patch-aa
blob: 7d4774df67851a62922f2535c684838de0403b84 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
$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 <config.h>
+#endif
+
+#include <stdio.h>
+#include <math.h>
+#include <errno.h>
+#include <ieeefp.h>
+#include <setjmp.h>
+#include <signal.h>
+
+#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);
+}