Blame gettext-runtime/m4/intdiv0.m4

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