public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
From: Marcin Juszkiewicz <mjuszkiewicz@redhat.com>
To: git-commits@fedoraproject.org
Subject: [rpms/spasm] f45: fix build on RISC-V
Date: Wed, 21 Oct 2026 15:57:02 GMT [thread overview]
Message-ID: <179259822225.1.14091903300969044185.rpms-spasm-6567358e540a@fedoraproject.org> (raw)
A new commit has been pushed.
Repo : rpms/spasm
Branch : f45
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=f45
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;
reply other threads:[~2026-10-21 15:57 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=179259822225.1.14091903300969044185.rpms-spasm-6567358e540a@fedoraproject.org \
--to=mjuszkiewicz@redhat.com \
--cc=git-commits@fedoraproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox