summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2002-06-07 12:41:14 +0000
committerBruno Haible <bruno@clisp.org>2009-06-23 12:08:35 +0200
commitdebd770197aea679bc013ab123db6bd8f9c5f9e4 (patch)
treec2d1d2219cb57d89da9552a20b097b2ccad6ba32
parent39286fc473b3c9f2c980e249022069e678e28318 (diff)
downloadexternal_gettext-debd770197aea679bc013ab123db6bd8f9c5f9e4.zip
external_gettext-debd770197aea679bc013ab123db6bd8f9c5f9e4.tar.gz
external_gettext-debd770197aea679bc013ab123db6bd8f9c5f9e4.tar.bz2
Make division by zero signal SIGFPE on all platforms.
-rw-r--r--intl/ChangeLog7
-rw-r--r--intl/dcigettext.c14
-rw-r--r--intl/eval-plural.h8
-rw-r--r--m4/ChangeLog7
-rw-r--r--m4/Makefile.am13
-rw-r--r--m4/gettext.m41
-rw-r--r--m4/intdiv0.m472
-rw-r--r--src/ChangeLog6
-rw-r--r--src/msgfmt.c8
9 files changed, 122 insertions, 14 deletions
diff --git a/intl/ChangeLog b/intl/ChangeLog
index 35ff7f8..2e18e90 100644
--- a/intl/ChangeLog
+++ b/intl/ChangeLog
@@ -1,3 +1,10 @@
+2002-06-07 Bruno Haible <bruno@clisp.org>
+
+ * dcigettext.c (INTDIV0_RAISES_SIGFPE): Define a fallback.
+ Include <signal.h>.
+ * eval-plural.h (plural_eval): Let division by zero cause SIGFPE on
+ all platforms.
+
2002-05-30 Bruno Haible <bruno@clisp.org>
* libgnuintl.h (_INTL_REDIRECT_ASM, _INTL_REDIRECT_INLINE,
diff --git a/intl/dcigettext.c b/intl/dcigettext.c
index 329dc09..b5bf3fb 100644
--- a/intl/dcigettext.c
+++ b/intl/dcigettext.c
@@ -64,6 +64,20 @@ extern int errno;
#include <locale.h>
+#ifdef _LIBC
+ /* Guess whether integer division by zero raises signal SIGFPE.
+ Set to 1 only if you know for sure. In case of doubt, set to 0. */
+# if defined __alpha__ || defined __arm__ || defined __i386__ \
+ || defined __m68k__ || defined __s390__
+# define INTDIV0_RAISES_SIGFPE 1
+# else
+# define INTDIV0_RAISES_SIGFPE 0
+# endif
+#endif
+#if !INTDIV0_RAISES_SIGFPE
+# include <signal.h>
+#endif
+
#if defined HAVE_SYS_PARAM_H || defined _LIBC
# include <sys/param.h>
#endif
diff --git a/intl/eval-plural.h b/intl/eval-plural.h
index 44f4934..19c7ca6 100644
--- a/intl/eval-plural.h
+++ b/intl/eval-plural.h
@@ -68,8 +68,16 @@ plural_eval (pexp, n)
case mult:
return leftarg * rightarg;
case divide:
+#if !INTDIV0_RAISES_SIGFPE
+ if (rightarg == 0)
+ raise (SIGFPE);
+#endif
return leftarg / rightarg;
case module:
+#if !INTDIV0_RAISES_SIGFPE
+ if (rightarg == 0)
+ raise (SIGFPE);
+#endif
return leftarg % rightarg;
case plus:
return leftarg + rightarg;
diff --git a/m4/ChangeLog b/m4/ChangeLog
index 8fec47a..9a40fd5 100644
--- a/m4/ChangeLog
+++ b/m4/ChangeLog
@@ -1,3 +1,10 @@
+2002-06-07 Bruno Haible <bruno@clisp.org>
+
+ * intdiv0.m4: New file.
+ * gettext.m4 (AM_INTL_SUBDIR): Require gt_INTDIV0.
+ * Makefile.am (aclocal_DATA): Add intdiv0.m4.
+ (EXTRA_DIST): Add intdiv0.m4.
+
2002-05-18 Bruno Haible <bruno@clisp.org>
Make it possible to invoke AM_ICONV after AM_GNU_GETTEXT.
diff --git a/m4/Makefile.am b/m4/Makefile.am
index 58d06f4..7ebe8b8 100644
--- a/m4/Makefile.am
+++ b/m4/Makefile.am
@@ -1,15 +1,16 @@
## Process this file with automake to produce Makefile.in -*-Makefile-*-
aclocaldir = @aclocaldir@
-aclocal_DATA = codeset.m4 gettext.m4 glibc21.m4 iconv.m4 isc-posix.m4 lib-ld.m4 lib-link.m4 lib-prefix.m4 lcmessage.m4 progtest.m4
+aclocal_DATA = codeset.m4 gettext.m4 glibc21.m4 iconv.m4 intdiv0.m4 isc-posix.m4 lib-ld.m4 lib-link.m4 lib-prefix.m4 lcmessage.m4 progtest.m4
# Generate this list with
# find . -type f -name '*.m4' -printf '%f\n'|sort |fmt |tr '\012' @ \
# |sed 's/@$/%/;s/@/ \\@/g' |tr @% '\012\012'
EXTRA_DIST = README \
backupfile.m4 c-bs-a.m4 codeset.m4 error.m4 flex.m4 fnmatch.m4 getline.m4 \
-gettext.m4 glibc21.m4 hostname.m4 iconv.m4 inttypes_h.m4 isc-posix.m4 \
-javacomp.m4 javaexec.m4 lcmessage.m4 lib-ld.m4 lib-link.m4 lib-prefix.m4 \
-libtool.m4 mbrtowc.m4 mbstate_t.m4 mbswidth.m4 mkdtemp.m4 progtest.m4 \
-setenv.m4 setlocale.m4 siginfo.m4 signalblocking.m4 signed.m4 ssize_t.m4 \
-stdbool.m4 stdint_h.m4 tmpdir.m4 uintmax_t.m4 ulonglong.m4 unionwait.m4
+gettext.m4 glibc21.m4 hostname.m4 iconv.m4 intdiv0.m4 inttypes_h.m4 \
+isc-posix.m4 javacomp.m4 javaexec.m4 lcmessage.m4 lib-ld.m4 lib-link.m4 \
+lib-prefix.m4 libtool.m4 mbrtowc.m4 mbstate_t.m4 mbswidth.m4 mkdtemp.m4 \
+progtest.m4 setenv.m4 setlocale.m4 siginfo.m4 signalblocking.m4 signed.m4 \
+ssize_t.m4 stdbool.m4 stdint_h.m4 tmpdir.m4 uintmax_t.m4 ulonglong.m4 \
+unionwait.m4
diff --git a/m4/gettext.m4 b/m4/gettext.m4
index a65b03d..146cef2 100644
--- a/m4/gettext.m4
+++ b/m4/gettext.m4
@@ -494,6 +494,7 @@ AC_DEFUN([AM_INTL_SUBDIR],
AC_REQUIRE([AC_FUNC_ALLOCA])dnl
AC_REQUIRE([AC_FUNC_MMAP])dnl
AC_REQUIRE([jm_GLIBC21])dnl
+ AC_REQUIRE([gt_INTDIV0])dnl
AC_CHECK_HEADERS([argz.h limits.h locale.h nl_types.h malloc.h stddef.h \
stdlib.h string.h unistd.h sys/param.h])
diff --git a/m4/intdiv0.m4 b/m4/intdiv0.m4
new file mode 100644
index 0000000..55dddcf
--- /dev/null
+++ b/m4/intdiv0.m4
@@ -0,0 +1,72 @@
+# intdiv0.m4 serial 1 (gettext-0.11.3)
+dnl Copyright (C) 2002 Free Software Foundation, Inc.
+dnl This file is free software, distributed under the terms of the GNU
+dnl General Public License. As a special exception to the GNU General
+dnl Public License, this file may be distributed as part of a program
+dnl that contains a configuration script generated by Autoconf, under
+dnl the same distribution terms as the rest of that program.
+
+dnl From Bruno Haible.
+
+AC_DEFUN([gt_INTDIV0],
+[
+ AC_REQUIRE([AC_PROG_CC])dnl
+ AC_REQUIRE([AC_CANONICAL_HOST])dnl
+
+ AC_CACHE_CHECK([whether integer division by zero raises SIGFPE],
+ gt_cv_int_divbyzero_sigfpe,
+ [
+ AC_TRY_RUN([
+#include <stdlib.h>
+#include <signal.h>
+
+static void
+#ifdef __cplusplus
+sigfpe_handler (int sig)
+#else
+sigfpe_handler (sig) int sig;
+#endif
+{
+ /* Exit with code 0 if SIGFPE, with code 1 if any other signal. */
+ exit (sig != SIGFPE);
+}
+
+int x = 1;
+int y = 0;
+int z;
+int nan;
+
+int main ()
+{
+ signal (SIGFPE, sigfpe_handler);
+/* IRIX and AIX (when "xlc -qcheck" is used) yield signal SIGTRAP. */
+#if (defined (__sgi) || defined (_AIX)) && defined (SIGTRAP)
+ signal (SIGTRAP, sigfpe_handler);
+#endif
+/* Linux/SPARC yields signal SIGILL. */
+#if defined (__sparc__) && defined (__linux__)
+ signal (SIGILL, sigfpe_handler);
+#endif
+
+ z = x / y;
+ nan = y / y;
+ exit (1);
+}
+], gt_cv_int_divbyzero_sigfpe=yes, gt_cv_int_divbyzero_sigfpe=no,
+ [
+ # Guess based on the CPU.
+ case "$host_cpu" in
+ alpha* | i[34567]86 | m68k | s390*)
+ gt_cv_int_divbyzero_sigfpe="guessing yes";;
+ *)
+ gt_cv_int_divbyzero_sigfpe="guessing no";;
+ esac
+ ])
+ ])
+ case "$gt_cv_int_divbyzero_sigfpe" in
+ *yes) value=1;;
+ *) value=0;;
+ esac
+ AC_DEFINE_UNQUOTED(INTDIV0_RAISES_SIGFPE, $value,
+ [Define if integer division by zero raises signal SIGFPE.])
+])
diff --git a/src/ChangeLog b/src/ChangeLog
index 3f9355d..6a95a35 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,9 @@
+2002-06-07 Bruno Haible <bruno@clisp.org>
+
+ * msgfmt.c (install_sigfpe_handler): Assume the signal is always
+ SIGFPE, regardless of the platform.
+ (uninstall_sigfpe_handler): Likewise.
+
2002-05-29 Bruno Haible <bruno@clisp.org>
* dir-list.h (dir_list_save_reset, dir_list_restore): New declarations.
diff --git a/src/msgfmt.c b/src/msgfmt.c
index f8883f9..058178d 100644
--- a/src/msgfmt.c
+++ b/src/msgfmt.c
@@ -720,10 +720,6 @@ install_sigfpe_handler ()
sigaction (SIGFPE, &action, (struct sigaction *) NULL);
#else
signal (SIGFPE, sigfpe_handler);
- /* Irix and AIX send SIGTRAP, not SIGFPE. */
-# if (defined (__sgi) || defined (_AIX)) && defined (SIGTRAP)
- signal (SIGTRAP, sigfpe_handler);
-# endif
#endif
}
@@ -738,10 +734,6 @@ uninstall_sigfpe_handler ()
sigaction (SIGFPE, &action, (struct sigaction *) NULL);
#else
signal (SIGFPE, SIG_DFL);
- /* Irix and AIX send SIGTRAP, not SIGFPE. */
-# if (defined (__sgi) || defined (_AIX)) && defined (SIGTRAP)
- signal (SIGTRAP, SIG_DFL);
-# endif
#endif
}