1# intdiv0.m4 serial 7 (gettext-0.20.2) 2dnl Copyright (C) 2002, 2007-2008, 2010-2020 Free Software Foundation, Inc. 3dnl This file is free software; the Free Software Foundation 4dnl gives unlimited permission to copy and/or distribute it, 5dnl with or without modifications, as long as this notice is preserved. 6 7dnl From Bruno Haible. 8 9AC_DEFUN([gt_INTDIV0], 10[ 11 AC_REQUIRE([AC_PROG_CC])dnl 12 AC_REQUIRE([AC_CANONICAL_HOST])dnl 13 14 AC_CACHE_CHECK([whether integer division by zero raises SIGFPE], 15 gt_cv_int_divbyzero_sigfpe, 16 [ 17 gt_cv_int_divbyzero_sigfpe= 18changequote(,)dnl 19 case "$host_os" in 20 macos* | darwin[6-9]* | darwin[1-9][0-9]*) 21 # On Mac OS X 10.2 or newer, just assume the same as when cross- 22 # compiling. If we were to perform the real test, 1 Crash Report 23 # dialog window would pop up. 24 case "$host_cpu" in 25 i[34567]86 | x86_64) 26 gt_cv_int_divbyzero_sigfpe="guessing yes" ;; 27 esac 28 ;; 29 esac 30changequote([,])dnl 31 if test -z "$gt_cv_int_divbyzero_sigfpe"; then 32 AC_RUN_IFELSE( 33 [AC_LANG_SOURCE([[ 34#include <stdlib.h> /* for exit() */ 35#include <signal.h> 36#if !(defined _WIN32 && !defined __CYGWIN__) 37#include <unistd.h> /* for _exit() */ 38#endif 39 40static void 41sigfpe_handler (int sig) 42{ 43 /* Exit with code 0 if SIGFPE, with code 1 if any other signal. */ 44 _exit (sig != SIGFPE); 45} 46 47int x = 1; 48int y = 0; 49int z; 50int nan; 51 52int main () 53{ 54 signal (SIGFPE, sigfpe_handler); 55/* IRIX and AIX (when "xlc -qcheck" is used) yield signal SIGTRAP. */ 56#if (defined (__sgi) || defined (_AIX)) && defined (SIGTRAP) 57 signal (SIGTRAP, sigfpe_handler); 58#endif 59/* Linux/SPARC yields signal SIGILL. */ 60#if defined (__sparc__) && defined (__linux__) 61 signal (SIGILL, sigfpe_handler); 62#endif 63 64 z = x / y; 65 nan = y / y; 66 exit (2); 67} 68]])], 69 [gt_cv_int_divbyzero_sigfpe=yes], 70 [gt_cv_int_divbyzero_sigfpe=no], 71 [ 72 # Guess based on the CPU. 73changequote(,)dnl 74 case "$host_cpu" in 75 alpha* | i[34567]86 | x86_64 | m68k | s390*) 76 gt_cv_int_divbyzero_sigfpe="guessing yes";; 77 *) 78 gt_cv_int_divbyzero_sigfpe="guessing no";; 79 esac 80changequote([,])dnl 81 ]) 82 fi 83 ]) 84 case "$gt_cv_int_divbyzero_sigfpe" in 85 *yes) value=1;; 86 *) value=0;; 87 esac 88 AC_DEFINE_UNQUOTED([INTDIV0_RAISES_SIGFPE], [$value], 89 [Define if integer division by zero raises signal SIGFPE.]) 90]) 91