Skip to content

Commit de29a3f

Browse files
authored
Merge pull request #4060 from tgross35/remove-more-cfg
[0.2] Remove more outdated configuration
2 parents 3807bd3 + d00d1de commit de29a3f

File tree

28 files changed

+79
-372
lines changed

28 files changed

+79
-372
lines changed

build.rs

-35
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,10 @@ const ALLOWED_CFGS: &'static [&'static str] = &[
1414
"freebsd13",
1515
"freebsd14",
1616
"freebsd15",
17-
"libc_cfg_target_vendor",
1817
"libc_const_extern_fn",
1918
"libc_const_extern_fn_unstable",
20-
"libc_core_cvoid",
2119
"libc_deny_warnings",
22-
"libc_int128",
2320
"libc_long_array",
24-
"libc_non_exhaustive",
25-
"libc_packedN",
2621
"libc_ptr_addr_of",
2722
"libc_thread_local",
2823
"libc_underscore_const_names",
@@ -54,13 +49,6 @@ fn main() {
5449
let libc_ci = env::var("LIBC_CI").is_ok();
5550
let libc_check_cfg = env::var("LIBC_CHECK_CFG").is_ok() || rustc_minor_ver >= 80;
5651

57-
if env::var("CARGO_FEATURE_USE_STD").is_ok() {
58-
println!(
59-
"cargo:warning=\"libc's use_std cargo feature is deprecated since libc 0.2.55; \
60-
please consider using the `std` cargo feature instead\""
61-
);
62-
}
63-
6452
// The ABI of libc used by std is backward compatible with FreeBSD 12.
6553
// The ABI of libc from crates.io is backward compatible with FreeBSD 11.
6654
//
@@ -94,29 +82,6 @@ fn main() {
9482
set_cfg("libc_deny_warnings");
9583
}
9684

97-
// Rust >= 1.26 supports i128 and u128:
98-
if rustc_minor_ver >= 26 || rustc_dep_of_std {
99-
set_cfg("libc_int128");
100-
}
101-
102-
// Rust >= 1.30 supports `core::ffi::c_void`, so libc can just re-export it.
103-
// Otherwise, it defines an incompatible type to retaining
104-
// backwards-compatibility.
105-
if rustc_minor_ver >= 30 || rustc_dep_of_std {
106-
set_cfg("libc_core_cvoid");
107-
}
108-
109-
// Rust >= 1.33 supports repr(packed(N)) and cfg(target_vendor).
110-
if rustc_minor_ver >= 33 || rustc_dep_of_std {
111-
set_cfg("libc_packedN");
112-
set_cfg("libc_cfg_target_vendor");
113-
}
114-
115-
// Rust >= 1.40 supports #[non_exhaustive].
116-
if rustc_minor_ver >= 40 || rustc_dep_of_std {
117-
set_cfg("libc_non_exhaustive");
118-
}
119-
12085
// Rust >= 1.47 supports long array:
12186
if rustc_minor_ver >= 47 || rustc_dep_of_std {
12287
set_cfg("libc_long_array");

libc-test/build.rs

+11-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ fn do_ctest() {
6767

6868
fn ctest_cfg() -> ctest::TestGenerator {
6969
let mut cfg = ctest::TestGenerator::new();
70-
let libc_cfgs = ["libc_core_cvoid", "libc_packedN", "libc_thread_local"];
70+
let libc_cfgs = ["libc_thread_local"];
7171
for f in &libc_cfgs {
7272
cfg.cfg(f, None);
7373
}
@@ -327,6 +327,9 @@ fn test_apple(target: &str) {
327327
// FIXME: Requires the macOS 14.4 SDK.
328328
"os_sync_wake_by_address_flags_t" | "os_sync_wait_on_address_flags_t" => true,
329329

330+
// FIXME: "'__uint128' undeclared" in C
331+
"__uint128" => true,
332+
330333
_ => false,
331334
}
332335
});
@@ -1858,6 +1861,10 @@ fn test_android(target: &str) {
18581861
// These are intended to be opaque
18591862
"posix_spawn_file_actions_t" => true,
18601863
"posix_spawnattr_t" => true,
1864+
1865+
// FIXME: "'__uint128' undeclared" in C
1866+
"__uint128" => true,
1867+
18611868
_ => false,
18621869
}
18631870
});
@@ -3702,6 +3709,9 @@ fn test_linux(target: &str) {
37023709
"priority_t" if musl => true,
37033710
"name_t" if musl => true,
37043711

3712+
// FIXME: "'__uint128' undeclared" in C
3713+
"__uint128" => true,
3714+
37053715
t => {
37063716
if musl {
37073717
// LFS64 types have been removed in musl 1.2.4+

src/fixed_width_ints.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ pub type uint32_t = u32;
2020
pub type uint64_t = u64;
2121

2222
cfg_if! {
23-
if #[cfg(all(libc_int128, target_arch = "aarch64", not(target_os = "windows")))] {
23+
if #[cfg(all(target_arch = "aarch64", not(target_os = "windows")))] {
2424
// This introduces partial support for FFI with __int128 and
2525
// equivalent types on platforms where Rust's definition is validated
2626
// to match the standard C ABI of that platform.

src/fuchsia/mod.rs

+2-20
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
//! More functions and definitions can be found in the more specific modules
44
//! according to the platform in question.
55
6+
use c_void;
7+
68
// PUB_TYPE
79

810
pub type c_schar = i8;
@@ -4490,23 +4492,3 @@ cfg_if! {
44904492
// Unknown target_arch
44914493
}
44924494
}
4493-
4494-
cfg_if! {
4495-
if #[cfg(libc_core_cvoid)] {
4496-
pub use ::ffi::c_void;
4497-
} else {
4498-
// Use repr(u8) as LLVM expects `void*` to be the same as `i8*` to help
4499-
// enable more optimization opportunities around it recognizing things
4500-
// like malloc/free.
4501-
#[repr(u8)]
4502-
#[allow(missing_copy_implementations)]
4503-
#[allow(missing_debug_implementations)]
4504-
pub enum c_void {
4505-
// Two dummy variants so the #[repr] attribute can be used.
4506-
#[doc(hidden)]
4507-
__variant1,
4508-
#[doc(hidden)]
4509-
__variant2,
4510-
}
4511-
}
4512-
}

src/hermit.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
//! Hermit C type definitions
22
3+
use c_void;
4+
35
cfg_if! {
46
if #[cfg(any(target_arch = "aarch64", target_arch = "riscv64"))] {
57
pub type c_char = u8;
@@ -576,5 +578,3 @@ extern "C" {
576578
#[link_name = "sys_poll"]
577579
pub fn poll(fds: *mut pollfd, nfds: nfds_t, timeout: i32) -> i32;
578580
}
579-
580-
pub use ffi::c_void;

src/lib.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,6 @@ cfg_if! {
4646
#[doc(hidden)]
4747
#[allow(unused_imports)]
4848
use core::clone::Clone;
49-
#[cfg(libc_core_cvoid)]
50-
#[allow(unused_imports)]
51-
use core::ffi;
5249
#[allow(unused_imports)]
5350
use core::fmt;
5451
#[allow(unused_imports)]
@@ -64,6 +61,8 @@ use core::num;
6461
#[allow(unused_imports)]
6562
use core::option::Option;
6663

64+
pub use core::ffi::c_void;
65+
6766
cfg_if! {
6867
if #[cfg(windows)] {
6968
mod fixed_width_ints;

src/psp.rs

+2-20
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
//! by the linker. Crates that use these definitions must, somewhere in the
55
//! crate graph, include a stub provider crate such as the `psp` crate.
66
7+
use c_void;
8+
79
pub type c_schar = i8;
810
pub type c_uchar = u8;
911
pub type c_short = i16;
@@ -27,26 +29,6 @@ pub type c_char = u8;
2729
pub type c_long = i64;
2830
pub type c_ulong = u64;
2931

30-
cfg_if! {
31-
if #[cfg(libc_core_cvoid)] {
32-
pub use ::ffi::c_void;
33-
} else {
34-
// Use repr(u8) as LLVM expects `void*` to be the same as `i8*` to help
35-
// enable more optimization opportunities around it recognizing things
36-
// like malloc/free.
37-
#[repr(u8)]
38-
#[allow(missing_copy_implementations)]
39-
#[allow(missing_debug_implementations)]
40-
pub enum c_void {
41-
// Two dummy variants so the #[repr] attribute can be used.
42-
#[doc(hidden)]
43-
__variant1,
44-
#[doc(hidden)]
45-
__variant2,
46-
}
47-
}
48-
}
49-
5032
pub type SceKernelVTimerHandler = unsafe extern "C" fn(
5133
uid: SceUid,
5234
arg1: *mut SceKernelSysClock,

src/sgx.rs

-20
Original file line numberDiff line numberDiff line change
@@ -25,23 +25,3 @@ pub type c_ulong = u64;
2525

2626
pub const INT_MIN: c_int = -2147483648;
2727
pub const INT_MAX: c_int = 2147483647;
28-
29-
cfg_if! {
30-
if #[cfg(libc_core_cvoid)] {
31-
pub use ::ffi::c_void;
32-
} else {
33-
// Use repr(u8) as LLVM expects `void*` to be the same as `i8*` to help
34-
// enable more optimization opportunities around it recognizing things
35-
// like malloc/free.
36-
#[repr(u8)]
37-
#[allow(missing_copy_implementations)]
38-
#[allow(missing_debug_implementations)]
39-
pub enum c_void {
40-
// Two dummy variants so the #[repr] attribute can be used.
41-
#[doc(hidden)]
42-
__variant1,
43-
#[doc(hidden)]
44-
__variant2,
45-
}
46-
}
47-
}

src/solid/mod.rs

+2-20
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
//!
33
//! [SOLID]: https://solid.kmckk.com/
44
5+
use c_void;
6+
57
pub type c_schar = i8;
68
pub type c_uchar = u8;
79
pub type c_short = i16;
@@ -871,26 +873,6 @@ extern "C" {
871873
pub fn lseek(arg1: c_int, arg2: __off_t, arg3: c_int) -> __off_t;
872874
}
873875

874-
cfg_if! {
875-
if #[cfg(libc_core_cvoid)] {
876-
pub use ::ffi::c_void;
877-
} else {
878-
// Use repr(u8) as LLVM expects `void*` to be the same as `i8*` to help
879-
// enable more optimization opportunities around it recognizing things
880-
// like malloc/free.
881-
#[repr(u8)]
882-
#[allow(missing_copy_implementations)]
883-
#[allow(missing_debug_implementations)]
884-
pub enum c_void {
885-
// Two dummy variants so the #[repr] attribute can be used.
886-
#[doc(hidden)]
887-
__variant1,
888-
#[doc(hidden)]
889-
__variant2,
890-
}
891-
}
892-
}
893-
894876
cfg_if! {
895877
if #[cfg(target_arch = "aarch64")] {
896878
mod aarch64;

src/switch.rs

-20
Original file line numberDiff line numberDiff line change
@@ -27,23 +27,3 @@ pub type wchar_t = u32;
2727

2828
pub const INT_MIN: c_int = -2147483648;
2929
pub const INT_MAX: c_int = 2147483647;
30-
31-
cfg_if! {
32-
if #[cfg(libc_core_cvoid)] {
33-
pub use ::ffi::c_void;
34-
} else {
35-
// Use repr(u8) as LLVM expects `void*` to be the same as `i8*` to help
36-
// enable more optimization opportunities around it recognizing things
37-
// like malloc/free.
38-
#[repr(u8)]
39-
#[allow(missing_copy_implementations)]
40-
#[allow(missing_debug_implementations)]
41-
pub enum c_void {
42-
// Two dummy variants so the #[repr] attribute can be used.
43-
#[doc(hidden)]
44-
__variant1,
45-
#[doc(hidden)]
46-
__variant2,
47-
}
48-
}
49-
}

src/unix/bsd/apple/b64/aarch64/mod.rs

-8
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,8 @@ s! {
3737
pub __pad: u32,
3838
}
3939

40-
// This type natively uses a uint128, but for a while we hacked
41-
// it in with repr(align) and `[u64; 2]`. uint128 isn't available
42-
// all the way back to our earliest supported versions so we
43-
// preserver the old shim.
44-
#[cfg_attr(not(libc_int128), repr(align(16)))]
4540
pub struct __darwin_arm_neon_state64 {
46-
#[cfg(libc_int128)]
4741
pub __v: [::__uint128_t; 32],
48-
#[cfg(not(libc_int128))]
49-
pub __v: [[u64; 2]; 32],
5042
pub __fpsr: u32,
5143
pub __fpcr: u32,
5244
}

0 commit comments

Comments
 (0)