From 71b44eae79947dd32267ed534972fe8b64e1b5c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20H=C3=BCbinette=20=28Hubbe=29?= <hubbe@hubbe.net> Date: Fri, 5 Jun 1998 20:11:48 -0700 Subject: [PATCH] now ignores SIGFPE if need be Rev: src/acconfig.h:1.26 Rev: src/configure.in:1.198 Rev: src/signal_handler.c:1.67 --- src/acconfig.h | 5 ++- src/configure.in | 92 +++++++++++++++++++++++++++++++++++++++++++- src/signal_handler.c | 6 ++- 3 files changed, 100 insertions(+), 3 deletions(-) diff --git a/src/acconfig.h b/src/acconfig.h index c2a54d5b34..524d70e278 100644 --- a/src/acconfig.h +++ b/src/acconfig.h @@ -1,5 +1,5 @@ /* - * $Id: acconfig.h,v 1.25 1998/05/29 20:41:39 grubba Exp $ + * $Id: acconfig.h,v 1.26 1998/06/06 03:11:48 hubbe Exp $ */ #ifndef MACHINE_H #define MACHINE_H @@ -38,6 +38,9 @@ /* Define as the return type of signal handlers (int or void). */ #undef RETSIGTYPE +/* define this if igonoring SIGFPE helps with core dumps */ +#undef IGNORE_SIGFPE + /* If using the C implementation of alloca, define if you know the direction of stack growth for your system; otherwise it will be automatically deduced at run-time. diff --git a/src/configure.in b/src/configure.in index e767b8e9fa..4ec8ccfa73 100644 --- a/src/configure.in +++ b/src/configure.in @@ -1,4 +1,4 @@ -AC_REVISION("$Id: configure.in,v 1.197 1998/06/04 13:12:17 grubba Exp $") +AC_REVISION("$Id: configure.in,v 1.198 1998/06/06 03:11:48 hubbe Exp $") AC_INIT(interpret.c) AC_CONFIG_HEADER(machine.h) @@ -209,6 +209,7 @@ AC_DEFUN(AC_SYS_COMPILER_FLAG, if test x"[$]pike_cv_option_$2" = "xyes" ; then $3="[$]$3 $1" AC_MSG_RESULT(yes) + $5 else AC_MSG_RESULT(no) $4 @@ -1565,6 +1566,95 @@ fi ############################################################################# +AC_MSG_CHECKING(if float conversion can cause SIGFPE) +AC_CACHE_VAL(pike_cv_sys_idiot_sigfpe, +[ + AC_TRY_RUN([ +#include <math.h> + +int main(int argc, char **argv) +{ + float x=2.0,y=-128.0; + x=pow(2.0,-128.0); + if(x==3.0) exit(1); + exit(0); +} +],pike_cv_sys_idiot_sigfpe=no,pike_cv_sys_idiot_sigfpe=yes) +]) + +if test $pike_cv_sys_idiot_sigfpe = yes ; then + AC_MSG_RESULT(yes) + + IEEE_FLAG=no + if test "x${GCC-}" = xyes ; then + AC_SYS_COMPILER_FLAG(-mieee, mieee, CFLAGS,[],IEEE_FLAG=yes) + else + AC_SYS_COMPILER_FLAG(-ieee, ieee, CFLAGS,[],IEEE_FLAG=yes) + fi + TEST_IGNORE_SIGFPE=yes + + if test $IEEE_FLAG = yes; then +AC_CACHE_VAL(pike_cv_sys_idiot_sigfpe_with_ieee, +[ + AC_TRY_RUN([ +#include <math.h> +int main(int argc, char **argv) +{ + + float x=2.0,y=-128.0; + x=pow(2.0,-128.0); + if(x==3.0) exit(1); + exit(0); +} +],pike_cv_sys_idiot_sigfpe_with_ieee=no,pike_cv_sys_idiot_sigfpe_with_ieee=yes) +]) + +if test $pike_cv_sys_idiot_sigfpe_with_ieee = yes ; then + AC_MSG_RESULT(yes) +else + AC_MSG_RESULT(no) + TEST_IGNORE_SIGFPE=no +fi +fi # IEEE_FLAG + +if test $TEST_IGNORE_SIGFPE = yes; then + AC_MSG_CHECKING(if ignoring SIGFPE helps) + AC_CACHE_VAL(pike_cv_sys_ignore_sigfpe, +[ +AC_TRY_RUN([ +#include <math.h> +int counter=0; +RETSIGTYPE func(void) +{ + if(counter++>10) exit(7); + signal(SIGFPE,func); +} + +int main(int argc, char **argv) +{ + float x=2.0,y=-128.0; + signal(SIGFPE,func); + x=pow(2.0,-128.0); + if(x==3.0) exit(1); + exit(0); +} +],pike_cv_sys_ignore_sigfpe=yes,pike_cv_sys_ignore_sigfpe=no) +]) + +if test "$pike_cv_sys_ignore_sigfpe" = yes; then + AC_MSG_RESULT(yes) + AC_DEFINE(IGNORE_SIGFPE) +else + AC_MSG_RESULT(no) +fi +fi # TEST_IGNORE_SIGFPE + +else + AC_MSG_RESULT(no) +fi # pike_cv_sys_idiot_sigfpe + +############################################################################# + define(float_check, [[ #include <math.h> #define TY $1 diff --git a/src/signal_handler.c b/src/signal_handler.c index 1cedf8c8a3..20ef39965b 100644 --- a/src/signal_handler.c +++ b/src/signal_handler.c @@ -22,7 +22,7 @@ #include "builtin_functions.h" #include <signal.h> -RCSID("$Id: signal_handler.c,v 1.66 1998/05/19 21:10:29 hubbe Exp $"); +RCSID("$Id: signal_handler.c,v 1.67 1998/06/06 03:11:48 hubbe Exp $"); #ifdef HAVE_PASSWD_H # include <passwd.h> @@ -1841,6 +1841,10 @@ void init_signals(void) #endif #endif +#ifdef IGNORE_SIGFPE + my_signal(SIGFPE, SIG_IGN); +#endif + for(e=0;e<MAX_SIGNALS;e++) signal_callbacks[e].type=T_INT; -- GitLab