Skip to content

Commit 627fc05

Browse files
committed
Re-export c perimitive types from core::ffi instead of defining them
1 parent c6a3cd6 commit 627fc05

File tree

1 file changed

+71
-64
lines changed

1 file changed

+71
-64
lines changed

src/primitives.rs

Lines changed: 71 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -6,70 +6,70 @@
66
//!
77
//! The fixed-width integer aliases are deprecated: use the Rust types instead.
88
9-
pub type c_schar = i8;
10-
pub type c_uchar = u8;
11-
pub type c_short = i16;
12-
pub type c_ushort = u16;
13-
14-
pub type c_longlong = i64;
15-
pub type c_ulonglong = u64;
16-
17-
pub type c_float = f32;
18-
pub type c_double = f64;
19-
20-
cfg_if! {
21-
if #[cfg(all(
22-
not(windows),
23-
// FIXME(ctest): just use `target_vendor` = "apple"` once `ctest` supports it
24-
not(any(
25-
target_os = "macos",
26-
target_os = "ios",
27-
target_os = "tvos",
28-
target_os = "watchos",
29-
target_os = "visionos",
30-
)),
31-
not(target_os = "vita"),
32-
any(
33-
target_arch = "aarch64",
34-
target_arch = "arm",
35-
target_arch = "csky",
36-
target_arch = "hexagon",
37-
target_arch = "msp430",
38-
target_arch = "powerpc",
39-
target_arch = "powerpc64",
40-
target_arch = "riscv32",
41-
target_arch = "riscv64",
42-
target_arch = "s390x",
43-
target_arch = "xtensa",
44-
)
45-
))] {
46-
pub type c_char = u8;
47-
} else {
48-
// On every other target, c_char is signed.
49-
pub type c_char = i8;
50-
}
51-
}
52-
53-
cfg_if! {
54-
if #[cfg(any(target_arch = "avr", target_arch = "msp430"))] {
55-
pub type c_int = i16;
56-
pub type c_uint = u16;
57-
} else {
58-
pub type c_int = i32;
59-
pub type c_uint = u32;
60-
}
61-
}
62-
63-
cfg_if! {
64-
if #[cfg(all(target_pointer_width = "64", not(windows)))] {
65-
pub type c_long = i64;
66-
pub type c_ulong = u64;
67-
} else {
68-
// The minimal size of `long` in the C standard is 32 bits
69-
pub type c_long = i32;
70-
pub type c_ulong = u32;
71-
}
72-
}
9+
// pub type c_schar = i8;
10+
// pub type c_uchar = u8;
11+
// pub type c_short = i16;
12+
// pub type c_ushort = u16;
13+
//
14+
// pub type c_longlong = i64;
15+
// pub type c_ulonglong = u64;
16+
//
17+
// pub type c_float = f32;
18+
// pub type c_double = f64;
19+
//
20+
// cfg_if! {
21+
// if #[cfg(all(
22+
// not(windows),
23+
// // FIXME(ctest): just use `target_vendor` = "apple"` once `ctest` supports it
24+
// not(any(
25+
// target_os = "macos",
26+
// target_os = "ios",
27+
// target_os = "tvos",
28+
// target_os = "watchos",
29+
// target_os = "visionos",
30+
// )),
31+
// not(target_os = "vita"),
32+
// any(
33+
// target_arch = "aarch64",
34+
// target_arch = "arm",
35+
// target_arch = "csky",
36+
// target_arch = "hexagon",
37+
// target_arch = "msp430",
38+
// target_arch = "powerpc",
39+
// target_arch = "powerpc64",
40+
// target_arch = "riscv32",
41+
// target_arch = "riscv64",
42+
// target_arch = "s390x",
43+
// target_arch = "xtensa",
44+
// )
45+
// ))] {
46+
// pub type c_char = u8;
47+
// } else {
48+
// // On every other target, c_char is signed.
49+
// pub type c_char = i8;
50+
// }
51+
// }
52+
//
53+
// cfg_if! {
54+
// if #[cfg(any(target_arch = "avr", target_arch = "msp430"))] {
55+
// pub type c_int = i16;
56+
// pub type c_uint = u16;
57+
// } else {
58+
// pub type c_int = i32;
59+
// pub type c_uint = u32;
60+
// }
61+
// }
62+
//
63+
// cfg_if! {
64+
// if #[cfg(all(target_pointer_width = "64", not(windows)))] {
65+
// pub type c_long = i64;
66+
// pub type c_ulong = u64;
67+
// } else {
68+
// // The minimal size of `long` in the C standard is 32 bits
69+
// pub type c_long = i32;
70+
// pub type c_ulong = u32;
71+
// }
72+
// }
7373

7474
#[deprecated(since = "0.2.55", note = "Use i8 instead.")]
7575
pub type int8_t = i8;
@@ -186,3 +186,10 @@ cfg_if! {
186186
pub type __uint128_t = u128;
187187
}
188188
}
189+
190+
// Re-export rust core::ffi c perimitive types
191+
#[allow(unused_imports)]
192+
pub use core::ffi::{
193+
c_char, c_double, c_float, c_int, c_long, c_longlong, c_schar, c_short, c_uchar, c_uint,
194+
c_ulong, c_ulonglong, c_ushort,
195+
};

0 commit comments

Comments
 (0)