Blame m4/intdiv0.m4

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