diff options
author | Joseph Myers <joseph@codesourcery.com> | 2017-11-07 18:08:44 +0000 |
---|---|---|
committer | Joseph Myers <joseph@codesourcery.com> | 2017-11-07 18:08:44 +0000 |
commit | 58c4a1612db6a52d814d856f20bf93f1cac45232 (patch) | |
tree | df0d6ed7c208c8a41e21e740c869fd50b4141989 /stdlib | |
parent | feda96a1781e6d79a091df8747e696ba2751df82 (diff) | |
download | glibc-58c4a1612db6a52d814d856f20bf93f1cac45232.zip glibc-58c4a1612db6a52d814d856f20bf93f1cac45232.tar.gz glibc-58c4a1612db6a52d814d856f20bf93f1cac45232.tar.bz2 |
Handle more _FloatN, _FloatNx types in type-generic strtod tests.
Continuing the preparation for additional _FloatN / _FloatNx type
support, this patch adds support to type-generic strtod tests.
GEN_STRTOD_TEST_FOREACH and STRTOD_TEST_FOREACH are made to handle the
full set of such types. tst-strtod-round-skeleton.c is updated for
those types it can handle without needing changes to the generator
(i.e. those types that have already-handled formats).
Tested for x86_64.
* stdlib/tst-strtod.h (F16): New macro.
(F32): Likewise.
(F64): Likewise.
(F32X): Likewise.
(F64X): Likewise.
(F128X): Likewise.
(IF_FLOAT16): Likewise.
(IF_FLOAT32): Likewise.
(IF_FLOAT64): Likewise.
(IF_FLOAT32X): Likewise.
(IF_FLOAT64X): Likewise.
(IF_FLOAT128X): Likewise.
(GEN_TEST_STRTOD_FOREACH): Conditionally call macros for _Float16,
_Float32, _Float64, _Float32x, _Float64x and _Float128x.
(STRTOD_TEST_FOREACH): Likewise.
* stdlib/tst-strtod-round-skeleton.c (CHOOSE_f32): New macro.
(CHOOSE_f64): Likewise.
(CHOOSE_f32x): Likewise.
(CHOOSE_f64x): Likewise.
Diffstat (limited to 'stdlib')
-rw-r--r-- | stdlib/tst-strtod-round-skeleton.c | 20 | ||||
-rw-r--r-- | stdlib/tst-strtod.h | 83 |
2 files changed, 91 insertions, 12 deletions
diff --git a/stdlib/tst-strtod-round-skeleton.c b/stdlib/tst-strtod-round-skeleton.c index 1a9f663..763c9ce 100644 --- a/stdlib/tst-strtod-round-skeleton.c +++ b/stdlib/tst-strtod-round-skeleton.c @@ -92,9 +92,27 @@ /* Add type specific choosing macros below. */ #define CHOOSE_f(f,...) f +#define CHOOSE_f32(f,...) f #define CHOOSE_d(f,d,...) d +#define CHOOSE_f64(f,d,...) d +#define CHOOSE_f32x(f,d,...) d #define CHOOSE_f128(f,d,ld64i,ld64m,ld106,ld113,...) ld113 -/* long double is special, and handled above. */ +/* long double is special, and handled above. _Float16 would require + updates to the generator to generate appropriate expectations, and + updates to the test inputs to cover difficult rounding cases for + _Float16. */ + +#if __HAVE_FLOAT64X +# if FLT64X_MANT_DIG == 113 && FLT64X_MAX_EXP == 16384 +# define CHOOSE_f64x(f,d,ld64i,ld64m,ld106,ld113,...) ld113 +# elif (FLT64X_MANT_DIG == 64 \ + && FLT64X_MAX_EXP == 16384 \ + && FLT64X_MIN_EXP == -16381) +# define CHOOSE_f64x(f,d,ld64i,...) ld64i +# else +# error "unknown _Float64x format" +# endif +#endif /* Selector for expected result field of a given type. */ #define _ENTRY(FSUF, FTYPE, FTOSTR, LSUF, CSUF, ...) \ diff --git a/stdlib/tst-strtod.h b/stdlib/tst-strtod.h index bc82ee0..3520735 100644 --- a/stdlib/tst-strtod.h +++ b/stdlib/tst-strtod.h @@ -23,16 +23,59 @@ #include <bits/floatn.h> +#define F16 __f16 () +#define F32 __f32 () +#define F64 __f64 () #define F128 __f128 () +#define F32X __f32x () +#define F64X __f64x () +#define F128X __f128x () + +/* Test strfromfN and strtofN on all platforms that provide them, + whether or not the type _FloatN is ABI-distinct from other types; + likewise _FloatNx functions. */ +#if __HAVE_FLOAT16 +# define IF_FLOAT16(x) x +#else +# define IF_FLOAT16(x) +#endif + +#if __HAVE_FLOAT32 +# define IF_FLOAT32(x) x +#else +# define IF_FLOAT32(x) +#endif + +#if __HAVE_FLOAT64 +# define IF_FLOAT64(x) x +#else +# define IF_FLOAT64(x) +#endif -/* Test strfromf128 and strtof128 on all platforms that provide them, - whether or not the type _Float128 is ABI-distinct from long double. */ #if __HAVE_FLOAT128 # define IF_FLOAT128(x) x #else # define IF_FLOAT128(x) #endif +#if __HAVE_FLOAT32X +# define IF_FLOAT32X(x) x +#else +# define IF_FLOAT32X(x) +#endif + +#if __HAVE_FLOAT64X +# define IF_FLOAT64X(x) x +#else +# define IF_FLOAT64X(x) +#endif + +#if __HAVE_FLOAT128X +# define IF_FLOAT128X(x) x +#else +# define IF_FLOAT128X(x) +#endif + /* Provide an extra parameter expansion for mfunc. */ #define MMFUNC(mmfunc, ...) mmfunc (__VA_ARGS__) @@ -41,8 +84,20 @@ mfunc ( f, float, strfromf, f, f, ##__VA_ARGS__) \ mfunc ( d, double, strfromd, , , ##__VA_ARGS__) \ mfunc ( ld, long double, strfroml, L, l, ##__VA_ARGS__) \ + IF_FLOAT16 (MMFUNC \ + (mfunc, f16, _Float16, strfromf16, F16, f16, ##__VA_ARGS__)) \ + IF_FLOAT32 (MMFUNC \ + (mfunc, f32, _Float32, strfromf32, F32, f32, ##__VA_ARGS__)) \ + IF_FLOAT64 (MMFUNC \ + (mfunc, f64, _Float64, strfromf64, F64, f64, ##__VA_ARGS__)) \ IF_FLOAT128 (MMFUNC \ - (mfunc, f128, _Float128, strfromf128, F128, f128, ##__VA_ARGS__)) + (mfunc, f128, _Float128, strfromf128, F128, f128, ##__VA_ARGS__)) \ + IF_FLOAT32X (MMFUNC \ + (mfunc, f32x, _Float32x, strfromf32x, F32X, f32x, ##__VA_ARGS__)) \ + IF_FLOAT64X (MMFUNC \ + (mfunc, f64x, _Float64x, strfromf64x, F64X, f64x, ##__VA_ARGS__)) \ + IF_FLOAT128X (MMFUNC \ + (mfunc, f128x, _Float128x, strfromf128x, F128X, f128x, ##__VA_ARGS__)) /* The arguments to the generated macros are: FSUF - Function suffix FTYPE - float type @@ -53,14 +108,20 @@ -#define STRTOD_TEST_FOREACH(mfunc, ...) \ -({ \ - int result = 0; \ - result |= mfunc ## f (__VA_ARGS__); \ - result |= mfunc ## d (__VA_ARGS__); \ - result |= mfunc ## ld (__VA_ARGS__); \ - IF_FLOAT128 (result |= mfunc ## f128 (__VA_ARGS__)); \ - result; \ +#define STRTOD_TEST_FOREACH(mfunc, ...) \ +({ \ + int result = 0; \ + result |= mfunc ## f (__VA_ARGS__); \ + result |= mfunc ## d (__VA_ARGS__); \ + result |= mfunc ## ld (__VA_ARGS__); \ + IF_FLOAT16 (result |= mfunc ## f16 (__VA_ARGS__)); \ + IF_FLOAT32 (result |= mfunc ## f32 (__VA_ARGS__)); \ + IF_FLOAT64 (result |= mfunc ## f64 (__VA_ARGS__)); \ + IF_FLOAT128 (result |= mfunc ## f128 (__VA_ARGS__)); \ + IF_FLOAT32X (result |= mfunc ## f32x (__VA_ARGS__)); \ + IF_FLOAT64X (result |= mfunc ## f64x (__VA_ARGS__)); \ + IF_FLOAT128X (result |= mfunc ## f128x (__VA_ARGS__)); \ + result; \ }) |