fpieee.m4 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. # fpieee.m4 serial 2 -*- coding: utf-8 -*-
  2. dnl Copyright (C) 2007, 2009-2021 Free Software Foundation, Inc.
  3. dnl This file is free software; the Free Software Foundation
  4. dnl gives unlimited permission to copy and/or distribute it,
  5. dnl with or without modifications, as long as this notice is preserved.
  6. dnl IEEE 754 standardized three items:
  7. dnl - The formats of single-float and double-float - nowadays commonly
  8. dnl available as 'float' and 'double' in C and C++.
  9. dnl No autoconf test needed.
  10. dnl - The overflow and division by zero behaviour: The result are values
  11. dnl '±Inf' and 'NaN', rather than exceptions as it was before.
  12. dnl This file provides an autoconf macro for ensuring this behaviour of
  13. dnl floating-point operations.
  14. dnl - A set of conditions (overflow, underflow, inexact, etc.) which can
  15. dnl be configured to trigger an exception.
  16. dnl This cannot be done in a portable way: it depends on the compiler,
  17. dnl libc, kernel, and CPU. No autoconf macro is provided for this.
  18. dnl Ensure non-trapping behaviour of floating-point overflow and
  19. dnl floating-point division by zero.
  20. dnl (For integer overflow, see gcc's -ftrapv option; for integer division by
  21. dnl zero, see the autoconf macro in intdiv0.m4.)
  22. AC_DEFUN([gl_FP_IEEE],
  23. [
  24. AC_REQUIRE([AC_PROG_CC])
  25. AC_REQUIRE([AC_CANONICAL_HOST])
  26. # IEEE behaviour is the default on all CPUs except Alpha and SH
  27. # (according to the test results of Bruno Haible's ieeefp/fenv_default.m4
  28. # and the GCC 4.1.2 manual).
  29. case "$host_cpu" in
  30. alpha*)
  31. # On Alpha systems, a compiler option provides the behaviour.
  32. # See the ieee(3) manual page, also available at
  33. # <https://backdrift.org/man/tru64/man3/ieee.3.html>
  34. if test -n "$GCC"; then
  35. # GCC has the option -mieee.
  36. # For full IEEE compliance (rarely needed), use option -mieee-with-inexact.
  37. CPPFLAGS="$CPPFLAGS -mieee"
  38. else
  39. # Compaq (ex-DEC) C has the option -ieee, equivalent to -ieee_with_no_inexact.
  40. # For full IEEE compliance (rarely needed), use option -ieee_with_inexact.
  41. CPPFLAGS="$CPPFLAGS -ieee"
  42. fi
  43. ;;
  44. sh*)
  45. if test -n "$GCC"; then
  46. # GCC has the option -mieee.
  47. CPPFLAGS="$CPPFLAGS -mieee"
  48. fi
  49. ;;
  50. esac
  51. ])