Blame gettext-runtime/m4/intdiv0.m4

Packit Bot 06c835
# intdiv0.m4 serial 6 (gettext-0.18.2)
Packit Bot 06c835
dnl Copyright (C) 2002, 2007-2008, 2010-2015 Free Software Foundation, Inc.
Packit Bot 06c835
dnl This file is free software; the Free Software Foundation
Packit Bot 06c835
dnl gives unlimited permission to copy and/or distribute it,
Packit Bot 06c835
dnl with or without modifications, as long as this notice is preserved.
Packit Bot 06c835
Packit Bot 06c835
dnl From Bruno Haible.
Packit Bot 06c835
Packit Bot 06c835
AC_DEFUN([gt_INTDIV0],
Packit Bot 06c835
[
Packit Bot 06c835
  AC_REQUIRE([AC_PROG_CC])dnl
Packit Bot 06c835
  AC_REQUIRE([AC_CANONICAL_HOST])dnl
Packit Bot 06c835
Packit Bot 06c835
  AC_CACHE_CHECK([whether integer division by zero raises SIGFPE],
Packit Bot 06c835
    gt_cv_int_divbyzero_sigfpe,
Packit Bot 06c835
    [
Packit Bot 06c835
      gt_cv_int_divbyzero_sigfpe=
Packit Bot 06c835
changequote(,)dnl
Packit Bot 06c835
      case "$host_os" in
Packit Bot 06c835
        macos* | darwin[6-9]* | darwin[1-9][0-9]*)
Packit Bot 06c835
          # On Mac OS X 10.2 or newer, just assume the same as when cross-
Packit Bot 06c835
          # compiling. If we were to perform the real test, 1 Crash Report
Packit Bot 06c835
          # dialog window would pop up.
Packit Bot 06c835
          case "$host_cpu" in
Packit Bot 06c835
            i[34567]86 | x86_64)
Packit Bot 06c835
              gt_cv_int_divbyzero_sigfpe="guessing yes" ;;
Packit Bot 06c835
          esac
Packit Bot 06c835
          ;;
Packit Bot 06c835
      esac
Packit Bot 06c835
changequote([,])dnl
Packit Bot 06c835
      if test -z "$gt_cv_int_divbyzero_sigfpe"; then
Packit Bot 06c835
        AC_RUN_IFELSE(
Packit Bot 06c835
          [AC_LANG_SOURCE([[
Packit Bot 06c835
#include <stdlib.h>
Packit Bot 06c835
#include <signal.h>
Packit Bot 06c835
Packit Bot 06c835
static void
Packit Bot 06c835
sigfpe_handler (int sig)
Packit Bot 06c835
{
Packit Bot 06c835
  /* Exit with code 0 if SIGFPE, with code 1 if any other signal.  */
Packit Bot 06c835
  exit (sig != SIGFPE);
Packit Bot 06c835
}
Packit Bot 06c835
Packit Bot 06c835
int x = 1;
Packit Bot 06c835
int y = 0;
Packit Bot 06c835
int z;
Packit Bot 06c835
int nan;
Packit Bot 06c835
Packit Bot 06c835
int main ()
Packit Bot 06c835
{
Packit Bot 06c835
  signal (SIGFPE, sigfpe_handler);
Packit Bot 06c835
/* IRIX and AIX (when "xlc -qcheck" is used) yield signal SIGTRAP.  */
Packit Bot 06c835
#if (defined (__sgi) || defined (_AIX)) && defined (SIGTRAP)
Packit Bot 06c835
  signal (SIGTRAP, sigfpe_handler);
Packit Bot 06c835
#endif
Packit Bot 06c835
/* Linux/SPARC yields signal SIGILL.  */
Packit Bot 06c835
#if defined (__sparc__) && defined (__linux__)
Packit Bot 06c835
  signal (SIGILL, sigfpe_handler);
Packit Bot 06c835
#endif
Packit Bot 06c835
Packit Bot 06c835
  z = x / y;
Packit Bot 06c835
  nan = y / y;
Packit Bot 06c835
  exit (2);
Packit Bot 06c835
}
Packit Bot 06c835
]])],
Packit Bot 06c835
          [gt_cv_int_divbyzero_sigfpe=yes],
Packit Bot 06c835
          [gt_cv_int_divbyzero_sigfpe=no],
Packit Bot 06c835
          [
Packit Bot 06c835
            # Guess based on the CPU.
Packit Bot 06c835
changequote(,)dnl
Packit Bot 06c835
            case "$host_cpu" in
Packit Bot 06c835
              alpha* | i[34567]86 | x86_64 | m68k | s390*)
Packit Bot 06c835
                gt_cv_int_divbyzero_sigfpe="guessing yes";;
Packit Bot 06c835
              *)
Packit Bot 06c835
                gt_cv_int_divbyzero_sigfpe="guessing no";;
Packit Bot 06c835
            esac
Packit Bot 06c835
changequote([,])dnl
Packit Bot 06c835
          ])
Packit Bot 06c835
      fi
Packit Bot 06c835
    ])
Packit Bot 06c835
  case "$gt_cv_int_divbyzero_sigfpe" in
Packit Bot 06c835
    *yes) value=1;;
Packit Bot 06c835
    *) value=0;;
Packit Bot 06c835
  esac
Packit Bot 06c835
  AC_DEFINE_UNQUOTED([INTDIV0_RAISES_SIGFPE], [$value],
Packit Bot 06c835
    [Define if integer division by zero raises signal SIGFPE.])
Packit Bot 06c835
])