summaryrefslogtreecommitdiff
path: root/math/math.h
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2017-08-29 14:15:37 +0000
committerJoseph Myers <joseph@codesourcery.com>2017-08-29 14:15:37 +0000
commit7daada0319613fec8c2a10b28eed911f4d359a6a (patch)
tree322a791c6c073650b01d41ac91e54a1be5887edd /math/math.h
parent1cf1232cd4721dc155a5cf7d571e5b1dae506430 (diff)
Fix bits/math-finite.h _MSUF_ expansion namespace (bug 22028).
The current bits/math-finite.h approach to defining functions for different types, involving math.h defining _MSUF_ and _MSUFTO_ for the function suffixes involved, is not namespace-clean if one of those suffixes (f, l, f128) is defined as a macro by the user before math.h is included; too many levels of macro expansion occur. Instead, those suffixes should appear directly in the expansion of the macro using ## so they don't get expanded even if defined as macros by the user (that is, math.h should be defining __REDIRFROM_X and __REDIRTO_X directly to use those suffixes rather than suffixes being passed as an argument by macro callers). This patch makes that change. Tested for x86_64. [BZ #22028] * math/math.h [__FINITE_MATH_ONLY__ && __FINITE_MATH_ONLY__ > 0] (_MSUF_): Remove macro. [__FINITE_MATH_ONLY__ && __FINITE_MATH_ONLY__ > 0] (_MSUFTO_): Likewise. [__FINITE_MATH_ONLY__ && __FINITE_MATH_ONLY__ > 0] (__REDIRFROM_X): New macro. [__FINITE_MATH_ONLY__ && __FINITE_MATH_ONLY__ > 0] (__REDIRTO_X): Likewise. * math/bits/math-finite.h (__REDIRFROM_X): Remove macro. (__REDIRTO_X): Likewise. (__MATH_REDIRCALL): Do not pass _MSUF_ or _MSUFTO_ macro arguments. (__MATH_REDIRCALL_2): Likewise. (__MATH_REDIRCALL_INTERNAL): Likewise. (__REDIRFROM (lgamma, , _MSUF_)): Likewise. (__REDIRFROM (gamma, , _MSUF_)): Likweise. (__REDIRFROM (__gamma, _r_finite, _MSUF_)): Likewise. (__REDIRFROM (tgamma, , _MSUF_)): Likewise. * math/test-finite-macros.c: New file. * math/Makefile (tests): Add test-finite-macros. (CFLAGS-test-finite-macros.c): New variable.
Diffstat (limited to 'math/math.h')
-rw-r--r--math/math.h46
1 files changed, 28 insertions, 18 deletions
diff --git a/math/math.h b/math/math.h
index f3eb677a40..7e41b0dd3a 100644
--- a/math/math.h
+++ b/math/math.h
@@ -644,14 +644,16 @@ iszero (__T __val)
# define _Mdouble_ double
# define __MATH_DECLARING_DOUBLE 1
# define __MATH_DECLARING_FLOATN 0
-# define _MSUF_
-# define _MSUFTO_
+# define __REDIRFROM_X(function, reentrant) \
+ function ## reentrant
+# define __REDIRTO_X(function, reentrant) \
+ __ ## function ## reentrant ## _finite
# include <bits/math-finite.h>
# undef _Mdouble_
# undef __MATH_DECLARING_DOUBLE
# undef __MATH_DECLARING_FLOATN
-# undef _MSUF_
-# undef _MSUFTO_
+# undef __REDIRFROM_X
+# undef __REDIRTO_X
/* When __USE_ISOC99 is defined, include math-finite for float and
long double, as well. */
@@ -661,32 +663,37 @@ iszero (__T __val)
# define _Mdouble_ float
# define __MATH_DECLARING_DOUBLE 0
# define __MATH_DECLARING_FLOATN 0
-# define _MSUF_ f
-# define _MSUFTO_ f
+# define __REDIRFROM_X(function, reentrant) \
+ function ## f ## reentrant
+# define __REDIRTO_X(function, reentrant) \
+ __ ## function ## f ## reentrant ## _finite
# include <bits/math-finite.h>
# undef _Mdouble_
# undef __MATH_DECLARING_DOUBLE
# undef __MATH_DECLARING_FLOATN
-# undef _MSUF_
-# undef _MSUFTO_
+# undef __REDIRFROM_X
+# undef __REDIRTO_X
/* Include bits/math-finite.h for long double. */
# ifdef __MATH_DECLARE_LDOUBLE
# define _Mdouble_ long double
# define __MATH_DECLARING_DOUBLE 0
# define __MATH_DECLARING_FLOATN 0
-# define _MSUF_ l
+# define __REDIRFROM_X(function, reentrant) \
+ function ## l ## reentrant
# ifdef __NO_LONG_DOUBLE_MATH
-# define _MSUFTO_
+# define __REDIRTO_X(function, reentrant) \
+ __ ## function ## reentrant ## _finite
# else
-# define _MSUFTO_ l
+# define __REDIRTO_X(function, reentrant) \
+ __ ## function ## l ## reentrant ## _finite
# endif
# include <bits/math-finite.h>
# undef _Mdouble_
# undef __MATH_DECLARING_DOUBLE
# undef __MATH_DECLARING_FLOATN
-# undef _MSUF_
-# undef _MSUFTO_
+# undef __REDIRFROM_X
+# undef __REDIRTO_X
# endif
# endif /* __USE_ISOC99. */
@@ -697,18 +704,21 @@ iszero (__T __val)
# define _Mdouble_ _Float128
# define __MATH_DECLARING_DOUBLE 0
# define __MATH_DECLARING_FLOATN 1
-# define _MSUF_ f128
+# define __REDIRFROM_X(function, reentrant) \
+ function ## f128 ## reentrant
# if __HAVE_DISTINCT_FLOAT128
-# define _MSUFTO_ f128
+# define __REDIRTO_X(function, reentrant) \
+ __ ## function ## f128 ## reentrant ## _finite
# else
-# define _MSUFTO_ l
+# define __REDIRTO_X(function, reentrant) \
+ __ ## function ## l ## reentrant ## _finite
# endif
# include <bits/math-finite.h>
# undef _Mdouble_
# undef __MATH_DECLARING_DOUBLE
# undef __MATH_DECLARING_FLOATN
-# undef _MSUF_
-# undef _MSUFTO_
+# undef __REDIRFROM_X
+# undef __REDIRTO_X
# endif
#endif /* __FINITE_MATH_ONLY__ > 0. */