diff options
Diffstat (limited to 'stdlib')
-rw-r--r-- | stdlib/Makefile | 1 | ||||
-rw-r--r-- | stdlib/stdlib.h | 14 | ||||
-rw-r--r-- | stdlib/tst-strtod-nan-locale-main.c | 36 | ||||
-rw-r--r-- | stdlib/tst-strtod-round-skeleton.c | 1 | ||||
-rw-r--r-- | stdlib/tst-strtod.h | 36 |
5 files changed, 59 insertions, 29 deletions
diff --git a/stdlib/Makefile b/stdlib/Makefile index 9b0acce..0314d59 100644 --- a/stdlib/Makefile +++ b/stdlib/Makefile @@ -198,6 +198,7 @@ $(objpfx)tst-putenvmod.so: $(objpfx)tst-putenvmod.os $(link-libc-deps) libof-tst-putenvmod = extramodules $(objpfx)bug-getcontext: $(libm) +$(objpfx)bug-strtod2: $(libm) $(objpfx)tst-strtod-round: $(libm) $(objpfx)tst-tininess: $(libm) $(objpfx)tst-strtod-underflow: $(libm) diff --git a/stdlib/stdlib.h b/stdlib/stdlib.h index 0a693c2..6f1e70e 100644 --- a/stdlib/stdlib.h +++ b/stdlib/stdlib.h @@ -128,6 +128,13 @@ extern long double strtold (const char *__restrict __nptr, __THROW __nonnull ((1)); #endif +#if __HAVE_FLOAT128 && __GLIBC_USE (IEC_60559_TYPES_EXT) +/* Likewise for the '_Float128' format */ +extern _Float128 strtof128 (const char *__restrict __nptr, + char **__restrict __endptr) + __THROW __nonnull ((1)); +#endif + /* Convert a string to a long integer. */ extern long int strtol (const char *__restrict __nptr, char **__restrict __endptr, int __base) @@ -236,6 +243,13 @@ extern long double strtold_l (const char *__restrict __nptr, char **__restrict __endptr, __locale_t __loc) __THROW __nonnull ((1, 3)); + +# if __HAVE_FLOAT128 +extern _Float128 strtof128_l (const char *__restrict __nptr, + char **__restrict __endptr, + __locale_t __loc) + __THROW __nonnull ((1, 3)); +# endif #endif /* GNU */ diff --git a/stdlib/tst-strtod-nan-locale-main.c b/stdlib/tst-strtod-nan-locale-main.c index 8044dad..8222174 100644 --- a/stdlib/tst-strtod-nan-locale-main.c +++ b/stdlib/tst-strtod-nan-locale-main.c @@ -23,6 +23,8 @@ #include <stdlib.h> #include <wchar.h> +#include <stdlib/tst-strtod.h> + #define STR_(X) #X #define STR(X) STR_(X) #define FNPFXS STR (FNPFX) @@ -30,20 +32,22 @@ #define CONCAT(X, Y) CONCAT_ (X, Y) #define FNX(FN) CONCAT (FNPFX, FN) -#define TEST(LOC, STR, FN, TYPE) \ - do \ +#define TEST_STRTOD(FSUF, FTYPE, FTOSTR, LSUF, CSUF) \ +static int \ +test_strto ## FSUF (const char * loc, CHAR * s) \ +{ \ + CHAR *ep; \ + FTYPE val = FNX (FSUF) (s, &ep); \ + if (isnan (val) && *ep == 0) \ + printf ("PASS: %s: " FNPFXS #FSUF " (" SFMT ")\n", loc, s); \ + else \ { \ - CHAR *ep; \ - TYPE val = FNX (FN) (STR, &ep); \ - if (isnan (val) && *ep == 0) \ - printf ("PASS: %s: " FNPFXS #FN " (" SFMT ")\n", LOC, STR); \ - else \ - { \ - printf ("FAIL: %s: " FNPFXS #FN " (" SFMT ")\n", LOC, STR); \ - result = 1; \ - } \ + printf ("FAIL: %s: " FNPFXS #FSUF " (" SFMT ")\n", loc, s); \ + return 1; \ } \ - while (0) + return 0; \ +} +GEN_TEST_STRTOD_FOREACH (TEST_STRTOD) static int test_one_locale (const char *loc) @@ -64,13 +68,9 @@ test_one_locale (const char *loc) s[4] = L_('A') + i - 10; s[5] = L_(')'); s[6] = 0; - TEST (loc, s, f, float); - TEST (loc, s, d, double); - TEST (loc, s, ld, long double); + result |= STRTOD_TEST_FOREACH (test_strto, loc, s); s[4] = L_('a') + i - 10; - TEST (loc, s, f, float); - TEST (loc, s, d, double); - TEST (loc, s, ld, long double); + result |= STRTOD_TEST_FOREACH (test_strto, loc, s); } return result; } diff --git a/stdlib/tst-strtod-round-skeleton.c b/stdlib/tst-strtod-round-skeleton.c index 73603e6..1a9f663 100644 --- a/stdlib/tst-strtod-round-skeleton.c +++ b/stdlib/tst-strtod-round-skeleton.c @@ -93,6 +93,7 @@ /* Add type specific choosing macros below. */ #define CHOOSE_f(f,...) f #define CHOOSE_d(f,d,...) d +#define CHOOSE_f128(f,d,ld64i,ld64m,ld106,ld113,...) ld113 /* long double is special, and handled above. */ /* Selector for expected result field of a given type. */ diff --git a/stdlib/tst-strtod.h b/stdlib/tst-strtod.h index bf5f901..e23ac3f 100644 --- a/stdlib/tst-strtod.h +++ b/stdlib/tst-strtod.h @@ -21,11 +21,24 @@ #define FSTRLENMAX 128 +#include <bits/floatn.h> + +#define F128 __f128 () + +/* 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 + /* Splat n variants of the same test for the various strtod functions. */ -#define GEN_TEST_STRTOD_FOREACH(mfunc, ...) \ - mfunc ( f, float, strfromf, f, f, ##__VA_ARGS__) \ - mfunc ( d, double, strfromd, , , ##__VA_ARGS__) \ - mfunc ( ld, long double, strfroml, L, l, ##__VA_ARGS__) +#define GEN_TEST_STRTOD_FOREACH(mfunc, ...) \ + mfunc ( f, float, strfromf, f, f, ##__VA_ARGS__) \ + mfunc ( d, double, strfromd, , , ##__VA_ARGS__) \ + mfunc ( ld, long double, strfroml, L, l, ##__VA_ARGS__) \ + IF_FLOAT128 (mfunc (f128, _Float128, strfromf128, F128, f128, ##__VA_ARGS__)) /* The arguments to the generated macros are: FSUF - Function suffix FTYPE - float type @@ -36,13 +49,14 @@ -#define STRTOD_TEST_FOREACH(mfunc, ...) \ -({ \ - int result = 0; \ - result |= mfunc ## f (__VA_ARGS__); \ - result |= mfunc ## d (__VA_ARGS__); \ - result |= mfunc ## ld (__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_FLOAT128 (result |= mfunc ## f128 (__VA_ARGS__)); \ + result; \ }) |