Files
ports/multimedia/vvenc/patches/patch-thirdparty_simde_simde-math_h
T
kmos 6da9e16f45 Patch from Brad Smith to fix build of vvenc on
powerpc, powerpc64, and mips64.
2026-03-30 22:13:49 +00:00

65 lines
3.2 KiB
Plaintext

- math: guard __builtin_roundeven against non-glibc platforms
6b772fe4e9a0b647f5413a2b56489c776406eaa9
- math: extend non-glibc guard to Clang and add exp10 guard
e6f82439d5088c57344f0bc1113ecf8c4cc0a42a
Index: thirdparty/simde/simde-math.h
--- thirdparty/simde/simde-math.h.orig
+++ thirdparty/simde/simde-math.h
@@ -972,13 +972,18 @@ simde_math_fpclass(double v, const int imm8) {
#endif
#endif
-#if HEDLEY_HAS_BUILTIN(__builtin_exp10) || HEDLEY_GCC_VERSION_CHECK(3,4,0)
+/* __builtin_exp10 lowers to exp10() which is a GNU extension available
+ * only in glibc. Other libcs (musl, OpenBSD, FreeBSD, MinGW, etc.)
+ * lack the symbol and produce a link error. Fall back to pow(10, v). */
+#if (HEDLEY_HAS_BUILTIN(__builtin_exp10) || HEDLEY_GCC_VERSION_CHECK(3,4,0)) && \
+ defined(__GLIBC__)
# define simde_math_exp10(v) __builtin_exp10(v)
#else
# define simde_math_exp10(v) simde_math_pow(10.0, (v))
#endif
-#if HEDLEY_HAS_BUILTIN(__builtin_exp10f) || HEDLEY_GCC_VERSION_CHECK(3,4,0)
+#if (HEDLEY_HAS_BUILTIN(__builtin_exp10f) || HEDLEY_GCC_VERSION_CHECK(3,4,0)) && \
+ defined(__GLIBC__)
# define simde_math_exp10f(v) __builtin_exp10f(v)
#else
# define simde_math_exp10f(v) simde_math_powf(10.0f, (v))
@@ -1265,9 +1270,16 @@ simde_math_fpclass(double v, const int imm8) {
#endif
#if !defined(simde_math_roundeven)
+ /* __builtin_roundeven lowers to a roundeven() libm call on targets
+ * without a native rounding instruction (x86 without SSE4.1,
+ * powerpc, sparc, i386, etc.). roundeven() is C23 and only
+ * available in glibc >= 2.25; other libcs (musl, OpenBSD, FreeBSD,
+ * MinGW, etc.) lack the symbol and produce a link error. Guard for
+ * all compilers: non-glibc platforms use the inline fallback below. */
#if \
- ((!defined(HEDLEY_EMSCRIPTEN_VERSION) || HEDLEY_EMSCRIPTEN_VERSION_CHECK(3, 1, 43)) && HEDLEY_HAS_BUILTIN(__builtin_roundeven)) || \
- HEDLEY_GCC_VERSION_CHECK(10,0,0)
+ ((!defined(HEDLEY_EMSCRIPTEN_VERSION) || HEDLEY_EMSCRIPTEN_VERSION_CHECK(3, 1, 43)) && \
+ HEDLEY_HAS_BUILTIN(__builtin_roundeven) && \
+ (defined(__GLIBC__) && ((__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 25))))
#define simde_math_roundeven(v) __builtin_roundeven(v)
#elif defined(simde_math_round) && defined(simde_math_fabs)
static HEDLEY_INLINE
@@ -1285,9 +1297,13 @@ simde_math_fpclass(double v, const int imm8) {
#endif
#if !defined(simde_math_roundevenf)
+ /* Same rationale as simde_math_roundeven above; applies to the float
+ * variant. Both GCC and Clang emit a roundevenf() libm call on
+ * targets without a native instruction. */
#if \
- ((!defined(HEDLEY_EMSCRIPTEN_VERSION) || HEDLEY_EMSCRIPTEN_VERSION_CHECK(3, 1, 43)) && HEDLEY_HAS_BUILTIN(__builtin_roundevenf)) || \
- HEDLEY_GCC_VERSION_CHECK(10,0,0)
+ ((!defined(HEDLEY_EMSCRIPTEN_VERSION) || HEDLEY_EMSCRIPTEN_VERSION_CHECK(3, 1, 43)) && \
+ HEDLEY_HAS_BUILTIN(__builtin_roundevenf) && \
+ (defined(__GLIBC__) && ((__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 25))))
#define simde_math_roundevenf(v) __builtin_roundevenf(v)
#elif defined(simde_math_roundf) && defined(simde_math_fabsf)
static HEDLEY_INLINE