1 /* Common utilities for testing strtod and its derivatives.
2 This file is part of the GNU C Library.
3 Copyright (C) 2016-2023 Free Software Foundation, Inc.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
22 #define FSTRLENMAX 128
24 #include <bits/floatn.h>
29 #define F128 __f128 ()
30 #define F32X __f32x ()
31 #define F64X __f64x ()
32 #define F128X __f128x ()
34 /* Test strfromfN and strtofN on all platforms that provide them,
35 whether or not the type _FloatN is ABI-distinct from other types;
36 likewise _FloatNx functions. */
38 # define IF_FLOAT16(x) x
40 # define IF_FLOAT16(x)
44 # define IF_FLOAT32(x) x
46 # define IF_FLOAT32(x)
50 # define IF_FLOAT64(x) x
52 # define IF_FLOAT64(x)
56 # define IF_FLOAT128(x) x
58 # define IF_FLOAT128(x)
62 # define IF_FLOAT32X(x) x
64 # define IF_FLOAT32X(x)
68 # define IF_FLOAT64X(x) x
70 # define IF_FLOAT64X(x)
74 # define IF_FLOAT128X(x) x
76 # define IF_FLOAT128X(x)
79 /* Provide an extra parameter expansion for mfunc. */
80 #define MMFUNC(mmfunc, ...) mmfunc (__VA_ARGS__)
82 /* Splat n variants of the same test for the various strtod functions. */
83 #define GEN_TEST_STRTOD_FOREACH(mfunc, ...) \
84 mfunc ( f, float, strfromf, f, f, ##__VA_ARGS__) \
85 mfunc ( d, double, strfromd, , , ##__VA_ARGS__) \
86 mfunc ( ld, long double, strfroml, L, l, ##__VA_ARGS__) \
88 (mfunc, f16, _Float16, strfromf16, F16, f16, ##__VA_ARGS__)) \
90 (mfunc, f32, _Float32, strfromf32, F32, f32, ##__VA_ARGS__)) \
92 (mfunc, f64, _Float64, strfromf64, F64, f64, ##__VA_ARGS__)) \
94 (mfunc, f128, _Float128, strfromf128, F128, f128, ##__VA_ARGS__)) \
96 (mfunc, f32x, _Float32x, strfromf32x, F32X, f32x, ##__VA_ARGS__)) \
98 (mfunc, f64x, _Float64x, strfromf64x, F64X, f64x, ##__VA_ARGS__)) \
99 IF_FLOAT128X (MMFUNC \
100 (mfunc, f128x, _Float128x, strfromf128x, F128X, f128x, ##__VA_ARGS__))
101 /* The arguments to the generated macros are:
102 FSUF - Function suffix
104 FTOSTR - float to string func
105 LSUF - Literal suffix
106 CSUF - C standardish suffix for many of the math functions
111 #define STRTOD_TEST_FOREACH(mfunc, ...) \
114 result |= mfunc ## f (__VA_ARGS__); \
115 result |= mfunc ## d (__VA_ARGS__); \
116 result |= mfunc ## ld (__VA_ARGS__); \
117 IF_FLOAT16 (result |= mfunc ## f16 (__VA_ARGS__)); \
118 IF_FLOAT32 (result |= mfunc ## f32 (__VA_ARGS__)); \
119 IF_FLOAT64 (result |= mfunc ## f64 (__VA_ARGS__)); \
120 IF_FLOAT128 (result |= mfunc ## f128 (__VA_ARGS__)); \
121 IF_FLOAT32X (result |= mfunc ## f32x (__VA_ARGS__)); \
122 IF_FLOAT64X (result |= mfunc ## f64x (__VA_ARGS__)); \
123 IF_FLOAT128X (result |= mfunc ## f128x (__VA_ARGS__)); \