aboutsummaryrefslogtreecommitdiff
path: root/math/bits
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/bits
parent1cf1232cd4721dc155a5cf7d571e5b1dae506430 (diff)
downloadglibc-7daada0319613fec8c2a10b28eed911f4d359a6a.tar
glibc-7daada0319613fec8c2a10b28eed911f4d359a6a.tar.gz
glibc-7daada0319613fec8c2a10b28eed911f4d359a6a.tar.bz2
glibc-7daada0319613fec8c2a10b28eed911f4d359a6a.zip
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/bits')
-rw-r--r--math/bits/math-finite.h34
1 files changed, 14 insertions, 20 deletions
diff --git a/math/bits/math-finite.h b/math/bits/math-finite.h
index 4c8295842c..de57b504bd 100644
--- a/math/bits/math-finite.h
+++ b/math/bits/math-finite.h
@@ -20,30 +20,26 @@
# error "Never use <bits/math-finite.h> directly; include <math.h> instead."
#endif
-#define __REDIRFROM_X(function, reentrant, suffix) \
- function ## suffix ## reentrant
#define __REDIRFROM(...) __REDIRFROM_X(__VA_ARGS__)
-#define __REDIRTO_X(function, reentrant, suffix) \
- __ ## function ## suffix ## reentrant ## _finite
#define __REDIRTO(...) __REDIRTO_X(__VA_ARGS__)
#define __MATH_REDIRCALL_X(from, args, to) \
extern _Mdouble_ __REDIRECT_NTH (from, args, to)
#define __MATH_REDIRCALL(function, reentrant, args) \
__MATH_REDIRCALL_X \
- (__REDIRFROM (function, reentrant, _MSUF_), args, \
- __REDIRTO (function, reentrant, _MSUFTO_))
+ (__REDIRFROM (function, reentrant), args, \
+ __REDIRTO (function, reentrant))
#define __MATH_REDIRCALL_2(from, reentrant, args, to) \
__MATH_REDIRCALL_X \
- (__REDIRFROM (from, reentrant, _MSUF_), args, \
- __REDIRTO (to, reentrant, _MSUFTO_))
+ (__REDIRFROM (from, reentrant), args, \
+ __REDIRTO (to, reentrant))
#define __MATH_REDIRCALL_INTERNAL(function, reentrant, args) \
__MATH_REDIRCALL_X \
(__REDIRFROM (__CONCAT (__, function), \
- __CONCAT (reentrant, _finite), _MSUF_), \
- args, __REDIRTO (function, _r, _MSUFTO_))
+ __CONCAT (reentrant, _finite)), \
+ args, __REDIRTO (function, _r))
/* acos. */
@@ -129,13 +125,13 @@ __MATH_REDIRCALL_INTERNAL (lgamma, _r, (_Mdouble_, int *));
&& defined __extern_always_inline)
/* lgamma. */
__extern_always_inline _Mdouble_
-__NTH (__REDIRFROM (lgamma, , _MSUF_) (_Mdouble_ __d))
+__NTH (__REDIRFROM (lgamma, ) (_Mdouble_ __d))
{
# if defined __USE_MISC || defined __USE_XOPEN
- return __REDIRTO (lgamma, _r, _MSUFTO_) (__d, &signgam);
+ return __REDIRTO (lgamma, _r) (__d, &signgam);
# else
int __local_signgam = 0;
- return __REDIRTO (lgamma, _r, _MSUFTO_) (__d, &__local_signgam);
+ return __REDIRTO (lgamma, _r) (__d, &__local_signgam);
# endif
}
#endif
@@ -144,9 +140,9 @@ __NTH (__REDIRFROM (lgamma, , _MSUF_) (_Mdouble_ __d))
&& defined __extern_always_inline) && !__MATH_DECLARING_FLOATN
/* gamma. */
__extern_always_inline _Mdouble_
-__NTH (__REDIRFROM (gamma, , _MSUF_) (_Mdouble_ __d))
+__NTH (__REDIRFROM (gamma, ) (_Mdouble_ __d))
{
- return __REDIRTO (lgamma, _r, _MSUFTO_) (__d, &signgam);
+ return __REDIRTO (lgamma, _r) (__d, &signgam);
}
#endif
@@ -187,21 +183,19 @@ __MATH_REDIRCALL (sqrt, , (_Mdouble_));
#if defined __USE_ISOC99 && defined __extern_always_inline
/* tgamma. */
extern _Mdouble_
-__REDIRFROM (__gamma, _r_finite, _MSUF_) (_Mdouble_, int *);
+__REDIRFROM (__gamma, _r_finite) (_Mdouble_, int *);
__extern_always_inline _Mdouble_
-__NTH (__REDIRFROM (tgamma, , _MSUF_) (_Mdouble_ __d))
+__NTH (__REDIRFROM (tgamma, ) (_Mdouble_ __d))
{
int __local_signgam = 0;
- _Mdouble_ __res = __REDIRTO (gamma, _r, _MSUFTO_) (__d, &__local_signgam);
+ _Mdouble_ __res = __REDIRTO (gamma, _r) (__d, &__local_signgam);
return __local_signgam < 0 ? -__res : __res;
}
#endif
#undef __REDIRFROM
-#undef __REDIRFROM_X
#undef __REDIRTO
-#undef __REDIRTO_X
#undef __MATH_REDIRCALL
#undef __MATH_REDIRCALL_2
#undef __MATH_REDIRCALL_INTERNAL