Blame m4/fpieee.m4

Packit Service a2489d
# fpieee.m4 serial 2  -*- coding: utf-8 -*-
Packit Service a2489d
dnl Copyright (C) 2007, 2009-2018 Free Software Foundation, Inc.
Packit Service a2489d
dnl This file is free software; the Free Software Foundation
Packit Service a2489d
dnl gives unlimited permission to copy and/or distribute it,
Packit Service a2489d
dnl with or without modifications, as long as this notice is preserved.
Packit Service a2489d
Packit Service a2489d
dnl IEEE 754 standardized three items:
Packit Service a2489d
dnl - The formats of single-float and double-float - nowadays commonly
Packit Service a2489d
dnl   available as 'float' and 'double' in C and C++.
Packit Service a2489d
dnl   No autoconf test needed.
Packit Service a2489d
dnl - The overflow and division by zero behaviour: The result are values
Packit Service a2489d
dnl   '±Inf' and 'NaN', rather than exceptions as it was before.
Packit Service a2489d
dnl   This file provides an autoconf macro for ensuring this behaviour of
Packit Service a2489d
dnl   floating-point operations.
Packit Service a2489d
dnl - A set of conditions (overflow, underflow, inexact, etc.) which can
Packit Service a2489d
dnl   be configured to trigger an exception.
Packit Service a2489d
dnl   This cannot be done in a portable way: it depends on the compiler,
Packit Service a2489d
dnl   libc, kernel, and CPU.  No autoconf macro is provided for this.
Packit Service a2489d
Packit Service a2489d
dnl Ensure non-trapping behaviour of floating-point overflow and
Packit Service a2489d
dnl floating-point division by zero.
Packit Service a2489d
dnl (For integer overflow, see gcc's -ftrapv option; for integer division by
Packit Service a2489d
dnl zero, see the autoconf macro in intdiv0.m4.)
Packit Service a2489d
Packit Service a2489d
AC_DEFUN([gl_FP_IEEE],
Packit Service a2489d
[
Packit Service a2489d
  AC_REQUIRE([AC_PROG_CC])
Packit Service a2489d
  AC_REQUIRE([AC_CANONICAL_HOST])
Packit Service a2489d
  # IEEE behaviour is the default on all CPUs except Alpha and SH
Packit Service a2489d
  # (according to the test results of Bruno Haible's ieeefp/fenv_default.m4
Packit Service a2489d
  # and the GCC 4.1.2 manual).
Packit Service a2489d
  case "$host_cpu" in
Packit Service a2489d
    alpha*)
Packit Service a2489d
      # On Alpha systems, a compiler option provides the behaviour.
Packit Service a2489d
      # See the ieee(3) manual page, also available at
Packit Service a2489d
      # <https://backdrift.org/man/tru64/man3/ieee.3.html>
Packit Service a2489d
      if test -n "$GCC"; then
Packit Service a2489d
        # GCC has the option -mieee.
Packit Service a2489d
        # For full IEEE compliance (rarely needed), use option -mieee-with-inexact.
Packit Service a2489d
        CPPFLAGS="$CPPFLAGS -mieee"
Packit Service a2489d
      else
Packit Service a2489d
        # Compaq (ex-DEC) C has the option -ieee, equivalent to -ieee_with_no_inexact.
Packit Service a2489d
        # For full IEEE compliance (rarely needed), use option -ieee_with_inexact.
Packit Service a2489d
        CPPFLAGS="$CPPFLAGS -ieee"
Packit Service a2489d
      fi
Packit Service a2489d
      ;;
Packit Service a2489d
    sh*)
Packit Service a2489d
      if test -n "$GCC"; then
Packit Service a2489d
        # GCC has the option -mieee.
Packit Service a2489d
        CPPFLAGS="$CPPFLAGS -mieee"
Packit Service a2489d
      fi
Packit Service a2489d
      ;;
Packit Service a2489d
  esac
Packit Service a2489d
])