Blame m4/fpieee.m4

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