From 5a43dd2754366f99b3a83881b30246ce0e51833c Mon Sep 17 00:00:00 2001 From: Josh Triplett Date: Mon, 11 Jul 2022 19:02:03 -0700 Subject: [PATCH] Require rust >= 1.24 and drop libc_const_size_of conditional [ resolve conflicts and remove a couple newer `cfg`s - Trevor ] --- build.rs | 6 -- libc-test/build.rs | 1 - src/unix/bsd/apple/mod.rs | 102 +++++++----------- src/unix/bsd/freebsdlike/freebsd/aarch64.rs | 11 +- src/unix/bsd/freebsdlike/freebsd/arm.rs | 12 +-- src/unix/bsd/freebsdlike/freebsd/powerpc.rs | 11 +- src/unix/bsd/freebsdlike/freebsd/powerpc64.rs | 12 +-- src/unix/bsd/freebsdlike/freebsd/riscv64.rs | 13 +-- src/unix/bsd/freebsdlike/freebsd/x86.rs | 13 +-- .../bsd/freebsdlike/freebsd/x86_64/mod.rs | 11 +- src/unix/bsd/freebsdlike/mod.rs | 10 +- src/unix/bsd/netbsdlike/netbsd/aarch64.rs | 12 +-- src/unix/bsd/netbsdlike/netbsd/arm.rs | 11 +- src/unix/bsd/netbsdlike/netbsd/mips.rs | 10 +- src/unix/bsd/netbsdlike/netbsd/powerpc.rs | 11 +- src/unix/bsd/netbsdlike/netbsd/riscv64.rs | 10 +- src/unix/bsd/netbsdlike/netbsd/x86.rs | 11 +- src/unix/bsd/netbsdlike/netbsd/x86_64.rs | 11 +- src/unix/bsd/netbsdlike/openbsd/aarch64.rs | 11 +- src/unix/bsd/netbsdlike/openbsd/arm.rs | 11 +- src/unix/bsd/netbsdlike/openbsd/powerpc.rs | 11 +- src/unix/bsd/netbsdlike/openbsd/powerpc64.rs | 11 +- src/unix/bsd/netbsdlike/openbsd/riscv64.rs | 11 +- src/unix/bsd/netbsdlike/openbsd/x86.rs | 11 +- src/unix/bsd/netbsdlike/openbsd/x86_64.rs | 11 +- src/unix/linux_like/linux/mod.rs | 25 ++--- 26 files changed, 74 insertions(+), 306 deletions(-) diff --git a/build.rs b/build.rs index 6f35689379cb6..241c489d9a183 100644 --- a/build.rs +++ b/build.rs @@ -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", @@ -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"); diff --git a/libc-test/build.rs b/libc-test/build.rs index 534a27a8df8d6..d4a2d9cfaa3cd 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -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", diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index 09fcbfb7f8c1f..efde59bc8d32e 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -5484,76 +5484,52 @@ cfg_if! { const __DARWIN_ALIGNBYTES32: usize = ::mem::size_of::() - 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::() - 1; - p + __DARWIN_ALIGNBYTES32 & !__DARWIN_ALIGNBYTES32 - } } else { fn __DARWIN_ALIGN32(p: usize) -> usize { - let __DARWIN_ALIGNBYTES32: usize = ::mem::size_of::() - 1; + const __DARWIN_ALIGNBYTES32: usize = ::mem::size_of::() - 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::() / ::mem::size_of::()) - as mach_msg_type_number_t; - pub const THREAD_TIME_CONSTRAINT_POLICY_COUNT: mach_msg_type_number_t = - (::mem::size_of::() / - ::mem::size_of::()) as mach_msg_type_number_t; - pub const THREAD_PRECEDENCE_POLICY_COUNT: mach_msg_type_number_t = - (::mem::size_of::() / ::mem::size_of::()) - as mach_msg_type_number_t; - pub const THREAD_AFFINITY_POLICY_COUNT: mach_msg_type_number_t = - (::mem::size_of::() / ::mem::size_of::()) - as mach_msg_type_number_t; - pub const THREAD_BACKGROUND_POLICY_COUNT: mach_msg_type_number_t = - (::mem::size_of::() / ::mem::size_of::()) - as mach_msg_type_number_t; - pub const THREAD_LATENCY_QOS_POLICY_COUNT: mach_msg_type_number_t = - (::mem::size_of::() / ::mem::size_of::()) - as mach_msg_type_number_t; - pub const THREAD_THROUGHPUT_QOS_POLICY_COUNT: mach_msg_type_number_t = - (::mem::size_of::() / - ::mem::size_of::()) as mach_msg_type_number_t; - pub const THREAD_BASIC_INFO_COUNT: mach_msg_type_number_t = - (::mem::size_of::() / ::mem::size_of::()) - as mach_msg_type_number_t; - pub const THREAD_IDENTIFIER_INFO_COUNT: mach_msg_type_number_t = - (::mem::size_of::() / ::mem::size_of::()) - as mach_msg_type_number_t; - pub const THREAD_EXTENDED_INFO_COUNT: mach_msg_type_number_t = - (::mem::size_of::() / ::mem::size_of::()) - as mach_msg_type_number_t; - - pub const TASK_THREAD_TIMES_INFO_COUNT: u32 = - (::mem::size_of::() - / ::mem::size_of::()) as u32; - pub const MACH_TASK_BASIC_INFO_COUNT: u32 = (::mem::size_of::() - / ::mem::size_of::()) as u32; - pub const HOST_VM_INFO64_COUNT: mach_msg_type_number_t = - (::mem::size_of::() / ::mem::size_of::()) - 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::() / ::mem::size_of::()) + as mach_msg_type_number_t; +pub const THREAD_TIME_CONSTRAINT_POLICY_COUNT: mach_msg_type_number_t = + (::mem::size_of::() / ::mem::size_of::()) + as mach_msg_type_number_t; +pub const THREAD_PRECEDENCE_POLICY_COUNT: mach_msg_type_number_t = + (::mem::size_of::() / ::mem::size_of::()) + as mach_msg_type_number_t; +pub const THREAD_AFFINITY_POLICY_COUNT: mach_msg_type_number_t = + (::mem::size_of::() / ::mem::size_of::()) + as mach_msg_type_number_t; +pub const THREAD_BACKGROUND_POLICY_COUNT: mach_msg_type_number_t = + (::mem::size_of::() / ::mem::size_of::()) + as mach_msg_type_number_t; +pub const THREAD_LATENCY_QOS_POLICY_COUNT: mach_msg_type_number_t = + (::mem::size_of::() / ::mem::size_of::()) + as mach_msg_type_number_t; +pub const THREAD_THROUGHPUT_QOS_POLICY_COUNT: mach_msg_type_number_t = + (::mem::size_of::() / ::mem::size_of::()) + as mach_msg_type_number_t; +pub const THREAD_BASIC_INFO_COUNT: mach_msg_type_number_t = + (::mem::size_of::() / ::mem::size_of::()) + as mach_msg_type_number_t; +pub const THREAD_IDENTIFIER_INFO_COUNT: mach_msg_type_number_t = + (::mem::size_of::() / ::mem::size_of::()) + as mach_msg_type_number_t; +pub const THREAD_EXTENDED_INFO_COUNT: mach_msg_type_number_t = + (::mem::size_of::() / ::mem::size_of::()) + as mach_msg_type_number_t; + +pub const TASK_THREAD_TIMES_INFO_COUNT: u32 = + (::mem::size_of::() / ::mem::size_of::()) as u32; +pub const MACH_TASK_BASIC_INFO_COUNT: u32 = + (::mem::size_of::() / ::mem::size_of::()) as u32; +pub const HOST_VM_INFO64_COUNT: mach_msg_type_number_t = + (::mem::size_of::() / ::mem::size_of::()) + as mach_msg_type_number_t; f! { pub fn CMSG_NXTHDR(mhdr: *const ::msghdr, diff --git a/src/unix/bsd/freebsdlike/freebsd/aarch64.rs b/src/unix/bsd/freebsdlike/freebsd/aarch64.rs index 004b6266ea863..05fe64b5c0c8a 100644 --- a/src/unix/bsd/freebsdlike/freebsd/aarch64.rs +++ b/src/unix/bsd/freebsdlike/freebsd/aarch64.rs @@ -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")] { diff --git a/src/unix/bsd/freebsdlike/freebsd/arm.rs b/src/unix/bsd/freebsdlike/freebsd/arm.rs index 82112a868b0ba..07cac6a331547 100644 --- a/src/unix/bsd/freebsdlike/freebsd/arm.rs +++ b/src/unix/bsd/freebsdlike/freebsd/arm.rs @@ -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; diff --git a/src/unix/bsd/freebsdlike/freebsd/powerpc.rs b/src/unix/bsd/freebsdlike/freebsd/powerpc.rs index f85df97f3666a..0f4f0dffee4cd 100644 --- a/src/unix/bsd/freebsdlike/freebsd/powerpc.rs +++ b/src/unix/bsd/freebsdlike/freebsd/powerpc.rs @@ -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; diff --git a/src/unix/bsd/freebsdlike/freebsd/powerpc64.rs b/src/unix/bsd/freebsdlike/freebsd/powerpc64.rs index 1b2d59c31c0cd..c1577f5194e57 100644 --- a/src/unix/bsd/freebsdlike/freebsd/powerpc64.rs +++ b/src/unix/bsd/freebsdlike/freebsd/powerpc64.rs @@ -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; diff --git a/src/unix/bsd/freebsdlike/freebsd/riscv64.rs b/src/unix/bsd/freebsdlike/freebsd/riscv64.rs index bad84177e6f0a..8be949df01583 100644 --- a/src/unix/bsd/freebsdlike/freebsd/riscv64.rs +++ b/src/unix/bsd/freebsdlike/freebsd/riscv64.rs @@ -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 { @@ -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; diff --git a/src/unix/bsd/freebsdlike/freebsd/x86.rs b/src/unix/bsd/freebsdlike/freebsd/x86.rs index b9da7caa2001e..9d5122846362d 100644 --- a/src/unix/bsd/freebsdlike/freebsd/x86.rs +++ b/src/unix/bsd/freebsdlike/freebsd/x86.rs @@ -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 { @@ -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; diff --git a/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs b/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs index f614bb2dbea38..327e0ad78fadb 100644 --- a/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs @@ -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; diff --git a/src/unix/bsd/freebsdlike/mod.rs b/src/unix/bsd/freebsdlike/mod.rs index d4749178f3c2c..f247e6bf6a02b 100644 --- a/src/unix/bsd/freebsdlike/mod.rs +++ b/src/unix/bsd/freebsdlike/mod.rs @@ -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", diff --git a/src/unix/bsd/netbsdlike/netbsd/aarch64.rs b/src/unix/bsd/netbsdlike/netbsd/aarch64.rs index f3f87b5e6f984..5f57779d3037e 100644 --- a/src/unix/bsd/netbsdlike/netbsd/aarch64.rs +++ b/src/unix/bsd/netbsdlike/netbsd/aarch64.rs @@ -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; diff --git a/src/unix/bsd/netbsdlike/netbsd/arm.rs b/src/unix/bsd/netbsdlike/netbsd/arm.rs index b5000d34d66fb..2da780ec6ddcb 100644 --- a/src/unix/bsd/netbsdlike/netbsd/arm.rs +++ b/src/unix/bsd/netbsdlike/netbsd/arm.rs @@ -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; diff --git a/src/unix/bsd/netbsdlike/netbsd/mips.rs b/src/unix/bsd/netbsdlike/netbsd/mips.rs index a536254ceb4b3..c25407fd97393 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mips.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mips.rs @@ -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; diff --git a/src/unix/bsd/netbsdlike/netbsd/powerpc.rs b/src/unix/bsd/netbsdlike/netbsd/powerpc.rs index e12fd5e112332..b4bfacf6a0185 100644 --- a/src/unix/bsd/netbsdlike/netbsd/powerpc.rs +++ b/src/unix/bsd/netbsdlike/netbsd/powerpc.rs @@ -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; diff --git a/src/unix/bsd/netbsdlike/netbsd/riscv64.rs b/src/unix/bsd/netbsdlike/netbsd/riscv64.rs index bc09149efeabd..643940d03de85 100644 --- a/src/unix/bsd/netbsdlike/netbsd/riscv64.rs +++ b/src/unix/bsd/netbsdlike/netbsd/riscv64.rs @@ -5,15 +5,7 @@ pub type c_ulong = u64; pub type c_char = u8; 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_long>() - 1; - } else { - #[doc(hidden)] - pub const _ALIGNBYTES: usize = 8 - 1; - } -} +pub(crate) const _ALIGNBYTES: usize = ::mem::size_of::<::c_long>() - 1; pub const PT_GETREGS: ::c_int = PT_FIRSTMACH + 0; pub const PT_SETREGS: ::c_int = PT_FIRSTMACH + 1; diff --git a/src/unix/bsd/netbsdlike/netbsd/x86.rs b/src/unix/bsd/netbsdlike/netbsd/x86.rs index daa89a11a67cb..d3a3967df17ef 100644 --- a/src/unix/bsd/netbsdlike/netbsd/x86.rs +++ b/src/unix/bsd/netbsdlike/netbsd/x86.rs @@ -3,13 +3,4 @@ pub type c_ulong = u32; pub type c_char = i8; pub type __cpu_simple_lock_nv_t = ::c_uchar; -// 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; diff --git a/src/unix/bsd/netbsdlike/netbsd/x86_64.rs b/src/unix/bsd/netbsdlike/netbsd/x86_64.rs index ba259074f6129..a2087c34e43ef 100644 --- a/src/unix/bsd/netbsdlike/netbsd/x86_64.rs +++ b/src/unix/bsd/netbsdlike/netbsd/x86_64.rs @@ -22,16 +22,7 @@ s! { } } -// 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 PT_STEP: ::c_int = PT_FIRSTMACH + 0; pub const PT_GETREGS: ::c_int = PT_FIRSTMACH + 1; diff --git a/src/unix/bsd/netbsdlike/openbsd/aarch64.rs b/src/unix/bsd/netbsdlike/openbsd/aarch64.rs index 2bc82e486c596..f2159c4dc2142 100644 --- a/src/unix/bsd/netbsdlike/openbsd/aarch64.rs +++ b/src/unix/bsd/netbsdlike/openbsd/aarch64.rs @@ -16,15 +16,6 @@ s! { } } -// 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 _MAX_PAGE_SHIFT: u32 = 12; diff --git a/src/unix/bsd/netbsdlike/openbsd/arm.rs b/src/unix/bsd/netbsdlike/openbsd/arm.rs index f1ab365d1cd1b..6394df9300245 100644 --- a/src/unix/bsd/netbsdlike/openbsd/arm.rs +++ b/src/unix/bsd/netbsdlike/openbsd/arm.rs @@ -2,15 +2,6 @@ pub type c_long = i32; pub type c_ulong = u32; pub type c_char = u8; -// 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 _MAX_PAGE_SHIFT: u32 = 12; diff --git a/src/unix/bsd/netbsdlike/openbsd/powerpc.rs b/src/unix/bsd/netbsdlike/openbsd/powerpc.rs index f1ab365d1cd1b..6394df9300245 100644 --- a/src/unix/bsd/netbsdlike/openbsd/powerpc.rs +++ b/src/unix/bsd/netbsdlike/openbsd/powerpc.rs @@ -2,15 +2,6 @@ pub type c_long = i32; pub type c_ulong = u32; pub type c_char = u8; -// 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 _MAX_PAGE_SHIFT: u32 = 12; diff --git a/src/unix/bsd/netbsdlike/openbsd/powerpc64.rs b/src/unix/bsd/netbsdlike/openbsd/powerpc64.rs index 99350ec8dc3d4..df0cdd6d1ac53 100644 --- a/src/unix/bsd/netbsdlike/openbsd/powerpc64.rs +++ b/src/unix/bsd/netbsdlike/openbsd/powerpc64.rs @@ -2,15 +2,6 @@ pub type c_long = i64; pub type c_ulong = u64; pub type c_char = u8; -// 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 _MAX_PAGE_SHIFT: u32 = 12; diff --git a/src/unix/bsd/netbsdlike/openbsd/riscv64.rs b/src/unix/bsd/netbsdlike/openbsd/riscv64.rs index 35f1672bbec9e..fbcc5a76bbed3 100644 --- a/src/unix/bsd/netbsdlike/openbsd/riscv64.rs +++ b/src/unix/bsd/netbsdlike/openbsd/riscv64.rs @@ -21,15 +21,6 @@ s! { } } -// 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 _MAX_PAGE_SHIFT: u32 = 12; diff --git a/src/unix/bsd/netbsdlike/openbsd/x86.rs b/src/unix/bsd/netbsdlike/openbsd/x86.rs index e87d0ff1e7d5d..a12107bc2a482 100644 --- a/src/unix/bsd/netbsdlike/openbsd/x86.rs +++ b/src/unix/bsd/netbsdlike/openbsd/x86.rs @@ -2,15 +2,6 @@ pub type c_long = i32; pub type c_ulong = u32; pub type c_char = i8; -// 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 _MAX_PAGE_SHIFT: u32 = 12; diff --git a/src/unix/bsd/netbsdlike/openbsd/x86_64.rs b/src/unix/bsd/netbsdlike/openbsd/x86_64.rs index 60dab004456fc..5cc7dc1fc060f 100644 --- a/src/unix/bsd/netbsdlike/openbsd/x86_64.rs +++ b/src/unix/bsd/netbsdlike/openbsd/x86_64.rs @@ -110,16 +110,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 _MAX_PAGE_SHIFT: u32 = 12; diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index ec6c4ac235599..99f3f45a9950b 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -3084,22 +3084,15 @@ pub const TP_FT_REQ_FILL_RXHASH: ::__u32 = 1; pub const TPACKET_ALIGNMENT: usize = 16; -cfg_if! { - if #[cfg(libc_const_size_of)] { - pub const TPACKET_HDRLEN: usize = ( - (::mem::size_of::<::tpacket_hdr>() + TPACKET_ALIGNMENT - 1) - & !(TPACKET_ALIGNMENT - 1) - ) + ::mem::size_of::<::sockaddr_ll>(); - pub const TPACKET2_HDRLEN: usize = ( - (::mem::size_of::<::tpacket2_hdr>() + TPACKET_ALIGNMENT - 1) - & !(TPACKET_ALIGNMENT - 1) - ) + ::mem::size_of::<::sockaddr_ll>(); - pub const TPACKET3_HDRLEN: usize = ( - (::mem::size_of::<::tpacket3_hdr>() + TPACKET_ALIGNMENT - 1) - & !(TPACKET_ALIGNMENT - 1) - ) + ::mem::size_of::<::sockaddr_ll>(); - } -} +pub const TPACKET_HDRLEN: usize = ((::mem::size_of::<::tpacket_hdr>() + TPACKET_ALIGNMENT - 1) + & !(TPACKET_ALIGNMENT - 1)) + + ::mem::size_of::<::sockaddr_ll>(); +pub const TPACKET2_HDRLEN: usize = ((::mem::size_of::<::tpacket2_hdr>() + TPACKET_ALIGNMENT - 1) + & !(TPACKET_ALIGNMENT - 1)) + + ::mem::size_of::<::sockaddr_ll>(); +pub const TPACKET3_HDRLEN: usize = ((::mem::size_of::<::tpacket3_hdr>() + TPACKET_ALIGNMENT - 1) + & !(TPACKET_ALIGNMENT - 1)) + + ::mem::size_of::<::sockaddr_ll>(); // linux/netfilter.h pub const NF_DROP: ::c_int = 0;