From bdfd01599e0f1962287a9b54b01d05cede3c304b Mon Sep 17 00:00:00 2001
From: Alistair Francis <alistair.francis@wdc.com>
Date: Thu, 1 Oct 2020 07:15:39 -0700
Subject: [PATCH] unix: riscv32: Move type defines inside confif

Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
---
 src/unix/linux_like/linux/gnu/b32/mod.rs      | 37 ++++++++++++++-----
 .../linux_like/linux/gnu/b32/riscv32/mod.rs   | 15 --------
 2 files changed, 27 insertions(+), 25 deletions(-)

diff --git a/src/unix/linux_like/linux/gnu/b32/mod.rs b/src/unix/linux_like/linux/gnu/b32/mod.rs
index 2ff3b359..28e9f7fe 100644
--- a/src/unix/linux_like/linux/gnu/b32/mod.rs
+++ b/src/unix/linux_like/linux/gnu/b32/mod.rs
@@ -5,22 +5,39 @@ use pthread_mutex_t;
 pub type c_long = i32;
 pub type c_ulong = u32;
 pub type clock_t = i32;
-pub type time_t = i32;
-pub type suseconds_t = i32;
-pub type ino_t = u32;
-pub type off_t = i32;
-pub type blkcnt_t = i32;
-
-pub type fsblkcnt_t = ::c_ulong;
-pub type fsfilcnt_t = ::c_ulong;
-pub type rlim_t = c_ulong;
+
 pub type shmatt_t = ::c_ulong;
 pub type msgqnum_t = ::c_ulong;
 pub type msglen_t = ::c_ulong;
-pub type blksize_t = i32;
 pub type nlink_t = u32;
 pub type __u64 = ::c_ulonglong;
 pub type __fsword_t = i32;
+pub type fsblkcnt64_t = u64;
+pub type fsfilcnt64_t = u64;
+
+cfg_if! {
+    if #[cfg(target_arch = "riscv32")] {
+        pub type time_t = i64;
+        pub type suseconds_t = i64;
+        pub type ino_t = u64;
+        pub type off_t = i64;
+        pub type blkcnt_t = i64;
+        pub type fsblkcnt_t = u64;
+        pub type fsfilcnt_t = u64;
+        pub type rlim_t = u64;
+        pub type blksize_t = i64;
+    } else {
+        pub type time_t = i32;
+        pub type suseconds_t = i32;
+        pub type ino_t = u32;
+        pub type off_t = i32;
+        pub type blkcnt_t = i32;
+        pub type fsblkcnt_t = ::c_ulong;
+        pub type fsfilcnt_t = ::c_ulong;
+        pub type rlim_t = c_ulong;
+        pub type blksize_t = i32;
+    }
+}
 
 s! {
     pub struct stat {
diff --git a/src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs b/src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs
index 1edca64a..0d54886e 100644
--- a/src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs
+++ b/src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs
@@ -1,23 +1,8 @@
 //! RISC-V-specific definitions for 32-bit linux-like values
 
 pub type c_char = u8;
-pub type c_ulong = u32;
 pub type wchar_t = ::c_int;
 
-pub type nlink_t = ::c_uint;
-pub type fsblkcnt64_t = u64;
-pub type fsfilcnt64_t = u64;
-pub type suseconds_t = i64;
-pub type time_t = i64;
-pub type fsfilcnt_t = u64;
-pub type fsblkcnt_t = u64;
-pub type blksize_t = i64;
-pub type blkcnt_t = i64;
-pub type rlim_t = u64;
-pub type off_t = i64;
-pub type ino_t = u64;
-pub type __u64 = ::c_ulonglong;
-
 s! {
     pub struct pthread_attr_t {
         __size: [::c_ulong; 7],
-- 
GitLab