mirror of
https://sourceware.org/git/glibc.git
synced 2024-12-23 03:10:05 +00:00
Clean up bits/math-finite.h for aliasing types.
This patch cleans up how bits/math-finite.h handles types that are ABI-aliases of other types. For such types, no __*_finite functions exist; instead, bits/math-finite.h must redirect calls to a the functions for a canonical choice of type for each floating-point format. (For the actual public interfaces, symbols need exporting for each type, even those that are ABI-aliases, because of standard requirements that programs can declare the functions themselves without including <math.h>, but that does not apply to __*_finite.) At present, there is a special-case conditional in bits/math-finite.h on __MATH_DECLARING_LDOUBLE && defined __NO_LONG_DOUBLE_MATH to handle redirecting long double function calls to double __*_finite. This patch replaces this by a more general mechanism. math.h, before each inclusion of bits/math-finite.h, defines _MSUFTO_ as the suffix to use on the target of redirection, in addition to the existing _MSUF_. This way, __MATH_DECLARING_LDOUBLE can go away, as can the special conditional in bits/math-finite.h. With this patch, math.h is now prepared for the case of supporting float128 functions as aliases of long double ones on platforms where long double is binary128, with _MSUFTO_ appropriately defined for that case, and appropriate _MSUFTO_ definitions can easily be included when supporting _Float32 / _Float64 / _Float32x / _Float64x (which will always be ABI-aliases of another type when supported). Tested for x86_64, and did a compilation test for ARM with build-many-glibcs.py to cover the long double = double case. * math/math.h (_MSUFTO_): Define and undefine for each inclusion of <bits/math-finite.h>. (__MATH_DECLARING_LDOUBLE): Do not define and undefine for each inclusion of <bits/math-finite.h>. * math/bits/math-finite.h (__REDIRTO_X): Do not define conditionally on [__MATH_DECLARING_LDOUBLE && defined __NO_LONG_DOUBLE_MATH]. (__MATH_REDIRCALL): Use _MSUFTO_ in __REDIRTO call. (__MATH_REDIRCALL_2): Likewise. (__MATH_REDIRCALL_INTERNAL): Likewise. (__REDIRFROM (lgamma, , _MSUF_)): Likewise. (__REDIRFROM (gamma, , _MSUF_)): Likewise. (__REDIRFROM (tgamma, , _MSUF_)): Likewise.
This commit is contained in:
parent
bba5c93094
commit
23761119fe
14
ChangeLog
14
ChangeLog
@ -1,5 +1,19 @@
|
|||||||
2017-08-25 Joseph Myers <joseph@codesourcery.com>
|
2017-08-25 Joseph Myers <joseph@codesourcery.com>
|
||||||
|
|
||||||
|
* math/math.h (_MSUFTO_): Define and undefine for each inclusion
|
||||||
|
of <bits/math-finite.h>.
|
||||||
|
(__MATH_DECLARING_LDOUBLE): Do not define and undefine for each
|
||||||
|
inclusion of <bits/math-finite.h>.
|
||||||
|
* math/bits/math-finite.h (__REDIRTO_X): Do not define
|
||||||
|
conditionally on [__MATH_DECLARING_LDOUBLE && defined
|
||||||
|
__NO_LONG_DOUBLE_MATH].
|
||||||
|
(__MATH_REDIRCALL): Use _MSUFTO_ in __REDIRTO call.
|
||||||
|
(__MATH_REDIRCALL_2): Likewise.
|
||||||
|
(__MATH_REDIRCALL_INTERNAL): Likewise.
|
||||||
|
(__REDIRFROM (lgamma, , _MSUF_)): Likewise.
|
||||||
|
(__REDIRFROM (gamma, , _MSUF_)): Likewise.
|
||||||
|
(__REDIRFROM (tgamma, , _MSUF_)): Likewise.
|
||||||
|
|
||||||
* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/w_sqrt_compat-power5.S:
|
* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/w_sqrt_compat-power5.S:
|
||||||
Remove file.
|
Remove file.
|
||||||
* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/w_sqrt_compat-ppc32.S:
|
* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/w_sqrt_compat-ppc32.S:
|
||||||
|
@ -24,15 +24,8 @@
|
|||||||
function ## suffix ## reentrant
|
function ## suffix ## reentrant
|
||||||
#define __REDIRFROM(...) __REDIRFROM_X(__VA_ARGS__)
|
#define __REDIRFROM(...) __REDIRFROM_X(__VA_ARGS__)
|
||||||
|
|
||||||
/* Redirect long double versions of the functions to the corresponding
|
#define __REDIRTO_X(function, reentrant, suffix) \
|
||||||
double version if __NO_LONG_DOUBLE_MATH is defined. */
|
|
||||||
#if __MATH_DECLARING_LDOUBLE && defined __NO_LONG_DOUBLE_MATH
|
|
||||||
# define __REDIRTO_X(function, reentrant, suffix) \
|
|
||||||
__ ## function ## reentrant ## _finite
|
|
||||||
#else
|
|
||||||
# define __REDIRTO_X(function, reentrant, suffix) \
|
|
||||||
__ ## function ## suffix ## reentrant ## _finite
|
__ ## function ## suffix ## reentrant ## _finite
|
||||||
#endif
|
|
||||||
#define __REDIRTO(...) __REDIRTO_X(__VA_ARGS__)
|
#define __REDIRTO(...) __REDIRTO_X(__VA_ARGS__)
|
||||||
|
|
||||||
#define __MATH_REDIRCALL_X(from, args, to) \
|
#define __MATH_REDIRCALL_X(from, args, to) \
|
||||||
@ -40,17 +33,17 @@
|
|||||||
#define __MATH_REDIRCALL(function, reentrant, args) \
|
#define __MATH_REDIRCALL(function, reentrant, args) \
|
||||||
__MATH_REDIRCALL_X \
|
__MATH_REDIRCALL_X \
|
||||||
(__REDIRFROM (function, reentrant, _MSUF_), args, \
|
(__REDIRFROM (function, reentrant, _MSUF_), args, \
|
||||||
__REDIRTO (function, reentrant, _MSUF_))
|
__REDIRTO (function, reentrant, _MSUFTO_))
|
||||||
#define __MATH_REDIRCALL_2(from, reentrant, args, to) \
|
#define __MATH_REDIRCALL_2(from, reentrant, args, to) \
|
||||||
__MATH_REDIRCALL_X \
|
__MATH_REDIRCALL_X \
|
||||||
(__REDIRFROM (from, reentrant, _MSUF_), args, \
|
(__REDIRFROM (from, reentrant, _MSUF_), args, \
|
||||||
__REDIRTO (to, reentrant, _MSUF_))
|
__REDIRTO (to, reentrant, _MSUFTO_))
|
||||||
|
|
||||||
#define __MATH_REDIRCALL_INTERNAL(function, reentrant, args) \
|
#define __MATH_REDIRCALL_INTERNAL(function, reentrant, args) \
|
||||||
__MATH_REDIRCALL_X \
|
__MATH_REDIRCALL_X \
|
||||||
(__REDIRFROM (__CONCAT (__, function), \
|
(__REDIRFROM (__CONCAT (__, function), \
|
||||||
__CONCAT (reentrant, _finite), _MSUF_), \
|
__CONCAT (reentrant, _finite), _MSUF_), \
|
||||||
args, __REDIRTO (function, _r, _MSUF_))
|
args, __REDIRTO (function, _r, _MSUFTO_))
|
||||||
|
|
||||||
|
|
||||||
/* acos. */
|
/* acos. */
|
||||||
@ -139,10 +132,10 @@ __extern_always_inline _Mdouble_
|
|||||||
__NTH (__REDIRFROM (lgamma, , _MSUF_) (_Mdouble_ __d))
|
__NTH (__REDIRFROM (lgamma, , _MSUF_) (_Mdouble_ __d))
|
||||||
{
|
{
|
||||||
# if defined __USE_MISC || defined __USE_XOPEN
|
# if defined __USE_MISC || defined __USE_XOPEN
|
||||||
return __REDIRTO (lgamma, _r, _MSUF_) (__d, &signgam);
|
return __REDIRTO (lgamma, _r, _MSUFTO_) (__d, &signgam);
|
||||||
# else
|
# else
|
||||||
int __local_signgam = 0;
|
int __local_signgam = 0;
|
||||||
return __REDIRTO (lgamma, _r, _MSUF_) (__d, &__local_signgam);
|
return __REDIRTO (lgamma, _r, _MSUFTO_) (__d, &__local_signgam);
|
||||||
# endif
|
# endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -153,7 +146,7 @@ __NTH (__REDIRFROM (lgamma, , _MSUF_) (_Mdouble_ __d))
|
|||||||
__extern_always_inline _Mdouble_
|
__extern_always_inline _Mdouble_
|
||||||
__NTH (__REDIRFROM (gamma, , _MSUF_) (_Mdouble_ __d))
|
__NTH (__REDIRFROM (gamma, , _MSUF_) (_Mdouble_ __d))
|
||||||
{
|
{
|
||||||
return __REDIRTO (lgamma, _r, _MSUF_) (__d, &signgam);
|
return __REDIRTO (lgamma, _r, _MSUFTO_) (__d, &signgam);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -200,7 +193,7 @@ __extern_always_inline _Mdouble_
|
|||||||
__NTH (__REDIRFROM (tgamma, , _MSUF_) (_Mdouble_ __d))
|
__NTH (__REDIRFROM (tgamma, , _MSUF_) (_Mdouble_ __d))
|
||||||
{
|
{
|
||||||
int __local_signgam = 0;
|
int __local_signgam = 0;
|
||||||
_Mdouble_ __res = __REDIRTO (gamma, _r, _MSUF_) (__d, &__local_signgam);
|
_Mdouble_ __res = __REDIRTO (gamma, _r, _MSUFTO_) (__d, &__local_signgam);
|
||||||
return __local_signgam < 0 ? -__res : __res;
|
return __local_signgam < 0 ? -__res : __res;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
24
math/math.h
24
math/math.h
@ -618,15 +618,15 @@ iszero (__T __val)
|
|||||||
/* Include bits/math-finite.h for double. */
|
/* Include bits/math-finite.h for double. */
|
||||||
# define _Mdouble_ double
|
# define _Mdouble_ double
|
||||||
# define __MATH_DECLARING_DOUBLE 1
|
# define __MATH_DECLARING_DOUBLE 1
|
||||||
# define __MATH_DECLARING_LDOUBLE 0
|
|
||||||
# define __MATH_DECLARING_FLOATN 0
|
# define __MATH_DECLARING_FLOATN 0
|
||||||
# define _MSUF_
|
# define _MSUF_
|
||||||
|
# define _MSUFTO_
|
||||||
# include <bits/math-finite.h>
|
# include <bits/math-finite.h>
|
||||||
# undef _Mdouble_
|
# undef _Mdouble_
|
||||||
# undef __MATH_DECLARING_DOUBLE
|
# undef __MATH_DECLARING_DOUBLE
|
||||||
# undef __MATH_DECLARING_LDOUBLE
|
|
||||||
# undef __MATH_DECLARING_FLOATN
|
# undef __MATH_DECLARING_FLOATN
|
||||||
# undef _MSUF_
|
# undef _MSUF_
|
||||||
|
# undef _MSUFTO_
|
||||||
|
|
||||||
/* When __USE_ISOC99 is defined, include math-finite for float and
|
/* When __USE_ISOC99 is defined, include math-finite for float and
|
||||||
long double, as well. */
|
long double, as well. */
|
||||||
@ -635,29 +635,33 @@ iszero (__T __val)
|
|||||||
/* Include bits/math-finite.h for float. */
|
/* Include bits/math-finite.h for float. */
|
||||||
# define _Mdouble_ float
|
# define _Mdouble_ float
|
||||||
# define __MATH_DECLARING_DOUBLE 0
|
# define __MATH_DECLARING_DOUBLE 0
|
||||||
# define __MATH_DECLARING_LDOUBLE 0
|
|
||||||
# define __MATH_DECLARING_FLOATN 0
|
# define __MATH_DECLARING_FLOATN 0
|
||||||
# define _MSUF_ f
|
# define _MSUF_ f
|
||||||
|
# define _MSUFTO_ f
|
||||||
# include <bits/math-finite.h>
|
# include <bits/math-finite.h>
|
||||||
# undef _Mdouble_
|
# undef _Mdouble_
|
||||||
# undef __MATH_DECLARING_DOUBLE
|
# undef __MATH_DECLARING_DOUBLE
|
||||||
# undef __MATH_DECLARING_LDOUBLE
|
|
||||||
# undef __MATH_DECLARING_FLOATN
|
# undef __MATH_DECLARING_FLOATN
|
||||||
# undef _MSUF_
|
# undef _MSUF_
|
||||||
|
# undef _MSUFTO_
|
||||||
|
|
||||||
/* Include bits/math-finite.h for long double. */
|
/* Include bits/math-finite.h for long double. */
|
||||||
# ifdef __MATH_DECLARE_LDOUBLE
|
# ifdef __MATH_DECLARE_LDOUBLE
|
||||||
# define _Mdouble_ long double
|
# define _Mdouble_ long double
|
||||||
# define __MATH_DECLARING_DOUBLE 0
|
# define __MATH_DECLARING_DOUBLE 0
|
||||||
# define __MATH_DECLARING_LDOUBLE 1
|
|
||||||
# define __MATH_DECLARING_FLOATN 0
|
# define __MATH_DECLARING_FLOATN 0
|
||||||
# define _MSUF_ l
|
# define _MSUF_ l
|
||||||
|
# ifdef __NO_LONG_DOUBLE_MATH
|
||||||
|
# define _MSUFTO_
|
||||||
|
# else
|
||||||
|
# define _MSUFTO_ l
|
||||||
|
# endif
|
||||||
# include <bits/math-finite.h>
|
# include <bits/math-finite.h>
|
||||||
# undef _Mdouble_
|
# undef _Mdouble_
|
||||||
# undef __MATH_DECLARING_DOUBLE
|
# undef __MATH_DECLARING_DOUBLE
|
||||||
# undef __MATH_DECLARING_LDOUBLE
|
|
||||||
# undef __MATH_DECLARING_FLOATN
|
# undef __MATH_DECLARING_FLOATN
|
||||||
# undef _MSUF_
|
# undef _MSUF_
|
||||||
|
# undef _MSUFTO_
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# endif /* __USE_ISOC99. */
|
# endif /* __USE_ISOC99. */
|
||||||
@ -667,15 +671,19 @@ iszero (__T __val)
|
|||||||
&& __GLIBC_USE (IEC_60559_TYPES_EXT)
|
&& __GLIBC_USE (IEC_60559_TYPES_EXT)
|
||||||
# define _Mdouble_ _Float128
|
# define _Mdouble_ _Float128
|
||||||
# define __MATH_DECLARING_DOUBLE 0
|
# define __MATH_DECLARING_DOUBLE 0
|
||||||
# define __MATH_DECLARING_LDOUBLE 0
|
|
||||||
# define __MATH_DECLARING_FLOATN 1
|
# define __MATH_DECLARING_FLOATN 1
|
||||||
# define _MSUF_ f128
|
# define _MSUF_ f128
|
||||||
|
# if __HAVE_DISTINCT_FLOAT128
|
||||||
|
# define _MSUFTO_ f128
|
||||||
|
# else
|
||||||
|
# define _MSUFTO_ l
|
||||||
|
# endif
|
||||||
# include <bits/math-finite.h>
|
# include <bits/math-finite.h>
|
||||||
# undef _Mdouble_
|
# undef _Mdouble_
|
||||||
# undef __MATH_DECLARING_DOUBLE
|
# undef __MATH_DECLARING_DOUBLE
|
||||||
# undef __MATH_DECLARING_LDOUBLE
|
|
||||||
# undef __MATH_DECLARING_FLOATN
|
# undef __MATH_DECLARING_FLOATN
|
||||||
# undef _MSUF_
|
# undef _MSUF_
|
||||||
|
# undef _MSUFTO_
|
||||||
# endif
|
# endif
|
||||||
#endif /* __FINITE_MATH_ONLY__ > 0. */
|
#endif /* __FINITE_MATH_ONLY__ > 0. */
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user