summaryrefslogtreecommitdiff
path: root/gcc/toplev.c
diff options
context:
space:
mode:
authorRichard Kenner <kenner@gcc.gnu.org>1997-01-19 21:19:04 -0500
committerRichard Kenner <kenner@gcc.gnu.org>1997-01-19 21:19:04 -0500
commit3bbfa29694126e0745fbe241ed4be97fa324a98f (patch)
tree3df9dc9f9fefbad7fb5874149c15703477ad2dce /gcc/toplev.c
parent299b54ba04836b48d2e8c599a84b8be74f70510f (diff)
downloadgcc-3bbfa29694126e0745fbe241ed4be97fa324a98f.tar.gz
(set_float_handler): Set up signal catcher on first call in case a
front end has disabled it. From-SVN: r13534
Diffstat (limited to 'gcc/toplev.c')
-rw-r--r--gcc/toplev.c41
1 files changed, 24 insertions, 17 deletions
diff --git a/gcc/toplev.c b/gcc/toplev.c
index 34e695de5c9..1828ecb3ad1 100644
--- a/gcc/toplev.c
+++ b/gcc/toplev.c
@@ -1870,9 +1870,27 @@ floor_log2_wide (x)
return log;
}
+static int float_handler_set;
int float_handled;
jmp_buf float_handler;
+/* Signals actually come here. */
+
+static void
+float_signal (signo)
+ /* If this is missing, some compilers complain. */
+ int signo;
+{
+ if (float_handled == 0)
+ abort ();
+#if defined (USG) || defined (hpux)
+ signal (SIGFPE, float_signal); /* re-enable the signal catcher */
+#endif
+ float_handled = 0;
+ signal (SIGFPE, float_signal);
+ longjmp (float_handler, 1);
+}
+
/* Specify where to longjmp to when a floating arithmetic error happens.
If HANDLER is 0, it means don't handle the errors any more. */
@@ -1883,6 +1901,12 @@ set_float_handler (handler)
float_handled = (handler != 0);
if (handler)
bcopy ((char *) handler, (char *) float_handler, sizeof (float_handler));
+
+ if (float_handled && ! float_handler_set)
+ {
+ signal (SIGFPE, float_signal);
+ float_handler_set = 1;
+ }
}
/* Specify, in HANDLER, where to longjmp to when a floating arithmetic
@@ -1917,23 +1941,6 @@ pop_float_handler (handled, handler)
bcopy ((char *) handler, (char *) float_handler, sizeof (float_handler));
}
-/* Signals actually come here. */
-
-static void
-float_signal (signo)
- /* If this is missing, some compilers complain. */
- int signo;
-{
- if (float_handled == 0)
- abort ();
-#if defined (USG) || defined (hpux)
- signal (SIGFPE, float_signal); /* re-enable the signal catcher */
-#endif
- float_handled = 0;
- signal (SIGFPE, float_signal);
- longjmp (float_handler, 1);
-}
-
/* Handler for SIGPIPE. */
static void