[2/4] Macroize inclusion of math-finite.h (part 2)
Commit Message
I could not come up with a more clever way to declare __lgammal_r_finite when
__NO_LONG_DOUBLE_MATH is set.
---
math/bits/math-finite.h | 49 ++++++++++++++++---------------------------------
math/math.h | 6 ++++++
2 files changed, 22 insertions(+), 33 deletions(-)
Comments
On Mon, 13 Mar 2017, Gabriel F. T. Gomes wrote:
> I could not come up with a more clever way to declare __lgammal_r_finite when
> __NO_LONG_DOUBLE_MATH is set.
It should be OK to use __REDIRECT_NTH when the asm name used is the same
name the function would have had anyway. So declare __lgamma*_r_finite
using __MATH_REDIRCALL_2 (__lgamma, _r_finite, (_Mdouble_, int *), lgamma)
or similar.
@@ -126,50 +126,33 @@ __MATH_REDIRCALL (yn, , (int, _Mdouble_));
__MATH_REDIRCALL (lgamma, _r, (_Mdouble_, int *));
#endif
-extern double __lgamma_r_finite (double, int *);
-extern float __lgammaf_r_finite (float, int *);
-#ifdef __NO_LONG_DOUBLE_MATH
-extern long double __REDIRECT_NTH (__lgammal_r_finite, (long double, int *),
- __lgamma_r_finite);
+/* Special case when declaring the finite long double version of
+ lgamma_r (__lgammal_r_finite). */
+#if __MATH_DECLARING_LGAMMAL && defined __NO_LONG_DOUBLE_MATH
+extern long double
+__REDIRECT_NTH (__lgammal_r_finite, (long double, int *),
+ __lgamma_r_finite);
#else
-extern long double __lgammal_r_finite (long double, int *);
+extern _Mdouble_
+__REDIRFROM (__lgamma, _r_finite, _MSUF_) (_Mdouble_, int *);
#endif
-#if ((defined __USE_XOPEN || defined __USE_ISOC99) \
- && defined __extern_always_inline)
+#if defined __extern_always_inline \
+ && ((__MATH_DECLARING_DOUBLE && \
+ (defined __USE_XOPEN || defined __USE_ISOC99)) \
+ || (!__MATH_DECLARING_DOUBLE && defined __USE_ISOC99))
/* lgamma. */
-__extern_always_inline double __NTH (lgamma (double __d))
+__extern_always_inline _Mdouble_
+__NTH (__REDIRFROM (lgamma, , _MSUF_) (_Mdouble_ __d))
{
# if defined __USE_MISC || defined __USE_XOPEN
- return __lgamma_r_finite (__d, &signgam);
+ return __REDIRTO (lgamma, _r, _MSUF_) (__d, &signgam);
# else
int __local_signgam = 0;
- return __lgamma_r_finite (__d, &__local_signgam);
+ return __REDIRTO (lgamma, _r, _MSUF_) (__d, &__local_signgam);
# endif
}
#endif
-#if defined __USE_ISOC99 && defined __extern_always_inline
-__extern_always_inline float __NTH (lgammaf (float __d))
-{
-# if defined __USE_MISC || defined __USE_XOPEN
- return __lgammaf_r_finite (__d, &signgam);
-# else
- int __local_signgam = 0;
- return __lgammaf_r_finite (__d, &__local_signgam);
-# endif
-}
-# ifdef __MATH_DECLARE_LDOUBLE
-__extern_always_inline long double __NTH (lgammal (long double __d))
-{
-# if defined __USE_MISC || defined __USE_XOPEN
- return __lgammal_r_finite (__d, &signgam);
-# else
- int __local_signgam = 0;
- return __lgammal_r_finite (__d, &__local_signgam);
-# endif
-}
-# endif
-#endif
#if ((defined __USE_MISC || (defined __USE_XOPEN && !defined __USE_XOPEN2K)) \
&& defined __extern_always_inline)
@@ -572,27 +572,33 @@ extern int matherr (struct exception *__exc);
/* Include bits/math-finite.h for double. */
# define _Mdouble_ double
# define __MATH_DECLARING_DOUBLE 1
+# define __MATH_DECLARING_LGAMMAL 0
# define _MSUF_
# include <bits/math-finite.h>
# undef _Mdouble_
# undef __MATH_DECLARING_DOUBLE
+# undef __MATH_DECLARING_LGAMMAL
# undef _MSUF_
/* Include bits/math-finite.h for float. */
# define _Mdouble_ float
# define __MATH_DECLARING_DOUBLE 0
+# define __MATH_DECLARING_LGAMMAL 0
# define _MSUF_ f
# include <bits/math-finite.h>
# undef _Mdouble_
# undef __MATH_DECLARING_DOUBLE
+# undef __MATH_DECLARING_LGAMMAL
# 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_LGAMMAL 1
# define _MSUF_ l
# include <bits/math-finite.h>
# undef _Mdouble_
# undef __MATH_DECLARING_DOUBLE
+# undef __MATH_DECLARING_LGAMMAL
# undef _MSUF_
# endif
#endif