summaryrefslogtreecommitdiffstats
path: root/gl/float.in.h
diff options
context:
space:
mode:
authorLorenz Kästle <12514511+RincewindsHat@users.noreply.github.com>2025-12-28 12:13:40 +0100
committerLorenz Kästle <12514511+RincewindsHat@users.noreply.github.com>2025-12-28 12:13:40 +0100
commitb0afb8fe0ff1d87165af9df61501197a06240dda (patch)
tree274ac6a96c53ef4c19ab4974ce24a06a233128c5 /gl/float.in.h
parent68fc05381ee5fa0aee1413118fbb3d81ca888b09 (diff)
downloadmonitoring-plugins-b0afb8fe0ff1d87165af9df61501197a06240dda.tar.gz
Sync with Gnulib stable-202507 code (a8ac9f9ce5)
Diffstat (limited to 'gl/float.in.h')
-rw-r--r--gl/float.in.h221
1 files changed, 194 insertions, 27 deletions
diff --git a/gl/float.in.h b/gl/float.in.h
index 73e8d406..d75a06e7 100644
--- a/gl/float.in.h
+++ b/gl/float.in.h
@@ -1,6 +1,6 @@
1/* A correct <float.h>. 1/* A correct <float.h>.
2 2
3 Copyright (C) 2007-2024 Free Software Foundation, Inc. 3 Copyright (C) 2007-2025 Free Software Foundation, Inc.
4 4
5 This file is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as 6 it under the terms of the GNU Lesser General Public License as
@@ -28,6 +28,8 @@
28#ifndef _@GUARD_PREFIX@_FLOAT_H 28#ifndef _@GUARD_PREFIX@_FLOAT_H
29#define _@GUARD_PREFIX@_FLOAT_H 29#define _@GUARD_PREFIX@_FLOAT_H
30 30
31/* ============================ ISO C99 support ============================ */
32
31/* 'long double' properties. */ 33/* 'long double' properties. */
32 34
33#if defined __i386__ && (defined __BEOS__ || defined __OpenBSD__) 35#if defined __i386__ && (defined __BEOS__ || defined __OpenBSD__)
@@ -111,44 +113,38 @@ extern const union gl_long_double_union gl_LDBL_MAX;
111# define LDBL_MAX_10_EXP 4932 113# define LDBL_MAX_10_EXP 4932
112#endif 114#endif
113 115
114/* On AIX 7.1 with gcc 4.2, the values of LDBL_MIN_EXP, LDBL_MIN, LDBL_MAX are 116/* On PowerPC with gcc 15 when using __ibm128 long double, the value of
115 wrong. 117 LDBL_MIN_EXP, LDBL_MIN, LDBL_MAX, and LDBL_NORM_MAX are wrong. */
116 On Linux/PowerPC with gcc 4.4, the value of LDBL_MAX is wrong. */ 118#if (defined _ARCH_PPC && LDBL_MANT_DIG == 106 \
117#if (defined _ARCH_PPC || defined _POWER) && defined _AIX && (LDBL_MANT_DIG == 106) && defined __GNUC__ 119 && defined __GNUC__)
118# undef LDBL_MIN_EXP 120# undef LDBL_MIN_EXP
119# define LDBL_MIN_EXP DBL_MIN_EXP 121# define LDBL_MIN_EXP DBL_MIN_EXP
120# undef LDBL_MIN_10_EXP 122# undef LDBL_MIN_10_EXP
121# define LDBL_MIN_10_EXP DBL_MIN_10_EXP 123# define LDBL_MIN_10_EXP DBL_MIN_10_EXP
122# undef LDBL_MIN 124# undef LDBL_MIN
123# define LDBL_MIN 2.22507385850720138309023271733240406422e-308L /* DBL_MIN = 2^-1022 */ 125# define LDBL_MIN 2.22507385850720138309023271733240406422e-308L /* DBL_MIN = 2^-1022 */
124#endif
125#if (defined _ARCH_PPC || defined _POWER) && (defined _AIX || defined __linux__) && (LDBL_MANT_DIG == 106) && defined __GNUC__
126# undef LDBL_MAX 126# undef LDBL_MAX
127/* LDBL_MAX is represented as { 0x7FEFFFFF, 0xFFFFFFFF, 0x7C8FFFFF, 0xFFFFFFFF }. 127/* LDBL_MAX is 2**1024 - 2**918, represented as: { 0x7FEFFFFF, 0xFFFFFFFF,
128 It is not easy to define: 128 0x7C9FFFFF, 0xFFFFFFFF }.
129 #define LDBL_MAX 1.79769313486231580793728971405302307166e308L 129
130 is too small, whereas 130 Do not write it as a constant expression, as GCC would likely treat
131 #define LDBL_MAX 1.79769313486231580793728971405302307167e308L 131 that as infinity due to the vagaries of this platform's funky arithmetic.
132 is too large. Apparently a bug in GCC decimal-to-binary conversion. 132 Instead, define it through a reference to an external variable.
133 Also, I can't get values larger than 133 Like the following, but using a union to avoid type mismatches:
134 #define LDBL63 ((long double) (1ULL << 63))
135 #define LDBL882 (LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63)
136 #define LDBL945 (LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63)
137 #define LDBL1008 (LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63)
138 #define LDBL_MAX (LDBL1008 * 65535.0L + LDBL945 * (long double) 9223372036821221375ULL + LDBL882 * (long double) 4611686018427387904ULL)
139 which is represented as { 0x7FEFFFFF, 0xFFFFFFFF, 0x7C8FFFFF, 0xF8000000 }.
140 So, define it like this through a reference to an external variable
141 134
142 const double LDBL_MAX[2] = { DBL_MAX, DBL_MAX / (double)134217728UL / (double)134217728UL }; 135 const double LDBL_MAX[2] = { DBL_MAX, DBL_MAX / 0x1p53 };
143 extern const long double LDBL_MAX; 136 extern const long double LDBL_MAX;
144 137
145 or through a pointer cast 138 The following alternative would not work as well when GCC is optimizing:
146 139
147 #define LDBL_MAX \ 140 #define LDBL_MAX (*(long double const *) (double[])
148 (*(const long double *) (double[]) { DBL_MAX, DBL_MAX / (double)134217728UL / (double)134217728UL }) 141 { DBL_MAX, DBL_MAX / 0x1p53 })
149 142
150 Unfortunately, this is not a constant expression, and the latter expression 143 The following alternative would require GCC 6 or later:
151 does not work well when GCC is optimizing.. */ 144
145 #define LDBL_MAX __builtin_pack_longdouble (DBL_MAX, DBL_MAX / 0x1p53)
146
147 Unfortunately none of the alternatives are constant expressions. */
152# if !GNULIB_defined_long_double_union 148# if !GNULIB_defined_long_double_union
153union gl_long_double_union 149union gl_long_double_union
154 { 150 {
@@ -159,6 +155,8 @@ union gl_long_double_union
159# endif 155# endif
160extern const union gl_long_double_union gl_LDBL_MAX; 156extern const union gl_long_double_union gl_LDBL_MAX;
161# define LDBL_MAX (gl_LDBL_MAX.ld) 157# define LDBL_MAX (gl_LDBL_MAX.ld)
158# undef LDBL_NORM_MAX
159# define LDBL_NORM_MAX LDBL_MAX
162#endif 160#endif
163 161
164/* On IRIX 6.5, with cc, the value of LDBL_MANT_DIG is wrong. 162/* On IRIX 6.5, with cc, the value of LDBL_MANT_DIG is wrong.
@@ -179,6 +177,175 @@ extern const union gl_long_double_union gl_LDBL_MAX;
179# endif 177# endif
180#endif 178#endif
181 179
180/* On PowerPC platforms, 'long double' has a double-double representation.
181 Up to ISO C 17, this was outside the scope of ISO C because it can represent
182 numbers with mantissas of the form 1.<52 bits><many zeroes><52 bits>, such as
183 1.0L + 4.94065645841246544176568792868221e-324L = 1 + 2^-1074; see
184 ISO C 17 § 5.2.4.2.2.(3).
185 In ISO C 23, wording has been included that makes this 'long double'
186 representation compliant; see ISO C 23 § 5.2.5.3.3.(8)-(9). In this setting,
187 numbers with mantissas of the form 1.<52 bits><many zeroes><52 bits> are
188 called "unnormalized". And since LDBL_EPSILON must be normalized (per
189 ISO C 23 § 5.2.5.3.3.(33)), it must be 2^-105. */
190#if defined __powerpc__ && LDBL_MANT_DIG == 106
191# undef LDBL_EPSILON
192# define LDBL_EPSILON 2.46519032881566189191165176650870696773e-32L /* 2^-105 */
193#endif
194
195/* ============================ ISO C11 support ============================ */
196
197/* 'float' properties */
198
199#ifndef FLT_HAS_SUBNORM
200# define FLT_HAS_SUBNORM 1
201#endif
202#ifndef FLT_DECIMAL_DIG
203/* FLT_MANT_DIG = 24 => FLT_DECIMAL_DIG = 9 */
204# define FLT_DECIMAL_DIG ((int)(FLT_MANT_DIG * 0.3010299956639812 + 2))
205#endif
206#if defined _AIX && !defined __GNUC__
207/* On AIX, the value of FLT_TRUE_MIN in /usr/include/float.h is a 'double',
208 not a 'float'. */
209# undef FLT_TRUE_MIN
210#endif
211#ifndef FLT_TRUE_MIN
212/* FLT_MIN / 2^(FLT_MANT_DIG-1) */
213# define FLT_TRUE_MIN (FLT_MIN / 8388608.0f)
214#endif
215
216/* 'double' properties */
217
218#ifndef DBL_HAS_SUBNORM
219# define DBL_HAS_SUBNORM 1
220#endif
221#ifndef DBL_DECIMAL_DIG
222/* DBL_MANT_DIG = 53 => DBL_DECIMAL_DIG = 17 */
223# define DBL_DECIMAL_DIG ((int)(DBL_MANT_DIG * 0.3010299956639812 + 2))
224#endif
225#ifndef DBL_TRUE_MIN
226/* DBL_MIN / 2^(DBL_MANT_DIG-1) */
227# define DBL_TRUE_MIN (DBL_MIN / 4503599627370496.0)
228#endif
229
230/* 'long double' properties */
231
232#ifndef LDBL_HAS_SUBNORM
233# define LDBL_HAS_SUBNORM 1
234#endif
235#ifndef LDBL_DECIMAL_DIG
236/* LDBL_MANT_DIG = 53 => LDBL_DECIMAL_DIG = 17 */
237/* LDBL_MANT_DIG = 64 => LDBL_DECIMAL_DIG = 21 */
238/* LDBL_MANT_DIG = 106 => LDBL_DECIMAL_DIG = 33 */
239/* LDBL_MANT_DIG = 113 => LDBL_DECIMAL_DIG = 36 */
240# define LDBL_DECIMAL_DIG ((int)(LDBL_MANT_DIG * 0.3010299956639812 + 2))
241#endif
242#ifndef LDBL_TRUE_MIN
243/* LDBL_MIN / 2^(LDBL_MANT_DIG-1) */
244# if LDBL_MANT_DIG == 53
245# define LDBL_TRUE_MIN (LDBL_MIN / 4503599627370496.0L)
246# elif LDBL_MANT_DIG == 64
247# if defined __i386__ && (defined __FreeBSD__ || defined __DragonFly__)
248/* Work around FreeBSD/x86 problem mentioned above. */
249extern const union gl_long_double_union gl_LDBL_TRUE_MIN;
250# define LDBL_TRUE_MIN (gl_LDBL_TRUE_MIN.ld)
251# else
252# define LDBL_TRUE_MIN (LDBL_MIN / 9223372036854775808.0L)
253# endif
254# elif LDBL_MANT_DIG == 106
255# define LDBL_TRUE_MIN (LDBL_MIN / 40564819207303340847894502572032.0L)
256# elif LDBL_MANT_DIG == 113
257# define LDBL_TRUE_MIN (LDBL_MIN / 5192296858534827628530496329220096.0L)
258# endif
259#endif
260
261/* ============================ ISO C23 support ============================ */
262
263/* 'float' properties */
264
265#ifndef FLT_IS_IEC_60559
266# if defined __m68k__
267# define FLT_IS_IEC_60559 0
268# else
269# define FLT_IS_IEC_60559 1
270# endif
271#endif
272#ifndef FLT_NORM_MAX
273# define FLT_NORM_MAX FLT_MAX
274#endif
275#ifndef FLT_SNAN
276/* For sh, beware of <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111814>. */
277# if ((__GNUC__ + (__GNUC_MINOR__ >= 3) > 3) || defined __clang__) && !defined __sh__
278# define FLT_SNAN __builtin_nansf ("")
279# else
280typedef union { unsigned int word[1]; float value; } gl_FLT_SNAN_t;
281extern gl_FLT_SNAN_t gl_FLT_SNAN;
282# define FLT_SNAN (gl_FLT_SNAN.value)
283# define GNULIB_defined_FLT_SNAN 1
284# endif
285#endif
286
287/* 'double' properties */
288
289#ifndef DBL_IS_IEC_60559
290# if defined __m68k__
291# define DBL_IS_IEC_60559 0
292# else
293# define DBL_IS_IEC_60559 1
294# endif
295#endif
296#ifndef DBL_NORM_MAX
297# define DBL_NORM_MAX DBL_MAX
298#endif
299#ifndef DBL_SNAN
300/* For sh, beware of <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111814>. */
301# if ((__GNUC__ + (__GNUC_MINOR__ >= 3) > 3) || defined __clang__) && !defined __sh__
302# define DBL_SNAN __builtin_nans ("")
303# else
304typedef union { unsigned long long word[1]; double value; } gl_DBL_SNAN_t;
305extern gl_DBL_SNAN_t gl_DBL_SNAN;
306# define DBL_SNAN (gl_DBL_SNAN.value)
307# define GNULIB_defined_DBL_SNAN 1
308# endif
309#endif
310
311/* 'long double' properties */
312
313#ifndef LDBL_IS_IEC_60559
314# if defined __m68k__
315# define LDBL_IS_IEC_60559 0
316# elif LDBL_MANT_DIG == 53 || LDBL_MANT_DIG == 113
317# define LDBL_IS_IEC_60559 1
318# else
319# define LDBL_IS_IEC_60559 0
320# endif
321#endif
322#ifndef LDBL_NORM_MAX
323# ifdef __LDBL_NORM_MAX__
324# define LDBL_NORM_MAX __LDBL_NORM_MAX__
325# else
326# define LDBL_NORM_MAX LDBL_MAX
327# endif
328#endif
329#ifndef LDBL_SNAN
330/* For sh, beware of <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111814>. */
331# if ((__GNUC__ + (__GNUC_MINOR__ >= 3) > 3) || defined __clang__) && !defined __sh__
332# define LDBL_SNAN __builtin_nansl ("")
333# else
334# if LDBL_MANT_DIG == 53
335typedef union { unsigned long long word[1]; long double value; } gl_LDBL_SNAN_t;
336# elif defined __m68k__
337typedef union { unsigned int word[3]; long double value; } gl_LDBL_SNAN_t;
338# else
339typedef union { unsigned long long word[2]; long double value; } gl_LDBL_SNAN_t;
340# endif
341extern gl_LDBL_SNAN_t gl_LDBL_SNAN;
342# define LDBL_SNAN (gl_LDBL_SNAN.value)
343# define GNULIB_defined_LDBL_SNAN 1
344# endif
345#endif
346
347/* ================================= Other ================================= */
348
182#if @REPLACE_ITOLD@ 349#if @REPLACE_ITOLD@
183/* Pull in a function that fixes the 'int' to 'long double' conversion 350/* Pull in a function that fixes the 'int' to 'long double' conversion
184 of glibc 2.7. */ 351 of glibc 2.7. */