Blame m4/intdiv0.m4

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