public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [rpms/spasm] rawhide: fix build on RISC-V
@ 2026-10-21 15:47 Marcin Juszkiewicz
0 siblings, 0 replies; only message in thread
From: Marcin Juszkiewicz @ 2026-10-21 15:47 UTC (permalink / raw)
To: git-commits
A new commit has been pushed.
Repo : rpms/spasm
Branch : rawhide
Commit : 6567358e540a85cccf362c641c35bdfb4c0b6713
Author : Marcin Juszkiewicz <mjuszkiewicz@redhat.com>
Date : 2026-10-20T17:51:57+02:00
Stats : +11/-13 in 1 file(s)
URL : https://src.fedoraproject.org/rpms/spasm/c/6567358e540a85cccf362c641c35bdfb4c0b6713?branch=rawhide
Log:
fix build on RISC-V
RDCYCLE is priviledged instruction since Linux 6.6 version. RDTIME is
usespace one.
---
diff --git a/spasm-cycleclock.patch b/spasm-cycleclock.patch
index 48aad08..02faf07 100644
--- a/spasm-cycleclock.patch
+++ b/spasm-cycleclock.patch
@@ -56,7 +56,7 @@ at all for s390x.
#elif defined(__sparc__)
int64 tick;
asm(".byte 0x83, 0x41, 0x00, 0x00");
-@@ -136,38 +142,113 @@ extern "C" uint64 __rdtsc();
+@@ -136,40 +142,113 @@ extern "C" uint64 __rdtsc();
// when I know it will work. Otherwise, I'll use __rdtsc and hope
// the code is being compiled with a non-ancient compiler.
_asm rdtsc
@@ -146,25 +146,23 @@ at all for s390x.
+#endif
+ return tsc;
+#elif defined(__riscv) // RISC-V
-+ // Use RDCYCLE (and RDCYCLEH on riscv32)
++ // Use RDTIME (and RDTIMEH on riscv32); rdcycle is not accessible from user space
+#if __riscv_xlen == 32
-+ uint32_t cycles_lo, cycles_hi0, cycles_hi1;
-+ // This asm also includes the PowerPC overflow handling strategy, as above.
-+ // Implemented in assembly because Clang insisted on branching.
++ uint32_t time_lo, time_hi0, time_hi1;
+ asm volatile(
-+ "rdcycleh %0\n"
-+ "rdcycle %1\n"
-+ "rdcycleh %2\n"
++ "rdtimeh %0\n"
++ "rdtime %1\n"
++ "rdtimeh %2\n"
+ "sub %0, %0, %2\n"
+ "seqz %0, %0\n"
+ "sub %0, zero, %0\n"
+ "and %1, %1, %0\n"
-+ : "=r"(cycles_hi0), "=r"(cycles_lo), "=r"(cycles_hi1));
-+ return (static_cast<uint64_t>(cycles_hi1) << 32) | cycles_lo;
++ : "=r"(time_hi0), "=r"(time_lo), "=r"(time_hi1));
++ return (static_cast<uint64_t>(time_hi1) << 32) | time_lo;
+#else
-+ uint64_t cycles;
-+ asm volatile("rdcycle %0" : "=r"(cycles));
-+ return cycles;
++ uint64_t t;
++ asm volatile("rdtime %0" : "=r"(t));
++ return t;
+#endif
+#elif defined(__e2k__) || defined(__elbrus__)
+ struct timeval tv;
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-10-21 15:47 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-21 15:47 [rpms/spasm] rawhide: fix build on RISC-V Marcin Juszkiewicz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox