Provide an additional macro expansion for F128 in stdlib/tst-strtod.h
[platform/upstream/glibc.git] / stdlib / tst-strtod.h
1 /* Common utilities for testing strtod and its derivatives.
2    This file is part of the GNU C Library.
3    Copyright (C) 2016-2017 Free Software Foundation, Inc.
4
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.
9
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.
14
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    <http://www.gnu.org/licenses/>.  */
18
19 #ifndef _TST_STRTOD_H
20 #define _TST_STRTOD_H
21
22 #define FSTRLENMAX 128
23
24 #include <bits/floatn.h>
25
26 #define F128 __f128 ()
27
28 /* Test strfromf128 and strtof128 on all platforms that provide them,
29    whether or not the type _Float128 is ABI-distinct from long double.  */
30 #if __HAVE_FLOAT128
31 # define IF_FLOAT128(x) x
32 #else
33 # define IF_FLOAT128(x)
34 #endif
35
36 /* Provide an extra parameter expansion for mfunc.  */
37 #define MMFUNC(mmfunc, ...) mmfunc (__VA_ARGS__)
38
39 /* Splat n variants of the same test for the various strtod functions.  */
40 #define GEN_TEST_STRTOD_FOREACH(mfunc, ...)                                   \
41   mfunc (  f,       float, strfromf, f, f, ##__VA_ARGS__)                     \
42   mfunc (  d,      double, strfromd,  ,  , ##__VA_ARGS__)                     \
43   mfunc ( ld, long double, strfroml, L, l, ##__VA_ARGS__)                     \
44   IF_FLOAT128 (MMFUNC                                                         \
45    (mfunc, f128, _Float128, strfromf128, F128, f128, ##__VA_ARGS__))
46 /* The arguments to the generated macros are:
47    FSUF - Function suffix
48    FTYPE - float type
49    FTOSTR - float to string func
50    LSUF - Literal suffix
51    CSUF - C standardish suffix for many of the math functions
52 */
53
54
55
56 #define STRTOD_TEST_FOREACH(mfunc, ...)                 \
57 ({                                                      \
58    int result = 0;                                      \
59    result |= mfunc ## f  (__VA_ARGS__);                 \
60    result |= mfunc ## d  (__VA_ARGS__);                 \
61    result |= mfunc ## ld (__VA_ARGS__);                 \
62    IF_FLOAT128 (result |= mfunc ## f128 (__VA_ARGS__)); \
63    result;                                              \
64 })
65
66
67 #endif