Commit 52e6723c by Benjamin Kosnik Committed by Benjamin Kosnik

acinclude.m4 (GLIBCXX_ENABLE_C99): Test for complex math functions...


2005-01-25  Benjamin Kosnik  <bkoz@redhat.com>

	* acinclude.m4 (GLIBCXX_ENABLE_C99): Test for complex math
	functions, and enable _GLIBCXX_USE_C99_COMPLEX_MATH if they exist.
	* acconfig.h: Add _GLIBCXX_USE_C99_COMPLEX_MATH.
	* config.h.in: Regenerate.
	* configure: Regenerate.
	* include/std/std_complex.h: Protect complex builtins with
	_GLIBCXX_USE_C99_COMPLEX_MATH.

From-SVN: r94221
parent e71c0aa7
2005-01-25 Benjamin Kosnik <bkoz@redhat.com>
* acinclude.m4 (GLIBCXX_ENABLE_C99): Test for complex math
functions, and enable _GLIBCXX_USE_C99_COMPLEX_MATH if they exist.
* acconfig.h: Add _GLIBCXX_USE_C99_COMPLEX_MATH.
* config.h.in: Regenerate.
* configure: Regenerate.
* include/std/std_complex.h: Protect complex builtins with
_GLIBCXX_USE_C99_COMPLEX_MATH.
2005-01-24 Paolo Carlini <pcarlini@suse.de>
* include/tr1/type_traits: Implement is_signed and is_unsigned.
......
......@@ -13,11 +13,14 @@
// Include I/O support for 'long long' and 'unsigned long long'.
#undef _GLIBCXX_USE_LONG_LONG
// Define if C99 features such as lldiv_t, llabs, lldiv should be exposed.
#undef _GLIBCXX_USE_C99
// Define if C99 math functions (like fpclassify) should be exposed.
#undef _GLIBCXX_USE_C99_MATH
// Define if C99 features such as lldiv_t, llabs, lldiv should be exposed.
#undef _GLIBCXX_USE_C99
// Define if C99 complex math functions should be used in std::complex.
#undef _GLIBCXX_USE_C99_COMPLEX_MATH
// Define if code specialized for wchar_t should be used.
#undef _GLIBCXX_USE_WCHAR_T
......
......@@ -871,6 +871,121 @@ AC_DEFUN([GLIBCXX_ENABLE_C99], [
AC_DEFINE(_GLIBCXX_USE_C99_MATH)
fi
# Check for the existence of <math.h> complex functions.
# This is necessary even though libstdc++ uses the builtin versions
# of these functions, because if the builtin cannot be used, a reference
# to the library function is emitted.
AC_CHECK_HEADERS(complex.h, ac_has_complex_h=yes, ac_has_complex_h=no)
ac_c99_complex=no;
if test x"$ac_has_complex_h" = x"yes"; then
ac_c99_complex=yes;
AC_MSG_CHECKING([for ISO C99 support in <complex.h>])
AC_TRY_COMPILE([#include <complex.h>],
[typedef __complex__ float _ComplexT; _ComplexT tmp;
cabsf(tmp);],, [ac_c99_complex=no])
AC_TRY_COMPILE([#include <complex.h>],
[typedef __complex__ double _ComplexT; _ComplexT tmp;
cabs(tmp);],, [ac_c99_complex=no])
AC_TRY_COMPILE([#include <complex.h>],
[typedef __complex__ long double _ComplexT; _ComplexT tmp;
cabsl(tmp);],, [ac_c99_complex=no])
AC_TRY_COMPILE([#include <complex.h>],
[typedef __complex__ float _ComplexT; _ComplexT tmp;
cargf(tmp);],, [ac_c99_complex=no])
AC_TRY_COMPILE([#include <complex.h>],
[typedef __complex__ double _ComplexT; _ComplexT tmp;
carg(tmp);],, [ac_c99_complex=no])
AC_TRY_COMPILE([#include <complex.h>],
[typedef __complex__ long double _ComplexT; _ComplexT tmp;
cargl(tmp);],, [ac_c99_complex=no])
AC_TRY_COMPILE([#include <complex.h>],
[typedef __complex__ float _ComplexT; _ComplexT tmp;
ccosf(tmp);],, [ac_c99_complex=no])
AC_TRY_COMPILE([#include <complex.h>],
[typedef __complex__ double _ComplexT; _ComplexT tmp;
ccos(tmp);],, [ac_c99_complex=no])
AC_TRY_COMPILE([#include <complex.h>],
[typedef __complex__ long double _ComplexT; _ComplexT tmp;
ccosl(tmp);],, [ac_c99_complex=no])
AC_TRY_COMPILE([#include <complex.h>],
[typedef __complex__ float _ComplexT; _ComplexT tmp;
ccoshf(tmp);],, [ac_c99_complex=no])
AC_TRY_COMPILE([#include <complex.h>],
[typedef __complex__ double _ComplexT; _ComplexT tmp;
ccosh(tmp);],, [ac_c99_complex=no])
AC_TRY_COMPILE([#include <complex.h>],
[typedef __complex__ long double _ComplexT; _ComplexT tmp;
ccoshl(tmp);],, [ac_c99_complex=no])
AC_TRY_COMPILE([#include <complex.h>],
[typedef __complex__ float _ComplexT; _ComplexT tmp;
cexpf(tmp);],, [ac_c99_complex=no])
AC_TRY_COMPILE([#include <complex.h>],
[typedef __complex__ double _ComplexT; _ComplexT tmp;
cexp(tmp);],, [ac_c99_complex=no])
AC_TRY_COMPILE([#include <complex.h>],
[typedef __complex__ long double _ComplexT; _ComplexT tmp;
cexpl(tmp);],, [ac_c99_complex=no])
AC_TRY_COMPILE([#include <complex.h>],
[typedef __complex__ float _ComplexT; _ComplexT tmp;
csinf(tmp);],, [ac_c99_complex=no])
AC_TRY_COMPILE([#include <complex.h>],
[typedef __complex__ double _ComplexT; _ComplexT tmp;
csin(tmp);],, [ac_c99_complex=no])
AC_TRY_COMPILE([#include <complex.h>],
[typedef __complex__ long double _ComplexT; _ComplexT tmp;
csinl(tmp);],, [ac_c99_complex=no])
AC_TRY_COMPILE([#include <complex.h>],
[typedef __complex__ float _ComplexT; _ComplexT tmp;
csinhf(tmp);],, [ac_c99_complex=no])
AC_TRY_COMPILE([#include <complex.h>],
[typedef __complex__ double _ComplexT; _ComplexT tmp;
csinh(tmp);],, [ac_c99_complex=no])
AC_TRY_COMPILE([#include <complex.h>],
[typedef __complex__ long double _ComplexT; _ComplexT tmp;
csinhl(tmp);],, [ac_c99_complex=no])
AC_TRY_COMPILE([#include <complex.h>],
[typedef __complex__ float _ComplexT; _ComplexT tmp;
csqrtf(tmp);],, [ac_c99_complex=no])
AC_TRY_COMPILE([#include <complex.h>],
[typedef __complex__ double _ComplexT; _ComplexT tmp;
csqrt(tmp);],, [ac_c99_complex=no])
AC_TRY_COMPILE([#include <complex.h>],
[typedef __complex__ long double _ComplexT; _ComplexT tmp;
csqrtl(tmp);],, [ac_c99_complex=no])
AC_TRY_COMPILE([#include <complex.h>],
[typedef __complex__ float _ComplexT; _ComplexT tmp;
ctanf(tmp);],, [ac_c99_complex=no])
AC_TRY_COMPILE([#include <complex.h>],
[typedef __complex__ double _ComplexT; _ComplexT tmp;
ctan(tmp);],, [ac_c99_complex=no])
AC_TRY_COMPILE([#include <complex.h>],
[typedef __complex__ long double _ComplexT; _ComplexT tmp;
ctanl(tmp);],, [ac_c99_complex=no])
AC_TRY_COMPILE([#include <complex.h>],
[typedef __complex__ float _ComplexT; _ComplexT tmp;
ctanhf(tmp);],, [ac_c99_complex=no])
AC_TRY_COMPILE([#include <complex.h>],
[typedef __complex__ double _ComplexT; _ComplexT tmp;
ctanh(tmp);],, [ac_c99_complex=no])
AC_TRY_COMPILE([#include <complex.h>],
[typedef __complex__ long double _ComplexT; _ComplexT tmp;
ctanhl(tmp);],, [ac_c99_complex=no])
AC_TRY_COMPILE([#include <complex.h>],
[typedef __complex__ float _ComplexT; _ComplexT tmp;
cpowf(tmp, tmp);],, [ac_c99_complex=no])
AC_TRY_COMPILE([#include <complex.h>],
[typedef __complex__ double _ComplexT; _ComplexT tmp;
cpow(tmp, tmp);],, [ac_c99_complex=no])
AC_TRY_COMPILE([#include <complex.h>],
[typedef __complex__ long double _ComplexT; _ComplexT tmp;
cpowl(tmp, tmp);],, [ac_c99_complex=no])
fi
AC_MSG_RESULT($ac_c99_complex)
if test x"$ac_c99_complex" = x"yes"; then
AC_DEFINE(_GLIBCXX_USE_C99_COMPLEX_MATH)
fi
# Check for the existence in <stdio.h> of vscanf, et. al.
ac_c99_stdio=yes;
AC_MSG_CHECKING([for ISO C99 support in <stdio.h>])
......
......@@ -14,11 +14,14 @@
// Include I/O support for 'long long' and 'unsigned long long'.
#undef _GLIBCXX_USE_LONG_LONG
// Define if C99 features such as lldiv_t, llabs, lldiv should be exposed.
#undef _GLIBCXX_USE_C99
// Define if C99 math functions (like fpclassify) should be exposed.
#undef _GLIBCXX_USE_C99_MATH
// Define if C99 features such as lldiv_t, llabs, lldiv should be exposed.
#undef _GLIBCXX_USE_C99
// Define if C99 complex math functions should be used in std::complex.
#undef _GLIBCXX_USE_C99_COMPLEX_MATH
// Define if code specialized for wchar_t should be used.
#undef _GLIBCXX_USE_WCHAR_T
......@@ -200,6 +203,9 @@
/* Define to 1 if you have the `ceill' function. */
#undef HAVE_CEILL
/* Define to 1 if you have the <complex.h> header file. */
#undef HAVE_COMPLEX_H
/* Define to 1 if you have the `copysign' function. */
#undef HAVE_COPYSIGN
......
// The template and inlines for the -*- C++ -*- complex number classes.
// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
......@@ -51,7 +51,7 @@
namespace std
{
// Forward declarations
// Forward declarations.
template<typename _Tp> class complex;
template<> class complex<float>;
template<> class complex<double>;
......@@ -561,6 +561,7 @@ namespace std
return __s * sqrt(__x * __x + __y * __y);
}
#if _GLIBCXX_USE_C99_COMPLEX_MATH
inline float
__complex_abs(__complex__ float __z) { return __builtin_cabsf(__z); }
......@@ -569,23 +570,25 @@ namespace std
inline long double
__complex_abs(const __complex__ long double& __z)
{
return __builtin_cabsl(__z);
}
{ return __builtin_cabsl(__z); }
template<typename _Tp>
inline _Tp
abs(const complex<_Tp>& __z) { return __complex_abs(__z.__rep()); }
#else
template<typename _Tp>
inline _Tp
abs(const complex<_Tp>& __z) { return __complex_abs(__z); }
#endif
// 26.2.7/4: arg(__z): Returns the phase angle of __z.
template<typename _Tp>
inline _Tp
__complex_arg(const complex<_Tp>& __z)
{
return atan2(__z.imag(), __z.real());
}
{ return atan2(__z.imag(), __z.real()); }
#if _GLIBCXX_USE_C99_COMPLEX_MATH
inline float
__complex_arg(__complex__ float __z) { return __builtin_cargf(__z); }
......@@ -599,6 +602,11 @@ namespace std
template<typename _Tp>
inline _Tp
arg(const complex<_Tp>& __z) { return __complex_arg(__z.__rep()); }
#else
template<typename _Tp>
inline _Tp
arg(const complex<_Tp>& __z) { return __complex_arg(__z); }
#endif
// 26.2.7/5: norm(__z) returns the squared magintude of __z.
// As defined, norm() is -not- a norm is the common mathematical
......@@ -632,7 +640,8 @@ namespace std
inline _Tp
norm(const complex<_Tp>& __z)
{
return _Norm_helper<__is_floating<_Tp>::_M_type && !_GLIBCXX_FAST_MATH>::_S_do_it(__z);
return _Norm_helper<__is_floating<_Tp>::_M_type
&& !_GLIBCXX_FAST_MATH>::_S_do_it(__z);
}
template<typename _Tp>
......@@ -657,6 +666,7 @@ namespace std
return complex<_Tp>(cos(__x) * cosh(__y), -sin(__x) * sinh(__y));
}
#if _GLIBCXX_USE_C99_COMPLEX_MATH
inline __complex__ float
__complex_cos(__complex__ float __z) { return __builtin_ccosf(__z); }
......@@ -670,6 +680,11 @@ namespace std
template<typename _Tp>
inline complex<_Tp>
cos(const complex<_Tp>& __z) { return __complex_cos(__z.__rep()); }
#else
template<typename _Tp>
inline complex<_Tp>
cos(const complex<_Tp>& __z) { return __complex_cos(__z); }
#endif
// 26.2.8/2 cosh(__z): Returns the hyperbolic cosine of __z.
template<typename _Tp>
......@@ -681,6 +696,7 @@ namespace std
return complex<_Tp>(cosh(__x) * cos(__y), sinh(__x) * sin(__y));
}
#if _GLIBCXX_USE_C99_COMPLEX_MATH
inline __complex__ float
__complex_cosh(__complex__ float __z) { return __builtin_ccoshf(__z); }
......@@ -694,6 +710,11 @@ namespace std
template<typename _Tp>
inline complex<_Tp>
cosh(const complex<_Tp>& __z) { return __complex_cosh(__z.__rep()); }
#else
template<typename _Tp>
inline complex<_Tp>
cosh(const complex<_Tp>& __z) { return __complex_cosh(__z); }
#endif
// 26.2.8/3 exp(__z): Returns the complex base e exponential of x
template<typename _Tp>
......@@ -701,6 +722,7 @@ namespace std
__complex_exp(const complex<_Tp>& __z)
{ return std::polar(exp(__z.real()), __z.imag()); }
#if _GLIBCXX_USE_C99_COMPLEX_MATH
inline __complex__ float
__complex_exp(__complex__ float __z) { return __builtin_cexpf(__z); }
......@@ -714,6 +736,11 @@ namespace std
template<typename _Tp>
inline complex<_Tp>
exp(const complex<_Tp>& __z) { return __complex_exp(__z.__rep()); }
#else
template<typename _Tp>
inline complex<_Tp>
exp(const complex<_Tp>& __z) { return __complex_exp(__z); }
#endif
// 26.2.8/5 log(__z): Reurns the natural complex logaritm of __z.
// The branch cut is along the negative axis.
......@@ -733,7 +760,7 @@ namespace std
__complex_log(const __complex__ long double& __z)
{ return __builtin_clogl(__z); } */
// FIXME: Currently wer don't use built-ins for log() because of some
// FIXME: Currently we don't use built-ins for log() because of some
// obscure user name-space issues. So, we use the generic version
// which is why we don't use __z.__rep() in the call below.
template<typename _Tp>
......@@ -755,6 +782,7 @@ namespace std
return complex<_Tp>(sin(__x) * cosh(__y), cos(__x) * sinh(__y));
}
#if _GLIBCXX_USE_C99_COMPLEX_MATH
inline __complex__ float
__complex_sin(__complex__ float __z) { return __builtin_csinf(__z); }
......@@ -768,6 +796,11 @@ namespace std
template<typename _Tp>
inline complex<_Tp>
sin(const complex<_Tp>& __z) { return __complex_sin(__z.__rep()); }
#else
template<typename _Tp>
inline complex<_Tp>
sin(const complex<_Tp>& __z) { return __complex_sin(__z); }
#endif
// 26.2.8/11 sinh(__z): Returns the hyperbolic sine of __z.
template<typename _Tp>
......@@ -779,6 +812,7 @@ namespace std
return complex<_Tp>(sinh(__x) * cos(__y), cosh(__x) * sin(__y));
}
#if _GLIBCXX_USE_C99_COMPLEX_MATH
inline __complex__ float
__complex_sinh(__complex__ float __z) { return __builtin_csinhf(__z); }
......@@ -792,6 +826,11 @@ namespace std
template<typename _Tp>
inline complex<_Tp>
sinh(const complex<_Tp>& __z) { return __complex_sinh(__z.__rep()); }
#else
template<typename _Tp>
inline complex<_Tp>
sinh(const complex<_Tp>& __z) { return __complex_sinh(__z); }
#endif
// 26.2.8/13 sqrt(__z): Returns the complex square root of __z.
// The branch cut is on the negative axis.
......@@ -817,6 +856,7 @@ namespace std
}
}
#if _GLIBCXX_USE_C99_COMPLEX_MATH
inline __complex__ float
__complex_sqrt(__complex__ float __z) { return __builtin_csqrtf(__z); }
......@@ -830,6 +870,11 @@ namespace std
template<typename _Tp>
inline complex<_Tp>
sqrt(const complex<_Tp>& __z) { return __complex_sqrt(__z.__rep()); }
#else
template<typename _Tp>
inline complex<_Tp>
sqrt(const complex<_Tp>& __z) { return __complex_sqrt(__z); }
#endif
// 26.2.8/14 tan(__z): Return the complex tangent of __z.
......@@ -838,6 +883,7 @@ namespace std
__complex_tan(const complex<_Tp>& __z)
{ return std::sin(__z) / std::cos(__z); }
#if _GLIBCXX_USE_C99_COMPLEX_MATH
inline __complex__ float
__complex_tan(__complex__ float __z) { return __builtin_ctanf(__z); }
......@@ -851,6 +897,12 @@ namespace std
template<typename _Tp>
inline complex<_Tp>
tan(const complex<_Tp>& __z) { return __complex_tan(__z.__rep()); }
#else
template<typename _Tp>
inline complex<_Tp>
tan(const complex<_Tp>& __z) { return __complex_tan(__z); }
#endif
// 26.2.8/15 tanh(__z): Returns the hyperbolic tangent of __z.
......@@ -859,6 +911,7 @@ namespace std
__complex_tanh(const complex<_Tp>& __z)
{ return std::sinh(__z) / std::cosh(__z); }
#if _GLIBCXX_USE_C99_COMPLEX_MATH
inline __complex__ float
__complex_tanh(__complex__ float __z) { return __builtin_ctanhf(__z); }
......@@ -872,6 +925,12 @@ namespace std
template<typename _Tp>
inline complex<_Tp>
tanh(const complex<_Tp>& __z) { return __complex_tanh(__z.__rep()); }
#else
template<typename _Tp>
inline complex<_Tp>
tanh(const complex<_Tp>& __z) { return __complex_tanh(__z); }
#endif
// 26.2.8/9 pow(__x, __y): Returns the complex power base of __x
// raised to the __y-th power. The branch
......@@ -879,9 +938,7 @@ namespace std
template<typename _Tp>
inline complex<_Tp>
pow(const complex<_Tp>& __z, int __n)
{
return std::__pow_helper(__z, __n);
}
{ return std::__pow_helper(__z, __n); }
template<typename _Tp>
complex<_Tp>
......@@ -899,6 +956,7 @@ namespace std
__complex_pow(const complex<_Tp>& __x, const complex<_Tp>& __y)
{ return __x == _Tp() ? _Tp() : std::exp(__y * std::log(__x)); }
#if _GLIBCXX_USE_C99_COMPLEX_MATH
inline __complex__ float
__complex_pow(__complex__ float __x, __complex__ float __y)
{ return __builtin_cpowf(__x, __y); }
......@@ -910,6 +968,7 @@ namespace std
inline __complex__ long double
__complex_pow(__complex__ long double& __x, __complex__ long double& __y)
{ return __builtin_cpowl(__x, __y); }
#endif
template<typename _Tp>
inline complex<_Tp>
......@@ -936,7 +995,7 @@ namespace std
complex(_ComplexT __z) : _M_value(__z) { }
complex(float = 0.0f, float = 0.0f);
#ifdef _GLIBCXX_BUGGY_COMPLEX
#if _GLIBCXX_BUGGY_COMPLEX
complex(const complex& __z) : _M_value(__z._M_value) { }
#endif
explicit complex(const complex<double>&);
......@@ -1092,7 +1151,7 @@ namespace std
complex(_ComplexT __z) : _M_value(__z) { }
complex(double = 0.0, double = 0.0);
#ifdef _GLIBCXX_BUGGY_COMPLEX
#if _GLIBCXX_BUGGY_COMPLEX
complex(const complex& __z) : _M_value(__z._M_value) { }
#endif
complex(const complex<float>&);
......@@ -1247,7 +1306,7 @@ namespace std
complex(_ComplexT __z) : _M_value(__z) { }
complex(long double = 0.0L, long double = 0.0L);
#ifdef _GLIBCXX_BUGGY_COMPLEX
#if _GLIBCXX_BUGGY_COMPLEX
complex(const complex& __z) : _M_value(__z._M_value) { }
#endif
complex(const complex<float>&);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment