Commit e339291f by Jonathan Wakely Committed by Jonathan Wakely

Fix new testcase to not require std::copysign

Use __builtin_copysign{,f,l} when std::copysign isn't available.

	PR libstdc++/61761
	* testsuite/26_numerics/complex/proj.cc: Don't assume <cmath> defines
	std::copysign.

From-SVN: r270859
parent 56e5b093
2019-05-03 Jonathan Wakely <jwakely@redhat.com> 2019-05-03 Jonathan Wakely <jwakely@redhat.com>
PR libstdc++/61761
* testsuite/26_numerics/complex/proj.cc: Don't assume <cmath> defines
std::copysign.
PR libstdc++/52119 PR libstdc++/52119
* include/ext/numeric_traits.h (__glibcxx_min): Avoid integer * include/ext/numeric_traits.h (__glibcxx_min): Avoid integer
overflow warning with -Wpedantic -Wsystem-headers. overflow warning with -Wpedantic -Wsystem-headers.
......
...@@ -21,6 +21,22 @@ ...@@ -21,6 +21,22 @@
#include <limits> #include <limits>
#include <testsuite_hooks.h> #include <testsuite_hooks.h>
namespace test
{
#ifdef _GLIBCXX_USE_C99_MATH_TR1
using std::copysign;
#else
bool copysign(float x, float y)
{ return __builtin_copysignf(x, y); }
bool copysign(double x, double y)
{ return __builtin_copysign(x, y); }
bool copysign(long double x, long double y)
{ return __builtin_copysignl(x, y); }
#endif
}
template<typename T> template<typename T>
bool eq(const std::complex<T>& x, const std::complex<T>& y) bool eq(const std::complex<T>& x, const std::complex<T>& y)
{ {
...@@ -28,9 +44,9 @@ bool eq(const std::complex<T>& x, const std::complex<T>& y) ...@@ -28,9 +44,9 @@ bool eq(const std::complex<T>& x, const std::complex<T>& y)
bool nan_imags = std::isnan(x.imag()) && std::isnan(y.imag()); bool nan_imags = std::isnan(x.imag()) && std::isnan(y.imag());
bool sign_reals bool sign_reals
= std::copysign(T(1), x.real()) == std::copysign(T(1), y.real()); = test::copysign(T(1), x.real()) == test::copysign(T(1), y.real());
bool sign_imags bool sign_imags
= std::copysign(T(1), x.imag()) == std::copysign(T(1), y.imag()); = test::copysign(T(1), x.imag()) == test::copysign(T(1), y.imag());
return ((x.real() == y.real() && sign_reals) || nan_reals) return ((x.real() == y.real() && sign_reals) || nan_reals)
&& ((x.imag() == y.imag() && sign_imags) || nan_imags); && ((x.imag() == y.imag() && sign_imags) || nan_imags);
......
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