aports/community/simde/musl-compatibility.patch

43 lines
1.3 KiB
Diff

commit 2c1fb491120a150743c7a1d4a5e08301361f0ec9
Author: Francesco Colista <fcolista@alpinelinux.org>
Date: Fri Nov 21 14:26:09 2025 +0000
Added musl compatibility layer
diff --git a/simde/musl-roundeven-compat.h b/simde/musl-roundeven-compat.h
new file mode 100644
index 0000000..d3b31f6
--- /dev/null
+++ b/simde/musl-roundeven-compat.h
@@ -0,0 +1,19 @@
+#if defined(__musl__)
+/* musl does not provide roundeven()/roundevenf(), and GCC may generate calls
+ to them during LTO even when SIMDe tries to avoid it.
+ Provide lightweight wrappers to ensure linking succeeds. */
+
+#include <math.h>
+
+static inline float simde_musl_roundevenf(float x) {
+ return nearbyintf(x); /* nearbyintf implements ties-to-even */
+}
+
+static inline double simde_musl_roundeven(double x) {
+ return nearbyint(x);
+}
+
+#define roundevenf simde_musl_roundevenf
+#define roundeven simde_musl_roundeven
+#endif
+
diff --git a/simde/simde-common.h b/simde/simde-common.h
index 5a755cc..2719642 100644
--- a/simde/simde-common.h
+++ b/simde/simde-common.h
@@ -1,3 +1,6 @@
+/* musl compatibility shim: ensure roundevenf()/roundeven() exist */
+#include "musl-roundeven-compat.h"
+
/* SPDX-License-Identifier: MIT
*
* Permission is hereby granted, free of charge, to any person