1*dc174305Schristos# intdiv0.m4 serial 1 (gettext-0.11.3) 2*dc174305Schristosdnl Copyright (C) 2002 Free Software Foundation, Inc. 3*dc174305Schristosdnl This file is free software, distributed under the terms of the GNU 4*dc174305Schristosdnl General Public License. As a special exception to the GNU General 5*dc174305Schristosdnl Public License, this file may be distributed as part of a program 6*dc174305Schristosdnl that contains a configuration script generated by Autoconf, under 7*dc174305Schristosdnl the same distribution terms as the rest of that program. 8*dc174305Schristos 9*dc174305Schristosdnl From Bruno Haible. 10*dc174305Schristos 11*dc174305SchristosAC_DEFUN([gt_INTDIV0], 12*dc174305Schristos[ 13*dc174305Schristos AC_REQUIRE([AC_PROG_CC])dnl 14*dc174305Schristos AC_REQUIRE([AC_CANONICAL_HOST])dnl 15*dc174305Schristos 16*dc174305Schristos AC_CACHE_CHECK([whether integer division by zero raises SIGFPE], 17*dc174305Schristos gt_cv_int_divbyzero_sigfpe, 18*dc174305Schristos [ 19*dc174305Schristos AC_TRY_RUN([ 20*dc174305Schristos#include <stdlib.h> 21*dc174305Schristos#include <signal.h> 22*dc174305Schristos 23*dc174305Schristosstatic void 24*dc174305Schristos#ifdef __cplusplus 25*dc174305Schristossigfpe_handler (int sig) 26*dc174305Schristos#else 27*dc174305Schristossigfpe_handler (sig) int sig; 28*dc174305Schristos#endif 29*dc174305Schristos{ 30*dc174305Schristos /* Exit with code 0 if SIGFPE, with code 1 if any other signal. */ 31*dc174305Schristos exit (sig != SIGFPE); 32*dc174305Schristos} 33*dc174305Schristos 34*dc174305Schristosint x = 1; 35*dc174305Schristosint y = 0; 36*dc174305Schristosint z; 37*dc174305Schristosint nan; 38*dc174305Schristos 39*dc174305Schristosint main () 40*dc174305Schristos{ 41*dc174305Schristos signal (SIGFPE, sigfpe_handler); 42*dc174305Schristos/* IRIX and AIX (when "xlc -qcheck" is used) yield signal SIGTRAP. */ 43*dc174305Schristos#if (defined (__sgi) || defined (_AIX)) && defined (SIGTRAP) 44*dc174305Schristos signal (SIGTRAP, sigfpe_handler); 45*dc174305Schristos#endif 46*dc174305Schristos/* Linux/SPARC yields signal SIGILL. */ 47*dc174305Schristos#if defined (__sparc__) && defined (__linux__) 48*dc174305Schristos signal (SIGILL, sigfpe_handler); 49*dc174305Schristos#endif 50*dc174305Schristos 51*dc174305Schristos z = x / y; 52*dc174305Schristos nan = y / y; 53*dc174305Schristos exit (1); 54*dc174305Schristos} 55*dc174305Schristos], gt_cv_int_divbyzero_sigfpe=yes, gt_cv_int_divbyzero_sigfpe=no, 56*dc174305Schristos [ 57*dc174305Schristos # Guess based on the CPU. 58*dc174305Schristos case "$host_cpu" in 59*dc174305Schristos alpha* | i[34567]86 | m68k | s390*) 60*dc174305Schristos gt_cv_int_divbyzero_sigfpe="guessing yes";; 61*dc174305Schristos *) 62*dc174305Schristos gt_cv_int_divbyzero_sigfpe="guessing no";; 63*dc174305Schristos esac 64*dc174305Schristos ]) 65*dc174305Schristos ]) 66*dc174305Schristos case "$gt_cv_int_divbyzero_sigfpe" in 67*dc174305Schristos *yes) value=1;; 68*dc174305Schristos *) value=0;; 69*dc174305Schristos esac 70*dc174305Schristos AC_DEFINE_UNQUOTED(INTDIV0_RAISES_SIGFPE, $value, 71*dc174305Schristos [Define if integer division by zero raises signal SIGFPE.]) 72*dc174305Schristos]) 73