Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[0.2] Remove more outdated configuration #4060

Merged
merged 6 commits into from
Nov 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 0 additions & 35 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,10 @@ const ALLOWED_CFGS: &'static [&'static str] = &[
"freebsd13",
"freebsd14",
"freebsd15",
"libc_cfg_target_vendor",
"libc_const_extern_fn",
"libc_const_extern_fn_unstable",
"libc_core_cvoid",
"libc_deny_warnings",
"libc_int128",
"libc_long_array",
"libc_non_exhaustive",
"libc_packedN",
"libc_ptr_addr_of",
"libc_thread_local",
"libc_underscore_const_names",
Expand Down Expand Up @@ -54,13 +49,6 @@ fn main() {
let libc_ci = env::var("LIBC_CI").is_ok();
let libc_check_cfg = env::var("LIBC_CHECK_CFG").is_ok() || rustc_minor_ver >= 80;

if env::var("CARGO_FEATURE_USE_STD").is_ok() {
println!(
"cargo:warning=\"libc's use_std cargo feature is deprecated since libc 0.2.55; \
please consider using the `std` cargo feature instead\""
);
}

// The ABI of libc used by std is backward compatible with FreeBSD 12.
// The ABI of libc from crates.io is backward compatible with FreeBSD 11.
//
Expand Down Expand Up @@ -94,29 +82,6 @@ fn main() {
set_cfg("libc_deny_warnings");
}

// Rust >= 1.26 supports i128 and u128:
if rustc_minor_ver >= 26 || rustc_dep_of_std {
set_cfg("libc_int128");
}

// Rust >= 1.30 supports `core::ffi::c_void`, so libc can just re-export it.
// Otherwise, it defines an incompatible type to retaining
// backwards-compatibility.
if rustc_minor_ver >= 30 || rustc_dep_of_std {
set_cfg("libc_core_cvoid");
}

// Rust >= 1.33 supports repr(packed(N)) and cfg(target_vendor).
if rustc_minor_ver >= 33 || rustc_dep_of_std {
set_cfg("libc_packedN");
set_cfg("libc_cfg_target_vendor");
}

// Rust >= 1.40 supports #[non_exhaustive].
if rustc_minor_ver >= 40 || rustc_dep_of_std {
set_cfg("libc_non_exhaustive");
}

// Rust >= 1.47 supports long array:
if rustc_minor_ver >= 47 || rustc_dep_of_std {
set_cfg("libc_long_array");
Expand Down
12 changes: 11 additions & 1 deletion libc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ fn do_ctest() {

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

// FIXME: "'__uint128' undeclared" in C
"__uint128" => true,

_ => false,
}
});
Expand Down Expand Up @@ -1858,6 +1861,10 @@ fn test_android(target: &str) {
// These are intended to be opaque
"posix_spawn_file_actions_t" => true,
"posix_spawnattr_t" => true,

// FIXME: "'__uint128' undeclared" in C
"__uint128" => true,

_ => false,
}
});
Expand Down Expand Up @@ -3702,6 +3709,9 @@ fn test_linux(target: &str) {
"priority_t" if musl => true,
"name_t" if musl => true,

// FIXME: "'__uint128' undeclared" in C
"__uint128" => true,

t => {
if musl {
// LFS64 types have been removed in musl 1.2.4+
Expand Down
2 changes: 1 addition & 1 deletion src/fixed_width_ints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub type uint32_t = u32;
pub type uint64_t = u64;

cfg_if! {
if #[cfg(all(libc_int128, target_arch = "aarch64", not(target_os = "windows")))] {
if #[cfg(all(target_arch = "aarch64", not(target_os = "windows")))] {
// This introduces partial support for FFI with __int128 and
// equivalent types on platforms where Rust's definition is validated
// to match the standard C ABI of that platform.
Expand Down
22 changes: 2 additions & 20 deletions src/fuchsia/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
//! More functions and definitions can be found in the more specific modules
//! according to the platform in question.

use c_void;

// PUB_TYPE

pub type c_schar = i8;
Expand Down Expand Up @@ -4490,23 +4492,3 @@ cfg_if! {
// Unknown target_arch
}
}

cfg_if! {
if #[cfg(libc_core_cvoid)] {
pub use ::ffi::c_void;
} else {
// Use repr(u8) as LLVM expects `void*` to be the same as `i8*` to help
// enable more optimization opportunities around it recognizing things
// like malloc/free.
#[repr(u8)]
#[allow(missing_copy_implementations)]
#[allow(missing_debug_implementations)]
pub enum c_void {
// Two dummy variants so the #[repr] attribute can be used.
#[doc(hidden)]
__variant1,
#[doc(hidden)]
__variant2,
}
}
}
4 changes: 2 additions & 2 deletions src/hermit.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
//! Hermit C type definitions

use c_void;

cfg_if! {
if #[cfg(any(target_arch = "aarch64", target_arch = "riscv64"))] {
pub type c_char = u8;
Expand Down Expand Up @@ -576,5 +578,3 @@ extern "C" {
#[link_name = "sys_poll"]
pub fn poll(fds: *mut pollfd, nfds: nfds_t, timeout: i32) -> i32;
}

pub use ffi::c_void;
5 changes: 2 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@ cfg_if! {
#[doc(hidden)]
#[allow(unused_imports)]
use core::clone::Clone;
#[cfg(libc_core_cvoid)]
#[allow(unused_imports)]
use core::ffi;
#[allow(unused_imports)]
use core::fmt;
#[allow(unused_imports)]
Expand All @@ -64,6 +61,8 @@ use core::num;
#[allow(unused_imports)]
use core::option::Option;

pub use core::ffi::c_void;

cfg_if! {
if #[cfg(windows)] {
mod fixed_width_ints;
Expand Down
22 changes: 2 additions & 20 deletions src/psp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
//! by the linker. Crates that use these definitions must, somewhere in the
//! crate graph, include a stub provider crate such as the `psp` crate.
use c_void;

pub type c_schar = i8;
pub type c_uchar = u8;
pub type c_short = i16;
Expand All @@ -27,26 +29,6 @@ pub type c_char = u8;
pub type c_long = i64;
pub type c_ulong = u64;

cfg_if! {
if #[cfg(libc_core_cvoid)] {
pub use ::ffi::c_void;
} else {
// Use repr(u8) as LLVM expects `void*` to be the same as `i8*` to help
// enable more optimization opportunities around it recognizing things
// like malloc/free.
#[repr(u8)]
#[allow(missing_copy_implementations)]
#[allow(missing_debug_implementations)]
pub enum c_void {
// Two dummy variants so the #[repr] attribute can be used.
#[doc(hidden)]
__variant1,
#[doc(hidden)]
__variant2,
}
}
}

pub type SceKernelVTimerHandler = unsafe extern "C" fn(
uid: SceUid,
arg1: *mut SceKernelSysClock,
Expand Down
20 changes: 0 additions & 20 deletions src/sgx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,3 @@ pub type c_ulong = u64;

pub const INT_MIN: c_int = -2147483648;
pub const INT_MAX: c_int = 2147483647;

cfg_if! {
if #[cfg(libc_core_cvoid)] {
pub use ::ffi::c_void;
} else {
// Use repr(u8) as LLVM expects `void*` to be the same as `i8*` to help
// enable more optimization opportunities around it recognizing things
// like malloc/free.
#[repr(u8)]
#[allow(missing_copy_implementations)]
#[allow(missing_debug_implementations)]
pub enum c_void {
// Two dummy variants so the #[repr] attribute can be used.
#[doc(hidden)]
__variant1,
#[doc(hidden)]
__variant2,
}
}
}
22 changes: 2 additions & 20 deletions src/solid/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
//!
//! [SOLID]: https://solid.kmckk.com/
use c_void;

pub type c_schar = i8;
pub type c_uchar = u8;
pub type c_short = i16;
Expand Down Expand Up @@ -871,26 +873,6 @@ extern "C" {
pub fn lseek(arg1: c_int, arg2: __off_t, arg3: c_int) -> __off_t;
}

cfg_if! {
if #[cfg(libc_core_cvoid)] {
pub use ::ffi::c_void;
} else {
// Use repr(u8) as LLVM expects `void*` to be the same as `i8*` to help
// enable more optimization opportunities around it recognizing things
// like malloc/free.
#[repr(u8)]
#[allow(missing_copy_implementations)]
#[allow(missing_debug_implementations)]
pub enum c_void {
// Two dummy variants so the #[repr] attribute can be used.
#[doc(hidden)]
__variant1,
#[doc(hidden)]
__variant2,
}
}
}

cfg_if! {
if #[cfg(target_arch = "aarch64")] {
mod aarch64;
Expand Down
20 changes: 0 additions & 20 deletions src/switch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,3 @@ pub type wchar_t = u32;

pub const INT_MIN: c_int = -2147483648;
pub const INT_MAX: c_int = 2147483647;

cfg_if! {
if #[cfg(libc_core_cvoid)] {
pub use ::ffi::c_void;
} else {
// Use repr(u8) as LLVM expects `void*` to be the same as `i8*` to help
// enable more optimization opportunities around it recognizing things
// like malloc/free.
#[repr(u8)]
#[allow(missing_copy_implementations)]
#[allow(missing_debug_implementations)]
pub enum c_void {
// Two dummy variants so the #[repr] attribute can be used.
#[doc(hidden)]
__variant1,
#[doc(hidden)]
__variant2,
}
}
}
8 changes: 0 additions & 8 deletions src/unix/bsd/apple/b64/aarch64/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,8 @@ s! {
pub __pad: u32,
}

// This type natively uses a uint128, but for a while we hacked
// it in with repr(align) and `[u64; 2]`. uint128 isn't available
// all the way back to our earliest supported versions so we
// preserver the old shim.
#[cfg_attr(not(libc_int128), repr(align(16)))]
pub struct __darwin_arm_neon_state64 {
#[cfg(libc_int128)]
pub __v: [::__uint128_t; 32],
#[cfg(not(libc_int128))]
pub __v: [[u64; 2]; 32],
pub __fpsr: u32,
pub __fpcr: u32,
}
Expand Down
Loading