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