Skip to content

Commit fead383

Browse files
committed
Replace arch-conditional c_char with a reexport
For any platforms that have `c_char` within a `cfg_if` block, ensure they match the top-level `arch` definitions and reexport that to clean up code.
1 parent c33744e commit fead383

File tree

5 files changed

+5
-42
lines changed

5 files changed

+5
-42
lines changed

src/hermit.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,8 @@
11
//! Hermit C type definitions
22
3+
pub use crate::arch::c_char_def as c_char;
34
use crate::prelude::*;
45

5-
cfg_if! {
6-
if #[cfg(any(target_arch = "aarch64", target_arch = "riscv64"))] {
7-
pub type c_char = u8;
8-
} else {
9-
pub type c_char = i8;
10-
}
11-
}
12-
136
pub type c_schar = i8;
147
pub type c_uchar = u8;
158
pub type c_short = i16;

src/trusty.rs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,10 @@
1+
pub use crate::arch::c_char_def as c_char;
12
use crate::prelude::*;
2-
33
pub type size_t = usize;
44
pub type ssize_t = isize;
55

66
pub type off_t = i64;
77

8-
cfg_if! {
9-
if #[cfg(any(target_arch = "aarch64", target_arch = "arm"))] {
10-
pub type c_char = u8;
11-
} else if #[cfg(target_arch = "x86_64")] {
12-
pub type c_char = i8;
13-
}
14-
}
15-
168
pub type c_schar = i8;
179
pub type c_uchar = u8;
1810
pub type c_short = i16;

src/unix/nuttx/mod.rs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,11 @@
1+
pub use crate::arch::c_char_def as c_char;
12
use crate::prelude::*;
23
use crate::{in6_addr, in_addr_t, timespec, DIR};
34

45
pub type nlink_t = u16;
56
pub type ino_t = u16;
67
pub type blkcnt_t = u64;
78
pub type blksize_t = i16;
8-
cfg_if! {
9-
if #[cfg(any(
10-
target_arch = "arm",
11-
target_arch = "riscv32",
12-
target_arch = "riscv64",
13-
))] {
14-
pub type c_char = u8;
15-
} else {
16-
pub type c_char = i8;
17-
}
18-
}
199
pub type c_long = isize;
2010
pub type c_ulong = usize;
2111
pub type cc_t = u8;

src/unix/redox/mod.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
1+
pub use crate::arch::c_char_def as c_char;
12
use crate::prelude::*;
23

3-
cfg_if! {
4-
if #[cfg(target_arch = "aarch64")] {
5-
pub type c_char = u8;
6-
} else {
7-
pub type c_char = i8;
8-
}
9-
}
104
pub type wchar_t = i32;
115

126
cfg_if! {

src/unix/solarish/mod.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
11
use core::mem::size_of;
22

3+
pub use crate::arch::c_char_def as c_char;
34
use crate::prelude::*;
45

5-
cfg_if! {
6-
if #[cfg(target_arch = "aarch64")] {
7-
pub type c_char = u8;
8-
} else {
9-
pub type c_char = i8;
10-
}
11-
}
126
pub type c_long = i64;
137
pub type c_ulong = u64;
148
pub type caddr_t = *mut c_char;

0 commit comments

Comments
 (0)