From 08a4519714444e10d6f494b426805e265f981628 Mon Sep 17 00:00:00 2001
From: gnzlbg <gonzalobg88@gmail.com>
Date: Wed, 29 May 2019 13:05:49 +0200
Subject: [PATCH] Refactor fixed-width integer types into its own module

---
 src/cloudabi/mod.rs     |  9 ---------
 src/fixed_width_ints.rs | 12 ++++++++++++
 src/fuchsia/mod.rs      |  9 ---------
 src/hermit/mod.rs       |  9 ---------
 src/lib.rs              | 24 ++++++++++++++++++++++++
 src/sgx.rs              |  9 ---------
 src/switch.rs           |  9 ---------
 src/unix/mod.rs         |  9 ---------
 src/wasi.rs             |  8 --------
 src/windows/mod.rs      |  9 ---------
 10 files changed, 36 insertions(+), 71 deletions(-)
 create mode 100644 src/fixed_width_ints.rs

diff --git a/src/cloudabi/mod.rs b/src/cloudabi/mod.rs
index 81919675..0d869621 100644
--- a/src/cloudabi/mod.rs
+++ b/src/cloudabi/mod.rs
@@ -1,12 +1,3 @@
-pub type int8_t = i8;
-pub type int16_t = i16;
-pub type int32_t = i32;
-pub type int64_t = i64;
-pub type uint8_t = u8;
-pub type uint16_t = u16;
-pub type uint32_t = u32;
-pub type uint64_t = u64;
-
 pub type c_schar = i8;
 pub type c_uchar = u8;
 pub type c_short = i16;
diff --git a/src/fixed_width_ints.rs b/src/fixed_width_ints.rs
new file mode 100644
index 00000000..9b5a13c0
--- /dev/null
+++ b/src/fixed_width_ints.rs
@@ -0,0 +1,12 @@
+//! This module contains type aliases for C's fixed-width integer types .
+//!
+//! These aliases are deprecated: use the Rust types instead.
+
+pub type int8_t = i8;
+pub type int16_t = i16;
+pub type int32_t = i32;
+pub type int64_t = i64;
+pub type uint8_t = u8;
+pub type uint16_t = u16;
+pub type uint32_t = u32;
+pub type uint64_t = u64;
diff --git a/src/fuchsia/mod.rs b/src/fuchsia/mod.rs
index 2ce2f408..3f4fbafb 100644
--- a/src/fuchsia/mod.rs
+++ b/src/fuchsia/mod.rs
@@ -5,15 +5,6 @@
 
 // PUB_TYPE
 
-pub type int8_t = i8;
-pub type int16_t = i16;
-pub type int32_t = i32;
-pub type int64_t = i64;
-pub type uint8_t = u8;
-pub type uint16_t = u16;
-pub type uint32_t = u32;
-pub type uint64_t = u64;
-
 pub type c_schar = i8;
 pub type c_uchar = u8;
 pub type c_short = i16;
diff --git a/src/hermit/mod.rs b/src/hermit/mod.rs
index 3e15175a..9880b507 100644
--- a/src/hermit/mod.rs
+++ b/src/hermit/mod.rs
@@ -13,15 +13,6 @@
 // Ported by Colin Fink <colin.finck@rwth-aachen.de>
 //       and Stefan Lankes <slankes@eonerc.rwth-aachen.de>
 
-pub type int8_t = i8;
-pub type int16_t = i16;
-pub type int32_t = i32;
-pub type int64_t = i64;
-pub type uint8_t = u8;
-pub type uint16_t = u16;
-pub type uint32_t = u32;
-pub type uint64_t = u64;
-
 pub type c_schar = i8;
 pub type c_uchar = u8;
 pub type c_short = i16;
diff --git a/src/lib.rs b/src/lib.rs
index baf63243..2dc42702 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -90,27 +90,51 @@ cfg_if! {
 
 cfg_if! {
     if #[cfg(windows)] {
+        mod fixed_width_ints;
+        pub use fixed_width_ints::*;
+
         mod windows;
         pub use windows::*;
     } else if #[cfg(target_os = "cloudabi")] {
+        mod fixed_width_ints;
+        pub use fixed_width_ints::*;
+
         mod cloudabi;
         pub use cloudabi::*;
     } else if #[cfg(target_os = "fuchsia")] {
+        mod fixed_width_ints;
+        pub use fixed_width_ints::*;
+
         mod fuchsia;
         pub use fuchsia::*;
     } else if #[cfg(target_os = "switch")] {
+        mod fixed_width_ints;
+        pub use fixed_width_ints::*;
+
         mod switch;
         pub use switch::*;
     } else if #[cfg(unix)] {
+        mod fixed_width_ints;
+        pub use fixed_width_ints::*;
+
         mod unix;
         pub use unix::*;
     } else if #[cfg(target_os = "hermit")] {
+        mod fixed_width_ints;
+        pub use fixed_width_ints::*;
+
         mod hermit;
         pub use hermit::*;
     } else if #[cfg(all(target_env = "sgx", target_vendor = "fortanix"))] {
+        mod fixed_width_ints;
+        pub use fixed_width_ints::*;
+
         mod sgx;
         pub use sgx::*;
     } else if #[cfg(any(target_env = "wasi", target_os = "wasi"))] {
+        mod fixed_width_ints;
+        pub use fixed_width_ints::*;
+
         mod wasi;
         pub use wasi::*;
     } else {
diff --git a/src/sgx.rs b/src/sgx.rs
index 8a69ad36..7da62693 100644
--- a/src/sgx.rs
+++ b/src/sgx.rs
@@ -1,14 +1,5 @@
 //! SGX C types definition
 
-pub type int8_t = i8;
-pub type int16_t = i16;
-pub type int32_t = i32;
-pub type int64_t = i64;
-pub type uint8_t = u8;
-pub type uint16_t = u16;
-pub type uint32_t = u32;
-pub type uint64_t = u64;
-
 pub type c_schar = i8;
 pub type c_uchar = u8;
 pub type c_short = i16;
diff --git a/src/switch.rs b/src/switch.rs
index 06fa2030..801b8ed5 100644
--- a/src/switch.rs
+++ b/src/switch.rs
@@ -1,14 +1,5 @@
 //! Switch C type definitions
 
-pub type int8_t = i8;
-pub type int16_t = i16;
-pub type int32_t = i32;
-pub type int64_t = i64;
-pub type uint8_t = u8;
-pub type uint16_t = u16;
-pub type uint32_t = u32;
-pub type uint64_t = u64;
-
 pub type c_schar = i8;
 pub type c_uchar = u8;
 pub type c_short = i16;
diff --git a/src/unix/mod.rs b/src/unix/mod.rs
index afb81be3..efaad41e 100644
--- a/src/unix/mod.rs
+++ b/src/unix/mod.rs
@@ -3,15 +3,6 @@
 //! More functions and definitions can be found in the more specific modules
 //! according to the platform in question.
 
-pub type int8_t = i8;
-pub type int16_t = i16;
-pub type int32_t = i32;
-pub type int64_t = i64;
-pub type uint8_t = u8;
-pub type uint16_t = u16;
-pub type uint32_t = u32;
-pub type uint64_t = u64;
-
 pub type c_schar = i8;
 pub type c_uchar = u8;
 pub type c_short = i16;
diff --git a/src/wasi.rs b/src/wasi.rs
index b9348612..95a0837d 100644
--- a/src/wasi.rs
+++ b/src/wasi.rs
@@ -19,14 +19,6 @@ pub type intptr_t = isize;
 pub type uintptr_t = usize;
 pub type off_t = i64;
 pub type pid_t = i32;
-pub type int8_t = i8;
-pub type uint8_t = u8;
-pub type int16_t = i16;
-pub type uint16_t = u16;
-pub type int32_t = i32;
-pub type uint32_t = u32;
-pub type int64_t = i64;
-pub type uint64_t = u64;
 pub type clock_t = c_longlong;
 pub type time_t = c_longlong;
 pub type c_double = f64;
diff --git a/src/windows/mod.rs b/src/windows/mod.rs
index 70ca675b..be28b70f 100644
--- a/src/windows/mod.rs
+++ b/src/windows/mod.rs
@@ -1,14 +1,5 @@
 //! Windows CRT definitions
 
-pub type int8_t = i8;
-pub type int16_t = i16;
-pub type int32_t = i32;
-pub type int64_t = i64;
-pub type uint8_t = u8;
-pub type uint16_t = u16;
-pub type uint32_t = u32;
-pub type uint64_t = u64;
-
 pub type c_schar = i8;
 pub type c_uchar = u8;
 pub type c_short = i16;
-- 
GitLab