From ac1b473832792d03a32b81a5a09b689c1a10dd8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=91=D1=80=D0=B0=D0=BD=D0=B8=D0=BC=D0=B8=D1=80=20=D0=9A?= =?UTF-8?q?=D0=B0=D1=80=D0=B0=D1=9F=D0=B8=D1=9B?= Date: Thu, 1 Jun 2023 20:00:05 -0700 Subject: [PATCH] Clang: Fixed bx::signbit. --- include/bx/inline/math.inl | 3 ++- tests/string_test.cpp | 14 +++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/include/bx/inline/math.inl b/include/bx/inline/math.inl index 97e3b4c..055cf8a 100644 --- a/include/bx/inline/math.inl +++ b/include/bx/inline/math.inl @@ -143,7 +143,8 @@ namespace bx #if BX_COMPILER_MSVC return _signbit(_a); #else - return __builtin_signbit(_a); + return copysign(1, _a) < 0; +// return __builtin_signbit(_a); #endif // BX_COMPILER_MSVC } diff --git a/tests/string_test.cpp b/tests/string_test.cpp index bce5bd3..bd72629 100644 --- a/tests/string_test.cpp +++ b/tests/string_test.cpp @@ -18,29 +18,29 @@ TEST_CASE("StringLiteral", "") REQUIRE(bx::isSorted(tmp, BX_COUNTOF(tmp) ) ); - static_assert(4 == tmp[0].getLength() ); + STATIC_REQUIRE(4 == tmp[0].getLength() ); REQUIRE(4 == bx::strLen(tmp[0]) ); REQUIRE(0 == bx::strCmp("1389", tmp[0]) ); - static_assert(5 == tmp[1].getLength() ); + STATIC_REQUIRE(5 == tmp[1].getLength() ); REQUIRE(5 == bx::strLen(tmp[1]) ); REQUIRE(0 == bx::strCmp("abvgd", tmp[1]) ); - static_assert(3 == tmp[2].getLength() ); + STATIC_REQUIRE(3 == tmp[2].getLength() ); REQUIRE(3 == bx::strLen(tmp[2]) ); REQUIRE(0 == bx::strCmp("mac", tmp[2]) ); - static_assert(3 == tmp[3].getLength() ); + STATIC_REQUIRE(3 == tmp[3].getLength() ); REQUIRE(3 == bx::strLen(tmp[3]) ); REQUIRE(0 == bx::strCmp("pod", tmp[3]) ); - constexpr bx::StringLiteral copy = tmp[0]; + constexpr bx::StringLiteral copy(tmp[0]); - static_assert(4 == copy.getLength() ); + STATIC_REQUIRE(4 == copy.getLength() ); REQUIRE(4 == bx::strLen(copy) ); REQUIRE(0 == bx::strCmp("1389", copy) ); - constexpr bx::StringView sv = tmp[1]; + constexpr bx::StringView sv(tmp[1]); REQUIRE(5 == sv.getLength() ); REQUIRE(5 == bx::strLen(sv) );