diff options
author | Martynas Venckus <martynas@cvs.openbsd.org> | 2008-12-09 20:39:38 +0000 |
---|---|---|
committer | Martynas Venckus <martynas@cvs.openbsd.org> | 2008-12-09 20:39:38 +0000 |
commit | 1dbd7d1c98e6257eec43b1afd4b55fba71311095 (patch) | |
tree | 1fdcbe47e3c89e2bcf60028792a3c586998025c3 | |
parent | ec45c73bee8b228a0317b131bd194e013d3f58fb (diff) |
libstdc++ (cmath) needs to handle integer arguments for the math
functions: acos, asin, atan, atan2, cos, cosh, exp, fabs, floor,
log, log10, sqrt, sin, sinh, tan, tanh
fixes quite some ports
tested by brad@. no objections millert@
-rw-r--r-- | gnu/lib/libstdc++/libstdc++/include/bits/cpp_type_traits.h | 32 | ||||
-rw-r--r-- | gnu/lib/libstdc++/libstdc++/include/c_std/std_cmath.h | 99 | ||||
-rw-r--r-- | gnu/lib/libstdc++/shlib_version | 2 |
3 files changed, 132 insertions, 1 deletions
diff --git a/gnu/lib/libstdc++/libstdc++/include/bits/cpp_type_traits.h b/gnu/lib/libstdc++/libstdc++/include/bits/cpp_type_traits.h index 8a888e5e977..ad46a3bd433 100644 --- a/gnu/lib/libstdc++/libstdc++/include/bits/cpp_type_traits.h +++ b/gnu/lib/libstdc++/libstdc++/include/bits/cpp_type_traits.h @@ -66,6 +66,38 @@ namespace std { + // Compare for equality of types. + template<typename, typename> + struct __are_same + { + enum + { + _M_type = 0 + }; + }; + + template<typename _Tp> + struct __are_same<_Tp, _Tp> + { + enum + { + _M_type = 1 + }; + }; + + // Define a nested type if some predicate holds. + template<typename, bool> + struct __enable_if + { + }; + + template<typename _Tp> + struct __enable_if<_Tp, true> + { + typedef _Tp _M_type; + }; + + // Holds if the template-argument is a void type. template<typename _Tp> struct __is_void { diff --git a/gnu/lib/libstdc++/libstdc++/include/c_std/std_cmath.h b/gnu/lib/libstdc++/libstdc++/include/c_std/std_cmath.h index 1b999ab40a7..92e29fd7b1a 100644 --- a/gnu/lib/libstdc++/libstdc++/include/c_std/std_cmath.h +++ b/gnu/lib/libstdc++/libstdc++/include/c_std/std_cmath.h @@ -47,6 +47,7 @@ #pragma GCC system_header #include <bits/c++config.h> +#include <bits/cpp_type_traits.h> #include <math.h> @@ -197,6 +198,13 @@ namespace std acos(long double __x) { return ::acos(static_cast<double>(__x)); } #endif + template<typename _Tp> + inline typename __enable_if<double, __is_integer<_Tp>::_M_type>::_M_type + acos(_Tp __x) + { + return ::acos(static_cast<double>(__x)); + } + using ::asin; #if defined(_GLIBCPP_HAVE_ASINF) @@ -215,6 +223,11 @@ namespace std asin(long double __x) { return ::asin(static_cast<double>(__x)); } #endif + template<typename _Tp> + inline typename __enable_if<double, __is_integer<_Tp>::_M_type>::_M_type + asin(_Tp __x) + { return ::asin(static_cast<double>(__x)); } + using ::atan; #if defined(_GLIBCPP_HAVE_ATANF) @@ -233,6 +246,11 @@ namespace std atan(long double __x) { return ::atan(static_cast<double>(__x)); } #endif + template<typename _Tp> + inline typename __enable_if<double, __is_integer<_Tp>::_M_type>::_M_type + atan(_Tp __x) + { return ::atan(static_cast<double>(__x)); } + using ::atan2; #if defined(_GLIBCPP_HAVE_ATAN2F) @@ -253,6 +271,12 @@ namespace std { return ::atan2(static_cast<double>(__y), static_cast<double>(__x)); } #endif + template<typename _Tp, typename _Up> + inline typename __enable_if<double, __is_integer<_Tp>::_M_type + && __is_integer<_Up>::_M_type>::_M_type + atan2(_Tp __x, _Up __y) + { return ::atan2(static_cast<double>(__x), static_cast<double>(__y)); } + using ::ceil; #if defined(_GLIBCPP_HAVE_CEILF) @@ -271,6 +295,11 @@ namespace std ceil(long double __x) { return ::ceil(static_cast<double>(__x)); } #endif + template<typename _Tp> + inline typename __enable_if<double, __is_integer<_Tp>::_M_type>::_M_type + ceil(_Tp __x) + { return ::ceil(static_cast<double>(__x)); } + using ::cos; inline float @@ -281,6 +310,11 @@ namespace std cos(long double __x) { return __builtin_cosl(__x); } + template<typename _Tp> + inline typename __enable_if<double, __is_integer<_Tp>::_M_type>::_M_type + cos(_Tp __x) + { return __builtin_cos(__x); } + using ::cosh; #if defined(_GLIBCPP_HAVE_COSHF) @@ -299,6 +333,11 @@ namespace std cosh(long double __x) { return ::cosh(static_cast<double>(__x)); } #endif + template<typename _Tp> + inline typename __enable_if<double, __is_integer<_Tp>::_M_type>::_M_type + cosh(_Tp __x) + { return ::cosh(static_cast<double>(__x)); } + using ::exp; #if defined(_GLIBCPP_HAVE_EXPF) @@ -317,6 +356,11 @@ namespace std exp(long double __x) { return ::exp(static_cast<double>(__x)); } #endif + template<typename _Tp> + inline typename __enable_if<double, __is_integer<_Tp>::_M_type>::_M_type + exp(_Tp __x) + { return ::exp(static_cast<double>(__x)); } + using ::fabs; inline float @@ -327,6 +371,11 @@ namespace std fabs(long double __x) { return __builtin_fabsl(__x); } + template<typename _Tp> + inline typename __enable_if<double, __is_integer<_Tp>::_M_type>::_M_type + fabs(_Tp __x) + { return __builtin_fabs(__x); } + using ::floor; #if defined(_GLIBCPP_HAVE_FLOORF) @@ -345,6 +394,11 @@ namespace std floor(long double __x) { return ::floor(static_cast<double>(__x)); } #endif + template<typename _Tp> + inline typename __enable_if<double, __is_integer<_Tp>::_M_type>::_M_type + floor(_Tp __x) + { return ::floor(static_cast<double>(__x)); } + using ::fmod; #if defined(_GLIBCPP_HAVE_FMODF) @@ -384,6 +438,11 @@ namespace std { return ::frexp(static_cast<double>(__x), __exp); } #endif + template<typename _Tp> + inline typename __enable_if<double, __is_integer<_Tp>::_M_type>::_M_type + frexp(_Tp __x, int* __exp) + { return ::frexp(static_cast<double>(__x), __exp); } + using ::ldexp; #if defined(_GLIBCPP_HAVE_LDEXPF) @@ -404,6 +463,11 @@ namespace std { return ::ldexp(static_cast<double>(__x), __exp); } #endif + template<typename _Tp> + inline typename __enable_if<double, __is_integer<_Tp>::_M_type>::_M_type + ldexp(_Tp __x, int __exp) + { return ::ldexp(static_cast<double>(__x), __exp); } + using ::log; #if defined(_GLIBCPP_HAVE_LOGF) @@ -422,6 +486,11 @@ namespace std log(long double __x) { return ::log(static_cast<double>(__x)); } #endif + template<typename _Tp> + inline typename __enable_if<double, __is_integer<_Tp>::_M_type>::_M_type + log(_Tp __x) + { return ::log(static_cast<double>(__x)); } + using ::log10; #if defined(_GLIBCPP_HAVE_LOG10F) @@ -440,6 +509,11 @@ namespace std log10(long double __x) { return ::log10(static_cast<double>(__x)); } #endif + template<typename _Tp> + inline typename __enable_if<double, __is_integer<_Tp>::_M_type>::_M_type + log10(_Tp __x) + { return ::log10(static_cast<double>(__x)); } + using ::modf; #if defined(_GLIBCPP_HAVE_MODFF) @@ -521,6 +595,11 @@ namespace std sin(long double __x) { return __builtin_sinl(__x); } + template<typename _Tp> + inline typename __enable_if<double, __is_integer<_Tp>::_M_type>::_M_type + sin(_Tp __x) + { return __builtin_sin(__x); } + using ::sinh; #if defined(_GLIBCPP_HAVE_SINHF) @@ -539,6 +618,11 @@ namespace std sinh(long double __x) { return ::sinh(static_cast<double>(__x)); } #endif + template<typename _Tp> + inline typename __enable_if<double, __is_integer<_Tp>::_M_type>::_M_type + sinh(_Tp __x) + { return ::sinh(static_cast<_Tp>(__x)); } + using ::sqrt; inline float @@ -549,6 +633,11 @@ namespace std sqrt(long double __x) { return __builtin_sqrtl(__x); } + template<typename _Tp> + inline typename __enable_if<double, __is_integer<_Tp>::_M_type>::_M_type + sqrt(_Tp __x) + { return __builtin_sqrt(__x); } + using ::tan; #if defined(_GLIBCPP_HAVE_TANF) @@ -567,6 +656,11 @@ namespace std tan(long double __x) { return ::tan(static_cast<double>(__x)); } #endif + template<typename _Tp> + inline typename __enable_if<double, __is_integer<_Tp>::_M_type>::_M_type + tan(_Tp __x) + { return ::tan(static_cast<double>(__x)); } + using ::tanh; #if defined(_GLIBCPP_HAVE_TANHF) @@ -584,6 +678,11 @@ namespace std inline long double tanh(long double __x) { return ::tanh(static_cast<double>(__x)); } #endif + + template<typename _Tp> + inline typename __enable_if<double, __is_integer<_Tp>::_M_type>::_M_type + tanh(_Tp __x) + { return ::tanh(static_cast<double>(__x)); } } diff --git a/gnu/lib/libstdc++/shlib_version b/gnu/lib/libstdc++/shlib_version index 6c0d590e4a9..6cf543ad3a8 100644 --- a/gnu/lib/libstdc++/shlib_version +++ b/gnu/lib/libstdc++/shlib_version @@ -1,2 +1,2 @@ major=45 -minor=1 +minor=2 |