[systemd-devel] [PATCH] architecture: Add support for the RISC-V architecture.

Richard W.M. Jones rjones at redhat.com
Fri Sep 30 15:45:01 UTC 2016


Signed-off-by: Richard W.M. Jones <rjones at redhat.com>
---
 src/basic/architecture.c | 14 ++++++++++++++
 src/basic/architecture.h | 16 ++++++++++++++++
 2 files changed, 30 insertions(+)

diff --git a/src/basic/architecture.c b/src/basic/architecture.c
index b1c8e91..e1412be 100644
--- a/src/basic/architecture.c
+++ b/src/basic/architecture.c
@@ -123,6 +123,17 @@ int uname_architecture(void) {
                 { "crisv32",    ARCHITECTURE_CRIS     },
 #elif defined(__nios2__)
                 { "nios2",      ARCHITECTURE_NIOS2    },
+#elif defined(__riscv__)
+                { "riscv32",    ARCHITECTURE_RISCV32  },
+                { "riscv64",    ARCHITECTURE_RISCV64  },
+                { "riscv128",   ARCHITECTURE_RISCV128 },
+#  if __SIZEOF_POINTER__ == 4
+                { "riscv",      ARCHITECTURE_RISCV32  },
+#  elif __SIZEOF_POINTER__ == 8
+                { "riscv",      ARCHITECTURE_RISCV64  },
+#  elif __SIZEOF_POINTER__ == 16
+                { "riscv",      ARCHITECTURE_RISCV128 },
+#  endif
 #else
 #error "Please register your architecture here!"
 #endif
@@ -174,6 +185,9 @@ static const char *const architecture_table[_ARCHITECTURE_MAX] = {
         [ARCHITECTURE_TILEGX] = "tilegx",
         [ARCHITECTURE_CRIS] = "cris",
         [ARCHITECTURE_NIOS2] = "nios2",
+        [ARCHITECTURE_RISCV32] = "riscv32",
+        [ARCHITECTURE_RISCV64] = "riscv64",
+        [ARCHITECTURE_RISCV128] = "riscv128",
 };
 
 DEFINE_STRING_TABLE_LOOKUP(architecture, int);
diff --git a/src/basic/architecture.h b/src/basic/architecture.h
index b3e4d85..b8830fc 100644
--- a/src/basic/architecture.h
+++ b/src/basic/architecture.h
@@ -58,6 +58,9 @@ enum {
         ARCHITECTURE_TILEGX,
         ARCHITECTURE_CRIS,
         ARCHITECTURE_NIOS2,
+        ARCHITECTURE_RISCV32,
+        ARCHITECTURE_RISCV64,
+        ARCHITECTURE_RISCV128,
         _ARCHITECTURE_MAX,
         _ARCHITECTURE_INVALID = -1
 };
@@ -191,6 +194,19 @@ int uname_architecture(void);
 #elif defined(__nios2__)
 #  define native_architecture() ARCHITECTURE_NIOS2
 #  define LIB_ARCH_TUPLE "nios2-linux-gnu"
+#elif defined(__riscv__)
+#  if __SIZEOF_POINTER__ == 4
+#    define native_architecture() ARCHITECTURE_RISCV32
+#    define LIB_ARCH_TUPLE "riscv32-linux-gnu"
+#  elif __SIZEOF_POINTER__ == 8
+#    define native_architecture() ARCHITECTURE_RISCV64
+#    define LIB_ARCH_TUPLE "riscv64-linux-gnu"
+#  elif __SIZEOF_POINTER__ == 16
+#    define native_architecture() ARCHITECTURE_RISCV128
+#    define LIB_ARCH_TUPLE "riscv128-linux-gnu"
+#  else
+#    error "Unrecognized riscv architecture variant"
+#  endif
 #else
 #  error "Please register your architecture here!"
 #endif
-- 
2.7.4



More information about the systemd-devel mailing list