Fix mpc-devel -> libmpc-devel.
[fedora-riscv.git] / 0002-rpmrc-Convert-uname.machine-riscv-to-riscv32-riscv64.patch
1 From 331b0ac34a9767d1f0147daf3fd22b64e2e4e3af Mon Sep 17 00:00:00 2001
2 From: "Richard W.M. Jones" <rjones@redhat.com>
3 Date: Thu, 11 Aug 2016 11:38:18 +0100
4 Subject: [PATCH 2/4] rpmrc: Convert uname.machine == "riscv" to
5  "riscv32"/"riscv64"/"riscv128".
6
7 On RISC-V, the kernel returns uname.machine == "riscv" (for all bit
8 sizes).  GNU is using "riscv64".  Convert the kernel uname machine
9 type to a more suitable value.
10
11 This conversion is supposed to be done by the arch_canon table.
12 However the arch_canon table is not populated until after the
13 defaultMachine function is called for the first time, making it a bit
14 useless.  In any case, arch_canon cannot take into account the bit
15 size of the architecture, but the C code here can.
16
17 Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
18 ---
19  lib/rpmrc.c | 11 +++++++++++
20  1 file changed, 11 insertions(+)
21
22 diff --git a/lib/rpmrc.c b/lib/rpmrc.c
23 index f2e0f48..eb136d8 100644
24 --- a/lib/rpmrc.c
25 +++ b/lib/rpmrc.c
26 @@ -1216,6 +1216,17 @@ static void defaultMachine(rpmrcCtx ctx, const char ** arch, const char ** os)
27         }
28  #      endif   /* arm*-linux */
29  
30 +#      if defined(__linux__) && defined(__riscv__)
31 +       if (rstreq(un.machine, "riscv")) {
32 +               if (sizeof(long) == 4)
33 +                       strcpy(un.machine, "riscv32");
34 +               else if (sizeof(long) == 8)
35 +                       strcpy(un.machine, "riscv64");
36 +               else if (sizeof(long) == 16)
37 +                       strcpy(un.machine, "riscv128");
38 +       }
39 +#      endif   /* riscv */
40 +
41  #      if defined(__GNUC__) && defined(__alpha__)
42         {
43             unsigned long amask, implver;
44 -- 
45 2.7.4
46