summaryrefslogtreecommitdiff
path: root/math/math.h
diff options
context:
space:
mode:
authorGabriel F. T. Gomes <gftg@linux.vnet.ibm.com>2017-03-10 09:47:18 -0300
committerGabriel F. T. Gomes <gftg@linux.vnet.ibm.com>2017-03-30 09:59:25 -0300
commitf264cca59380bca8f372bd09a8da7c9e1bbbf493 (patch)
tree71c09cb174a4e768872acea55ee28fa0fb157e3d /math/math.h
parent3abeeec5f46ff036bd9df60bb096e20314ccd078 (diff)
Macroize inclusion of math-finite.h
This patch macroizes the declarations in math/bits/math-finite.h similarly to what math/bits/mathcalls.h does. For each floating-point type, the file is included once in math/math.h. This will reduce the amount of repetitive boilerplate required when adding float128 versions of these declarations. Tested for powerpc64le and s390x. * math/math.h: Include bits/math-finite.h once per floating-point type. * math/bits/math-finite.h: Macroize all declarations by floating-point type.
Diffstat (limited to 'math/math.h')
-rw-r--r--math/math.h42
1 files changed, 41 insertions, 1 deletions
diff --git a/math/math.h b/math/math.h
index c7895b735f..0c19d450ee 100644
--- a/math/math.h
+++ b/math/math.h
@@ -560,8 +560,48 @@ extern int matherr (struct exception *__exc);
/* Define special entry points to use when the compiler got told to
only expect finite results. */
#if defined __FINITE_MATH_ONLY__ && __FINITE_MATH_ONLY__ > 0
+
+/* Include bits/math-finite.h for double. */
+# define _Mdouble_ double
+# define __MATH_DECLARING_DOUBLE 1
+# define __MATH_DECLARING_LDOUBLE 0
+# define _MSUF_
# include <bits/math-finite.h>
-#endif
+# undef _Mdouble_
+# undef __MATH_DECLARING_DOUBLE
+# undef __MATH_DECLARING_LDOUBLE
+# undef _MSUF_
+
+/* When __USE_ISOC99 is defined, include math-finite for float and
+ long double, as well. */
+# ifdef __USE_ISOC99
+
+/* Include bits/math-finite.h for float. */
+# define _Mdouble_ float
+# define __MATH_DECLARING_DOUBLE 0
+# define __MATH_DECLARING_LDOUBLE 0
+# define _MSUF_ f
+# include <bits/math-finite.h>
+# undef _Mdouble_
+# undef __MATH_DECLARING_DOUBLE
+# undef __MATH_DECLARING_LDOUBLE
+# undef _MSUF_
+
+/* Include bits/math-finite.h for long double. */
+# if __MATH_DECLARE_LDOUBLE
+# define _Mdouble_ long double
+# define __MATH_DECLARING_DOUBLE 0
+# define __MATH_DECLARING_LDOUBLE 1
+# define _MSUF_ l
+# include <bits/math-finite.h>
+# undef _Mdouble_
+# undef __MATH_DECLARING_DOUBLE
+# undef __MATH_DECLARING_LDOUBLE
+# undef _MSUF_
+# endif
+
+# endif /* __USE_ISOC99. */
+#endif /* __FINITE_MATH_ONLY__ > 0. */
#ifdef __USE_ISOC99
/* If we've still got undefined comparison macros, provide defaults. */