summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2014-10-19 20:22:58 (GMT)
committerTobias Markmann <tm@ayena.de>2014-10-20 13:49:33 (GMT)
commit6b22dfcf59474dd016a0355a3102a1dd3692d92c (patch)
tree2b1fd33be433a91e81fee84fdc2bf1b52575d934 /3rdParty/Boost/src/boost/math/special_functions/sign.hpp
parent38b0cb785fea8eae5e48fae56440695fdfd10ee1 (diff)
downloadswift-6b22dfcf59474dd016a0355a3102a1dd3692d92c.zip
swift-6b22dfcf59474dd016a0355a3102a1dd3692d92c.tar.bz2
Update Boost in 3rdParty to version 1.56.0.
This updates Boost in our 3rdParty directory to version 1.56.0. Updated our update.sh script to stop on error. Changed error reporting in SwiftTools/CrashReporter.cpp to SWIFT_LOG due to missing include of <iostream> with newer Boost. Change-Id: I4b35c77de951333979a524097f35f5f83d325edc
Diffstat (limited to '3rdParty/Boost/src/boost/math/special_functions/sign.hpp')
-rw-r--r--3rdParty/Boost/src/boost/math/special_functions/sign.hpp71
1 files changed, 60 insertions, 11 deletions
diff --git a/3rdParty/Boost/src/boost/math/special_functions/sign.hpp b/3rdParty/Boost/src/boost/math/special_functions/sign.hpp
index 6de88b2..f5c562d 100644
--- a/3rdParty/Boost/src/boost/math/special_functions/sign.hpp
+++ b/3rdParty/Boost/src/boost/math/special_functions/sign.hpp
@@ -31,7 +31,10 @@ namespace detail {
}
#endif
- template<class T>
+ // Generic versions first, note that these do not handle
+ // signed zero or NaN.
+
+ template<class T>
inline int signbit_impl(T x, generic_tag<true> const&)
{
return x < 0;
@@ -43,7 +46,25 @@ namespace detail {
return x < 0;
}
- template<class T>
+#if defined(__GNUC__) && (LDBL_MANT_DIG == 106)
+ //
+ // Special handling for GCC's "double double" type,
+ // in this case the sign is the same as the sign we
+ // get by casting to double, no overflow/underflow
+ // can occur since the exponents are the same magnitude
+ // for the two types:
+ //
+ inline int signbit_impl(long double x, generic_tag<true> const&)
+ {
+ return boost::math::signbit(static_cast<double>(x));
+ }
+ inline int signbit_impl(long double x, generic_tag<false> const&)
+ {
+ return boost::math::signbit(static_cast<double>(x));
+ }
+#endif
+
+ template<class T>
inline int signbit_impl(T x, ieee_copy_all_bits_tag const&)
{
typedef BOOST_DEDUCED_TYPENAME fp_traits<T>::type traits;
@@ -65,6 +86,9 @@ namespace detail {
}
// Changesign
+
+ // Generic versions first, note that these do not handle
+ // signed zero or NaN.
template<class T>
inline T (changesign_impl)(T x, generic_tag<true> const&)
@@ -77,7 +101,27 @@ namespace detail {
{
return -x;
}
-
+#if defined(__GNUC__) && (LDBL_MANT_DIG == 106)
+ //
+ // Special handling for GCC's "double double" type,
+ // in this case we need to change the sign of both
+ // components of the "double double":
+ //
+ inline long double (changesign_impl)(long double x, generic_tag<true> const&)
+ {
+ double* pd = reinterpret_cast<double*>(&x);
+ pd[0] = boost::math::changesign(pd[0]);
+ pd[1] = boost::math::changesign(pd[1]);
+ return x;
+ }
+ inline long double (changesign_impl)(long double x, generic_tag<false> const&)
+ {
+ double* pd = reinterpret_cast<double*>(&x);
+ pd[0] = boost::math::changesign(pd[0]);
+ pd[1] = boost::math::changesign(pd[1]);
+ return x;
+ }
+#endif
template<class T>
inline T changesign_impl(T x, ieee_copy_all_bits_tag const&)
@@ -110,8 +154,9 @@ template<class T> int (signbit)(T x)
{
typedef typename detail::fp_traits<T>::type traits;
typedef typename traits::method method;
- typedef typename boost::is_floating_point<T>::type fp_tag;
- return detail::signbit_impl(x, method());
+ // typedef typename boost::is_floating_point<T>::type fp_tag;
+ typedef typename tools::promote_args_permissive<T>::type result_type;
+ return detail::signbit_impl(static_cast<result_type>(x), method());
}
template <class T>
@@ -120,20 +165,24 @@ inline int sign BOOST_NO_MACRO_EXPAND(const T& z)
return (z == 0) ? 0 : (boost::math::signbit)(z) ? -1 : 1;
}
-template<class T> T (changesign)(const T& x)
+template <class T> typename tools::promote_args_permissive<T>::type (changesign)(const T& x)
{ //!< \brief return unchanged binary pattern of x, except for change of sign bit.
typedef typename detail::fp_traits<T>::sign_change_type traits;
typedef typename traits::method method;
- typedef typename boost::is_floating_point<T>::type fp_tag;
+ // typedef typename boost::is_floating_point<T>::type fp_tag;
+ typedef typename tools::promote_args_permissive<T>::type result_type;
- return detail::changesign_impl(x, method());
+ return detail::changesign_impl(static_cast<result_type>(x), method());
}
-template <class T>
-inline T copysign BOOST_NO_MACRO_EXPAND(const T& x, const T& y)
+template <class T, class U>
+inline typename tools::promote_args_permissive<T, U>::type
+ copysign BOOST_NO_MACRO_EXPAND(const T& x, const U& y)
{
BOOST_MATH_STD_USING
- return (boost::math::signbit)(x) != (boost::math::signbit)(y) ? (boost::math::changesign)(x) : x;
+ typedef typename tools::promote_args_permissive<T, U>::type result_type;
+ return (boost::math::signbit)(static_cast<result_type>(x)) != (boost::math::signbit)(static_cast<result_type>(y))
+ ? (boost::math::changesign)(static_cast<result_type>(x)) : static_cast<result_type>(x);
}
} // namespace math