Tested powerpc64le-linux. Pushed to trunk. -- >8 --
The _GLIBCXX_USE_C99_COMPLEX_TR1 macro (and the comments about it in acinclude.m4 and config.h) are misleading when it is also used for <complex>, not only <tr1/complex>. It is also wrong, because the configure checks for TR1 use -std=c++98 and a target might define cacos etc. for C++11 but not for C++98. Add a separate configure check for the inverse trigonometric functions that are covered by _GLIBCXX_USE_C99_COMPLEX_TR1, but using -std=c++11 for the checks. Use the result of that separate check in <complex>. libstdc++-v3/ChangeLog: * acinclude.m4 (GLIBCXX_USE_C99): Check for complex inverse trig functions in C++11 mode and define _GLIBCXX_USE_C99_COMPLEX_ARC. * config.h.in: Regenerate. * configure: Regenerate. * doc/doxygen/user.cfg.in (PREDEFINED): Add new macro. * include/std/complex: Check _GLIBCXX_USE_C99_COMPLEX_ARC instead of _GLIBCXX_USE_C99_COMPLEX_TR1. --- libstdc++-v3/acinclude.m4 | 37 +++++++++++++++++++ libstdc++-v3/config.h.in | 5 +++ libstdc++-v3/configure | 53 ++++++++++++++++++++++++++++ libstdc++-v3/doc/doxygen/user.cfg.in | 1 + libstdc++-v3/include/std/complex | 14 ++++---- 5 files changed, 103 insertions(+), 7 deletions(-) diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4 index 0ce3b8b5b31..84b12adbc24 100644 --- a/libstdc++-v3/acinclude.m4 +++ b/libstdc++-v3/acinclude.m4 @@ -1200,6 +1200,43 @@ AC_DEFUN([GLIBCXX_ENABLE_C99], [ requires corresponding C99 library functions to be present.]) fi + # Check for the existence of <complex.h> complex inverse trigonometric + # math functions used by <complex> for C++11 and later. + ac_c99_complex_arc=no; + if test x"$ac_has_complex_h" = x"yes"; then + AC_MSG_CHECKING([for ISO C99 support for inverse trig functions in <complex.h>]) + AC_TRY_COMPILE([#include <complex.h>], + [typedef __complex__ float float_type; float_type tmpf; + cacosf(tmpf); + casinf(tmpf); + catanf(tmpf); + cacoshf(tmpf); + casinhf(tmpf); + catanhf(tmpf); + typedef __complex__ double double_type; double_type tmpd; + cacos(tmpd); + casin(tmpd); + catan(tmpd); + cacosh(tmpd); + casinh(tmpd); + catanh(tmpd); + typedef __complex__ long double ld_type; ld_type tmpld; + cacosl(tmpld); + casinl(tmpld); + catanl(tmpld); + cacoshl(tmpld); + casinhl(tmpld); + catanhl(tmpld); + ],[ac_c99_complex_arc=yes], [ac_c99_complex_arc=no]) + fi + AC_MSG_RESULT($ac_c99_complex_arc) + if test x"$ac_c99_complex_arc" = x"yes"; then + AC_DEFINE(_GLIBCXX_USE_C99_COMPLEX_ARC, 1, + [Define if C99 inverse trig functions in <complex.h> should be + used in <complex>. Using compiler builtins for these functions + requires corresponding C99 library functions to be present.]) + fi + # Check for the existence in <stdio.h> of vscanf, et. al. AC_CACHE_CHECK([for ISO C99 support in <stdio.h> for C++11], glibcxx_cv_c99_stdio_cxx11, [ diff --git a/libstdc++-v3/doc/doxygen/user.cfg.in b/libstdc++-v3/doc/doxygen/user.cfg.in index 14981c96f95..210e13400b9 100644 --- a/libstdc++-v3/doc/doxygen/user.cfg.in +++ b/libstdc++-v3/doc/doxygen/user.cfg.in @@ -2352,6 +2352,7 @@ PREDEFINED = __cplusplus=202002L \ _GLIBCXX_USE_NOEXCEPT=noexcept \ _GLIBCXX_USE_WCHAR_T \ _GLIBCXX_USE_LONG_LONG \ + _GLIBCXX_USE_C99_COMPLEX_ARC \ _GLIBCXX_USE_C99_STDINT_TR1 \ _GLIBCXX_USE_SCHED_YIELD \ _GLIBCXX_USE_NANOSLEEP \ diff --git a/libstdc++-v3/include/std/complex b/libstdc++-v3/include/std/complex index 0f5f14c3ddb..40fc062e53d 100644 --- a/libstdc++-v3/include/std/complex +++ b/libstdc++-v3/include/std/complex @@ -2021,7 +2021,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION return std::complex<_Tp>(__pi_2 - __t.real(), -__t.imag()); } -#if _GLIBCXX_USE_C99_COMPLEX_TR1 +#if _GLIBCXX_USE_C99_COMPLEX_ARC #if defined(__STDCPP_FLOAT16_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32) inline __complex__ _Float16 __complex_acos(__complex__ _Float16 __z) @@ -2177,7 +2177,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #endif #endif -#if _GLIBCXX_USE_C99_COMPLEX_TR1 +#if _GLIBCXX_USE_C99_COMPLEX_ARC inline __complex__ float __complex_acos(__complex__ float __z) { return __builtin_cacosf(__z); } @@ -2213,7 +2213,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION return std::complex<_Tp>(__t.imag(), -__t.real()); } -#if _GLIBCXX_USE_C99_COMPLEX_TR1 +#if _GLIBCXX_USE_C99_COMPLEX_ARC inline __complex__ float __complex_asin(__complex__ float __z) { return __builtin_casinf(__z); } @@ -2257,7 +2257,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _Tp(0.25) * log(__num / __den)); } -#if _GLIBCXX_USE_C99_COMPLEX_TR1 +#if _GLIBCXX_USE_C99_COMPLEX_ARC inline __complex__ float __complex_atan(__complex__ float __z) { return __builtin_catanf(__z); } @@ -2293,7 +2293,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION + std::sqrt(_Tp(0.5) * (__z - _Tp(1.0)))); } -#if _GLIBCXX_USE_C99_COMPLEX_TR1 +#if _GLIBCXX_USE_C99_COMPLEX_ARC inline __complex__ float __complex_acosh(__complex__ float __z) { return __builtin_cacoshf(__z); } @@ -2332,7 +2332,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION return std::log(__t + __z); } -#if _GLIBCXX_USE_C99_COMPLEX_TR1 +#if _GLIBCXX_USE_C99_COMPLEX_ARC inline __complex__ float __complex_asinh(__complex__ float __z) { return __builtin_casinhf(__z); } @@ -2376,7 +2376,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _Tp(0.5) * atan2(_Tp(2.0) * __z.imag(), __x)); } -#if _GLIBCXX_USE_C99_COMPLEX_TR1 +#if _GLIBCXX_USE_C99_COMPLEX_ARC inline __complex__ float __complex_atanh(__complex__ float __z) { return __builtin_catanhf(__z); } -- 2.40.1