From: André Zwing nerv@dawncrow.de
--- tools/tools.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/tools/tools.h b/tools/tools.h index 5372b5bd303..38c6ac1a267 100644 --- a/tools/tools.h +++ b/tools/tools.h @@ -65,7 +65,7 @@ extern char **environ; # define O_BINARY 0 # endif # ifndef __int64 -# if defined(__x86_64__) || defined(__aarch64__) || defined(__powerpc64__) +# if defined(__x86_64__) || defined(__aarch64__) || defined(__powerpc64__) || defined(__riscv64__) # define __int64 long # else # define __int64 long long @@ -90,7 +90,7 @@ extern char **environ;
struct target { - enum { CPU_i386, CPU_x86_64, CPU_ARM, CPU_ARM64, CPU_ARM64EC } cpu; + enum { CPU_i386, CPU_x86_64, CPU_ARM, CPU_ARM64, CPU_ARM64EC, CPU_RISCV64 } cpu;
enum { @@ -447,6 +447,8 @@ static inline struct target get_default_target(void) target.cpu = CPU_ARM; #elif defined(__aarch64__) target.cpu = CPU_ARM64; +#elif defined(__riscv64__) + target.cpu = CPU_RISCV64; #else #error Unsupported CPU #endif @@ -482,6 +484,7 @@ static inline unsigned int get_target_ptr_size( struct target target ) [CPU_ARM] = 4, [CPU_ARM64] = 8, [CPU_ARM64EC] = 8, + [CPU_RISCV64] = 8, }; return sizes[target.cpu]; } @@ -504,6 +507,9 @@ static inline void set_target_ptr_size( struct target *target, unsigned int size case CPU_ARM64EC: if (size == 4) target->cpu = CPU_ARM; break; + case CPU_RISCV64: + /* not necessary */ + break; } }
@@ -527,6 +533,7 @@ static inline int get_cpu_from_name( const char *name ) { "arm64ec", CPU_ARM64EC }, { "arm64", CPU_ARM64 }, { "arm", CPU_ARM }, + { "riscv64", CPU_RISCV64 }, }; unsigned int i;
@@ -574,6 +581,7 @@ static inline const char *get_arch_dir( struct target target ) [CPU_ARM] = "arm", [CPU_ARM64] = "aarch64", [CPU_ARM64EC] = "arm64ec", + [CPU_RISCV64] = "riscv64", };
if (!cpu_names[target.cpu]) return "";