From c2a86fabc26c029e8d9e2a22f25ba6aa7ae8b143 Mon Sep 17 00:00:00 2001 From: Xeonacid Date: Sat, 20 Jun 2026 09:24:56 +0200 Subject: [PATCH] addpatch: snmalloc 0.7.4-1 --- snmalloc/riscv64.patch | 17 +++++++++++ snmalloc/snmalloc-riscv-rdtime.patch | 43 ++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 snmalloc/riscv64.patch create mode 100644 snmalloc/snmalloc-riscv-rdtime.patch diff --git a/snmalloc/riscv64.patch b/snmalloc/riscv64.patch new file mode 100644 index 000000000..be97ca73b --- /dev/null +++ b/snmalloc/riscv64.patch @@ -0,0 +1,17 @@ +diff --git PKGBUILD PKGBUILD +index 22adf65..8c9710f 100644 +--- PKGBUILD ++++ PKGBUILD +@@ -46,3 +46,12 @@ + DESTDIR="$pkgdir" cmake --install build + install -vDm 644 $pkgname-$pkgver/LICENSE -t "$pkgdir/usr/share/licenses/$pkgname/" + } ++ ++source_riscv64=("$pkgname-riscv-rdtime.patch") ++sha512sums_riscv64=('04f5f4e070e94d3ec519e756d5c25b2a8f3c5cd5687895423f09deee5d17cd8bf000d0065181a3100547f41a6a690e8336c9bde1e1a3ada5b4b026bbb22c2c1a') ++b2sums_riscv64=('a27a8fcfe4279cf6e364d9414654861c35f3ec9492e2a1345a48d9ed61359771a43ca36cc2c74eb59e949b3921c889970f2e20c50b1d0189fa2cd84a879bc092') ++ ++prepare() { ++ cd "$pkgname-$pkgver" ++ patch -Np1 -i ../$pkgname-riscv-rdtime.patch ++} diff --git a/snmalloc/snmalloc-riscv-rdtime.patch b/snmalloc/snmalloc-riscv-rdtime.patch new file mode 100644 index 000000000..4d7b7ecf0 --- /dev/null +++ b/snmalloc/snmalloc-riscv-rdtime.patch @@ -0,0 +1,43 @@ +diff --git a/src/snmalloc/aal/aal.h b/src/snmalloc/aal/aal.h +index f0d1207..3ce0703 100644 +--- a/src/snmalloc/aal/aal.h ++++ b/src/snmalloc/aal/aal.h +@@ -173,6 +173,7 @@ namespace snmalloc + else + { + #if __has_builtin(__builtin_readcyclecounter) && !defined(__APPLE__) && \ ++ !defined(__riscv) && \ + !defined(SNMALLOC_NO_AAL_BUILTINS) + return __builtin_readcyclecounter(); + #else +diff --git a/src/snmalloc/aal/aal_riscv.h b/src/snmalloc/aal/aal_riscv.h +index 42d510c..b3dba74 100644 +--- a/src/snmalloc/aal/aal_riscv.h ++++ b/src/snmalloc/aal/aal_riscv.h +@@ -21,6 +21,26 @@ namespace snmalloc + + static constexpr AalName aal_name = RISCV; + ++ static inline uint64_t tick() noexcept ++ { ++#if __riscv_xlen == 64 ++ uint64_t t; ++ __asm__ volatile("rdtime %0" : "=r"(t)); ++ return t; ++#else ++ uint32_t hi; ++ uint32_t hi2; ++ uint32_t lo; ++ do ++ { ++ __asm__ volatile("rdtimeh %0" : "=r"(hi)); ++ __asm__ volatile("rdtime %0" : "=r"(lo)); ++ __asm__ volatile("rdtimeh %0" : "=r"(hi2)); ++ } while (hi != hi2); ++ return (static_cast(hi) << 32) | lo; ++#endif ++ } ++ + static void inline pause() + { + /*