godot-module-template/engine/thirdparty/clipper2/patches/0002-llvm-disable-int128-math.patch
2025-04-12 18:40:44 +02:00

33 lines
1.5 KiB
Diff

diff --git a/thirdparty/clipper2/include/clipper2/clipper.core.h b/thirdparty/clipper2/include/clipper2/clipper.core.h
index 110bee4c10..aa003bf032 100644
--- a/thirdparty/clipper2/include/clipper2/clipper.core.h
+++ b/thirdparty/clipper2/include/clipper2/clipper.core.h
@@ -715,11 +715,13 @@ namespace Clipper2Lib
// returns true if (and only if) a * b == c * d
inline bool ProductsAreEqual(int64_t a, int64_t b, int64_t c, int64_t d)
{
-#if (defined(__clang__) || defined(__GNUC__)) && UINTPTR_MAX >= UINT64_MAX
- const auto ab = static_cast<__int128_t>(a) * static_cast<__int128_t>(b);
- const auto cd = static_cast<__int128_t>(c) * static_cast<__int128_t>(d);
- return ab == cd;
-#else
+// Work around LLVM issue: https://github.com/llvm/llvm-project/issues/16778
+// Details: https://github.com/godotengine/godot/pull/95964#issuecomment-2306581804
+// #if (defined(__clang__) || defined(__GNUC__)) && UINTPTR_MAX >= UINT64_MAX
+// const auto ab = static_cast<__int128_t>(a) * static_cast<__int128_t>(b);
+// const auto cd = static_cast<__int128_t>(c) * static_cast<__int128_t>(d);
+// return ab == cd;
+// #else
// nb: unsigned values needed for calculating overflow carry
const auto abs_a = static_cast<uint64_t>(std::abs(a));
const auto abs_b = static_cast<uint64_t>(std::abs(b));
@@ -734,7 +736,7 @@ namespace Clipper2Lib
const auto sign_cd = TriSign(c) * TriSign(d);
return abs_ab == abs_cd && sign_ab == sign_cd;
-#endif
+// #endif
}
template <typename T>