summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard W.M. Jones <rjones@redhat.com>2016-08-11 11:38:18 +0100
committerRichard W.M. Jones <rjones@redhat.com>2016-08-22 21:16:48 +0100
commitcf5679397f36710a942fcb83a63c690eb25d72af (patch)
tree7998acdb6ec8c88672633228a706f7716e0b44cc
parentd9d47e01146a5d4411691a71916b1030ac7da193 (diff)
downloadrpm-cf5679397f36710a942fcb83a63c690eb25d72af.tar.gz
rpmrc: Convert uname.machine == "riscv" to "riscv32"/"riscv64"/"riscv128".
On RISC-V, the kernel can return uname.machine == "riscv" (for all bit sizes). I say "can" return, because that is the default, but it is also possible to compile the kernel specially so it returns "riscv64" etc. GNU is using "riscv64". This commit converts the kernel uname machine type "riscv" to a more suitable value. This conversion is supposed to be done by the arch_canon table. However the arch_canon table is not populated until after the defaultMachine function is called for the first time, making it a bit useless. In any case, arch_canon cannot take into account the bit size of the architecture, but the C code here can. Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
-rw-r--r--lib/rpmrc.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/rpmrc.c b/lib/rpmrc.c
index f2e0f485c..eb136d817 100644
--- a/lib/rpmrc.c
+++ b/lib/rpmrc.c
@@ -1216,6 +1216,17 @@ static void defaultMachine(rpmrcCtx ctx, const char ** arch, const char ** os)
}
# endif /* arm*-linux */
+# if defined(__linux__) && defined(__riscv__)
+ if (rstreq(un.machine, "riscv")) {
+ if (sizeof(long) == 4)
+ strcpy(un.machine, "riscv32");
+ else if (sizeof(long) == 8)
+ strcpy(un.machine, "riscv64");
+ else if (sizeof(long) == 16)
+ strcpy(un.machine, "riscv128");
+ }
+# endif /* riscv */
+
# if defined(__GNUC__) && defined(__alpha__)
{
unsigned long amask, implver;