Skip to content

Commit

Permalink
Require rust >= 1.24 and drop libc_const_size_of conditional
Browse files Browse the repository at this point in the history
[ resolve conflicts and remove a couple newer `cfg`s - Trevor ]
  • Loading branch information
joshtriplett authored and tgross35 committed Nov 16, 2024
1 parent b9e4d80 commit 5a43dd2
Show file tree
Hide file tree
Showing 26 changed files with 74 additions and 306 deletions.
6 changes: 0 additions & 6 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ const ALLOWED_CFGS: &'static [&'static str] = &[
"libc_cfg_target_vendor",
"libc_const_extern_fn",
"libc_const_extern_fn_unstable",
"libc_const_size_of",
"libc_core_cvoid",
"libc_deny_warnings",
"libc_int128",
Expand Down Expand Up @@ -97,11 +96,6 @@ fn main() {
set_cfg("libc_deny_warnings");
}

// Rust >= 1.24 supports const mem::size_of:
if rustc_minor_ver >= 24 || rustc_dep_of_std {
set_cfg("libc_const_size_of");
}

// Rust >= 1.25 supports repr(align):
if rustc_minor_ver >= 25 || rustc_dep_of_std || align_cargo_feature {
set_cfg("libc_align");
Expand Down
1 change: 0 additions & 1 deletion libc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ fn do_ctest() {
fn ctest_cfg() -> ctest::TestGenerator {
let mut cfg = ctest::TestGenerator::new();
let libc_cfgs = [
"libc_const_size_of",
"libc_align",
"libc_core_cvoid",
"libc_packedN",
Expand Down
102 changes: 39 additions & 63 deletions src/unix/bsd/apple/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5484,76 +5484,52 @@ cfg_if! {
const __DARWIN_ALIGNBYTES32: usize = ::mem::size_of::<u32>() - 1;
p + __DARWIN_ALIGNBYTES32 & !__DARWIN_ALIGNBYTES32
}
} else if #[cfg(libc_const_size_of)] {
fn __DARWIN_ALIGN32(p: usize) -> usize {
const __DARWIN_ALIGNBYTES32: usize = ::mem::size_of::<u32>() - 1;
p + __DARWIN_ALIGNBYTES32 & !__DARWIN_ALIGNBYTES32
}
} else {
fn __DARWIN_ALIGN32(p: usize) -> usize {
let __DARWIN_ALIGNBYTES32: usize = ::mem::size_of::<u32>() - 1;
const __DARWIN_ALIGNBYTES32: usize = ::mem::size_of::<u32>() - 1;
p + __DARWIN_ALIGNBYTES32 & !__DARWIN_ALIGNBYTES32
}
}
}

cfg_if! {
if #[cfg(libc_const_size_of)] {
pub const THREAD_EXTENDED_POLICY_COUNT: mach_msg_type_number_t =
(::mem::size_of::<thread_extended_policy_data_t>() / ::mem::size_of::<integer_t>())
as mach_msg_type_number_t;
pub const THREAD_TIME_CONSTRAINT_POLICY_COUNT: mach_msg_type_number_t =
(::mem::size_of::<thread_time_constraint_policy_data_t>() /
::mem::size_of::<integer_t>()) as mach_msg_type_number_t;
pub const THREAD_PRECEDENCE_POLICY_COUNT: mach_msg_type_number_t =
(::mem::size_of::<thread_precedence_policy_data_t>() / ::mem::size_of::<integer_t>())
as mach_msg_type_number_t;
pub const THREAD_AFFINITY_POLICY_COUNT: mach_msg_type_number_t =
(::mem::size_of::<thread_affinity_policy_data_t>() / ::mem::size_of::<integer_t>())
as mach_msg_type_number_t;
pub const THREAD_BACKGROUND_POLICY_COUNT: mach_msg_type_number_t =
(::mem::size_of::<thread_background_policy_data_t>() / ::mem::size_of::<integer_t>())
as mach_msg_type_number_t;
pub const THREAD_LATENCY_QOS_POLICY_COUNT: mach_msg_type_number_t =
(::mem::size_of::<thread_latency_qos_policy_data_t>() / ::mem::size_of::<integer_t>())
as mach_msg_type_number_t;
pub const THREAD_THROUGHPUT_QOS_POLICY_COUNT: mach_msg_type_number_t =
(::mem::size_of::<thread_throughput_qos_policy_data_t>() /
::mem::size_of::<integer_t>()) as mach_msg_type_number_t;
pub const THREAD_BASIC_INFO_COUNT: mach_msg_type_number_t =
(::mem::size_of::<thread_basic_info_data_t>() / ::mem::size_of::<integer_t>())
as mach_msg_type_number_t;
pub const THREAD_IDENTIFIER_INFO_COUNT: mach_msg_type_number_t =
(::mem::size_of::<thread_identifier_info_data_t>() / ::mem::size_of::<integer_t>())
as mach_msg_type_number_t;
pub const THREAD_EXTENDED_INFO_COUNT: mach_msg_type_number_t =
(::mem::size_of::<thread_extended_info_data_t>() / ::mem::size_of::<integer_t>())
as mach_msg_type_number_t;

pub const TASK_THREAD_TIMES_INFO_COUNT: u32 =
(::mem::size_of::<task_thread_times_info_data_t>()
/ ::mem::size_of::<natural_t>()) as u32;
pub const MACH_TASK_BASIC_INFO_COUNT: u32 = (::mem::size_of::<mach_task_basic_info_data_t>()
/ ::mem::size_of::<natural_t>()) as u32;
pub const HOST_VM_INFO64_COUNT: mach_msg_type_number_t =
(::mem::size_of::<vm_statistics64_data_t>() / ::mem::size_of::<integer_t>())
as mach_msg_type_number_t;
} else {
pub const THREAD_EXTENDED_POLICY_COUNT: mach_msg_type_number_t = 1;
pub const THREAD_TIME_CONSTRAINT_POLICY_COUNT: mach_msg_type_number_t = 4;
pub const THREAD_PRECEDENCE_POLICY_COUNT: mach_msg_type_number_t = 1;
pub const THREAD_AFFINITY_POLICY_COUNT: mach_msg_type_number_t = 1;
pub const THREAD_BACKGROUND_POLICY_COUNT: mach_msg_type_number_t = 1;
pub const THREAD_LATENCY_QOS_POLICY_COUNT: mach_msg_type_number_t = 1;
pub const THREAD_THROUGHPUT_QOS_POLICY_COUNT: mach_msg_type_number_t = 1;
pub const THREAD_BASIC_INFO_COUNT: mach_msg_type_number_t = 10;
pub const THREAD_IDENTIFIER_INFO_COUNT: mach_msg_type_number_t = 6;
pub const THREAD_EXTENDED_INFO_COUNT: mach_msg_type_number_t = 28;
pub const TASK_THREAD_TIMES_INFO_COUNT: u32 = 4;
pub const MACH_TASK_BASIC_INFO_COUNT: u32 = 12;
pub const HOST_VM_INFO64_COUNT: mach_msg_type_number_t = 38;
}
}
pub const THREAD_EXTENDED_POLICY_COUNT: mach_msg_type_number_t =
(::mem::size_of::<thread_extended_policy_data_t>() / ::mem::size_of::<integer_t>())
as mach_msg_type_number_t;
pub const THREAD_TIME_CONSTRAINT_POLICY_COUNT: mach_msg_type_number_t =
(::mem::size_of::<thread_time_constraint_policy_data_t>() / ::mem::size_of::<integer_t>())
as mach_msg_type_number_t;
pub const THREAD_PRECEDENCE_POLICY_COUNT: mach_msg_type_number_t =
(::mem::size_of::<thread_precedence_policy_data_t>() / ::mem::size_of::<integer_t>())
as mach_msg_type_number_t;
pub const THREAD_AFFINITY_POLICY_COUNT: mach_msg_type_number_t =
(::mem::size_of::<thread_affinity_policy_data_t>() / ::mem::size_of::<integer_t>())
as mach_msg_type_number_t;
pub const THREAD_BACKGROUND_POLICY_COUNT: mach_msg_type_number_t =
(::mem::size_of::<thread_background_policy_data_t>() / ::mem::size_of::<integer_t>())
as mach_msg_type_number_t;
pub const THREAD_LATENCY_QOS_POLICY_COUNT: mach_msg_type_number_t =
(::mem::size_of::<thread_latency_qos_policy_data_t>() / ::mem::size_of::<integer_t>())
as mach_msg_type_number_t;
pub const THREAD_THROUGHPUT_QOS_POLICY_COUNT: mach_msg_type_number_t =
(::mem::size_of::<thread_throughput_qos_policy_data_t>() / ::mem::size_of::<integer_t>())
as mach_msg_type_number_t;
pub const THREAD_BASIC_INFO_COUNT: mach_msg_type_number_t =
(::mem::size_of::<thread_basic_info_data_t>() / ::mem::size_of::<integer_t>())
as mach_msg_type_number_t;
pub const THREAD_IDENTIFIER_INFO_COUNT: mach_msg_type_number_t =
(::mem::size_of::<thread_identifier_info_data_t>() / ::mem::size_of::<integer_t>())
as mach_msg_type_number_t;
pub const THREAD_EXTENDED_INFO_COUNT: mach_msg_type_number_t =
(::mem::size_of::<thread_extended_info_data_t>() / ::mem::size_of::<integer_t>())
as mach_msg_type_number_t;

pub const TASK_THREAD_TIMES_INFO_COUNT: u32 =
(::mem::size_of::<task_thread_times_info_data_t>() / ::mem::size_of::<natural_t>()) as u32;
pub const MACH_TASK_BASIC_INFO_COUNT: u32 =
(::mem::size_of::<mach_task_basic_info_data_t>() / ::mem::size_of::<natural_t>()) as u32;
pub const HOST_VM_INFO64_COUNT: mach_msg_type_number_t =
(::mem::size_of::<vm_statistics64_data_t>() / ::mem::size_of::<integer_t>())
as mach_msg_type_number_t;

f! {
pub fn CMSG_NXTHDR(mhdr: *const ::msghdr,
Expand Down
11 changes: 1 addition & 10 deletions src/unix/bsd/freebsdlike/freebsd/aarch64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,7 @@ s_no_extra_traits! {
}
}

// should be pub(crate), but that requires Rust 1.18.0
cfg_if! {
if #[cfg(libc_const_size_of)] {
#[doc(hidden)]
pub const _ALIGNBYTES: usize = ::mem::size_of::<::c_longlong>() - 1;
} else {
#[doc(hidden)]
pub const _ALIGNBYTES: usize = 8 - 1;
}
}
pub(crate) const _ALIGNBYTES: usize = ::mem::size_of::<::c_longlong>() - 1;

cfg_if! {
if #[cfg(feature = "extra_traits")] {
Expand Down
12 changes: 2 additions & 10 deletions src/unix/bsd/freebsdlike/freebsd/arm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,11 @@ cfg_if! {
}
}

// should be pub(crate), but that requires Rust 1.18.0
cfg_if! {
if #[cfg(libc_const_size_of)] {
#[doc(hidden)]
pub const _ALIGNBYTES: usize = ::mem::size_of::<::c_int>() - 1;
} else {
#[doc(hidden)]
pub const _ALIGNBYTES: usize = 4 - 1;
}
}
pub(crate) const _ALIGNBYTES: usize = ::mem::size_of::<::c_int>() - 1;

pub const BIOCSRTIMEOUT: ::c_ulong = 0x8010426d;
pub const BIOCGRTIMEOUT: ::c_ulong = 0x4010426e;

pub const MAP_32BIT: ::c_int = 0x00080000;
pub const MINSIGSTKSZ: ::size_t = 4096; // 1024 * 4
pub const TIOCTIMESTAMP: ::c_ulong = 0x40107459;
11 changes: 1 addition & 10 deletions src/unix/bsd/freebsdlike/freebsd/powerpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,7 @@ cfg_if! {
}
}

// should be pub(crate), but that requires Rust 1.18.0
cfg_if! {
if #[cfg(libc_const_size_of)] {
#[doc(hidden)]
pub const _ALIGNBYTES: usize = ::mem::size_of::<::c_int>() - 1;
} else {
#[doc(hidden)]
pub const _ALIGNBYTES: usize = 4 - 1;
}
}
pub(crate) const _ALIGNBYTES: usize = ::mem::size_of::<::c_int>() - 1;

pub const BIOCSRTIMEOUT: ::c_ulong = 0x8010426d;
pub const BIOCGRTIMEOUT: ::c_ulong = 0x4010426e;
Expand Down
12 changes: 2 additions & 10 deletions src/unix/bsd/freebsdlike/freebsd/powerpc64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,19 +73,11 @@ cfg_if! {
}
}

// should be pub(crate), but that requires Rust 1.18.0
cfg_if! {
if #[cfg(libc_const_size_of)] {
#[doc(hidden)]
pub const _ALIGNBYTES: usize = ::mem::size_of::<::c_long>() - 1;
} else {
#[doc(hidden)]
pub const _ALIGNBYTES: usize = 8 - 1;
}
}
pub(crate) const _ALIGNBYTES: usize = ::mem::size_of::<::c_long>() - 1;

pub const BIOCSRTIMEOUT: ::c_ulong = 0x8010426d;
pub const BIOCGRTIMEOUT: ::c_ulong = 0x4010426e;

pub const MAP_32BIT: ::c_int = 0x00080000;
pub const MINSIGSTKSZ: ::size_t = 2048; // 512 * 4
pub const TIOCTIMESTAMP: ::c_ulong = 0x40107459;
13 changes: 2 additions & 11 deletions src/unix/bsd/freebsdlike/freebsd/riscv64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,6 @@ s_no_extra_traits! {
}
}

// should be pub(crate), but that requires Rust 1.18.0
cfg_if! {
if #[cfg(libc_const_size_of)] {
#[doc(hidden)]
pub const _ALIGNBYTES: usize = ::mem::size_of::<::c_longlong>() - 1;
} else {
#[doc(hidden)]
pub const _ALIGNBYTES: usize = 8 - 1;
}
}

cfg_if! {
if #[cfg(feature = "extra_traits")] {
impl PartialEq for gpregs {
Expand Down Expand Up @@ -151,6 +140,8 @@ cfg_if! {
}
}

pub(crate) const _ALIGNBYTES: usize = ::mem::size_of::<::c_longlong>() - 1;

pub const BIOCSRTIMEOUT: ::c_ulong = 0x8010426d;
pub const BIOCGRTIMEOUT: ::c_ulong = 0x4010426e;
pub const MAP_32BIT: ::c_int = 0x00080000;
Expand Down
13 changes: 2 additions & 11 deletions src/unix/bsd/freebsdlike/freebsd/x86.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,6 @@ cfg_if! {
}
}

// should be pub(crate), but that requires Rust 1.18.0
cfg_if! {
if #[cfg(libc_const_size_of)] {
#[doc(hidden)]
pub const _ALIGNBYTES: usize = ::mem::size_of::<::c_long>() - 1;
} else {
#[doc(hidden)]
pub const _ALIGNBYTES: usize = 4 - 1;
}
}

cfg_if! {
if #[cfg(all(libc_align, feature = "extra_traits"))] {
impl PartialEq for mcontext_t {
Expand Down Expand Up @@ -169,6 +158,8 @@ cfg_if! {
}
}

pub(crate) const _ALIGNBYTES: usize = ::mem::size_of::<::c_long>() - 1;

pub const MINSIGSTKSZ: ::size_t = 2048; // 512 * 4

pub const BIOCSRTIMEOUT: ::c_ulong = 0x8008426d;
Expand Down
11 changes: 1 addition & 10 deletions src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,16 +219,7 @@ cfg_if! {
}
}

// should be pub(crate), but that requires Rust 1.18.0
cfg_if! {
if #[cfg(libc_const_size_of)] {
#[doc(hidden)]
pub const _ALIGNBYTES: usize = ::mem::size_of::<::c_long>() - 1;
} else {
#[doc(hidden)]
pub const _ALIGNBYTES: usize = 8 - 1;
}
}
pub(crate) const _ALIGNBYTES: usize = ::mem::size_of::<::c_long>() - 1;

pub const BIOCSRTIMEOUT: ::c_ulong = 0x8010426d;
pub const BIOCGRTIMEOUT: ::c_ulong = 0x4010426e;
Expand Down
10 changes: 1 addition & 9 deletions src/unix/bsd/freebsdlike/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -432,15 +432,7 @@ cfg_if! {
}

// Non-public helper constant
cfg_if! {
if #[cfg(all(not(libc_const_size_of), target_pointer_width = "32"))] {
const SIZEOF_LONG: usize = 4;
} else if #[cfg(all(not(libc_const_size_of), target_pointer_width = "64"))] {
const SIZEOF_LONG: usize = 8;
} else if #[cfg(libc_const_size_of)] {
const SIZEOF_LONG: usize = ::mem::size_of::<::c_long>();
}
}
const SIZEOF_LONG: usize = ::mem::size_of::<::c_long>();

#[deprecated(
since = "0.2.64",
Expand Down
12 changes: 1 addition & 11 deletions src/unix/bsd/netbsdlike/netbsd/aarch64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,7 @@ cfg_if! {
}
}

// should be pub(crate), but that requires Rust 1.18.0
cfg_if! {
if #[cfg(libc_const_size_of)] {
#[doc(hidden)]
pub const _ALIGNBYTES: usize = ::mem::size_of::<::c_int>() - 1;
} else {
#[doc(hidden)]
pub const _ALIGNBYTES: usize = 4 - 1;
}
}

pub(crate) const _ALIGNBYTES: usize = ::mem::size_of::<::c_int>() - 1;
pub const PT_GETREGS: ::c_int = PT_FIRSTMACH + 0;
pub const PT_SETREGS: ::c_int = PT_FIRSTMACH + 1;
pub const PT_GETFPREGS: ::c_int = PT_FIRSTMACH + 2;
Expand Down
11 changes: 1 addition & 10 deletions src/unix/bsd/netbsdlike/netbsd/arm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,7 @@ pub type c_ulong = u32;
pub type c_char = u8;
pub type __cpu_simple_lock_nv_t = ::c_int;

// should be pub(crate), but that requires Rust 1.18.0
cfg_if! {
if #[cfg(libc_const_size_of)] {
#[doc(hidden)]
pub const _ALIGNBYTES: usize = ::mem::size_of::<::c_longlong>() - 1;
} else {
#[doc(hidden)]
pub const _ALIGNBYTES: usize = 8 - 1;
}
}
pub(crate) const _ALIGNBYTES: usize = ::mem::size_of::<::c_longlong>() - 1;

pub const PT_GETREGS: ::c_int = PT_FIRSTMACH + 1;
pub const PT_SETREGS: ::c_int = PT_FIRSTMACH + 2;
Expand Down
10 changes: 1 addition & 9 deletions src/unix/bsd/netbsdlike/netbsd/mips.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,7 @@ pub type c_ulong = u32;
pub type c_char = i8;
pub type __cpu_simple_lock_nv_t = ::c_int;

cfg_if! {
if #[cfg(libc_const_size_of)] {
#[doc(hidden)]
pub const _ALIGNBYTES: usize = ::mem::size_of::<::c_longlong>() - 1;
} else {
#[doc(hidden)]
pub const _ALIGNBYTES: usize = 8 - 1;
}
}
pub(crate) const _ALIGNBYTES: usize = ::mem::size_of::<::c_longlong>() - 1;

pub const PT_GETREGS: ::c_int = PT_FIRSTMACH + 1;
pub const PT_SETREGS: ::c_int = PT_FIRSTMACH + 2;
Expand Down
11 changes: 1 addition & 10 deletions src/unix/bsd/netbsdlike/netbsd/powerpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,7 @@ pub type c_ulong = u32;
pub type c_char = u8;
pub type __cpu_simple_lock_nv_t = ::c_int;

// should be pub(crate), but that requires Rust 1.18.0
cfg_if! {
if #[cfg(libc_const_size_of)] {
#[doc(hidden)]
pub const _ALIGNBYTES: usize = ::mem::size_of::<::c_double>() - 1;
} else {
#[doc(hidden)]
pub const _ALIGNBYTES: usize = 8 - 1;
}
}
pub(crate) const _ALIGNBYTES: usize = ::mem::size_of::<::c_double>() - 1;

pub const PT_STEP: ::c_int = PT_FIRSTMACH + 0;
pub const PT_GETREGS: ::c_int = PT_FIRSTMACH + 1;
Expand Down
Loading

0 comments on commit 5a43dd2

Please sign in to comment.