-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wpewebkit: Fix build failure on musl (roundeven and roundevenf)
While building WPEWebKit on musl-based systems, errors occur due to the absence of roundevenf and roundeven functions. These are not available in musl and other non-glibc platforms. This patch provides fallback implementations for both functions. Upstream: https://bugs.webkit.org/show_bug.cgi?id=281216
- Loading branch information
Showing
2 changed files
with
62 additions
and
1 deletion.
There are no files selected for viewing
59 changes: 59 additions & 0 deletions
59
...owser/wpewebkit/wpewebkit/0001-JSC-Fix-build-failure-on-musl-Add-fallback-for-round.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
From 3c54d2278eba24fe75ff2c04b74807e118ed7562 Mon Sep 17 00:00:00 2001 | ||
From: Pablo Saavedra <[email protected]> | ||
Date: Thu, 10 Oct 2024 15:11:47 +0200 | ||
Subject: [PATCH] [JSC] Fix build failure on musl: Add fallback for roundeven | ||
and roundevenf https://bugs.webkit.org/show_bug.cgi?id=281216 | ||
|
||
Reviewed by NOBODY (OOPS!). | ||
|
||
While building WPEWebKit on musl-based systems, errors occur due to | ||
the absence of roundevenf and roundeven functions. These are not | ||
available in musl and other non-glibc platforms. | ||
|
||
This patch provides fallback implementations for both functions. | ||
|
||
* Source/JavaScriptCore/runtime/MathCommon.cpp: | ||
(JSC::Math::roundevenf): | ||
(JSC::Math::roundeven): | ||
--- | ||
Source/JavaScriptCore/runtime/MathCommon.cpp | 22 ++++++++++++++++++++ | ||
1 file changed, 22 insertions(+) | ||
|
||
Upstream-Status: Submitted [https://bugs.webkit.org/show_bug.cgi?id=281216] | ||
|
||
diff --git a/Source/JavaScriptCore/runtime/MathCommon.cpp b/Source/JavaScriptCore/runtime/MathCommon.cpp | ||
index 0cd276b20126..625f9146c1ea 100644 | ||
--- a/Source/JavaScriptCore/runtime/MathCommon.cpp | ||
+++ b/Source/JavaScriptCore/runtime/MathCommon.cpp | ||
@@ -635,6 +635,28 @@ JSC_DEFINE_NOEXCEPT_JIT_OPERATION(f64_nearest, double, (double operand)) | ||
return std::nearbyint(operand); | ||
} | ||
|
||
+#if OS(LINUX) && !defined(__GLIBC__) | ||
+static inline float roundevenf(float operand) | ||
+{ | ||
+ float rounded = roundf(operand); | ||
+ if (fabsf(operand - rounded) == 0.5f) { | ||
+ if (fmod(rounded, 2.0f) != 0.0f) | ||
+ return rounded - copysignf(1.0f, operand); | ||
+ } | ||
+ return rounded; | ||
+} | ||
+ | ||
+static inline double roundeven(double operand) | ||
+{ | ||
+ double rounded = round(operand); | ||
+ if (fabs(operand - rounded) == 0.5) { | ||
+ if (fmod(rounded, 2.0) != 0.0) | ||
+ return rounded - copysign(1.0, operand); | ||
+ } | ||
+ return rounded; | ||
+} | ||
+#endif | ||
+ | ||
JSC_DEFINE_NOEXCEPT_JIT_OPERATION(f32_roundeven, float, (float operand)) { return roundevenf(operand); } | ||
JSC_DEFINE_NOEXCEPT_JIT_OPERATION(f64_roundeven, double, (double operand)) { return roundeven(operand); } | ||
JSC_DEFINE_NOEXCEPT_JIT_OPERATION(f32_trunc, float, (float operand)) { return std::trunc(operand); } | ||
-- | ||
2.43.0 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters