Blame m4/fpieee.m4

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