Hash :
fda40b61
Author :
Date :
2024-08-01T00:46:49
float: Update to mostly guarantee ISO C 23 compliance. * doc/posix-headers/float.texi: Mention the various portability problems. * lib/float.in.h (FLT_HAS_SUBNORM, FLT_DECIMAL_DIG, FLT_TRUE_MIN, DBL_HAS_SUBNORM, DBL_DECIMAL_DIG, DBL_TRUE_MIN, LDBL_HAS_SUBNORM, LDBL_DECIMAL_DIG, LDBL_TRUE_MIN): New macros. (gl_LDBL_TRUE_MIN): New declaration. (FLT_IS_IEC_60559, FLT_NORM_MAX, FLT_SNAN, GNULIB_defined_FLT_SNAN, DBL_IS_IEC_60559, DBL_NORM_MAX, DBL_SNAN, GNULIB_defined_DBL_SNAN, LDBL_IS_IEC_60559, LDBL_NORM_MAX, LDBL_SNAN, GNULIB_defined_LDBL_SNAN): New macros. (gl_FLT_SNAN_t, gl_DBL_SNAN_t, gl_LDBL_SNAN_t): New types. (gl_FLT_SNAN, gl_DBL_SNAN, gl_LDBL_SNAN): New declarations. * lib/float.c (gl_LDBL_TRUE_MIN): New variable. (gl_FLT_SNAN, gl_DBL_SNAN, gl_LDBL_SNAN): New variables. * m4/float_h.m4 (gl_FLOAT_H): Add check whether float.h conforms to ISO C23. Set REPLACE_FLOAT_SNAN. * modules/float (configure.ac): Test also REPLACE_FLOAT_SNAN. Require gl_BIGENDIAN. * tests/test-float.c: Also check FLT_EVAL_METHOD, FLT_HAS_SUBNORM, FLT_DECIMAL_DIG, FLT_IS_IEC_60559, FLT_TRUE_MIN, FLT_NORM_MAX, DBL_HAS_SUBNORM, DBL_DECIMAL_DIG, DBL_IS_IEC_60559, DBL_TRUE_MIN, DBL_NORM_MAX, LDBL_HAS_SUBNORM, LDBL_DECIMAL_DIG, LDBL_IS_IEC_60559. Conditionally check LDBL_TRUE_MIN, LDBL_NORM_MAX. Include isnanf-nolibm.h, isnand-nolibm.h, isnanl-nolibm.h. (test_float): Check the values of FLT_HAS_SUBNORM, FLT_DECIMAL_DIG, FLT_TRUE_MIN, FLT_IS_IEC_60559, FLT_NORM_MAX, FLT_SNAN. (test_double): Check the values of DBL_HAS_SUBNORM, DBL_DECIMAL_DIG, DBL_TRUE_MIN, DBL_IS_IEC_60559, DBL_NORM_MAX, DBL_SNAN. (test_long_double): Check the values of LDBL_HAS_SUBNORM, LDBL_DECIMAL_DIG, LDBL_TRUE_MIN, LDBL_IS_IEC_60559, LDBL_NORM_MAX, LDBL_SNAN. * modules/float-tests (Depends-on): Add isnanf-nolibm, isnand-nolibm, isnanl-nolibm.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
@node float.h
@section @file{float.h}
POSIX specification:@* @url{https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/float.h.html}
Gnulib module: float
Portability problems fixed by Gnulib:
@itemize
@item
The conversion from @code{int} to @code{long double} in incorrect on some
platforms:
glibc 2.7 on Linux/SPARC64.
@item
The values of @code{LDBL_*} macros are incorrect on some platforms:
On OpenBSD 4.0 and MirBSD 10, they are the same as the values of the
@code{DBL_*} macros, although @samp{long double} is a larger type than
@samp{double}.
On FreeBSD/x86 6.4, they represent the incorrect 53-bit precision assumptions
in the compiler, not the real 64-bit precision at runtime.
On Linux/PowerPC with GCC 4.4, and on AIX 7.1 with GCC 4.2,
they don't reflect the ``double double'' representation of @code{long double}
correctly.
@item
The macros
@code{FLT_HAS_SUBNORM}, @code{FLT_DECIMAL_DIG}, @code{FLT_TRUE_MIN},
@code{DBL_HAS_SUBNORM}, @code{DBL_DECIMAL_DIG}, @code{DBL_TRUE_MIN},
@code{LDBL_HAS_SUBNORM}, @code{LDBL_DECIMAL_DIG}, @code{LDBL_TRUE_MIN},
that were added in ISO C 11, are missing on some platforms:
gcc 4.5.4, clang 7, Solaris 11.3 with Sun C.
@item
The macro @code{LDBL_DECIMAL_DIG} is missing on some platforms:
MSVC 14.
@item
The value of macro @code{FLT_TRUE_MIN} is not a @code{float} on some platforms:
AIX 7.1 with xlc.
@item
The macros
@code{FLT_IS_IEC_60559}, @code{FLT_NORM_MAX}, @code{FLT_SNAN},
@code{DBL_IS_IEC_60559}, @code{DBL_NORM_MAX}, @code{DBL_SNAN},
@code{LDBL_IS_IEC_60559}, @code{LDBL_NORM_MAX}, @code{LDBL_SNAN},
that were added in ISO C 23, are missing on some platforms:
gcc 14 without @code{-std=c23} or @code{-std=gnu23}, clang 18, musl libc 1.2.5, AIX 7.3 with xlclang, Solaris 11.3 with Sun C, MSVC 14.
@end itemize
Portability problems not fixed by Gnulib:
@itemize
@item
The macro @code{FLT_ROUNDS} is a constant expression and does not represent
the current rounding mode on some platforms:
glibc 2.11, HP-UX 11, mingw.
@item
The value of @code{FLT_TRUE_MIN} is not a constant on some platforms:
FreeBSD/x86.
@item
The values of @code{FLT_SNAN}, @code{DBL_SNAN}, @code{LDBL_SNAN} are not
constants on some platforms:
AIX 7.3 with xlclang, and all platforms which use the gnulib replacements.
@end itemize