From 2ff5d5ceabafe720860375af9e4595f3cdf37de2 Mon Sep 17 00:00:00 2001 From: Joshua Liebow-Feeser Date: Sat, 14 Sep 2024 10:03:54 -0400 Subject: [PATCH] Bump MSRV to 1.31 This permits `Cargo.toml` to include optional dependencies. On toolchains earlier than 1.31, the optional dependency syntax is not supported. With the MSRV at 1.31, any optional dependency may be supported even if *its* MSRV is higher than *our* MSRV since only users using a more recent toolchain will enable that dependency. In particular, this paves the way for adding an optional `zerocopy` dependency (prototyped in #3407 and #3914; see also google/zerocopy#557), which permits many uses of libc to no longer require `unsafe` code. --- .github/workflows/full_ci.yml | 12 +- README.md | 7 +- build-tmp.rs | 38 --- build.rs | 39 --- ci/build.sh | 12 +- libc-test/build.rs | 10 +- src/fixed_width_ints.rs | 2 +- src/fuchsia/mod.rs | 31 +- src/fuchsia/no_align.rs | 129 --------- src/lib.rs | 65 ++--- src/macros.rs | 27 +- src/psp.rs | 20 +- src/sgx.rs | 20 +- src/solid/mod.rs | 20 +- src/switch.rs | 20 +- src/unix/aix/mod.rs | 28 +- src/unix/aix/powerpc64.rs | 55 +--- src/unix/bsd/apple/b32/mod.rs | 8 +- src/unix/bsd/apple/b64/aarch64/align.rs | 8 - src/unix/bsd/apple/b64/aarch64/mod.rs | 8 +- src/unix/bsd/apple/b64/x86_64/mod.rs | 8 +- src/unix/bsd/apple/mod.rs | 178 +++++------- src/unix/bsd/freebsdlike/freebsd/aarch64.rs | 11 +- src/unix/bsd/freebsdlike/freebsd/arm.rs | 11 +- src/unix/bsd/freebsdlike/freebsd/mod.rs | 76 +---- src/unix/bsd/freebsdlike/freebsd/powerpc.rs | 11 +- src/unix/bsd/freebsdlike/freebsd/powerpc64.rs | 11 +- src/unix/bsd/freebsdlike/freebsd/riscv64.rs | 11 +- src/unix/bsd/freebsdlike/freebsd/x86.rs | 11 +- .../bsd/freebsdlike/freebsd/x86_64/mod.rs | 40 +-- src/unix/bsd/freebsdlike/mod.rs | 10 +- src/unix/bsd/netbsdlike/netbsd/aarch64.rs | 17 +- src/unix/bsd/netbsdlike/netbsd/arm.rs | 11 +- src/unix/bsd/netbsdlike/netbsd/mips.rs | 10 +- src/unix/bsd/netbsdlike/netbsd/mod.rs | 25 +- 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/mod.rs | 268 ++++++++---------- 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/haiku/native.rs | 19 +- src/unix/hurd/mod.rs | 11 +- src/unix/hurd/no_align.rs | 1 - src/unix/linux_like/android/b32/arm.rs | 208 +++++++------- src/unix/linux_like/android/b32/x86/mod.rs | 204 +++++++------ .../linux_like/android/b64/aarch64/mod.rs | 16 +- .../linux_like/android/b64/riscv64/mod.rs | 8 +- src/unix/linux_like/android/b64/x86_64/mod.rs | 56 ++-- src/unix/linux_like/android/mod.rs | 109 +++---- src/unix/linux_like/emscripten/mod.rs | 12 +- src/unix/linux_like/emscripten/no_align.rs | 63 ---- src/unix/linux_like/linux/gnu/b32/arm/mod.rs | 8 +- src/unix/linux_like/linux/gnu/b32/csky/mod.rs | 8 +- src/unix/linux_like/linux/gnu/b32/mips/mod.rs | 8 +- .../linux_like/linux/gnu/b32/riscv32/mod.rs | 8 +- .../linux_like/linux/gnu/b32/sparc/mod.rs | 8 +- src/unix/linux_like/linux/gnu/b32/x86/mod.rs | 8 +- .../linux/gnu/b64/aarch64/fallback.rs | 8 - .../linux_like/linux/gnu/b64/aarch64/mod.rs | 21 +- .../linux/gnu/b64/loongarch64/mod.rs | 8 +- .../linux_like/linux/gnu/b64/mips64/mod.rs | 8 +- .../linux_like/linux/gnu/b64/powerpc64/mod.rs | 8 +- .../linux_like/linux/gnu/b64/riscv64/mod.rs | 8 +- .../linux_like/linux/gnu/b64/sparc64/mod.rs | 8 +- .../linux_like/linux/gnu/b64/x86_64/mod.rs | 8 +- src/unix/linux_like/linux/gnu/mod.rs | 136 ++++----- src/unix/linux_like/linux/gnu/no_align.rs | 10 - src/unix/linux_like/linux/mod.rs | 71 ++--- src/unix/linux_like/linux/musl/b32/arm/mod.rs | 8 +- .../linux_like/linux/musl/b32/mips/mod.rs | 8 +- .../linux_like/linux/musl/b32/riscv32/mod.rs | 8 +- src/unix/linux_like/linux/musl/b32/x86/mod.rs | 8 +- .../linux_like/linux/musl/b64/aarch64/mod.rs | 16 +- .../linux/musl/b64/loongarch64/mod.rs | 8 +- .../linux_like/linux/musl/b64/riscv64/mod.rs | 8 +- .../linux_like/linux/musl/b64/x86_64/mod.rs | 8 +- src/unix/linux_like/linux/musl/mod.rs | 98 +++---- src/unix/linux_like/linux/no_align.rs | 144 ---------- src/unix/linux_like/linux/uclibc/arm/mod.rs | 11 +- .../linux_like/linux/uclibc/arm/no_align.rs | 10 - .../linux/uclibc/mips/mips32/mod.rs | 11 +- .../linux/uclibc/mips/mips32/no_align.rs | 10 - .../linux/uclibc/mips/mips64/mod.rs | 11 +- .../linux/uclibc/mips/mips64/no_align.rs | 7 - src/unix/linux_like/linux/uclibc/no_align.rs | 53 ---- src/unix/mod.rs | 31 +- src/unix/newlib/mod.rs | 11 +- src/unix/newlib/no_align.rs | 51 ---- src/unix/no_align.rs | 16 -- src/unix/nto/x86_64.rs | 8 - src/unix/solarish/mod.rs | 16 +- src/unix/solarish/x86_64.rs | 4 - src/vxworks/mod.rs | 20 +- src/windows/gnu/mod.rs | 8 +- src/windows/mod.rs | 20 +- src/xous.rs | 20 +- 103 files changed, 753 insertions(+), 2316 deletions(-) delete mode 100644 src/fuchsia/no_align.rs delete mode 100644 src/unix/hurd/no_align.rs delete mode 100644 src/unix/linux_like/emscripten/no_align.rs delete mode 100644 src/unix/linux_like/linux/gnu/b64/aarch64/fallback.rs delete mode 100644 src/unix/linux_like/linux/gnu/no_align.rs delete mode 100644 src/unix/linux_like/linux/no_align.rs delete mode 100644 src/unix/linux_like/linux/uclibc/arm/no_align.rs delete mode 100644 src/unix/linux_like/linux/uclibc/mips/mips32/no_align.rs delete mode 100644 src/unix/linux_like/linux/uclibc/mips/mips64/no_align.rs delete mode 100644 src/unix/linux_like/linux/uclibc/no_align.rs delete mode 100644 src/unix/newlib/no_align.rs delete mode 100644 src/unix/no_align.rs diff --git a/.github/workflows/full_ci.yml b/.github/workflows/full_ci.yml index b36f4f9d2ba57..080ce790791f9 100644 --- a/.github/workflows/full_ci.yml +++ b/.github/workflows/full_ci.yml @@ -154,13 +154,7 @@ jobs: stable, beta, nightly, - # FIXME: Disabled due to: - # error: failed to parse registry's information for: serde - #1.13.0, - 1.19.0, - 1.24.0, - 1.25.0, - 1.30.0, + 1.31.0, ] steps: - uses: actions/checkout@v4 @@ -205,10 +199,6 @@ jobs: fail-fast: true matrix: toolchain: [ - 1.19.0, - 1.24.0, - 1.25.0, - 1.30.0, stable, ] steps: diff --git a/README.md b/README.md index 395b94ce0c8f3..6736b12a3f687 100644 --- a/README.md +++ b/README.md @@ -51,18 +51,13 @@ libc = "0.2" ## Rust version support -The minimum supported Rust toolchain version is currently **Rust 1.13.0**. +The minimum supported Rust toolchain version is currently **Rust 1.31.0**. (libc does not currently have any policy regarding changes to the minimum supported Rust version; such policy is a work in progress.) APIs requiring newer Rust features are only available on newer Rust toolchains: | Feature | Version | |----------------------|---------| -| `union` | 1.19.0 | -| `const mem::size_of` | 1.24.0 | -| `repr(align)` | 1.25.0 | -| `extra_traits` | 1.25.0 | -| `core::ffi::c_void` | 1.30.0 | | `repr(packed(N))` | 1.33.0 | | `cfg(target_vendor)` | 1.33.0 | | `const-extern-fn` | 1.62.0 | diff --git a/build-tmp.rs b/build-tmp.rs index 101f45ac262e9..ae588de1a68e4 100644 --- a/build-tmp.rs +++ b/build-tmp.rs @@ -15,22 +15,16 @@ const ALLOWED_CFGS: &'static [&'static str] = &[ "freebsd13", "freebsd14", "freebsd15", - "libc_align", "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", "libc_long_array", "libc_non_exhaustive", "libc_packedN", - "libc_priv_mod_use", "libc_ptr_addr_of", "libc_thread_local", "libc_underscore_const_names", - "libc_union", "libc_ctest", ]; @@ -95,38 +89,6 @@ fn main() { set_cfg("libc_deny_warnings"); } - // Rust >= 1.15 supports private module use: - if rustc_minor_ver >= 15 || rustc_dep_of_std { - set_cfg("libc_priv_mod_use"); - } - - // Rust >= 1.19 supports unions: - if rustc_minor_ver >= 19 || rustc_dep_of_std { - set_cfg("libc_union"); - } - - // 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"); - } - - // 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"); diff --git a/build.rs b/build.rs index ce4541e62955c..e0109b96a2374 100644 --- a/build.rs +++ b/build.rs @@ -14,22 +14,16 @@ const ALLOWED_CFGS: &'static [&'static str] = &[ "freebsd13", "freebsd14", "freebsd15", - "libc_align", "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", "libc_long_array", "libc_non_exhaustive", "libc_packedN", - "libc_priv_mod_use", "libc_ptr_addr_of", "libc_thread_local", "libc_underscore_const_names", - "libc_union", "libc_ctest", ]; @@ -49,7 +43,6 @@ fn main() { let (rustc_minor_ver, is_nightly) = rustc_minor_nightly(); let rustc_dep_of_std = env::var("CARGO_FEATURE_RUSTC_DEP_OF_STD").is_ok(); - let align_cargo_feature = env::var("CARGO_FEATURE_ALIGN").is_ok(); let const_extern_fn_cargo_feature = env::var("CARGO_FEATURE_CONST_EXTERN_FN").is_ok(); let libc_ci = env::var("LIBC_CI").is_ok(); let libc_check_cfg = env::var("LIBC_CHECK_CFG").is_ok() || rustc_minor_ver >= 80; @@ -94,38 +87,6 @@ fn main() { set_cfg("libc_deny_warnings"); } - // Rust >= 1.15 supports private module use: - if rustc_minor_ver >= 15 || rustc_dep_of_std { - set_cfg("libc_priv_mod_use"); - } - - // Rust >= 1.19 supports unions: - if rustc_minor_ver >= 19 || rustc_dep_of_std { - set_cfg("libc_union"); - } - - // 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"); - } - - // 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"); diff --git a/ci/build.sh b/ci/build.sh index d90872f4e8c84..561dd64ff97a4 100644 --- a/ci/build.sh +++ b/ci/build.sh @@ -169,15 +169,9 @@ case "${OS}" in linux*) TARGETS="${RUST_LINUX_TARGETS}" - if [ "${RUST}" != "1.13.0" ]; then - TARGETS="${TARGETS} ${RUST_GT_1_13_LINUX_TARGETS}" - if [ "${RUST}" != "1.19.0" ]; then - TARGETS="${TARGETS} ${RUST_GT_1_19_LINUX_TARGETS}" - if [ "${RUST}" != "1.24.0" ]; then - TARGETS="${TARGETS} ${RUST_GT_1_24_LINUX_TARGETS}" - fi - fi - fi + TARGETS="${TARGETS} ${RUST_GT_1_13_LINUX_TARGETS}" + TARGETS="${TARGETS} ${RUST_GT_1_19_LINUX_TARGETS}" + TARGETS="${TARGETS} ${RUST_GT_1_24_LINUX_TARGETS}" if [ "${RUST}" = "nightly" ]; then TARGETS="${TARGETS} ${RUST_NIGHTLY_LINUX_TARGETS}" diff --git a/libc-test/build.rs b/libc-test/build.rs index 75dcd14fc83be..6181f930aeb0f 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -68,15 +68,7 @@ fn do_ctest() { fn ctest_cfg() -> ctest::TestGenerator { let mut cfg = ctest::TestGenerator::new(); - let libc_cfgs = [ - "libc_priv_mod_use", - "libc_union", - "libc_const_size_of", - "libc_align", - "libc_core_cvoid", - "libc_packedN", - "libc_thread_local", - ]; + let libc_cfgs = ["libc_packedN", "libc_thread_local"]; for f in &libc_cfgs { cfg.cfg(f, None); } diff --git a/src/fixed_width_ints.rs b/src/fixed_width_ints.rs index 999de8f54f194..980ff61ecdaf3 100644 --- a/src/fixed_width_ints.rs +++ b/src/fixed_width_ints.rs @@ -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. diff --git a/src/fuchsia/mod.rs b/src/fuchsia/mod.rs index 9414d1674f26e..734e7de46c517 100644 --- a/src/fuchsia/mod.rs +++ b/src/fuchsia/mod.rs @@ -4362,33 +4362,8 @@ cfg_if! { } } -cfg_if! { - if #[cfg(libc_align)] { - #[macro_use] - mod align; - } else { - #[macro_use] - mod no_align; - } -} +#[macro_use] +mod align; expand_align!(); -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 use ffi::c_void; diff --git a/src/fuchsia/no_align.rs b/src/fuchsia/no_align.rs deleted file mode 100644 index 7ca90e0e48a39..0000000000000 --- a/src/fuchsia/no_align.rs +++ /dev/null @@ -1,129 +0,0 @@ -macro_rules! expand_align { - () => { - s! { - pub struct pthread_mutexattr_t { - #[cfg(target_arch = "x86_64")] - __align: [::c_int; 0], - #[cfg(not(target_arch = "x86_64"))] - __align: [::c_long; 0], - size: [u8; ::__SIZEOF_PTHREAD_MUTEXATTR_T], - } - - pub struct pthread_rwlockattr_t { - __align: [::c_long; 0], - size: [u8; ::__SIZEOF_PTHREAD_RWLOCKATTR_T], - } - - pub struct pthread_condattr_t { - __align: [::c_int; 0], - size: [u8; ::__SIZEOF_PTHREAD_CONDATTR_T], - } - } - - s_no_extra_traits! { - pub struct pthread_mutex_t { - #[cfg(any(target_arch = "arm", - all(target_arch = "x86_64", - target_pointer_width = "32")))] - __align: [::c_long; 0], - #[cfg(not(any(target_arch = "arm", - all(target_arch = "x86_64", - target_pointer_width = "32"))))] - __align: [::c_longlong; 0], - size: [u8; ::__SIZEOF_PTHREAD_MUTEX_T], - } - - pub struct pthread_rwlock_t { - __align: [::c_long; 0], - __align: [::c_longlong; 0], - size: [u8; ::__SIZEOF_PTHREAD_RWLOCK_T], - } - - pub struct pthread_cond_t { - __align: [*const ::c_void; 0], - #[cfg(not(target_env = "musl"))] - __align: [::c_longlong; 0], - size: [u8; ::__SIZEOF_PTHREAD_COND_T], - } - } - - cfg_if! { - if #[cfg(feature = "extra_traits")] { - impl PartialEq for pthread_cond_t { - fn eq(&self, other: &pthread_cond_t) -> bool { - // Ignore __align field - self.size - .iter() - .zip(other.size.iter()) - .all(|(a,b)| a == b) - } - } - impl Eq for pthread_cond_t {} - impl ::fmt::Debug for pthread_cond_t { - fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { - f.debug_struct("pthread_cond_t") - // Ignore __align field - // FIXME: .field("size", &self.size) - .finish() - } - } - impl ::hash::Hash for pthread_cond_t { - fn hash(&self, state: &mut H) { - // Ignore __align field - self.size.hash(state); - } - } - - impl PartialEq for pthread_mutex_t { - fn eq(&self, other: &pthread_mutex_t) -> bool { - // Ignore __align field - self.size - .iter() - .zip(other.size.iter()) - .all(|(a,b)| a == b) - } - } - impl Eq for pthread_mutex_t {} - impl ::fmt::Debug for pthread_mutex_t { - fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { - f.debug_struct("pthread_mutex_t") - // Ignore __align field - // FIXME: .field("size", &self.size) - .finish() - } - } - impl ::hash::Hash for pthread_mutex_t { - fn hash(&self, state: &mut H) { - // Ignore __align field - self.size.hash(state); - } - } - - impl PartialEq for pthread_rwlock_t { - fn eq(&self, other: &pthread_rwlock_t) -> bool { - // Ignore __align field - self.size - .iter() - .zip(other.size.iter()) - .all(|(a,b)| a == b) - } - } - impl Eq for pthread_rwlock_t {} - impl ::fmt::Debug for pthread_rwlock_t { - fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { - f.debug_struct("pthread_rwlock_t") - // Ignore __align field - // FIXME: .field("size", &self.size) - .finish() - } - } - impl ::hash::Hash for pthread_rwlock_t { - fn hash(&self, state: &mut H) { - // Ignore __align field - self.size.hash(state); - } - } - } - } - }; -} diff --git a/src/lib.rs b/src/lib.rs index 764d8e4cd096a..c7cc8fed29b6a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -43,52 +43,25 @@ cfg_if! { } } -cfg_if! { - if #[cfg(libc_priv_mod_use)] { - #[cfg(libc_core_cvoid)] - #[allow(unused_imports)] - use core::ffi; - #[allow(unused_imports)] - use core::fmt; - #[allow(unused_imports)] - use core::hash; - #[allow(unused_imports)] - use core::num; - #[allow(unused_imports)] - use core::mem; - #[doc(hidden)] - #[allow(unused_imports)] - use core::clone::Clone; - #[doc(hidden)] - #[allow(unused_imports)] - use core::marker::{Copy, Send, Sync}; - #[doc(hidden)] - #[allow(unused_imports)] - use core::option::Option; - } else { - #[doc(hidden)] - #[allow(unused_imports)] - pub use core::fmt; - #[doc(hidden)] - #[allow(unused_imports)] - pub use core::hash; - #[doc(hidden)] - #[allow(unused_imports)] - pub use core::num; - #[doc(hidden)] - #[allow(unused_imports)] - pub use core::mem; - #[doc(hidden)] - #[allow(unused_imports)] - pub use core::clone::Clone; - #[doc(hidden)] - #[allow(unused_imports)] - pub use core::marker::{Copy, Send, Sync}; - #[doc(hidden)] - #[allow(unused_imports)] - pub use core::option::Option; - } -} +#[doc(hidden)] +#[allow(unused_imports)] +use core::clone::Clone; +#[allow(unused_imports)] +use core::ffi; +#[allow(unused_imports)] +use core::fmt; +#[allow(unused_imports)] +use core::hash; +#[doc(hidden)] +#[allow(unused_imports)] +use core::marker::{Copy, Send, Sync}; +#[allow(unused_imports)] +use core::mem; +#[allow(unused_imports)] +use core::num; +#[doc(hidden)] +#[allow(unused_imports)] +use core::option::Option; cfg_if! { if #[cfg(windows)] { diff --git a/src/macros.rs b/src/macros.rs index beb80024dbfa3..57956ccb81241 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -90,19 +90,15 @@ macro_rules! s_no_extra_traits { s_no_extra_traits!(it: $(#[$attr])* pub $t $i { $($field)* }); )*); (it: $(#[$attr:meta])* pub union $i:ident { $($field:tt)* }) => ( - cfg_if! { - if #[cfg(libc_union)] { - __item! { - #[repr(C)] - $(#[$attr])* - pub union $i { $($field)* } - } + __item! { + #[repr(C)] + $(#[$attr])* + pub union $i { $($field)* } + } - impl ::Copy for $i {} - impl ::Clone for $i { - fn clone(&self) -> $i { *self } - } - } + impl ::Copy for $i {} + impl ::Clone for $i { + fn clone(&self) -> $i { *self } } ); (it: $(#[$attr:meta])* pub struct $i:ident { $($field:tt)* }) => ( @@ -286,16 +282,9 @@ macro_rules! align_const { ($($(#[$attr:meta])* pub const $name:ident : $t1:ty = $t2:ident { $($field:tt)* };)*) => ($( - #[cfg(libc_align)] - $(#[$attr])* - pub const $name : $t1 = $t2 { - $($field)* - }; - #[cfg(not(libc_align))] $(#[$attr])* pub const $name : $t1 = $t2 { $($field)* - __align: [], }; )*) } diff --git a/src/psp.rs b/src/psp.rs index a4ca029b6e0c1..2e0cabf9cd7d6 100644 --- a/src/psp.rs +++ b/src/psp.rs @@ -27,25 +27,7 @@ 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 use ffi::c_void; pub type SceKernelVTimerHandler = unsafe extern "C" fn( uid: SceUid, diff --git a/src/sgx.rs b/src/sgx.rs index 7da6269399d9e..09cc33eb73589 100644 --- a/src/sgx.rs +++ b/src/sgx.rs @@ -26,22 +26,4 @@ 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, - } - } -} +pub use ffi::c_void; diff --git a/src/solid/mod.rs b/src/solid/mod.rs index f0f2ae89bde90..c88c663ee3f8c 100644 --- a/src/solid/mod.rs +++ b/src/solid/mod.rs @@ -871,25 +871,7 @@ 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, - } - } -} +pub use ffi::c_void; cfg_if! { if #[cfg(target_arch = "aarch64")] { diff --git a/src/switch.rs b/src/switch.rs index 030ab20d7bd8e..1e8962823af84 100644 --- a/src/switch.rs +++ b/src/switch.rs @@ -28,22 +28,4 @@ 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, - } - } -} +pub use ffi::c_void; diff --git a/src/unix/aix/mod.rs b/src/unix/aix/mod.rs index c072ae55e5836..ebe81d87c854c 100644 --- a/src/unix/aix/mod.rs +++ b/src/unix/aix/mod.rs @@ -534,20 +534,17 @@ s! { } s_no_extra_traits! { - #[cfg(libc_union)] pub union __sigaction_sa_union { pub __su_handler: extern fn(c: ::c_int), pub __su_sigaction: extern fn(c: ::c_int, info: *mut siginfo_t, ptr: *mut ::c_void), } pub struct sigaction { - #[cfg(libc_union)] pub sa_union: __sigaction_sa_union, pub sa_mask: sigset_t, pub sa_flags: ::c_int, } - #[cfg(libc_union)] pub union __poll_ctl_ext_u { pub addr: *mut ::c_void, pub data32: u32, @@ -559,7 +556,6 @@ s_no_extra_traits! { pub command: u8, pub events: ::c_short, pub fd: ::c_int, - #[cfg(libc_union)] pub u: __poll_ctl_ext_u, pub reversed64: [u64; 6], } @@ -567,7 +563,6 @@ s_no_extra_traits! { cfg_if! { if #[cfg(feature = "extra_traits")] { - #[cfg(libc_union)] impl PartialEq for __sigaction_sa_union { fn eq(&self, other: &__sigaction_sa_union) -> bool { unsafe { @@ -576,9 +571,7 @@ cfg_if! { } } } - #[cfg(libc_union)] impl Eq for __sigaction_sa_union {} - #[cfg(libc_union)] impl ::fmt::Debug for __sigaction_sa_union { fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { f.debug_struct("__sigaction_sa_union") @@ -587,7 +580,6 @@ cfg_if! { .finish() } } - #[cfg(libc_union)] impl ::hash::Hash for __sigaction_sa_union { fn hash(&self, state: &mut H) { unsafe { @@ -599,20 +591,15 @@ cfg_if! { impl PartialEq for sigaction { fn eq(&self, other: &sigaction) -> bool { - #[cfg(libc_union)] - let union_eq = self.sa_union == other.sa_union; - #[cfg(not(libc_union))] - let union_eq = true; self.sa_mask == other.sa_mask && self.sa_flags == other.sa_flags - && union_eq + && self.sa_union == other.sa_union } } impl Eq for sigaction {} impl ::fmt::Debug for sigaction { fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { let mut struct_formatter = f.debug_struct("sigaction"); - #[cfg(libc_union)] struct_formatter.field("sa_union", &self.sa_union); struct_formatter.field("sa_mask", &self.sa_mask); struct_formatter.field("sa_flags", &self.sa_flags); @@ -621,14 +608,12 @@ cfg_if! { } impl ::hash::Hash for sigaction { fn hash(&self, state: &mut H) { - #[cfg(libc_union)] self.sa_union.hash(state); self.sa_mask.hash(state); self.sa_flags.hash(state); } } - #[cfg(libc_union)] impl PartialEq for __poll_ctl_ext_u { fn eq(&self, other: &__poll_ctl_ext_u) -> bool { unsafe { @@ -638,9 +623,7 @@ cfg_if! { } } } - #[cfg(libc_union)] impl Eq for __poll_ctl_ext_u {} - #[cfg(libc_union)] impl ::fmt::Debug for __poll_ctl_ext_u { fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { f.debug_struct("__poll_ctl_ext_u") @@ -650,7 +633,6 @@ cfg_if! { .finish() } } - #[cfg(libc_union)] impl ::hash::Hash for __poll_ctl_ext_u { fn hash(&self, state: &mut H) { unsafe { @@ -663,16 +645,12 @@ cfg_if! { impl PartialEq for poll_ctl_ext { fn eq(&self, other: &poll_ctl_ext) -> bool { - #[cfg(libc_union)] - let union_eq = self.u == other.u; - #[cfg(not(libc_union))] - let union_eq = true; self.version == other.version && self.command == other.command && self.events == other.events && self.fd == other.fd && self.reversed64 == other.reversed64 - && union_eq + && self.u == other.u } } impl Eq for poll_ctl_ext {} @@ -683,7 +661,6 @@ cfg_if! { struct_formatter.field("command", &self.command); struct_formatter.field("events", &self.events); struct_formatter.field("fd", &self.fd); - #[cfg(libc_union)] struct_formatter.field("u", &self.u); struct_formatter.field("reversed64", &self.reversed64); struct_formatter.finish() @@ -695,7 +672,6 @@ cfg_if! { self.command.hash(state); self.events.hash(state); self.fd.hash(state); - #[cfg(libc_union)] self.u.hash(state); self.reversed64.hash(state); } diff --git a/src/unix/aix/powerpc64.rs b/src/unix/aix/powerpc64.rs index 2cacf29f6b418..deec291b28dca 100644 --- a/src/unix/aix/powerpc64.rs +++ b/src/unix/aix/powerpc64.rs @@ -199,7 +199,6 @@ s_no_extra_traits! { pub __pad: [::c_int; 3], } - #[cfg(libc_union)] pub union _kernel_simple_lock { pub _slock: ::c_long, // Should be pointer to 'lock_data_instrumented' @@ -228,9 +227,7 @@ s_no_extra_traits! { pub f_dir_off: ::c_long, // Should be pointer to 'cred' pub f_cred: *mut ::c_void, - #[cfg(libc_union)] pub f_lock: _kernel_simple_lock, - #[cfg(libc_union)] pub f_offset_lock: _kernel_simple_lock, pub f_vinfo: ::caddr_t, pub f_ops: *mut fileops_t, @@ -239,7 +236,6 @@ s_no_extra_traits! { pub f_fdata: [::c_char; 160], } - #[cfg(libc_union)] pub union __ld_info_file { pub _ldinfo_fd: ::c_int, pub _ldinfo_fp: *mut file, @@ -249,7 +245,6 @@ s_no_extra_traits! { pub struct ld_info { pub ldinfo_next: ::c_uint, pub ldinfo_flags: ::c_uint, - #[cfg(libc_union)] pub _file: __ld_info_file, pub ldinfo_textorg: *mut ::c_void, pub ldinfo_textsize: ::c_ulong, @@ -258,7 +253,6 @@ s_no_extra_traits! { pub ldinfo_filename: [::c_char; 2], } - #[cfg(libc_union)] pub union __pollfd_ext_u { pub addr: *mut ::c_void, pub data32: u32, @@ -269,7 +263,6 @@ s_no_extra_traits! { pub fd: ::c_int, pub events: ::c_ushort, pub revents: ::c_ushort, - #[cfg(libc_union)] pub data: __pollfd_ext_u, } } @@ -300,10 +293,6 @@ cfg_if! { if #[cfg(feature = "extra_traits")] { impl PartialEq for siginfo_t { fn eq(&self, other: &siginfo_t) -> bool { - #[cfg(libc_union)] - let value_eq = self.si_value == other.si_value; - #[cfg(not(libc_union))] - let value_eq = true; self.si_signo == other.si_signo && self.si_errno == other.si_errno && self.si_code == other.si_code @@ -313,7 +302,7 @@ cfg_if! { && self.si_addr == other.si_addr && self.si_band == other.si_band && self.__si_flags == other.__si_flags - && value_eq + && self.si_value == other.si_value } } impl Eq for siginfo_t {} @@ -328,7 +317,6 @@ cfg_if! { struct_formatter.field("si_status", &self.si_status); struct_formatter.field("si_addr", &self.si_addr); struct_formatter.field("si_band", &self.si_band); - #[cfg(libc_union)] struct_formatter.field("si_value", &self.si_value); struct_formatter.field("__si_flags", &self.__si_flags); struct_formatter.finish() @@ -344,13 +332,11 @@ cfg_if! { self.si_status.hash(state); self.si_addr.hash(state); self.si_band.hash(state); - #[cfg(libc_union)] self.si_value.hash(state); self.__si_flags.hash(state); } } - #[cfg(libc_union)] impl PartialEq for _kernel_simple_lock { fn eq(&self, other: &_kernel_simple_lock) -> bool { unsafe { @@ -359,9 +345,7 @@ cfg_if! { } } } - #[cfg(libc_union)] impl Eq for _kernel_simple_lock {} - #[cfg(libc_union)] impl ::fmt::Debug for _kernel_simple_lock { fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { f.debug_struct("_kernel_simple_lock") @@ -370,7 +354,6 @@ cfg_if! { .finish() } } - #[cfg(libc_union)] impl ::hash::Hash for _kernel_simple_lock { fn hash(&self, state: &mut H) { unsafe { @@ -413,11 +396,6 @@ cfg_if! { impl PartialEq for file { fn eq(&self, other: &file) -> bool { - #[cfg(libc_union)] - let lock_eq = self.f_lock == other.f_lock - && self.f_offset_lock == other.f_offset_lock; - #[cfg(not(libc_union))] - let lock_eq = true; self.f_flag == other.f_flag && self.f_count == other.f_count && self.f_options == other.f_options @@ -431,7 +409,8 @@ cfg_if! { && self.f_parentp == other.f_parentp && self.f_fnamep == other.f_fnamep && self.f_fdata == other.f_fdata - && lock_eq + && self.f_lock == other.f_lock + && self.f_offset_lock == other.f_offset_lock } } impl Eq for file {} @@ -446,9 +425,7 @@ cfg_if! { struct_formatter.field("f_offset", &self.f_offset); struct_formatter.field("f_dir_off", &self.f_dir_off); struct_formatter.field("f_cred", &self.f_cred); - #[cfg(libc_union)] struct_formatter.field("f_lock", &self.f_lock); - #[cfg(libc_union)] struct_formatter.field("f_offset_lock", &self.f_offset_lock); struct_formatter.field("f_vinfo", &self.f_vinfo); struct_formatter.field("f_ops", &self.f_ops); @@ -468,9 +445,7 @@ cfg_if! { self.f_offset.hash(state); self.f_dir_off.hash(state); self.f_cred.hash(state); - #[cfg(libc_union)] self.f_lock.hash(state); - #[cfg(libc_union)] self.f_offset_lock.hash(state); self.f_vinfo.hash(state); self.f_ops.hash(state); @@ -480,7 +455,6 @@ cfg_if! { } } - #[cfg(libc_union)] impl PartialEq for __ld_info_file { fn eq(&self, other: &__ld_info_file) -> bool { unsafe { @@ -490,9 +464,7 @@ cfg_if! { } } } - #[cfg(libc_union)] impl Eq for __ld_info_file {} - #[cfg(libc_union)] impl ::fmt::Debug for __ld_info_file { fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { f.debug_struct("__ld_info_file") @@ -502,7 +474,6 @@ cfg_if! { .finish() } } - #[cfg(libc_union)] impl ::hash::Hash for __ld_info_file { fn hash(&self, state: &mut H) { unsafe { @@ -515,10 +486,6 @@ cfg_if! { impl PartialEq for ld_info { fn eq(&self, other: &ld_info) -> bool { - #[cfg(libc_union)] - let file_eq = self._file == other._file; - #[cfg(not(libc_union))] - let file_eq = true; self.ldinfo_next == other.ldinfo_next && self.ldinfo_flags == other.ldinfo_flags && self.ldinfo_textorg == other.ldinfo_textorg @@ -526,7 +493,7 @@ cfg_if! { && self.ldinfo_dataorg == other.ldinfo_dataorg && self.ldinfo_datasize == other.ldinfo_datasize && self.ldinfo_filename == other.ldinfo_filename - && file_eq + && self._file == other._file } } impl Eq for ld_info {} @@ -540,7 +507,6 @@ cfg_if! { struct_formatter.field("ldinfo_dataorg", &self.ldinfo_dataorg); struct_formatter.field("ldinfo_datasize", &self.ldinfo_datasize); struct_formatter.field("ldinfo_filename", &self.ldinfo_filename); - #[cfg(libc_union)] struct_formatter.field("_file", &self._file); struct_formatter.finish() } @@ -554,12 +520,10 @@ cfg_if! { self.ldinfo_dataorg.hash(state); self.ldinfo_datasize.hash(state); self.ldinfo_filename.hash(state); - #[cfg(libc_union)] self._file.hash(state); } } - #[cfg(libc_union)] impl PartialEq for __pollfd_ext_u { fn eq(&self, other: &__pollfd_ext_u) -> bool { unsafe { @@ -569,9 +533,7 @@ cfg_if! { } } } - #[cfg(libc_union)] impl Eq for __pollfd_ext_u {} - #[cfg(libc_union)] impl ::fmt::Debug for __pollfd_ext_u { fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { f.debug_struct("__pollfd_ext_u") @@ -581,7 +543,6 @@ cfg_if! { .finish() } } - #[cfg(libc_union)] impl ::hash::Hash for __pollfd_ext_u { fn hash(&self, state: &mut H) { unsafe { @@ -594,14 +555,10 @@ cfg_if! { impl PartialEq for pollfd_ext { fn eq(&self, other: &pollfd_ext) -> bool { - #[cfg(libc_union)] - let data_eq = self.data == other.data; - #[cfg(not(libc_union))] - let data_eq = true; self.fd == other.fd && self.events == other.events && self.revents == other.revents - && data_eq + && self.data == other.data } } impl Eq for pollfd_ext {} @@ -611,7 +568,6 @@ cfg_if! { struct_formatter.field("fd", &self.fd); struct_formatter.field("events", &self.events); struct_formatter.field("revents", &self.revents); - #[cfg(libc_union)] struct_formatter.field("data", &self.data); struct_formatter.finish() } @@ -621,7 +577,6 @@ cfg_if! { self.fd.hash(state); self.events.hash(state); self.revents.hash(state); - #[cfg(libc_union)] self.data.hash(state); } } diff --git a/src/unix/bsd/apple/b32/mod.rs b/src/unix/bsd/apple/b32/mod.rs index 0f1722f975744..4707fa4c99991 100644 --- a/src/unix/bsd/apple/b32/mod.rs +++ b/src/unix/bsd/apple/b32/mod.rs @@ -111,9 +111,5 @@ extern "C" { ) -> ::c_int; } -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; - } -} +mod align; +pub use self::align::*; diff --git a/src/unix/bsd/apple/b64/aarch64/align.rs b/src/unix/bsd/apple/b64/aarch64/align.rs index 131e15b69ad94..7f86a134649cf 100644 --- a/src/unix/bsd/apple/b64/aarch64/align.rs +++ b/src/unix/bsd/apple/b64/aarch64/align.rs @@ -39,16 +39,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, } diff --git a/src/unix/bsd/apple/b64/aarch64/mod.rs b/src/unix/bsd/apple/b64/aarch64/mod.rs index 79e9ac842f9ca..a32abf17008fd 100644 --- a/src/unix/bsd/apple/b64/aarch64/mod.rs +++ b/src/unix/bsd/apple/b64/aarch64/mod.rs @@ -6,9 +6,5 @@ s! { } } -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; - } -} +mod align; +pub use self::align::*; diff --git a/src/unix/bsd/apple/b64/x86_64/mod.rs b/src/unix/bsd/apple/b64/x86_64/mod.rs index 653650c26289f..a15d6cfe47c31 100644 --- a/src/unix/bsd/apple/b64/x86_64/mod.rs +++ b/src/unix/bsd/apple/b64/x86_64/mod.rs @@ -172,9 +172,5 @@ s! { } } -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; - } -} +mod align; +pub use self::align::*; diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index 92d724071a3d4..ac5fcf43c76a6 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -1140,13 +1140,10 @@ s! { #[cfg_attr(libc_packedN, repr(packed(4)))] pub struct ifconf { pub ifc_len: ::c_int, - #[cfg(libc_union)] pub ifc_ifcu: __c_anonymous_ifc_ifcu, - #[cfg(not(libc_union))] - pub ifc_ifcu: *mut ifreq, } - #[cfg_attr(libc_align, repr(align(8)))] + #[repr(align(8))] pub struct tcp_connection_info { pub tcpi_state: u8, pub tcpi_snd_wscale: u8, @@ -1485,7 +1482,6 @@ s_no_extra_traits! { pub ifdm_max: ::c_int, } - #[cfg(libc_union)] pub union __c_anonymous_ifk_data { pub ifk_ptr: *mut ::c_void, pub ifk_value: ::c_int, @@ -1495,11 +1491,9 @@ s_no_extra_traits! { pub struct ifkpi { pub ifk_module_id: ::c_uint, pub ifk_type: ::c_uint, - #[cfg(libc_union)] pub ifk_data: __c_anonymous_ifk_data, } - #[cfg(libc_union)] pub union __c_anonymous_ifr_ifru { pub ifru_addr: ::sockaddr, pub ifru_dstaddr: ::sockaddr, @@ -1521,13 +1515,9 @@ s_no_extra_traits! { pub struct ifreq { pub ifr_name: [::c_char; ::IFNAMSIZ], - #[cfg(libc_union)] pub ifr_ifru: __c_anonymous_ifr_ifru, - #[cfg(not(libc_union))] - pub ifr_ifru: ::sockaddr, } - #[cfg(libc_union)] pub union __c_anonymous_ifc_ifcu { pub ifcu_buf: *mut ::c_char, pub ifcu_req: *mut ifreq, @@ -1568,37 +1558,33 @@ impl siginfo_t { } } +s_no_extra_traits! { + pub union semun { + pub val: ::c_int, + pub buf: *mut semid_ds, + pub array: *mut ::c_ushort, + } +} + cfg_if! { - if #[cfg(libc_union)] { - s_no_extra_traits! { - pub union semun { - pub val: ::c_int, - pub buf: *mut semid_ds, - pub array: *mut ::c_ushort, + if #[cfg(feature = "extra_traits")] { + impl PartialEq for semun { + fn eq(&self, other: &semun) -> bool { + unsafe { self.val == other.val } } } - - cfg_if! { - if #[cfg(feature = "extra_traits")] { - impl PartialEq for semun { - fn eq(&self, other: &semun) -> bool { - unsafe { self.val == other.val } - } - } - impl Eq for semun {} - impl ::fmt::Debug for semun { - fn fmt(&self, f: &mut ::fmt::Formatter) - -> ::fmt::Result { - f.debug_struct("semun") - .field("val", unsafe { &self.val }) - .finish() - } - } - impl ::hash::Hash for semun { - fn hash(&self, state: &mut H) { - unsafe { self.val.hash(state) }; - } - } + impl Eq for semun {} + impl ::fmt::Debug for semun { + fn fmt(&self, f: &mut ::fmt::Formatter) + -> ::fmt::Result { + f.debug_struct("semun") + .field("val", unsafe { &self.val }) + .finish() + } + } + impl ::hash::Hash for semun { + fn hash(&self, state: &mut H) { + unsafe { self.val.hash(state) }; } } } @@ -2909,7 +2895,6 @@ cfg_if! { } } - #[cfg(libc_union)] impl PartialEq for __c_anonymous_ifk_data { fn eq(&self, other: &__c_anonymous_ifk_data) -> bool { unsafe { @@ -2919,10 +2904,8 @@ cfg_if! { } } - #[cfg(libc_union)] impl Eq for __c_anonymous_ifk_data {} - #[cfg(libc_union)] impl ::fmt::Debug for __c_anonymous_ifk_data { fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { f.debug_struct("__c_anonymous_ifk_data") @@ -2931,7 +2914,6 @@ cfg_if! { .finish() } } - #[cfg(libc_union)] impl ::hash::Hash for __c_anonymous_ifk_data { fn hash(&self, state: &mut H) { unsafe { @@ -2966,7 +2948,6 @@ cfg_if! { } } - #[cfg(libc_union)] impl PartialEq for __c_anonymous_ifr_ifru { fn eq(&self, other: &__c_anonymous_ifr_ifru) -> bool { unsafe { @@ -2990,10 +2971,8 @@ cfg_if! { } } - #[cfg(libc_union)] impl Eq for __c_anonymous_ifr_ifru {} - #[cfg(libc_union)] impl ::fmt::Debug for __c_anonymous_ifr_ifru { fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { f.debug_struct("__c_anonymous_ifr_ifru") @@ -3017,7 +2996,6 @@ cfg_if! { } } - #[cfg(libc_union)] impl ::hash::Hash for __c_anonymous_ifr_ifru { fn hash(&self, state: &mut H) { unsafe { @@ -3066,10 +3044,8 @@ cfg_if! { } } - #[cfg(libc_union)] impl Eq for __c_anonymous_ifc_ifcu {} - #[cfg(libc_union)] impl PartialEq for __c_anonymous_ifc_ifcu { fn eq(&self, other: &__c_anonymous_ifc_ifcu) -> bool { unsafe { @@ -3079,7 +3055,6 @@ cfg_if! { } } - #[cfg(libc_union)] impl ::fmt::Debug for __c_anonymous_ifc_ifcu { fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { f.debug_struct("ifc_ifcu") @@ -3089,7 +3064,6 @@ cfg_if! { } } - #[cfg(libc_union)] impl ::hash::Hash for __c_anonymous_ifc_ifcu { fn hash(&self, state: &mut H) { unsafe { self.ifcu_buf.hash(state) }; @@ -5488,76 +5462,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 e8be8815c028e..d240eb001ad5d 100644 --- a/src/unix/bsd/freebsdlike/freebsd/aarch64.rs +++ b/src/unix/bsd/freebsdlike/freebsd/aarch64.rs @@ -33,16 +33,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 300b3dd45ca9d..af3c8a7cf6f6c 100644 --- a/src/unix/bsd/freebsdlike/freebsd/arm.rs +++ b/src/unix/bsd/freebsdlike/freebsd/arm.rs @@ -36,15 +36,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_int>() - 1; - } else { - #[doc(hidden)] - pub const _ALIGNBYTES: usize = 4 - 1; - } -} +pub(crate) const _ALIGNBYTES: usize = ::mem::size_of::<::c_int>() - 1; pub const MAP_32BIT: ::c_int = 0x00080000; pub const MINSIGSTKSZ: ::size_t = 4096; // 1024 * 4 diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs index 47b4bd36e6d02..13ac54a432968 100644 --- a/src/unix/bsd/freebsdlike/freebsd/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs @@ -971,10 +971,7 @@ s! { pub struct ifconf { pub ifc_len: ::c_int, - #[cfg(libc_union)] pub ifc_ifcu: __c_anonymous_ifc_ifcu, - #[cfg(not(libc_union))] - pub ifc_ifcu: *mut ifreq, } pub struct au_mask_t { @@ -1359,7 +1356,6 @@ s_no_extra_traits! { pub __ut_spare: [::c_char; 64], } - #[cfg(libc_union)] pub union __c_anonymous_cr_pid { __cr_unused: *mut ::c_void, pub cr_pid: ::pid_t, @@ -1370,10 +1366,7 @@ s_no_extra_traits! { pub cr_uid: ::uid_t, pub cr_ngroups: ::c_short, pub cr_groups: [::gid_t; 16], - #[cfg(libc_union)] pub cr_pid__c_anonymous_union: __c_anonymous_cr_pid, - #[cfg(not(libc_union))] - __cr_unused1: *mut ::c_void, } pub struct sockaddr_dl { @@ -1415,24 +1408,20 @@ s_no_extra_traits! { pub devname: [::c_char; SPECNAMELEN as usize + 1], } - #[cfg(libc_union)] pub union __c_anonymous_elf32_auxv_union { pub a_val: ::c_int, } pub struct Elf32_Auxinfo { pub a_type: ::c_int, - #[cfg(libc_union)] pub a_un: __c_anonymous_elf32_auxv_union, } - #[cfg(libc_union)] pub union __c_anonymous_ifi_epoch { pub tt: ::time_t, pub ph: u64, } - #[cfg(libc_union)] pub union __c_anonymous_ifi_lastchange { pub tv: ::timeval, pub ph: __c_anonymous_ph, @@ -1486,20 +1475,11 @@ s_no_extra_traits! { /// HW offload capabilities, see IFCAP pub ifi_hwassist: u64, /// uptime at attach or stat reset - #[cfg(libc_union)] pub __ifi_epoch: __c_anonymous_ifi_epoch, - /// uptime at attach or stat reset - #[cfg(not(libc_union))] - pub __ifi_epoch: u64, /// time of last administrative change - #[cfg(libc_union)] pub __ifi_lastchange: __c_anonymous_ifi_lastchange, - /// time of last administrative change - #[cfg(not(libc_union))] - pub __ifi_lastchange: ::timeval, } - #[cfg(libc_union)] pub union __c_anonymous_ifr_ifru { pub ifru_addr: ::sockaddr, pub ifru_dstaddr: ::sockaddr, @@ -1521,13 +1501,9 @@ s_no_extra_traits! { pub struct ifreq { /// if name, e.g. "en0" pub ifr_name: [::c_char; ::IFNAMSIZ], - #[cfg(libc_union)] pub ifr_ifru: __c_anonymous_ifr_ifru, - #[cfg(not(libc_union))] - pub ifr_ifru: ::sockaddr, } - #[cfg(libc_union)] pub union __c_anonymous_ifc_ifcu { pub ifcu_buf: ::caddr_t, pub ifcu_req: *mut ifreq, @@ -1706,15 +1682,12 @@ cfg_if! { } } - #[cfg(libc_union)] impl PartialEq for __c_anonymous_cr_pid { fn eq(&self, other: &__c_anonymous_cr_pid) -> bool { unsafe { self.cr_pid == other.cr_pid} } } - #[cfg(libc_union)] impl Eq for __c_anonymous_cr_pid {} - #[cfg(libc_union)] impl ::fmt::Debug for __c_anonymous_cr_pid { fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { f.debug_struct("cr_pid") @@ -1722,7 +1695,6 @@ cfg_if! { .finish() } } - #[cfg(libc_union)] impl ::hash::Hash for __c_anonymous_cr_pid { fn hash(&self, state: &mut H) { unsafe { self.cr_pid.hash(state) }; @@ -1731,17 +1703,12 @@ cfg_if! { impl PartialEq for xucred { fn eq(&self, other: &xucred) -> bool { - #[cfg(libc_union)] - let equal_cr_pid = self.cr_pid__c_anonymous_union - == other.cr_pid__c_anonymous_union; - #[cfg(not(libc_union))] - let equal_cr_pid = self.__cr_unused1 == other.__cr_unused1; - self.cr_version == other.cr_version && self.cr_uid == other.cr_uid && self.cr_ngroups == other.cr_ngroups && self.cr_groups == other.cr_groups - && equal_cr_pid + && self.cr_pid__c_anonymous_union + == other.cr_pid__c_anonymous_union } } impl Eq for xucred {} @@ -1752,7 +1719,6 @@ cfg_if! { struct_formatter.field("cr_uid", &self.cr_uid); struct_formatter.field("cr_ngroups", &self.cr_ngroups); struct_formatter.field("cr_groups", &self.cr_groups); - #[cfg(libc_union)] struct_formatter.field( "cr_pid__c_anonymous_union", &self.cr_pid__c_anonymous_union @@ -1766,10 +1732,7 @@ cfg_if! { self.cr_uid.hash(state); self.cr_ngroups.hash(state); self.cr_groups.hash(state); - #[cfg(libc_union)] self.cr_pid__c_anonymous_union.hash(state); - #[cfg(not(libc_union))] - self.__cr_unused1.hash(state); } } @@ -1903,15 +1866,12 @@ cfg_if! { } } - #[cfg(libc_union)] impl PartialEq for __c_anonymous_elf32_auxv_union { fn eq(&self, other: &__c_anonymous_elf32_auxv_union) -> bool { unsafe { self.a_val == other.a_val} } } - #[cfg(libc_union)] impl Eq for __c_anonymous_elf32_auxv_union {} - #[cfg(libc_union)] impl ::fmt::Debug for __c_anonymous_elf32_auxv_union { fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { f.debug_struct("a_val") @@ -1919,13 +1879,6 @@ cfg_if! { .finish() } } - #[cfg(not(libc_union))] - impl PartialEq for Elf32_Auxinfo { - fn eq(&self, other: &Elf32_Auxinfo) -> bool { - self.a_type == other.a_type - } - } - #[cfg(libc_union)] impl PartialEq for Elf32_Auxinfo { fn eq(&self, other: &Elf32_Auxinfo) -> bool { self.a_type == other.a_type @@ -1933,15 +1886,6 @@ cfg_if! { } } impl Eq for Elf32_Auxinfo {} - #[cfg(not(libc_union))] - impl ::fmt::Debug for Elf32_Auxinfo { - fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { - f.debug_struct("Elf32_Auxinfo") - .field("a_type", &self.a_type) - .finish() - } - } - #[cfg(libc_union)] impl ::fmt::Debug for Elf32_Auxinfo { fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { f.debug_struct("Elf32_Auxinfo") @@ -1951,7 +1895,6 @@ cfg_if! { } } - #[cfg(libc_union)] impl PartialEq for __c_anonymous_ifr_ifru { fn eq(&self, other: &__c_anonymous_ifr_ifru) -> bool { unsafe { @@ -1973,9 +1916,7 @@ cfg_if! { } } } - #[cfg(libc_union)] impl Eq for __c_anonymous_ifr_ifru {} - #[cfg(libc_union)] impl ::fmt::Debug for __c_anonymous_ifr_ifru { fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { f.debug_struct("ifr_ifru") @@ -1997,7 +1938,6 @@ cfg_if! { .finish() } } - #[cfg(libc_union)] impl ::hash::Hash for __c_anonymous_ifr_ifru { fn hash(&self, state: &mut H) { unsafe { self.ifru_addr.hash(state) }; @@ -2039,10 +1979,8 @@ cfg_if! { } } - #[cfg(libc_union)] impl Eq for __c_anonymous_ifc_ifcu {} - #[cfg(libc_union)] impl PartialEq for __c_anonymous_ifc_ifcu { fn eq(&self, other: &__c_anonymous_ifc_ifcu) -> bool { unsafe { @@ -2052,7 +1990,6 @@ cfg_if! { } } - #[cfg(libc_union)] impl ::fmt::Debug for __c_anonymous_ifc_ifcu { fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { f.debug_struct("ifc_ifcu") @@ -2062,7 +1999,6 @@ cfg_if! { } } - #[cfg(libc_union)] impl ::hash::Hash for __c_anonymous_ifc_ifcu { fn hash(&self, state: &mut H) { unsafe { self.ifcu_buf.hash(state) }; @@ -2165,7 +2101,6 @@ cfg_if! { } } - #[cfg(libc_union)] impl PartialEq for __c_anonymous_ifi_epoch { fn eq(&self, other: &__c_anonymous_ifi_epoch) -> bool { unsafe { @@ -2174,9 +2109,7 @@ cfg_if! { } } } - #[cfg(libc_union)] impl Eq for __c_anonymous_ifi_epoch {} - #[cfg(libc_union)] impl ::fmt::Debug for __c_anonymous_ifi_epoch { fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { f.debug_struct("__c_anonymous_ifi_epoch") @@ -2185,7 +2118,6 @@ cfg_if! { .finish() } } - #[cfg(libc_union)] impl ::hash::Hash for __c_anonymous_ifi_epoch { fn hash(&self, state: &mut H) { unsafe { @@ -2195,7 +2127,6 @@ cfg_if! { } } - #[cfg(libc_union)] impl PartialEq for __c_anonymous_ifi_lastchange { fn eq(&self, other: &__c_anonymous_ifi_lastchange) -> bool { unsafe { @@ -2204,9 +2135,7 @@ cfg_if! { } } } - #[cfg(libc_union)] impl Eq for __c_anonymous_ifi_lastchange {} - #[cfg(libc_union)] impl ::fmt::Debug for __c_anonymous_ifi_lastchange { fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { f.debug_struct("__c_anonymous_ifi_lastchange") @@ -2215,7 +2144,6 @@ cfg_if! { .finish() } } - #[cfg(libc_union)] impl ::hash::Hash for __c_anonymous_ifi_lastchange { fn hash(&self, state: &mut H) { unsafe { diff --git a/src/unix/bsd/freebsdlike/freebsd/powerpc.rs b/src/unix/bsd/freebsdlike/freebsd/powerpc.rs index a0120c337e0ad..e38f88dc77fbc 100644 --- a/src/unix/bsd/freebsdlike/freebsd/powerpc.rs +++ b/src/unix/bsd/freebsdlike/freebsd/powerpc.rs @@ -32,16 +32,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_int>() - 1; - } else { - #[doc(hidden)] - pub const _ALIGNBYTES: usize = 4 - 1; - } -} +pub(crate) const _ALIGNBYTES: usize = ::mem::size_of::<::c_int>() - 1; pub const MAP_32BIT: ::c_int = 0x00080000; pub const MINSIGSTKSZ: ::size_t = 2048; // 512 * 4 diff --git a/src/unix/bsd/freebsdlike/freebsd/powerpc64.rs b/src/unix/bsd/freebsdlike/freebsd/powerpc64.rs index 7f5b9752264e3..07f2f11cdc9a4 100644 --- a/src/unix/bsd/freebsdlike/freebsd/powerpc64.rs +++ b/src/unix/bsd/freebsdlike/freebsd/powerpc64.rs @@ -32,16 +32,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 MAP_32BIT: ::c_int = 0x00080000; pub const MINSIGSTKSZ: ::size_t = 2048; // 512 * 4 diff --git a/src/unix/bsd/freebsdlike/freebsd/riscv64.rs b/src/unix/bsd/freebsdlike/freebsd/riscv64.rs index f9fa1c2750b22..c5ea8ee203a72 100644 --- a/src/unix/bsd/freebsdlike/freebsd/riscv64.rs +++ b/src/unix/bsd/freebsdlike/freebsd/riscv64.rs @@ -35,16 +35,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/x86.rs b/src/unix/bsd/freebsdlike/freebsd/x86.rs index c3c576ed66681..3e3e5cc9f34fb 100644 --- a/src/unix/bsd/freebsdlike/freebsd/x86.rs +++ b/src/unix/bsd/freebsdlike/freebsd/x86.rs @@ -77,16 +77,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 = 4 - 1; - } -} +pub(crate) const _ALIGNBYTES: usize = ::mem::size_of::<::c_long>() - 1; cfg_if! { if #[cfg(feature = "extra_traits")] { diff --git a/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs b/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs index fb4597927f3d6..fcb9d7e43fee1 100644 --- a/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs @@ -81,7 +81,6 @@ s_no_extra_traits! { pub xmm_pad: [u8; 224], } - #[cfg(libc_union)] pub union __c_anonymous_elf64_auxv_union { pub a_val: ::c_long, pub a_ptr: *mut ::c_void, @@ -90,7 +89,6 @@ s_no_extra_traits! { pub struct Elf64_Auxinfo { pub a_type: ::c_long, - #[cfg(libc_union)] pub a_un: __c_anonymous_elf64_auxv_union, } } @@ -187,7 +185,6 @@ cfg_if! { } } - #[cfg(libc_union)] impl PartialEq for __c_anonymous_elf64_auxv_union { fn eq(&self, other: &__c_anonymous_elf64_auxv_union) -> bool { unsafe { self.a_val == other.a_val @@ -195,9 +192,7 @@ cfg_if! { || self.a_fcn == other.a_fcn } } } - #[cfg(libc_union)] impl Eq for __c_anonymous_elf64_auxv_union {} - #[cfg(libc_union)] impl ::fmt::Debug for __c_anonymous_elf64_auxv_union { fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { f.debug_struct("a_val") @@ -205,13 +200,6 @@ cfg_if! { .finish() } } - #[cfg(not(libc_union))] - impl PartialEq for Elf64_Auxinfo { - fn eq(&self, other: &Elf64_Auxinfo) -> bool { - self.a_type == other.a_type - } - } - #[cfg(libc_union)] impl PartialEq for Elf64_Auxinfo { fn eq(&self, other: &Elf64_Auxinfo) -> bool { self.a_type == other.a_type @@ -219,15 +207,6 @@ cfg_if! { } } impl Eq for Elf64_Auxinfo {} - #[cfg(not(libc_union))] - impl ::fmt::Debug for Elf64_Auxinfo { - fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { - f.debug_struct("Elf64_Auxinfo") - .field("a_type", &self.a_type) - .finish() - } - } - #[cfg(libc_union)] impl ::fmt::Debug for Elf64_Auxinfo { fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { f.debug_struct("Elf64_Auxinfo") @@ -239,16 +218,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 MAP_32BIT: ::c_int = 0x00080000; pub const MINSIGSTKSZ: ::size_t = 2048; // 512 * 4 @@ -265,9 +235,5 @@ pub const _MC_FPOWNED_PCB: c_long = 0x20002; pub const KINFO_FILE_SIZE: ::c_int = 1392; -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; - } -} +mod align; +pub use self::align::*; diff --git a/src/unix/bsd/freebsdlike/mod.rs b/src/unix/bsd/freebsdlike/mod.rs index e0a0fbd01443f..f5780f322c847 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 45bca4778c20c..e285d0617ce20 100644 --- a/src/unix/bsd/netbsdlike/netbsd/aarch64.rs +++ b/src/unix/bsd/netbsdlike/netbsd/aarch64.rs @@ -8,7 +8,6 @@ pub type __cpu_simple_lock_nv_t = ::c_uchar; s! { pub struct __fregset { - #[cfg(libc_union)] pub __qregs: [__c_anonymous__freg; 32], pub __fpcr: u32, pub __fpsr: u32, @@ -30,7 +29,6 @@ s! { } s_no_extra_traits! { - #[cfg(libc_union)] #[repr(align(16))] pub union __c_anonymous__freg { pub __b8: [u8; 16], @@ -43,7 +41,6 @@ s_no_extra_traits! { cfg_if! { if #[cfg(feature = "extra_traits")] { - #[cfg(libc_union)] impl PartialEq for __c_anonymous__freg { fn eq(&self, other: &__c_anonymous__freg) -> bool { unsafe { @@ -55,9 +52,7 @@ cfg_if! { } } } - #[cfg(libc_union)] impl Eq for __c_anonymous__freg {} - #[cfg(libc_union)] impl ::fmt::Debug for __c_anonymous__freg { fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { unsafe { @@ -71,7 +66,6 @@ cfg_if! { } } } - #[cfg(libc_union)] impl ::hash::Hash for __c_anonymous__freg { fn hash(&self, state: &mut H) { unsafe { @@ -86,16 +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; 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/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index 0517a47b69c30..ccd01d92fb7fc 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -688,14 +688,12 @@ s! { pub struct posix_spawn_file_actions_entry_t { pub fae_action: fae_action, pub fae_fildes: ::c_int, - #[cfg(libc_union)] pub fae_data: __c_anonymous_posix_spawn_fae, } pub struct posix_spawn_file_actions_t { pub size: ::c_uint, pub len: ::c_uint, - #[cfg(libc_union)] pub fae: *mut posix_spawn_file_actions_entry_t, } @@ -734,7 +732,6 @@ s! { pub struct ifconf { pub ifc_len: ::c_int, - #[cfg(libc_union)] pub ifc_ifcu: __c_anonymous_ifc_ifcu, } @@ -893,13 +890,11 @@ s_no_extra_traits! { pub sigev_notify_attributes: *mut ::c_void } - #[cfg(libc_union)] pub union __c_anonymous_posix_spawn_fae { pub open: __c_anonymous_posix_spawn_fae_open, pub dup2: __c_anonymous_posix_spawn_fae_dup2, } - #[cfg(libc_union)] pub union __c_anonymous_ifc_ifcu { pub ifcu_buf: *mut ::c_void, pub ifcu_req: *mut ifreq, @@ -1332,10 +1327,8 @@ cfg_if! { } } - #[cfg(libc_union)] impl Eq for __c_anonymous_posix_spawn_fae {} - #[cfg(libc_union)] impl PartialEq for __c_anonymous_posix_spawn_fae { fn eq(&self, other: &__c_anonymous_posix_spawn_fae) -> bool { unsafe { @@ -1345,7 +1338,6 @@ cfg_if! { } } - #[cfg(libc_union)] impl ::fmt::Debug for __c_anonymous_posix_spawn_fae { fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { unsafe { @@ -1357,7 +1349,6 @@ cfg_if! { } } - #[cfg(libc_union)] impl ::hash::Hash for __c_anonymous_posix_spawn_fae { fn hash(&self, state: &mut H) { unsafe { @@ -1367,10 +1358,8 @@ cfg_if! { } } - #[cfg(libc_union)] impl Eq for __c_anonymous_ifc_ifcu {} - #[cfg(libc_union)] impl PartialEq for __c_anonymous_ifc_ifcu { fn eq(&self, other: &__c_anonymous_ifc_ifcu) -> bool { unsafe { @@ -1380,7 +1369,6 @@ cfg_if! { } } - #[cfg(libc_union)] impl ::fmt::Debug for __c_anonymous_ifc_ifcu { fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { unsafe { @@ -1392,7 +1380,6 @@ cfg_if! { } } - #[cfg(libc_union)] impl ::hash::Hash for __c_anonymous_ifc_ifcu { fn hash(&self, state: &mut H) { unsafe { @@ -3104,14 +3091,10 @@ extern "C" { ) -> ::c_int; } -cfg_if! { - if #[cfg(libc_union)] { - extern { - // these functions use statvfs: - pub fn getmntinfo(mntbufp: *mut *mut ::statvfs, flags: ::c_int) -> ::c_int; - pub fn getvfsstat(buf: *mut statvfs, bufsize: ::size_t, flags: ::c_int) -> ::c_int; - } - } +extern "C" { + // these functions use statvfs: + pub fn getmntinfo(mntbufp: *mut *mut ::statvfs, flags: ::c_int) -> ::c_int; + pub fn getvfsstat(buf: *mut statvfs, bufsize: ::size_t, flags: ::c_int) -> ::c_int; } cfg_if! { 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/mod.rs b/src/unix/bsd/netbsdlike/openbsd/mod.rs index 8f470aff9a357..aaf24092360d0 100644 --- a/src/unix/bsd/netbsdlike/openbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/openbsd/mod.rs @@ -540,10 +540,7 @@ s! { pub struct ifreq { pub ifr_name: [::c_char; ::IFNAMSIZ], - #[cfg(libc_union)] pub ifr_ifru: __c_anonymous_ifr_ifru, - #[cfg(not(libc_union))] - pub ifr_ifru: ::sockaddr, } pub struct tcp_info { @@ -716,7 +713,6 @@ s_no_extra_traits! { align: [::c_char; 160], } - #[cfg(libc_union)] pub union __c_anonymous_ifr_ifru { pub ifru_addr: ::sockaddr, pub ifru_dstaddr: ::sockaddr, @@ -935,7 +931,6 @@ cfg_if! { } } - #[cfg(libc_union)] impl PartialEq for __c_anonymous_ifr_ifru { fn eq(&self, other: &__c_anonymous_ifr_ifru) -> bool { unsafe { @@ -952,10 +947,8 @@ cfg_if! { } } - #[cfg(libc_union)] impl Eq for __c_anonymous_ifr_ifru {} - #[cfg(libc_union)] impl ::fmt::Debug for __c_anonymous_ifr_ifru { fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { f.debug_struct("__c_anonymous_ifr_ifru") @@ -972,7 +965,6 @@ cfg_if! { } } - #[cfg(libc_union)] impl ::hash::Hash for __c_anonymous_ifr_ifru { fn hash(&self, state: &mut H) { unsafe { @@ -991,135 +983,131 @@ cfg_if! { } } +s_no_extra_traits! { + // This type uses the union mount_info: + pub struct statfs { + pub f_flags: u32, + pub f_bsize: u32, + pub f_iosize: u32, + pub f_blocks: u64, + pub f_bfree: u64, + pub f_bavail: i64, + pub f_files: u64, + pub f_ffree: u64, + pub f_favail: i64, + pub f_syncwrites: u64, + pub f_syncreads: u64, + pub f_asyncwrites: u64, + pub f_asyncreads: u64, + pub f_fsid: ::fsid_t, + pub f_namemax: u32, + pub f_owner: ::uid_t, + pub f_ctime: u64, + pub f_fstypename: [::c_char; 16], + pub f_mntonname: [::c_char; 90], + pub f_mntfromname: [::c_char; 90], + pub f_mntfromspec: [::c_char; 90], + pub mount_info: mount_info, + } +} + cfg_if! { - if #[cfg(libc_union)] { - s_no_extra_traits! { - // This type uses the union mount_info: - pub struct statfs { - pub f_flags: u32, - pub f_bsize: u32, - pub f_iosize: u32, - pub f_blocks: u64, - pub f_bfree: u64, - pub f_bavail: i64, - pub f_files: u64, - pub f_ffree: u64, - pub f_favail: i64, - pub f_syncwrites: u64, - pub f_syncreads: u64, - pub f_asyncwrites: u64, - pub f_asyncreads: u64, - pub f_fsid: ::fsid_t, - pub f_namemax: u32, - pub f_owner: ::uid_t, - pub f_ctime: u64, - pub f_fstypename: [::c_char; 16], - pub f_mntonname: [::c_char; 90], - pub f_mntfromname: [::c_char; 90], - pub f_mntfromspec: [::c_char; 90], - pub mount_info: mount_info, + if #[cfg(feature = "extra_traits")] { + impl PartialEq for statfs { + fn eq(&self, other: &statfs) -> bool { + self.f_flags == other.f_flags + && self.f_bsize == other.f_bsize + && self.f_iosize == other.f_iosize + && self.f_blocks == other.f_blocks + && self.f_bfree == other.f_bfree + && self.f_bavail == other.f_bavail + && self.f_files == other.f_files + && self.f_ffree == other.f_ffree + && self.f_favail == other.f_favail + && self.f_syncwrites == other.f_syncwrites + && self.f_syncreads == other.f_syncreads + && self.f_asyncwrites == other.f_asyncwrites + && self.f_asyncreads == other.f_asyncreads + && self.f_fsid == other.f_fsid + && self.f_namemax == other.f_namemax + && self.f_owner == other.f_owner + && self.f_ctime == other.f_ctime + && self.f_fstypename + .iter() + .zip(other.f_fstypename.iter()) + .all(|(a,b)| a == b) + && self.f_mntonname + .iter() + .zip(other.f_mntonname.iter()) + .all(|(a,b)| a == b) + && self.f_mntfromname + .iter() + .zip(other.f_mntfromname.iter()) + .all(|(a,b)| a == b) + && self.f_mntfromspec + .iter() + .zip(other.f_mntfromspec.iter()) + .all(|(a,b)| a == b) + && self.mount_info == other.mount_info } } - cfg_if! { - if #[cfg(feature = "extra_traits")] { - impl PartialEq for statfs { - fn eq(&self, other: &statfs) -> bool { - self.f_flags == other.f_flags - && self.f_bsize == other.f_bsize - && self.f_iosize == other.f_iosize - && self.f_blocks == other.f_blocks - && self.f_bfree == other.f_bfree - && self.f_bavail == other.f_bavail - && self.f_files == other.f_files - && self.f_ffree == other.f_ffree - && self.f_favail == other.f_favail - && self.f_syncwrites == other.f_syncwrites - && self.f_syncreads == other.f_syncreads - && self.f_asyncwrites == other.f_asyncwrites - && self.f_asyncreads == other.f_asyncreads - && self.f_fsid == other.f_fsid - && self.f_namemax == other.f_namemax - && self.f_owner == other.f_owner - && self.f_ctime == other.f_ctime - && self.f_fstypename - .iter() - .zip(other.f_fstypename.iter()) - .all(|(a,b)| a == b) - && self.f_mntonname - .iter() - .zip(other.f_mntonname.iter()) - .all(|(a,b)| a == b) - && self.f_mntfromname - .iter() - .zip(other.f_mntfromname.iter()) - .all(|(a,b)| a == b) - && self.f_mntfromspec - .iter() - .zip(other.f_mntfromspec.iter()) - .all(|(a,b)| a == b) - && self.mount_info == other.mount_info - } - } - - impl Eq for statfs { } - - impl ::fmt::Debug for statfs { - fn fmt(&self, f: &mut ::fmt::Formatter) - -> ::fmt::Result { - f.debug_struct("statfs") - .field("f_flags", &self.f_flags) - .field("f_bsize", &self.f_bsize) - .field("f_iosize", &self.f_iosize) - .field("f_blocks", &self.f_blocks) - .field("f_bfree", &self.f_bfree) - .field("f_bavail", &self.f_bavail) - .field("f_files", &self.f_files) - .field("f_ffree", &self.f_ffree) - .field("f_favail", &self.f_favail) - .field("f_syncwrites", &self.f_syncwrites) - .field("f_syncreads", &self.f_syncreads) - .field("f_asyncwrites", &self.f_asyncwrites) - .field("f_asyncreads", &self.f_asyncreads) - .field("f_fsid", &self.f_fsid) - .field("f_namemax", &self.f_namemax) - .field("f_owner", &self.f_owner) - .field("f_ctime", &self.f_ctime) - // FIXME: .field("f_fstypename", &self.f_fstypename) - // FIXME: .field("f_mntonname", &self.f_mntonname) - // FIXME: .field("f_mntfromname", &self.f_mntfromname) - // FIXME: .field("f_mntfromspec", &self.f_mntfromspec) - .field("mount_info", &self.mount_info) - .finish() - } - } + impl Eq for statfs { } + + impl ::fmt::Debug for statfs { + fn fmt(&self, f: &mut ::fmt::Formatter) + -> ::fmt::Result { + f.debug_struct("statfs") + .field("f_flags", &self.f_flags) + .field("f_bsize", &self.f_bsize) + .field("f_iosize", &self.f_iosize) + .field("f_blocks", &self.f_blocks) + .field("f_bfree", &self.f_bfree) + .field("f_bavail", &self.f_bavail) + .field("f_files", &self.f_files) + .field("f_ffree", &self.f_ffree) + .field("f_favail", &self.f_favail) + .field("f_syncwrites", &self.f_syncwrites) + .field("f_syncreads", &self.f_syncreads) + .field("f_asyncwrites", &self.f_asyncwrites) + .field("f_asyncreads", &self.f_asyncreads) + .field("f_fsid", &self.f_fsid) + .field("f_namemax", &self.f_namemax) + .field("f_owner", &self.f_owner) + .field("f_ctime", &self.f_ctime) + // FIXME: .field("f_fstypename", &self.f_fstypename) + // FIXME: .field("f_mntonname", &self.f_mntonname) + // FIXME: .field("f_mntfromname", &self.f_mntfromname) + // FIXME: .field("f_mntfromspec", &self.f_mntfromspec) + .field("mount_info", &self.mount_info) + .finish() + } + } - impl ::hash::Hash for statfs { - fn hash(&self, state: &mut H) { - self.f_flags.hash(state); - self.f_bsize.hash(state); - self.f_iosize.hash(state); - self.f_blocks.hash(state); - self.f_bfree.hash(state); - self.f_bavail.hash(state); - self.f_files.hash(state); - self.f_ffree.hash(state); - self.f_favail.hash(state); - self.f_syncwrites.hash(state); - self.f_syncreads.hash(state); - self.f_asyncwrites.hash(state); - self.f_asyncreads.hash(state); - self.f_fsid.hash(state); - self.f_namemax.hash(state); - self.f_owner.hash(state); - self.f_ctime.hash(state); - self.f_fstypename.hash(state); - self.f_mntonname.hash(state); - self.f_mntfromname.hash(state); - self.f_mntfromspec.hash(state); - self.mount_info.hash(state); - } - } + impl ::hash::Hash for statfs { + fn hash(&self, state: &mut H) { + self.f_flags.hash(state); + self.f_bsize.hash(state); + self.f_iosize.hash(state); + self.f_blocks.hash(state); + self.f_bfree.hash(state); + self.f_bavail.hash(state); + self.f_files.hash(state); + self.f_ffree.hash(state); + self.f_favail.hash(state); + self.f_syncwrites.hash(state); + self.f_syncreads.hash(state); + self.f_asyncwrites.hash(state); + self.f_asyncreads.hash(state); + self.f_fsid.hash(state); + self.f_namemax.hash(state); + self.f_owner.hash(state); + self.f_ctime.hash(state); + self.f_fstypename.hash(state); + self.f_mntonname.hash(state); + self.f_mntfromname.hash(state); + self.f_mntfromspec.hash(state); + self.mount_info.hash(state); } } } @@ -2163,16 +2151,12 @@ extern "C" { ) -> *mut *mut ::c_char; } -cfg_if! { - if #[cfg(libc_union)] { - extern { - // these functions use statfs which uses the union mount_info: - pub fn statfs(path: *const ::c_char, buf: *mut statfs) -> ::c_int; - pub fn fstatfs(fd: ::c_int, buf: *mut statfs) -> ::c_int; - pub fn getmntinfo(mntbufp: *mut *mut ::statfs, flags: ::c_int) -> ::c_int; - pub fn getfsstat(buf: *mut statfs, bufsize: ::size_t, flags: ::c_int) -> ::c_int; - } - } +extern "C" { + // these functions use statfs which uses the union mount_info: + pub fn statfs(path: *const ::c_char, buf: *mut statfs) -> ::c_int; + pub fn fstatfs(fd: ::c_int, buf: *mut statfs) -> ::c_int; + pub fn getmntinfo(mntbufp: *mut *mut ::statfs, flags: ::c_int) -> ::c_int; + pub fn getfsstat(buf: *mut statfs, bufsize: ::size_t, flags: ::c_int) -> ::c_int; } cfg_if! { 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/haiku/native.rs b/src/unix/haiku/native.rs index 85865ad24cea6..7e4a17f1887d8 100644 --- a/src/unix/haiku/native.rs +++ b/src/unix/haiku/native.rs @@ -460,7 +460,6 @@ s! { } s_no_extra_traits! { - #[cfg(libc_union)] pub union cpuid_info { pub eax_0: __c_anonymous_eax_0, pub eax_1: __c_anonymous_eax_1, @@ -470,7 +469,6 @@ s_no_extra_traits! { pub regs: __c_anonymous_regs, } - #[cfg(libc_union)] pub union __c_anonymous_cpu_topology_info_data { pub root: cpu_topology_root_info, pub package: cpu_topology_package_info, @@ -481,16 +479,12 @@ s_no_extra_traits! { pub id: u32, pub type_: topology_level_type, pub level: u32, - #[cfg(libc_union)] pub data: __c_anonymous_cpu_topology_info_data, - #[cfg(not(libc_union))] - pub data: cpu_topology_core_info, } } cfg_if! { if #[cfg(feature = "extra_traits")] { - #[cfg(libc_union)] impl PartialEq for cpuid_info { fn eq(&self, other: &cpuid_info) -> bool { unsafe { @@ -503,9 +497,7 @@ cfg_if! { } } } - #[cfg(libc_union)] impl Eq for cpuid_info {} - #[cfg(libc_union)] impl ::fmt::Debug for cpuid_info { fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { unsafe { @@ -521,7 +513,6 @@ cfg_if! { } } - #[cfg(libc_union)] impl PartialEq for __c_anonymous_cpu_topology_info_data { fn eq(&self, other: &__c_anonymous_cpu_topology_info_data) -> bool { unsafe { @@ -531,9 +522,7 @@ cfg_if! { } } } - #[cfg(libc_union)] impl Eq for __c_anonymous_cpu_topology_info_data {} - #[cfg(libc_union)] impl ::fmt::Debug for __c_anonymous_cpu_topology_info_data { fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { unsafe { @@ -1341,12 +1330,8 @@ extern "C" { ) -> status_t; } -cfg_if! { - if #[cfg(libc_union)] { - extern "C" { - pub fn get_cpuid(info: *mut cpuid_info, eaxRegister: u32, cpuNum: u32) -> status_t; - } - } +extern "C" { + pub fn get_cpuid(info: *mut cpuid_info, eaxRegister: u32, cpuNum: u32) -> status_t; } // The following functions are defined as macros in C/C++ diff --git a/src/unix/hurd/mod.rs b/src/unix/hurd/mod.rs index ad422fe718349..c02e228604fb8 100644 --- a/src/unix/hurd/mod.rs +++ b/src/unix/hurd/mod.rs @@ -4675,15 +4675,8 @@ safe_f! { } } -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; - } else { - mod no_align; - pub use self::no_align::*; - } -} +mod align; +pub use self::align::*; cfg_if! { if #[cfg(target_pointer_width = "64")] { diff --git a/src/unix/hurd/no_align.rs b/src/unix/hurd/no_align.rs deleted file mode 100644 index 1dd7d8e541d29..0000000000000 --- a/src/unix/hurd/no_align.rs +++ /dev/null @@ -1 +0,0 @@ -// Placeholder file diff --git a/src/unix/linux_like/android/b32/arm.rs b/src/unix/linux_like/android/b32/arm.rs index c4c78939cba48..cbd514b4f6f6e 100644 --- a/src/unix/linux_like/android/b32/arm.rs +++ b/src/unix/linux_like/android/b32/arm.rs @@ -29,119 +29,115 @@ s! { } } +s_no_extra_traits! { + pub struct __c_anonymous_uc_sigmask_with_padding { + pub uc_sigmask: ::sigset_t, + /* Android has a wrong (smaller) sigset_t on x86. */ + __padding_rt_sigset: u32, + } + + pub union __c_anonymous_uc_sigmask { + uc_sigmask: __c_anonymous_uc_sigmask_with_padding, + uc_sigmask64: ::sigset64_t, + } + + pub struct ucontext_t { + pub uc_flags: ::c_ulong, + pub uc_link: *mut ucontext_t, + pub uc_stack: ::stack_t, + pub uc_mcontext: mcontext_t, + pub uc_sigmask__c_anonymous_union: __c_anonymous_uc_sigmask, + /* The kernel adds extra padding after uc_sigmask to match + * glibc sigset_t on ARM. */ + __padding: [c_char; 120], + __align: [::c_longlong; 0], + uc_regspace: [::c_ulong; 128], + } +} + cfg_if! { - if #[cfg(libc_union)] { - s_no_extra_traits! { - pub struct __c_anonymous_uc_sigmask_with_padding { - pub uc_sigmask: ::sigset_t, - /* Android has a wrong (smaller) sigset_t on x86. */ - __padding_rt_sigset: u32, + if #[cfg(feature = "extra_traits")] { + impl PartialEq for __c_anonymous_uc_sigmask_with_padding { + fn eq( + &self, other: &__c_anonymous_uc_sigmask_with_padding + ) -> bool { + self.uc_sigmask == other.uc_sigmask + // Ignore padding } - - pub union __c_anonymous_uc_sigmask { - uc_sigmask: __c_anonymous_uc_sigmask_with_padding, - uc_sigmask64: ::sigset64_t, + } + impl Eq for __c_anonymous_uc_sigmask_with_padding {} + impl ::fmt::Debug for __c_anonymous_uc_sigmask_with_padding { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("uc_sigmask_with_padding") + .field("uc_sigmask_with_padding", &self.uc_sigmask) + // Ignore padding + .finish() } - - pub struct ucontext_t { - pub uc_flags: ::c_ulong, - pub uc_link: *mut ucontext_t, - pub uc_stack: ::stack_t, - pub uc_mcontext: mcontext_t, - pub uc_sigmask__c_anonymous_union: __c_anonymous_uc_sigmask, - /* The kernel adds extra padding after uc_sigmask to match - * glibc sigset_t on ARM. */ - __padding: [c_char; 120], - __align: [::c_longlong; 0], - uc_regspace: [::c_ulong; 128], + } + impl ::hash::Hash for __c_anonymous_uc_sigmask_with_padding { + fn hash(&self, state: &mut H) { + self.uc_sigmask.hash(state) + // Ignore padding } } - cfg_if! { - if #[cfg(feature = "extra_traits")] { - impl PartialEq for __c_anonymous_uc_sigmask_with_padding { - fn eq( - &self, other: &__c_anonymous_uc_sigmask_with_padding - ) -> bool { - self.uc_sigmask == other.uc_sigmask - // Ignore padding - } - } - impl Eq for __c_anonymous_uc_sigmask_with_padding {} - impl ::fmt::Debug for __c_anonymous_uc_sigmask_with_padding { - fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { - f.debug_struct("uc_sigmask_with_padding") - .field("uc_sigmask_with_padding", &self.uc_sigmask) - // Ignore padding - .finish() - } - } - impl ::hash::Hash for __c_anonymous_uc_sigmask_with_padding { - fn hash(&self, state: &mut H) { - self.uc_sigmask.hash(state) - // Ignore padding - } - } - - impl PartialEq for __c_anonymous_uc_sigmask { - fn eq(&self, other: &__c_anonymous_uc_sigmask) -> bool { - unsafe { self.uc_sigmask == other.uc_sigmask } - } - } - impl Eq for __c_anonymous_uc_sigmask {} - impl ::fmt::Debug for __c_anonymous_uc_sigmask { - fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { - f.debug_struct("uc_sigmask") - .field("uc_sigmask", unsafe { &self.uc_sigmask }) - .finish() - } - } - impl ::hash::Hash for __c_anonymous_uc_sigmask { - fn hash(&self, state: &mut H) { - unsafe { self.uc_sigmask.hash(state) } - } - } + impl PartialEq for __c_anonymous_uc_sigmask { + fn eq(&self, other: &__c_anonymous_uc_sigmask) -> bool { + unsafe { self.uc_sigmask == other.uc_sigmask } + } + } + impl Eq for __c_anonymous_uc_sigmask {} + impl ::fmt::Debug for __c_anonymous_uc_sigmask { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("uc_sigmask") + .field("uc_sigmask", unsafe { &self.uc_sigmask }) + .finish() + } + } + impl ::hash::Hash for __c_anonymous_uc_sigmask { + fn hash(&self, state: &mut H) { + unsafe { self.uc_sigmask.hash(state) } + } + } - impl PartialEq for ucontext_t { - fn eq(&self, other: &Self) -> bool { - self.uc_flags == other.uc_flags - && self.uc_link == other.uc_link - && self.uc_stack == other.uc_stack - && self.uc_mcontext == other.uc_mcontext - && self.uc_sigmask__c_anonymous_union - == other.uc_sigmask__c_anonymous_union - && &self.uc_regspace[..] == &other.uc_regspace[..] - // Ignore padding field - } - } - impl Eq for ucontext_t {} - impl ::fmt::Debug for ucontext_t { - fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { - f.debug_struct("ucontext_t") - .field("uc_flags", &self.uc_flags) - .field("uc_link", &self.uc_link) - .field("uc_stack", &self.uc_stack) - .field("uc_mcontext", &self.uc_mcontext) - .field( - "uc_sigmask__c_anonymous_union", - &self.uc_sigmask__c_anonymous_union - ) - .field("uc_regspace", &&self.uc_regspace[..]) - // Ignore padding field - .finish() - } - } - impl ::hash::Hash for ucontext_t { - fn hash(&self, state: &mut H) { - self.uc_flags.hash(state); - self.uc_link.hash(state); - self.uc_stack.hash(state); - self.uc_mcontext.hash(state); - self.uc_sigmask__c_anonymous_union.hash(state); - self.uc_regspace[..].hash(state); - // Ignore padding field - } - } + impl PartialEq for ucontext_t { + fn eq(&self, other: &Self) -> bool { + self.uc_flags == other.uc_flags + && self.uc_link == other.uc_link + && self.uc_stack == other.uc_stack + && self.uc_mcontext == other.uc_mcontext + && self.uc_sigmask__c_anonymous_union + == other.uc_sigmask__c_anonymous_union + && &self.uc_regspace[..] == &other.uc_regspace[..] + // Ignore padding field + } + } + impl Eq for ucontext_t {} + impl ::fmt::Debug for ucontext_t { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("ucontext_t") + .field("uc_flags", &self.uc_flags) + .field("uc_link", &self.uc_link) + .field("uc_stack", &self.uc_stack) + .field("uc_mcontext", &self.uc_mcontext) + .field( + "uc_sigmask__c_anonymous_union", + &self.uc_sigmask__c_anonymous_union + ) + .field("uc_regspace", &&self.uc_regspace[..]) + // Ignore padding field + .finish() + } + } + impl ::hash::Hash for ucontext_t { + fn hash(&self, state: &mut H) { + self.uc_flags.hash(state); + self.uc_link.hash(state); + self.uc_stack.hash(state); + self.uc_mcontext.hash(state); + self.uc_sigmask__c_anonymous_union.hash(state); + self.uc_regspace[..].hash(state); + // Ignore padding field } } } diff --git a/src/unix/linux_like/android/b32/x86/mod.rs b/src/unix/linux_like/android/b32/x86/mod.rs index 64ce93dd22916..c56889ea37e4f 100644 --- a/src/unix/linux_like/android/b32/x86/mod.rs +++ b/src/unix/linux_like/android/b32/x86/mod.rs @@ -28,113 +28,109 @@ s! { } } +s_no_extra_traits! { + pub struct __c_anonymous_uc_sigmask_with_padding { + pub uc_sigmask: ::sigset_t, + /* Android has a wrong (smaller) sigset_t on x86. */ + __padding_rt_sigset: u32, + } + + pub union __c_anonymous_uc_sigmask { + uc_sigmask: __c_anonymous_uc_sigmask_with_padding, + uc_sigmask64: ::sigset64_t, + } + + pub struct ucontext_t { + pub uc_flags: ::c_ulong, + pub uc_link: *mut ucontext_t, + pub uc_stack: ::stack_t, + pub uc_mcontext: mcontext_t, + pub uc_sigmask__c_anonymous_union: __c_anonymous_uc_sigmask, + __padding_rt_sigset: u32, + __fpregs_mem: _libc_fpstate, + } +} + cfg_if! { - if #[cfg(libc_union)] { - s_no_extra_traits! { - pub struct __c_anonymous_uc_sigmask_with_padding { - pub uc_sigmask: ::sigset_t, - /* Android has a wrong (smaller) sigset_t on x86. */ - __padding_rt_sigset: u32, + if #[cfg(feature = "extra_traits")] { + impl PartialEq for __c_anonymous_uc_sigmask_with_padding { + fn eq( + &self, other: &__c_anonymous_uc_sigmask_with_padding + ) -> bool { + self.uc_sigmask == other.uc_sigmask + // Ignore padding } - - pub union __c_anonymous_uc_sigmask { - uc_sigmask: __c_anonymous_uc_sigmask_with_padding, - uc_sigmask64: ::sigset64_t, + } + impl Eq for __c_anonymous_uc_sigmask_with_padding {} + impl ::fmt::Debug for __c_anonymous_uc_sigmask_with_padding { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("uc_sigmask_with_padding") + .field("uc_sigmask_with_padding", &self.uc_sigmask) + // Ignore padding + .finish() } - - pub struct ucontext_t { - pub uc_flags: ::c_ulong, - pub uc_link: *mut ucontext_t, - pub uc_stack: ::stack_t, - pub uc_mcontext: mcontext_t, - pub uc_sigmask__c_anonymous_union: __c_anonymous_uc_sigmask, - __padding_rt_sigset: u32, - __fpregs_mem: _libc_fpstate, + } + impl ::hash::Hash for __c_anonymous_uc_sigmask_with_padding { + fn hash(&self, state: &mut H) { + self.uc_sigmask.hash(state) + // Ignore padding } } - cfg_if! { - if #[cfg(feature = "extra_traits")] { - impl PartialEq for __c_anonymous_uc_sigmask_with_padding { - fn eq( - &self, other: &__c_anonymous_uc_sigmask_with_padding - ) -> bool { - self.uc_sigmask == other.uc_sigmask - // Ignore padding - } - } - impl Eq for __c_anonymous_uc_sigmask_with_padding {} - impl ::fmt::Debug for __c_anonymous_uc_sigmask_with_padding { - fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { - f.debug_struct("uc_sigmask_with_padding") - .field("uc_sigmask_with_padding", &self.uc_sigmask) - // Ignore padding - .finish() - } - } - impl ::hash::Hash for __c_anonymous_uc_sigmask_with_padding { - fn hash(&self, state: &mut H) { - self.uc_sigmask.hash(state) - // Ignore padding - } - } - - impl PartialEq for __c_anonymous_uc_sigmask { - fn eq(&self, other: &__c_anonymous_uc_sigmask) -> bool { - unsafe { self.uc_sigmask == other.uc_sigmask } - } - } - impl Eq for __c_anonymous_uc_sigmask {} - impl ::fmt::Debug for __c_anonymous_uc_sigmask { - fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { - f.debug_struct("uc_sigmask") - .field("uc_sigmask", unsafe { &self.uc_sigmask }) - .finish() - } - } - impl ::hash::Hash for __c_anonymous_uc_sigmask { - fn hash(&self, state: &mut H) { - unsafe { self.uc_sigmask.hash(state) } - } - } + impl PartialEq for __c_anonymous_uc_sigmask { + fn eq(&self, other: &__c_anonymous_uc_sigmask) -> bool { + unsafe { self.uc_sigmask == other.uc_sigmask } + } + } + impl Eq for __c_anonymous_uc_sigmask {} + impl ::fmt::Debug for __c_anonymous_uc_sigmask { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("uc_sigmask") + .field("uc_sigmask", unsafe { &self.uc_sigmask }) + .finish() + } + } + impl ::hash::Hash for __c_anonymous_uc_sigmask { + fn hash(&self, state: &mut H) { + unsafe { self.uc_sigmask.hash(state) } + } + } - impl PartialEq for ucontext_t { - fn eq(&self, other: &Self) -> bool { - self.uc_flags == other.uc_flags - && self.uc_link == other.uc_link - && self.uc_stack == other.uc_stack - && self.uc_mcontext == other.uc_mcontext - && self.uc_sigmask__c_anonymous_union - == other.uc_sigmask__c_anonymous_union - // Ignore padding field - } - } - impl Eq for ucontext_t {} - impl ::fmt::Debug for ucontext_t { - fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { - f.debug_struct("ucontext_t") - .field("uc_flags", &self.uc_flags) - .field("uc_link", &self.uc_link) - .field("uc_stack", &self.uc_stack) - .field("uc_mcontext", &self.uc_mcontext) - .field( - "uc_sigmask__c_anonymous_union", - &self.uc_sigmask__c_anonymous_union - ) - // Ignore padding field - .finish() - } - } - impl ::hash::Hash for ucontext_t { - fn hash(&self, state: &mut H) { - self.uc_flags.hash(state); - self.uc_link.hash(state); - self.uc_stack.hash(state); - self.uc_mcontext.hash(state); - self.uc_sigmask__c_anonymous_union.hash(state); - // Ignore padding field - } - } + impl PartialEq for ucontext_t { + fn eq(&self, other: &Self) -> bool { + self.uc_flags == other.uc_flags + && self.uc_link == other.uc_link + && self.uc_stack == other.uc_stack + && self.uc_mcontext == other.uc_mcontext + && self.uc_sigmask__c_anonymous_union + == other.uc_sigmask__c_anonymous_union + // Ignore padding field + } + } + impl Eq for ucontext_t {} + impl ::fmt::Debug for ucontext_t { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("ucontext_t") + .field("uc_flags", &self.uc_flags) + .field("uc_link", &self.uc_link) + .field("uc_stack", &self.uc_stack) + .field("uc_mcontext", &self.uc_mcontext) + .field( + "uc_sigmask__c_anonymous_union", + &self.uc_sigmask__c_anonymous_union + ) + // Ignore padding field + .finish() + } + } + impl ::hash::Hash for ucontext_t { + fn hash(&self, state: &mut H) { + self.uc_flags.hash(state); + self.uc_link.hash(state); + self.uc_stack.hash(state); + self.uc_mcontext.hash(state); + self.uc_sigmask__c_anonymous_union.hash(state); + // Ignore padding field } } } @@ -619,9 +615,5 @@ f! { } } -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; - } -} +mod align; +pub use self::align::*; diff --git a/src/unix/linux_like/android/b64/aarch64/mod.rs b/src/unix/linux_like/android/b64/aarch64/mod.rs index bd3146deb7f9f..93659c7c0aabe 100644 --- a/src/unix/linux_like/android/b64/aarch64/mod.rs +++ b/src/unix/linux_like/android/b64/aarch64/mod.rs @@ -421,16 +421,8 @@ pub const PROT_MTE: ::c_int = 0x20; pub const AT_SYSINFO_EHDR: ::c_ulong = 33; pub const AT_VECTOR_SIZE_ARCH: ::c_ulong = 2; -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; - } -} +mod align; +pub use self::align::*; -cfg_if! { - if #[cfg(libc_int128)] { - mod int128; - pub use self::int128::*; - } -} +mod int128; +pub use self::int128::*; diff --git a/src/unix/linux_like/android/b64/riscv64/mod.rs b/src/unix/linux_like/android/b64/riscv64/mod.rs index 209f050f25ce5..9ad629f8b2528 100644 --- a/src/unix/linux_like/android/b64/riscv64/mod.rs +++ b/src/unix/linux_like/android/b64/riscv64/mod.rs @@ -357,9 +357,5 @@ pub const AT_L3_CACHESIZE: ::c_ulong = 46; pub const AT_L3_CACHEGEOMETRY: ::c_ulong = 47; pub const AT_VECTOR_SIZE_ARCH: ::c_ulong = 9; -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; - } -} +mod align; +pub use self::align::*; diff --git a/src/unix/linux_like/android/b64/x86_64/mod.rs b/src/unix/linux_like/android/b64/x86_64/mod.rs index a7363304c65ce..527788c88a9e8 100644 --- a/src/unix/linux_like/android/b64/x86_64/mod.rs +++ b/src/unix/linux_like/android/b64/x86_64/mod.rs @@ -104,35 +104,31 @@ s! { } +s_no_extra_traits! { + pub union __c_anonymous_uc_sigmask { + uc_sigmask: ::sigset_t, + uc_sigmask64: ::sigset64_t, + } +} + cfg_if! { - if #[cfg(libc_union)] { - s_no_extra_traits! { - pub union __c_anonymous_uc_sigmask { - uc_sigmask: ::sigset_t, - uc_sigmask64: ::sigset64_t, + if #[cfg(feature = "extra_traits")] { + impl PartialEq for __c_anonymous_uc_sigmask { + fn eq(&self, other: &__c_anonymous_uc_sigmask) -> bool { + unsafe { self.uc_sigmask == other.uc_sigmask } } } - - cfg_if! { - if #[cfg(feature = "extra_traits")] { - impl PartialEq for __c_anonymous_uc_sigmask { - fn eq(&self, other: &__c_anonymous_uc_sigmask) -> bool { - unsafe { self.uc_sigmask == other.uc_sigmask } - } - } - impl Eq for __c_anonymous_uc_sigmask {} - impl ::fmt::Debug for __c_anonymous_uc_sigmask { - fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { - f.debug_struct("uc_sigmask") - .field("uc_sigmask", unsafe { &self.uc_sigmask }) - .finish() - } - } - impl ::hash::Hash for __c_anonymous_uc_sigmask { - fn hash(&self, state: &mut H) { - unsafe { self.uc_sigmask.hash(state) } - } - } + impl Eq for __c_anonymous_uc_sigmask {} + impl ::fmt::Debug for __c_anonymous_uc_sigmask { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("uc_sigmask") + .field("uc_sigmask", unsafe { &self.uc_sigmask }) + .finish() + } + } + impl ::hash::Hash for __c_anonymous_uc_sigmask { + fn hash(&self, state: &mut H) { + unsafe { self.uc_sigmask.hash(state) } } } } @@ -798,9 +794,5 @@ pub const REG_CR2: ::c_int = 22; pub const AT_SYSINFO_EHDR: ::c_ulong = 33; pub const AT_VECTOR_SIZE_ARCH: ::c_ulong = 3; -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; - } -} +mod align; +pub use self::align::*; diff --git a/src/unix/linux_like/android/mod.rs b/src/unix/linux_like/android/mod.rs index a8e935967c132..64c27105e6c71 100644 --- a/src/unix/linux_like/android/mod.rs +++ b/src/unix/linux_like/android/mod.rs @@ -612,7 +612,6 @@ s_no_extra_traits! { __value: [[::c_char; 4]; 23], } - #[cfg(libc_union)] pub union __c_anonymous_ifr_ifru { pub ifru_addr: ::sockaddr, pub ifru_dstaddr: ::sockaddr, @@ -632,13 +631,9 @@ s_no_extra_traits! { pub struct ifreq { /// interface name, e.g. "en0" pub ifr_name: [::c_char; ::IFNAMSIZ], - #[cfg(libc_union)] pub ifr_ifru: __c_anonymous_ifr_ifru, - #[cfg(not(libc_union))] - pub ifr_ifru: ::sockaddr, } - #[cfg(libc_union)] pub union __c_anonymous_ifc_ifcu { pub ifcu_buf: *mut ::c_char, pub ifcu_req: *mut ::ifreq, @@ -649,10 +644,7 @@ s_no_extra_traits! { networks accessible). */ pub struct ifconf { pub ifc_len: ::c_int, /* Size of buffer. */ - #[cfg(libc_union)] pub ifc_ifcu: __c_anonymous_ifc_ifcu, - #[cfg(not(libc_union))] - pub ifc_ifcu: *mut ::ifreq, } } @@ -1002,7 +994,6 @@ cfg_if! { } } - #[cfg(libc_union)] impl ::fmt::Debug for __c_anonymous_ifr_ifru { fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { f.debug_struct("ifr_ifru") @@ -1031,7 +1022,6 @@ cfg_if! { } } - #[cfg(libc_union)] impl ::fmt::Debug for __c_anonymous_ifc_ifcu { fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { f.debug_struct("ifr_ifru") @@ -4184,65 +4174,60 @@ impl siginfo_t { (*(self as *const siginfo_t as *const siginfo_timer)).si_sigval } } +// Internal, for casts to access union fields +#[repr(C)] +struct sifields_sigchld { + si_pid: ::pid_t, + si_uid: ::uid_t, + si_status: ::c_int, + si_utime: ::c_long, + si_stime: ::c_long, +} +impl ::Copy for sifields_sigchld {} +impl ::Clone for sifields_sigchld { + fn clone(&self) -> sifields_sigchld { + *self + } +} -cfg_if! { - if #[cfg(libc_union)] { - // Internal, for casts to access union fields - #[repr(C)] - struct sifields_sigchld { - si_pid: ::pid_t, - si_uid: ::uid_t, - si_status: ::c_int, - si_utime: ::c_long, - si_stime: ::c_long, - } - impl ::Copy for sifields_sigchld {} - impl ::Clone for sifields_sigchld { - fn clone(&self) -> sifields_sigchld { - *self - } - } - - // Internal, for casts to access union fields - #[repr(C)] - union sifields { - _align_pointer: *mut ::c_void, - sigchld: sifields_sigchld, - } +// Internal, for casts to access union fields +#[repr(C)] +union sifields { + _align_pointer: *mut ::c_void, + sigchld: sifields_sigchld, +} - // Internal, for casts to access union fields. Note that some variants - // of sifields start with a pointer, which makes the alignment of - // sifields vary on 32-bit and 64-bit architectures. - #[repr(C)] - struct siginfo_f { - _siginfo_base: [::c_int; 3], - sifields: sifields, - } +// Internal, for casts to access union fields. Note that some variants +// of sifields start with a pointer, which makes the alignment of +// sifields vary on 32-bit and 64-bit architectures. +#[repr(C)] +struct siginfo_f { + _siginfo_base: [::c_int; 3], + sifields: sifields, +} - impl siginfo_t { - unsafe fn sifields(&self) -> &sifields { - &(*(self as *const siginfo_t as *const siginfo_f)).sifields - } +impl siginfo_t { + unsafe fn sifields(&self) -> &sifields { + &(*(self as *const siginfo_t as *const siginfo_f)).sifields + } - pub unsafe fn si_pid(&self) -> ::pid_t { - self.sifields().sigchld.si_pid - } + pub unsafe fn si_pid(&self) -> ::pid_t { + self.sifields().sigchld.si_pid + } - pub unsafe fn si_uid(&self) -> ::uid_t { - self.sifields().sigchld.si_uid - } + pub unsafe fn si_uid(&self) -> ::uid_t { + self.sifields().sigchld.si_uid + } - pub unsafe fn si_status(&self) -> ::c_int { - self.sifields().sigchld.si_status - } + pub unsafe fn si_status(&self) -> ::c_int { + self.sifields().sigchld.si_status + } - pub unsafe fn si_utime(&self) -> ::c_long { - self.sifields().sigchld.si_utime - } + pub unsafe fn si_utime(&self) -> ::c_long { + self.sifields().sigchld.si_utime + } - pub unsafe fn si_stime(&self) -> ::c_long { - self.sifields().sigchld.si_stime - } - } + pub unsafe fn si_stime(&self) -> ::c_long { + self.sifields().sigchld.si_stime } } diff --git a/src/unix/linux_like/emscripten/mod.rs b/src/unix/linux_like/emscripten/mod.rs index 1dc607496a2ad..6a64a96879684 100644 --- a/src/unix/linux_like/emscripten/mod.rs +++ b/src/unix/linux_like/emscripten/mod.rs @@ -1782,13 +1782,7 @@ extern "C" { mod lfs64; pub use self::lfs64::*; -cfg_if! { - if #[cfg(libc_align)] { - #[macro_use] - mod align; - } else { - #[macro_use] - mod no_align; - } -} +#[macro_use] +mod align; + expand_align!(); diff --git a/src/unix/linux_like/emscripten/no_align.rs b/src/unix/linux_like/emscripten/no_align.rs deleted file mode 100644 index 768dc73a434f6..0000000000000 --- a/src/unix/linux_like/emscripten/no_align.rs +++ /dev/null @@ -1,63 +0,0 @@ -macro_rules! expand_align { - () => { - s! { - pub struct pthread_mutex_t { - __align: [::c_long; 0], - size: [u8; ::__SIZEOF_PTHREAD_MUTEX_T], - } - - pub struct pthread_rwlock_t { - __align: [::c_long; 0], - size: [u8; ::__SIZEOF_PTHREAD_RWLOCK_T], - } - - pub struct pthread_mutexattr_t { - __align: [::c_int; 0], - size: [u8; ::__SIZEOF_PTHREAD_MUTEXATTR_T], - } - - pub struct pthread_rwlockattr_t { - __align: [::c_int; 0], - size: [u8; ::__SIZEOF_PTHREAD_RWLOCKATTR_T], - } - - pub struct pthread_condattr_t { - __align: [::c_int; 0], - size: [u8; ::__SIZEOF_PTHREAD_CONDATTR_T], - } - } - - s_no_extra_traits! { - pub struct pthread_cond_t { - __align: [*const ::c_void; 0], - size: [u8; ::__SIZEOF_PTHREAD_COND_T], - } - } - - cfg_if! { - if #[cfg(feature = "extra_traits")] { - impl PartialEq for pthread_cond_t { - fn eq(&self, other: &pthread_cond_t) -> bool { - self.size - .iter() - .zip(other.size.iter()) - .all(|(a,b)| a == b) - } - } - impl Eq for pthread_cond_t {} - impl ::fmt::Debug for pthread_cond_t { - fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { - f.debug_struct("pthread_cond_t") - // FIXME: .field("size", &self.size) - .finish() - } - } - impl ::hash::Hash for pthread_cond_t { - fn hash(&self, state: &mut H) { - self.size.hash(state); - } - } - } - } - }; -} diff --git a/src/unix/linux_like/linux/gnu/b32/arm/mod.rs b/src/unix/linux_like/linux/gnu/b32/arm/mod.rs index 4a14d692c8652..85c8999d2b11f 100644 --- a/src/unix/linux_like/linux/gnu/b32/arm/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/arm/mod.rs @@ -857,9 +857,5 @@ pub const SYS_futex_waitv: ::c_long = 449; pub const SYS_set_mempolicy_home_node: ::c_long = 450; pub const SYS_mseal: ::c_long = 462; -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; - } -} +mod align; +pub use self::align::*; diff --git a/src/unix/linux_like/linux/gnu/b32/csky/mod.rs b/src/unix/linux_like/linux/gnu/b32/csky/mod.rs index 5e92e30073bee..16b2f9b84034e 100644 --- a/src/unix/linux_like/linux/gnu/b32/csky/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/csky/mod.rs @@ -733,9 +733,5 @@ pub const SYS_process_mrelease: ::c_long = 448; pub const SYS_futex_waitv: ::c_long = 449; pub const SYS_set_mempolicy_home_node: ::c_long = 450; -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; - } -} +mod align; +pub use self::align::*; diff --git a/src/unix/linux_like/linux/gnu/b32/mips/mod.rs b/src/unix/linux_like/linux/gnu/b32/mips/mod.rs index fa2707500dbe4..8f5ed0f348459 100644 --- a/src/unix/linux_like/linux/gnu/b32/mips/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/mips/mod.rs @@ -811,9 +811,5 @@ pub const B4000000: ::speed_t = 0o010017; pub const EHWPOISON: ::c_int = 168; -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; - } -} +mod align; +pub use self::align::*; diff --git a/src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs b/src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs index 65b7aaa783559..8a75e6d42b32b 100644 --- a/src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs @@ -805,9 +805,5 @@ pub const SYS_process_mrelease: ::c_long = 448; pub const SYS_futex_waitv: ::c_long = 449; pub const SYS_set_mempolicy_home_node: ::c_long = 450; -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; - } -} +mod align; +pub use self::align::*; diff --git a/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs b/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs index da9cf29c48668..16b836f7e6128 100644 --- a/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs @@ -849,9 +849,5 @@ pub const SYS_process_mrelease: ::c_long = 448; pub const SYS_futex_waitv: ::c_long = 449; pub const SYS_set_mempolicy_home_node: ::c_long = 450; -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; - } -} +mod align; +pub use self::align::*; diff --git a/src/unix/linux_like/linux/gnu/b32/x86/mod.rs b/src/unix/linux_like/linux/gnu/b32/x86/mod.rs index 4391eb3fa7968..73e7a394775d6 100644 --- a/src/unix/linux_like/linux/gnu/b32/x86/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/x86/mod.rs @@ -1094,9 +1094,5 @@ extern "C" { pub fn swapcontext(uocp: *mut ucontext_t, ucp: *const ucontext_t) -> ::c_int; } -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; - } -} +mod align; +pub use self::align::*; diff --git a/src/unix/linux_like/linux/gnu/b64/aarch64/fallback.rs b/src/unix/linux_like/linux/gnu/b64/aarch64/fallback.rs deleted file mode 100644 index 398fbb53755c8..0000000000000 --- a/src/unix/linux_like/linux/gnu/b64/aarch64/fallback.rs +++ /dev/null @@ -1,8 +0,0 @@ -s! { - #[repr(align(16))] - pub struct user_fpsimd_struct { - pub vregs: [[u64; 2]; 32], - pub fpsr: ::c_uint, - pub fpcr: ::c_uint, - } -} diff --git a/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs b/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs index c8a805cdd36cb..96b5b532f74d2 100644 --- a/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs @@ -918,21 +918,8 @@ cfg_if! { } } -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; - } - - -} +mod align; +pub use self::align::*; -cfg_if! { - if #[cfg(libc_int128)] { - mod int128; - pub use self::int128::*; - } else if #[cfg(libc_align)] { - mod fallback; - pub use self::fallback::*; - } -} +mod int128; +pub use self::int128::*; diff --git a/src/unix/linux_like/linux/gnu/b64/loongarch64/mod.rs b/src/unix/linux_like/linux/gnu/b64/loongarch64/mod.rs index ac3f88905f38e..a3c1706aa62c0 100644 --- a/src/unix/linux_like/linux/gnu/b64/loongarch64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/loongarch64/mod.rs @@ -892,9 +892,5 @@ pub const EPOLL_CLOEXEC: ::c_int = 0x80000; pub const EFD_CLOEXEC: ::c_int = 0x80000; pub const EFD_NONBLOCK: ::c_int = 0x800; -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; - } -} +mod align; +pub use self::align::*; diff --git a/src/unix/linux_like/linux/gnu/b64/mips64/mod.rs b/src/unix/linux_like/linux/gnu/b64/mips64/mod.rs index f7b52be805cab..192881ab41a31 100644 --- a/src/unix/linux_like/linux/gnu/b64/mips64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/mips64/mod.rs @@ -926,9 +926,5 @@ extern "C" { ) -> ::c_int; } -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; - } -} +mod align; +pub use self::align::*; diff --git a/src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs b/src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs index 3088c25a2646f..0f811c689316b 100644 --- a/src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs @@ -971,9 +971,5 @@ extern "C" { ) -> ::c_int; } -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; - } -} +mod align; +pub use self::align::*; diff --git a/src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs b/src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs index 64f5cf10f8583..750ee8f8436e8 100644 --- a/src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs @@ -852,9 +852,5 @@ pub const SYS_process_mrelease: ::c_long = 448; pub const SYS_futex_waitv: ::c_long = 449; pub const SYS_set_mempolicy_home_node: ::c_long = 450; -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; - } -} +mod align; +pub use self::align::*; diff --git a/src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs b/src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs index de2f0d6e470f6..5b447bbdad474 100644 --- a/src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs @@ -923,9 +923,5 @@ extern "C" { ) -> ::c_int; } -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; - } -} +mod align; +pub use self::align::*; diff --git a/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs b/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs index 609c74429c5bc..86536f185750f 100644 --- a/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs @@ -816,9 +816,5 @@ cfg_if! { } } -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; - } -} +mod align; +pub use self::align::*; diff --git a/src/unix/linux_like/linux/gnu/mod.rs b/src/unix/linux_like/linux/gnu/mod.rs index 75d150c90d58a..cd4db3eb35261 100644 --- a/src/unix/linux_like/linux/gnu/mod.rs +++ b/src/unix/linux_like/linux/gnu/mod.rs @@ -353,7 +353,6 @@ s! { pub arch: ::__u32, pub instruction_pointer: ::__u64, pub stack_pointer: ::__u64, - #[cfg(libc_union)] pub u: __c_anonymous_ptrace_syscall_info_data, } @@ -482,77 +481,73 @@ impl siginfo_t { } } -cfg_if! { - if #[cfg(libc_union)] { - // Internal, for casts to access union fields - #[repr(C)] - struct sifields_sigchld { - si_pid: ::pid_t, - si_uid: ::uid_t, - si_status: ::c_int, - si_utime: ::c_long, - si_stime: ::c_long, - } - impl ::Copy for sifields_sigchld {} - impl ::Clone for sifields_sigchld { - fn clone(&self) -> sifields_sigchld { - *self - } - } +// Internal, for casts to access union fields +#[repr(C)] +struct sifields_sigchld { + si_pid: ::pid_t, + si_uid: ::uid_t, + si_status: ::c_int, + si_utime: ::c_long, + si_stime: ::c_long, +} +impl ::Copy for sifields_sigchld {} +impl ::Clone for sifields_sigchld { + fn clone(&self) -> sifields_sigchld { + *self + } +} - // Internal, for casts to access union fields - #[repr(C)] - union sifields { - _align_pointer: *mut ::c_void, - sigchld: sifields_sigchld, - } +// Internal, for casts to access union fields +#[repr(C)] +union sifields { + _align_pointer: *mut ::c_void, + sigchld: sifields_sigchld, +} - // Internal, for casts to access union fields. Note that some variants - // of sifields start with a pointer, which makes the alignment of - // sifields vary on 32-bit and 64-bit architectures. - #[repr(C)] - struct siginfo_f { - _siginfo_base: [::c_int; 3], - sifields: sifields, - } +// Internal, for casts to access union fields. Note that some variants +// of sifields start with a pointer, which makes the alignment of +// sifields vary on 32-bit and 64-bit architectures. +#[repr(C)] +struct siginfo_f { + _siginfo_base: [::c_int; 3], + sifields: sifields, +} - impl siginfo_t { - unsafe fn sifields(&self) -> &sifields { - &(*(self as *const siginfo_t as *const siginfo_f)).sifields - } +impl siginfo_t { + unsafe fn sifields(&self) -> &sifields { + &(*(self as *const siginfo_t as *const siginfo_f)).sifields + } - pub unsafe fn si_pid(&self) -> ::pid_t { - self.sifields().sigchld.si_pid - } + pub unsafe fn si_pid(&self) -> ::pid_t { + self.sifields().sigchld.si_pid + } - pub unsafe fn si_uid(&self) -> ::uid_t { - self.sifields().sigchld.si_uid - } + pub unsafe fn si_uid(&self) -> ::uid_t { + self.sifields().sigchld.si_uid + } - pub unsafe fn si_status(&self) -> ::c_int { - self.sifields().sigchld.si_status - } + pub unsafe fn si_status(&self) -> ::c_int { + self.sifields().sigchld.si_status + } - pub unsafe fn si_utime(&self) -> ::c_long { - self.sifields().sigchld.si_utime - } + pub unsafe fn si_utime(&self) -> ::c_long { + self.sifields().sigchld.si_utime + } - pub unsafe fn si_stime(&self) -> ::c_long { - self.sifields().sigchld.si_stime - } - } + pub unsafe fn si_stime(&self) -> ::c_long { + self.sifields().sigchld.si_stime + } +} - pub union __c_anonymous_ptrace_syscall_info_data { - pub entry: __c_anonymous_ptrace_syscall_info_entry, - pub exit: __c_anonymous_ptrace_syscall_info_exit, - pub seccomp: __c_anonymous_ptrace_syscall_info_seccomp, - } - impl ::Copy for __c_anonymous_ptrace_syscall_info_data {} - impl ::Clone for __c_anonymous_ptrace_syscall_info_data { - fn clone(&self) -> __c_anonymous_ptrace_syscall_info_data { - *self - } - } +pub union __c_anonymous_ptrace_syscall_info_data { + pub entry: __c_anonymous_ptrace_syscall_info_entry, + pub exit: __c_anonymous_ptrace_syscall_info_exit, + pub seccomp: __c_anonymous_ptrace_syscall_info_seccomp, +} +impl ::Copy for __c_anonymous_ptrace_syscall_info_data {} +impl ::Clone for __c_anonymous_ptrace_syscall_info_data { + fn clone(&self) -> __c_anonymous_ptrace_syscall_info_data { + *self } } @@ -656,7 +651,6 @@ cfg_if! { } } - #[cfg(libc_union)] impl PartialEq for __c_anonymous_ptrace_syscall_info_data { fn eq(&self, other: &__c_anonymous_ptrace_syscall_info_data) -> bool { unsafe { @@ -667,10 +661,8 @@ cfg_if! { } } - #[cfg(libc_union)] impl Eq for __c_anonymous_ptrace_syscall_info_data {} - #[cfg(libc_union)] impl ::fmt::Debug for __c_anonymous_ptrace_syscall_info_data { fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { unsafe { @@ -683,7 +675,6 @@ cfg_if! { } } - #[cfg(libc_union)] impl ::hash::Hash for __c_anonymous_ptrace_syscall_info_data { fn hash(&self, state: &mut H) { unsafe { @@ -1580,12 +1571,5 @@ cfg_if! { } } -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; - } else { - mod no_align; - pub use self::no_align::*; - } -} +mod align; +pub use self::align::*; diff --git a/src/unix/linux_like/linux/gnu/no_align.rs b/src/unix/linux_like/linux/gnu/no_align.rs deleted file mode 100644 index e32bf673d140e..0000000000000 --- a/src/unix/linux_like/linux/gnu/no_align.rs +++ /dev/null @@ -1,10 +0,0 @@ -s! { - // FIXME this is actually a union - pub struct sem_t { - #[cfg(target_pointer_width = "32")] - __size: [::c_char; 16], - #[cfg(target_pointer_width = "64")] - __size: [::c_char; 32], - __align: [::c_long; 0], - } -} diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index 1973b3f574efa..3283f09dcd294 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -823,7 +823,6 @@ s_no_extra_traits! { pad: [::c_long; 4], } - #[cfg(libc_union)] pub union __c_anonymous_ifr_ifru { pub ifru_addr: ::sockaddr, pub ifru_dstaddr: ::sockaddr, @@ -843,13 +842,9 @@ s_no_extra_traits! { pub struct ifreq { /// interface name, e.g. "en0" pub ifr_name: [::c_char; ::IFNAMSIZ], - #[cfg(libc_union)] pub ifr_ifru: __c_anonymous_ifr_ifru, - #[cfg(not(libc_union))] - pub ifr_ifru: ::sockaddr, } - #[cfg(libc_union)] pub union __c_anonymous_ifc_ifcu { pub ifcu_buf: *mut ::c_char, pub ifcu_req: *mut ::ifreq, @@ -860,10 +855,7 @@ s_no_extra_traits! { networks accessible). */ pub struct ifconf { pub ifc_len: ::c_int, /* Size of buffer. */ - #[cfg(libc_union)] pub ifc_ifcu: __c_anonymous_ifc_ifcu, - #[cfg(not(libc_union))] - pub ifc_ifcu: *mut ::ifreq, } pub struct hwtstamp_config { @@ -901,23 +893,19 @@ s_no_extra_traits! { } } -cfg_if! { - if #[cfg(libc_union)] { - s_no_extra_traits! { - // linux/can.h - #[allow(missing_debug_implementations)] - pub union __c_anonymous_sockaddr_can_can_addr { - pub tp: __c_anonymous_sockaddr_can_tp, - pub j1939: __c_anonymous_sockaddr_can_j1939, - } +s_no_extra_traits! { + // linux/can.h + #[allow(missing_debug_implementations)] + pub union __c_anonymous_sockaddr_can_can_addr { + pub tp: __c_anonymous_sockaddr_can_tp, + pub j1939: __c_anonymous_sockaddr_can_j1939, + } - #[allow(missing_debug_implementations)] - pub struct sockaddr_can { - pub can_family: ::sa_family_t, - pub can_ifindex: ::c_int, - pub can_addr: __c_anonymous_sockaddr_can_can_addr, - } - } + #[allow(missing_debug_implementations)] + pub struct sockaddr_can { + pub can_family: ::sa_family_t, + pub can_ifindex: ::c_int, + pub can_addr: __c_anonymous_sockaddr_can_can_addr, } } @@ -1285,7 +1273,6 @@ cfg_if! { self.mq_curmsgs.hash(state); } } - #[cfg(libc_union)] impl ::fmt::Debug for __c_anonymous_ifr_ifru { fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { f.debug_struct("ifr_ifru") @@ -1314,7 +1301,6 @@ cfg_if! { } } - #[cfg(libc_union)] impl ::fmt::Debug for __c_anonymous_ifc_ifcu { fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { f.debug_struct("ifr_ifru") @@ -4310,19 +4296,15 @@ pub const CANXL_MAX_DLEN: usize = 2048; pub const CANXL_XLF: ::c_int = 0x80; pub const CANXL_SEC: ::c_int = 0x01; -cfg_if! { - if #[cfg(libc_align)] { - pub const CAN_MTU: usize = ::mem::size_of::(); - pub const CANFD_MTU: usize = ::mem::size_of::(); - pub const CANXL_MTU: usize = ::mem::size_of::(); - // FIXME: use `core::mem::offset_of!` once that is available - // https://github.com/rust-lang/rfcs/pull/3308 - // pub const CANXL_HDR_SIZE: usize = core::mem::offset_of!(canxl_frame, data); - pub const CANXL_HDR_SIZE: usize = 12; - pub const CANXL_MIN_MTU: usize = CANXL_HDR_SIZE + 64; - pub const CANXL_MAX_MTU: usize = CANXL_MTU; - } -} +pub const CAN_MTU: usize = ::mem::size_of::(); +pub const CANFD_MTU: usize = ::mem::size_of::(); +pub const CANXL_MTU: usize = ::mem::size_of::(); +// FIXME: use `core::mem::offset_of!` once that is available +// https://github.com/rust-lang/rfcs/pull/3308 +// pub const CANXL_HDR_SIZE: usize = core::mem::offset_of!(canxl_frame, data); +pub const CANXL_HDR_SIZE: usize = 12; +pub const CANXL_MIN_MTU: usize = CANXL_HDR_SIZE + 64; +pub const CANXL_MAX_MTU: usize = CANXL_MTU; pub const CAN_RAW: ::c_int = 1; pub const CAN_BCM: ::c_int = 2; @@ -5689,15 +5671,8 @@ cfg_if! { mod arch; pub use self::arch::*; -cfg_if! { - if #[cfg(libc_align)] { - #[macro_use] - mod align; - } else { - #[macro_use] - mod no_align; - } -} +#[macro_use] +mod align; expand_align!(); cfg_if! { diff --git a/src/unix/linux_like/linux/musl/b32/arm/mod.rs b/src/unix/linux_like/linux/musl/b32/arm/mod.rs index 4ac3e60d43079..58097f1434015 100644 --- a/src/unix/linux_like/linux/musl/b32/arm/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/arm/mod.rs @@ -846,9 +846,5 @@ extern "C" { pub fn getrandom(buf: *mut ::c_void, buflen: ::size_t, flags: ::c_uint) -> ::ssize_t; } -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; - } -} +mod align; +pub use self::align::*; diff --git a/src/unix/linux_like/linux/musl/b32/mips/mod.rs b/src/unix/linux_like/linux/musl/b32/mips/mod.rs index 2fb405bbc6ceb..ab7a55b754c5e 100644 --- a/src/unix/linux_like/linux/musl/b32/mips/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/mips/mod.rs @@ -780,9 +780,5 @@ pub const SYS_process_mrelease: ::c_long = 4000 + 448; pub const SYS_futex_waitv: ::c_long = 4000 + 449; pub const SYS_set_mempolicy_home_node: ::c_long = 4000 + 450; -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; - } -} +mod align; +pub use self::align::*; diff --git a/src/unix/linux_like/linux/musl/b32/riscv32/mod.rs b/src/unix/linux_like/linux/musl/b32/riscv32/mod.rs index f963f645a9f10..8568f2f338094 100644 --- a/src/unix/linux_like/linux/musl/b32/riscv32/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/riscv32/mod.rs @@ -790,9 +790,5 @@ pub const SYS_process_madvise: ::c_long = 440; pub const SYS_epoll_pwait2: ::c_long = 441; pub const SYS_mount_setattr: ::c_long = 442; -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; - } -} +mod align; +pub use self::align::*; diff --git a/src/unix/linux_like/linux/musl/b32/x86/mod.rs b/src/unix/linux_like/linux/musl/b32/x86/mod.rs index 7fad04677f8a4..f43c7ea60f8c7 100644 --- a/src/unix/linux_like/linux/musl/b32/x86/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/x86/mod.rs @@ -961,9 +961,5 @@ extern "C" { pub fn getrandom(buf: *mut ::c_void, buflen: ::size_t, flags: ::c_uint) -> ::ssize_t; } -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; - } -} +mod align; +pub use self::align::*; diff --git a/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs b/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs index 24e6b8419253a..1d84a15790cbc 100644 --- a/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs @@ -644,16 +644,8 @@ pub const IEXTEN: ::tcflag_t = 0x00008000; pub const TOSTOP: ::tcflag_t = 0x00000100; pub const FLUSHO: ::tcflag_t = 0x00001000; -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; - } -} +mod align; +pub use self::align::*; -cfg_if! { - if #[cfg(libc_int128)] { - mod int128; - pub use self::int128::*; - } -} +mod int128; +pub use self::int128::*; diff --git a/src/unix/linux_like/linux/musl/b64/loongarch64/mod.rs b/src/unix/linux_like/linux/musl/b64/loongarch64/mod.rs index 59a824b237306..ed47b50b2b495 100644 --- a/src/unix/linux_like/linux/musl/b64/loongarch64/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/loongarch64/mod.rs @@ -661,9 +661,5 @@ pub const IEXTEN: ::tcflag_t = 0x00008000; pub const TOSTOP: ::tcflag_t = 0x00000100; pub const FLUSHO: ::tcflag_t = 0x00001000; -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; - } -} +mod align; +pub use self::align::*; diff --git a/src/unix/linux_like/linux/musl/b64/riscv64/mod.rs b/src/unix/linux_like/linux/musl/b64/riscv64/mod.rs index 393f54d3ff773..2a37bd976bc7c 100644 --- a/src/unix/linux_like/linux/musl/b64/riscv64/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/riscv64/mod.rs @@ -719,9 +719,5 @@ pub const REG_A0: usize = 10; pub const REG_S2: usize = 18; pub const REG_NARGS: usize = 8; -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; - } -} +mod align; +pub use self::align::*; diff --git a/src/unix/linux_like/linux/musl/b64/x86_64/mod.rs b/src/unix/linux_like/linux/musl/b64/x86_64/mod.rs index dc617d42fe0cc..b1ede42064f97 100644 --- a/src/unix/linux_like/linux/musl/b64/x86_64/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/x86_64/mod.rs @@ -909,9 +909,5 @@ pub const IEXTEN: ::tcflag_t = 0x00008000; pub const TOSTOP: ::tcflag_t = 0x00000100; pub const FLUSHO: ::tcflag_t = 0x00001000; -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; - } -} +mod align; +pub use self::align::*; diff --git a/src/unix/linux_like/linux/musl/mod.rs b/src/unix/linux_like/linux/musl/mod.rs index a4c8f79c35cad..7ae2d064bac88 100644 --- a/src/unix/linux_like/linux/musl/mod.rs +++ b/src/unix/linux_like/linux/musl/mod.rs @@ -58,65 +58,61 @@ impl siginfo_t { } } -cfg_if! { - if #[cfg(libc_union)] { - // Internal, for casts to access union fields - #[repr(C)] - struct sifields_sigchld { - si_pid: ::pid_t, - si_uid: ::uid_t, - si_status: ::c_int, - si_utime: ::c_long, - si_stime: ::c_long, - } - impl ::Copy for sifields_sigchld {} - impl ::Clone for sifields_sigchld { - fn clone(&self) -> sifields_sigchld { - *self - } - } +// Internal, for casts to access union fields +#[repr(C)] +struct sifields_sigchld { + si_pid: ::pid_t, + si_uid: ::uid_t, + si_status: ::c_int, + si_utime: ::c_long, + si_stime: ::c_long, +} +impl ::Copy for sifields_sigchld {} +impl ::Clone for sifields_sigchld { + fn clone(&self) -> sifields_sigchld { + *self + } +} - // Internal, for casts to access union fields - #[repr(C)] - union sifields { - _align_pointer: *mut ::c_void, - sigchld: sifields_sigchld, - } +// Internal, for casts to access union fields +#[repr(C)] +union sifields { + _align_pointer: *mut ::c_void, + sigchld: sifields_sigchld, +} - // Internal, for casts to access union fields. Note that some variants - // of sifields start with a pointer, which makes the alignment of - // sifields vary on 32-bit and 64-bit architectures. - #[repr(C)] - struct siginfo_f { - _siginfo_base: [::c_int; 3], - sifields: sifields, - } +// Internal, for casts to access union fields. Note that some variants +// of sifields start with a pointer, which makes the alignment of +// sifields vary on 32-bit and 64-bit architectures. +#[repr(C)] +struct siginfo_f { + _siginfo_base: [::c_int; 3], + sifields: sifields, +} - impl siginfo_t { - unsafe fn sifields(&self) -> &sifields { - &(*(self as *const siginfo_t as *const siginfo_f)).sifields - } +impl siginfo_t { + unsafe fn sifields(&self) -> &sifields { + &(*(self as *const siginfo_t as *const siginfo_f)).sifields + } - pub unsafe fn si_pid(&self) -> ::pid_t { - self.sifields().sigchld.si_pid - } + pub unsafe fn si_pid(&self) -> ::pid_t { + self.sifields().sigchld.si_pid + } - pub unsafe fn si_uid(&self) -> ::uid_t { - self.sifields().sigchld.si_uid - } + pub unsafe fn si_uid(&self) -> ::uid_t { + self.sifields().sigchld.si_uid + } - pub unsafe fn si_status(&self) -> ::c_int { - self.sifields().sigchld.si_status - } + pub unsafe fn si_status(&self) -> ::c_int { + self.sifields().sigchld.si_status + } - pub unsafe fn si_utime(&self) -> ::c_long { - self.sifields().sigchld.si_utime - } + pub unsafe fn si_utime(&self) -> ::c_long { + self.sifields().sigchld.si_utime + } - pub unsafe fn si_stime(&self) -> ::c_long { - self.sifields().sigchld.si_stime - } - } + pub unsafe fn si_stime(&self) -> ::c_long { + self.sifields().sigchld.si_stime } } diff --git a/src/unix/linux_like/linux/no_align.rs b/src/unix/linux_like/linux/no_align.rs deleted file mode 100644 index 328a5cc484231..0000000000000 --- a/src/unix/linux_like/linux/no_align.rs +++ /dev/null @@ -1,144 +0,0 @@ -macro_rules! expand_align { - () => { - s! { - pub struct pthread_mutexattr_t { - #[cfg(any(target_arch = "x86_64", - target_arch = "powerpc64", - target_arch = "mips64", - target_arch = "mips64r6", - target_arch = "s390x", - target_arch = "sparc64", - target_arch = "riscv64", - target_arch = "riscv32", - target_arch = "loongarch64", - all(target_arch = "aarch64", - any(target_env = "musl", target_env = "ohos"))))] - __align: [::c_int; 0], - #[cfg(not(any(target_arch = "x86_64", - target_arch = "powerpc64", - target_arch = "mips64", - target_arch = "mips64r6", - target_arch = "s390x", - target_arch = "sparc64", - target_arch = "riscv64", - target_arch = "riscv32", - target_arch = "loongarch64", - all(target_arch = "aarch64", - any(target_env = "musl", target_env = "ohos")))))] - __align: [::c_long; 0], - size: [u8; ::__SIZEOF_PTHREAD_MUTEXATTR_T], - } - - pub struct pthread_rwlockattr_t { - #[cfg(any(target_env = "musl", target_env = "ohos"))] - __align: [::c_int; 0], - #[cfg(not(any(target_env = "musl", target_env = "ohos")))] - __align: [::c_long; 0], - size: [u8; ::__SIZEOF_PTHREAD_RWLOCKATTR_T], - } - - pub struct pthread_condattr_t { - __align: [::c_int; 0], - size: [u8; ::__SIZEOF_PTHREAD_CONDATTR_T], - } - - pub struct pthread_barrierattr_t { - __align: [::c_int; 0], - size: [u8; ::__SIZEOF_PTHREAD_BARRIERATTR_T], - } - - pub struct fanotify_event_metadata { - __align: [::c_long; 0], - pub event_len: __u32, - pub vers: __u8, - pub reserved: __u8, - pub metadata_len: __u16, - pub mask: __u64, - pub fd: ::c_int, - pub pid: ::c_int, - } - } - - s_no_extra_traits! { - pub struct pthread_cond_t { - #[cfg(any(target_env = "musl", target_env = "ohos"))] - __align: [*const ::c_void; 0], - #[cfg(not(any(target_env = "musl", target_env = "ohos")))] - __align: [::c_longlong; 0], - size: [u8; ::__SIZEOF_PTHREAD_COND_T], - } - - pub struct pthread_mutex_t { - #[cfg(any(target_arch = "mips", - target_arch = "mips32r6", - target_arch = "arm", - target_arch = "m68k", - target_arch = "csky", - target_arch = "powerpc", - target_arch = "sparc", - all(target_arch = "x86_64", - target_pointer_width = "32")))] - __align: [::c_long; 0], - #[cfg(not(any(target_arch = "mips", - target_arch = "mips32r6", - target_arch = "arm", - target_arch = "m68k", - target_arch = "csky", - target_arch = "powerpc", - target_arch = "sparc", - all(target_arch = "x86_64", - target_pointer_width = "32"))))] - __align: [::c_longlong; 0], - size: [u8; ::__SIZEOF_PTHREAD_MUTEX_T], - } - - pub struct pthread_rwlock_t { - #[cfg(any(target_arch = "mips", - target_arch = "mips32r6", - target_arch = "arm", - target_arch = "m68k", - target_arch = "csky", - target_arch = "powerpc", - target_arch = "sparc", - all(target_arch = "x86_64", - target_pointer_width = "32")))] - __align: [::c_long; 0], - #[cfg(not(any(target_arch = "mips", - target_arch = "mips32r6", - target_arch = "arm", - target_arch = "m68k", - target_arch = "csky", - target_arch = "powerpc", - target_arch = "sparc", - all(target_arch = "x86_64", - target_pointer_width = "32"))))] - __align: [::c_longlong; 0], - size: [u8; ::__SIZEOF_PTHREAD_RWLOCK_T], - } - - pub struct pthread_barrier_t { - #[cfg(any(target_arch = "mips", - target_arch = "mips32r6", - target_arch = "arm", - target_arch = "m68k", - target_arch = "csky", - target_arch = "powerpc", - target_arch = "sparc", - all(target_arch = "x86_64", - target_pointer_width = "32")))] - __align: [::c_long; 0], - #[cfg(not(any(target_arch = "mips", - target_arch = "mips32r6", - target_arch = "arm", - target_arch = "m68k", - target_arch = "csky", - target_arch = "powerpc", - target_arch = "sparc", - all(target_arch = "x86_64", - target_pointer_width = "32"))))] - __align: [::c_longlong; 0], - size: [u8; ::__SIZEOF_PTHREAD_BARRIER_T], - } - } - }; -} diff --git a/src/unix/linux_like/linux/uclibc/arm/mod.rs b/src/unix/linux_like/linux/uclibc/arm/mod.rs index cff82f005acee..69187670587d6 100644 --- a/src/unix/linux_like/linux/uclibc/arm/mod.rs +++ b/src/unix/linux_like/linux/uclibc/arm/mod.rs @@ -914,12 +914,5 @@ pub const SYS_process_mrelease: ::c_long = 448; pub const SYS_futex_waitv: ::c_long = 449; pub const SYS_set_mempolicy_home_node: ::c_long = 450; -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; - } else { - mod no_align; - pub use self::no_align::*; - } -} +mod align; +pub use self::align::*; diff --git a/src/unix/linux_like/linux/uclibc/arm/no_align.rs b/src/unix/linux_like/linux/uclibc/arm/no_align.rs deleted file mode 100644 index e32bf673d140e..0000000000000 --- a/src/unix/linux_like/linux/uclibc/arm/no_align.rs +++ /dev/null @@ -1,10 +0,0 @@ -s! { - // FIXME this is actually a union - pub struct sem_t { - #[cfg(target_pointer_width = "32")] - __size: [::c_char; 16], - #[cfg(target_pointer_width = "64")] - __size: [::c_char; 32], - __align: [::c_long; 0], - } -} diff --git a/src/unix/linux_like/linux/uclibc/mips/mips32/mod.rs b/src/unix/linux_like/linux/uclibc/mips/mips32/mod.rs index a5aca85a3a741..9e5765e9568f1 100644 --- a/src/unix/linux_like/linux/uclibc/mips/mips32/mod.rs +++ b/src/unix/linux_like/linux/uclibc/mips/mips32/mod.rs @@ -681,12 +681,5 @@ extern "C" { ) -> ::c_int; } -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; - } else { - mod no_align; - pub use self::no_align::*; - } -} +mod align; +pub use self::align::*; diff --git a/src/unix/linux_like/linux/uclibc/mips/mips32/no_align.rs b/src/unix/linux_like/linux/uclibc/mips/mips32/no_align.rs deleted file mode 100644 index e32bf673d140e..0000000000000 --- a/src/unix/linux_like/linux/uclibc/mips/mips32/no_align.rs +++ /dev/null @@ -1,10 +0,0 @@ -s! { - // FIXME this is actually a union - pub struct sem_t { - #[cfg(target_pointer_width = "32")] - __size: [::c_char; 16], - #[cfg(target_pointer_width = "64")] - __size: [::c_char; 32], - __align: [::c_long; 0], - } -} diff --git a/src/unix/linux_like/linux/uclibc/mips/mips64/mod.rs b/src/unix/linux_like/linux/uclibc/mips/mips64/mod.rs index 8ca100fcd268f..4ac13f5c77866 100644 --- a/src/unix/linux_like/linux/uclibc/mips/mips64/mod.rs +++ b/src/unix/linux_like/linux/uclibc/mips/mips64/mod.rs @@ -196,12 +196,5 @@ pub const __SIZEOF_PTHREAD_BARRIER_T: usize = 32; pub const SYS_gettid: ::c_long = 5178; // Valid for n64 -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; - } else { - mod no_align; - pub use self::no_align::*; - } -} +mod align; +pub use self::align::*; diff --git a/src/unix/linux_like/linux/uclibc/mips/mips64/no_align.rs b/src/unix/linux_like/linux/uclibc/mips/mips64/no_align.rs deleted file mode 100644 index 8909114cdfa42..0000000000000 --- a/src/unix/linux_like/linux/uclibc/mips/mips64/no_align.rs +++ /dev/null @@ -1,7 +0,0 @@ -s! { - // FIXME this is actually a union - pub struct sem_t { - __size: [::c_char; 32], - __align: [::c_long; 0], - } -} diff --git a/src/unix/linux_like/linux/uclibc/no_align.rs b/src/unix/linux_like/linux/uclibc/no_align.rs deleted file mode 100644 index a73dbded57ac7..0000000000000 --- a/src/unix/linux_like/linux/uclibc/no_align.rs +++ /dev/null @@ -1,53 +0,0 @@ -macro_rules! expand_align { - () => { - s! { - pub struct pthread_mutex_t { - #[cfg(any(target_arch = "mips", - target_arch = "arm", - target_arch = "powerpc"))] - __align: [::c_long; 0], - #[cfg(any(libc_align, - target_arch = "mips", - target_arch = "arm", - target_arch = "powerpc"))] - __align: [::c_longlong; 0], - size: [u8; ::__SIZEOF_PTHREAD_MUTEX_T], - } - - pub struct pthread_rwlock_t { - #[cfg(any(target_arch = "mips", - target_arch = "arm", - target_arch = "powerpc"))] - __align: [::c_long; 0], - #[cfg(not(any( - target_arch = "mips", - target_arch = "arm", - target_arch = "powerpc")))] - __align: [::c_longlong; 0], - size: [u8; ::__SIZEOF_PTHREAD_RWLOCK_T], - } - - pub struct pthread_mutexattr_t { - #[cfg(any(target_arch = "x86_64", target_arch = "powerpc64", - target_arch = "mips64", target_arch = "s390x", - target_arch = "sparc64"))] - __align: [::c_int; 0], - #[cfg(not(any(target_arch = "x86_64", target_arch = "powerpc64", - target_arch = "mips64", target_arch = "s390x", - target_arch = "sparc64")))] - __align: [::c_long; 0], - size: [u8; ::__SIZEOF_PTHREAD_MUTEXATTR_T], - } - - pub struct pthread_cond_t { - __align: [::c_longlong; 0], - size: [u8; ::__SIZEOF_PTHREAD_COND_T], - } - - pub struct pthread_condattr_t { - __align: [::c_int; 0], - size: [u8; ::__SIZEOF_PTHREAD_CONDATTR_T], - } - } - } -} diff --git a/src/unix/mod.rs b/src/unix/mod.rs index 6bab825b0449b..e29170cb779ca 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -1622,32 +1622,7 @@ cfg_if! { } } -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 use ffi::c_void; -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; - } else { - mod no_align; - pub use self::no_align::*; - } -} +mod align; +pub use self::align::*; diff --git a/src/unix/newlib/mod.rs b/src/unix/newlib/mod.rs index 29693f6ec2402..ce45065b039cf 100644 --- a/src/unix/newlib/mod.rs +++ b/src/unix/newlib/mod.rs @@ -792,13 +792,6 @@ cfg_if! { } } -cfg_if! { - if #[cfg(libc_align)] { - #[macro_use] - mod align; - } else { - #[macro_use] - mod no_align; - } -} +#[macro_use] +mod align; expand_align!(); diff --git a/src/unix/newlib/no_align.rs b/src/unix/newlib/no_align.rs deleted file mode 100644 index ce3aca4ed5723..0000000000000 --- a/src/unix/newlib/no_align.rs +++ /dev/null @@ -1,51 +0,0 @@ -macro_rules! expand_align { - () => { - s! { - pub struct pthread_mutex_t { // Unverified - #[cfg(any(target_arch = "mips", - target_arch = "arm", - target_arch = "powerpc"))] - __align: [::c_long; 0], - #[cfg(not(any(target_arch = "mips", - target_arch = "arm", - target_arch = "powerpc")))] - __align: [::c_longlong; 0], - size: [u8; ::__SIZEOF_PTHREAD_MUTEX_T], - } - - pub struct pthread_rwlock_t { // Unverified - #[cfg(any(target_arch = "mips", - target_arch = "arm", - target_arch = "powerpc"))] - __align: [::c_long; 0], - #[cfg(not(any(target_arch = "mips", - target_arch = "arm", - target_arch = "powerpc")))] - __align: [::c_longlong; 0], - size: [u8; ::__SIZEOF_PTHREAD_RWLOCK_T], - } - - pub struct pthread_mutexattr_t { // Unverified - #[cfg(any(target_arch = "x86_64", target_arch = "powerpc64", - target_arch = "mips64", target_arch = "s390x", - target_arch = "sparc64"))] - __align: [::c_int; 0], - #[cfg(not(any(target_arch = "x86_64", target_arch = "powerpc64", - target_arch = "mips64", target_arch = "s390x", - target_arch = "sparc64")))] - __align: [::c_long; 0], - size: [u8; ::__SIZEOF_PTHREAD_MUTEXATTR_T], - } - - pub struct pthread_cond_t { // Unverified - __align: [::c_longlong; 0], - size: [u8; ::__SIZEOF_PTHREAD_COND_T], - } - - pub struct pthread_condattr_t { // Unverified - __align: [::c_int; 0], - size: [u8; ::__SIZEOF_PTHREAD_CONDATTR_T], - } - } - }; -} diff --git a/src/unix/no_align.rs b/src/unix/no_align.rs deleted file mode 100644 index b435d72aa7db0..0000000000000 --- a/src/unix/no_align.rs +++ /dev/null @@ -1,16 +0,0 @@ -s! { - pub struct in6_addr { - pub s6_addr: [u8; 16], - __align: [u32; 0], - } -} - -pub const IN6ADDR_LOOPBACK_INIT: in6_addr = in6_addr { - s6_addr: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], - __align: [0u32; 0], -}; - -pub const IN6ADDR_ANY_INIT: in6_addr = in6_addr { - s6_addr: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], - __align: [0u32; 0], -}; diff --git a/src/unix/nto/x86_64.rs b/src/unix/nto/x86_64.rs index 3a1d230bb98eb..29739ac83a3e9 100644 --- a/src/unix/nto/x86_64.rs +++ b/src/unix/nto/x86_64.rs @@ -34,10 +34,7 @@ s! { #[repr(align(8))] pub struct mcontext_t { pub cpu: x86_64_cpu_registers, - #[cfg(libc_union)] pub fpu: x86_64_fpu_registers, - #[cfg(not(libc_union))] - __reserved: [u8; 1024], } pub struct stack_t { @@ -80,7 +77,6 @@ s! { } s_no_extra_traits! { - #[cfg(libc_union)] pub union x86_64_fpu_registers { pub fsave_area: fsave_area_64, pub fxsave_area: fxsave_area_64, @@ -91,10 +87,8 @@ s_no_extra_traits! { cfg_if! { if #[cfg(feature = "extra_traits")] { - #[cfg(libc_union)] impl Eq for x86_64_fpu_registers {} - #[cfg(libc_union)] impl PartialEq for x86_64_fpu_registers { fn eq(&self, other: &x86_64_fpu_registers) -> bool { unsafe { @@ -105,7 +99,6 @@ cfg_if! { } } - #[cfg(libc_union)] impl ::fmt::Debug for x86_64_fpu_registers { fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { unsafe { @@ -118,7 +111,6 @@ cfg_if! { } } - #[cfg(libc_union)] impl ::hash::Hash for x86_64_fpu_registers { fn hash(&self, state: &mut H) { unsafe { diff --git a/src/unix/solarish/mod.rs b/src/unix/solarish/mod.rs index 63056bfbd7c7c..6c204b383b39a 100644 --- a/src/unix/solarish/mod.rs +++ b/src/unix/solarish/mod.rs @@ -541,7 +541,7 @@ s_no_extra_traits! { __ss_pad2: [u8; 240], } - #[cfg_attr(all(target_pointer_width = "64", libc_align), repr(align(8)))] + #[cfg_attr(target_pointer_width = "64", repr(align(8)))] pub struct siginfo_t { pub si_signo: ::c_int, pub si_code: ::c_int, @@ -571,15 +571,13 @@ s_no_extra_traits! { __sigev_pad2: ::c_int, } - #[cfg(libc_union)] - #[cfg_attr(libc_align, repr(align(16)))] + #[repr(align(16))] pub union pad128_t { // pub _q in this structure would be a "long double", of 16 bytes pub _l: [i32; 4], } - #[cfg(libc_union)] - #[cfg_attr(libc_align, repr(align(16)))] + #[repr(align(16))] pub union upad128_t { // pub _q in this structure would be a "long double", of 16 bytes pub _l: [u32; 4], @@ -947,7 +945,6 @@ cfg_if! { } } - #[cfg(libc_union)] impl PartialEq for pad128_t { fn eq(&self, other: &pad128_t) -> bool { unsafe { @@ -956,9 +953,7 @@ cfg_if! { } } } - #[cfg(libc_union)] impl Eq for pad128_t {} - #[cfg(libc_union)] impl ::fmt::Debug for pad128_t { fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { unsafe { @@ -969,7 +964,6 @@ cfg_if! { } } } - #[cfg(libc_union)] impl ::hash::Hash for pad128_t { fn hash(&self, state: &mut H) { unsafe { @@ -978,7 +972,6 @@ cfg_if! { } } } - #[cfg(libc_union)] impl PartialEq for upad128_t { fn eq(&self, other: &upad128_t) -> bool { unsafe { @@ -987,9 +980,7 @@ cfg_if! { } } } - #[cfg(libc_union)] impl Eq for upad128_t {} - #[cfg(libc_union)] impl ::fmt::Debug for upad128_t { fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { unsafe { @@ -1000,7 +991,6 @@ cfg_if! { } } } - #[cfg(libc_union)] impl ::hash::Hash for upad128_t { fn hash(&self, state: &mut H) { unsafe { diff --git a/src/unix/solarish/x86_64.rs b/src/unix/solarish/x86_64.rs index bca552f378202..d0e80b5588c46 100644 --- a/src/unix/solarish/x86_64.rs +++ b/src/unix/solarish/x86_64.rs @@ -50,7 +50,6 @@ s! { } s_no_extra_traits! { - #[cfg(libc_union)] pub union __c_anonymous_fp_reg_set { pub fpchip_state: __c_anonymous_fpchip_state, pub f_fpregs: [[u32; 13]; 10], @@ -77,7 +76,6 @@ s_no_extra_traits! { cfg_if! { if #[cfg(feature = "extra_traits")] { - #[cfg(libc_union)] impl PartialEq for __c_anonymous_fp_reg_set { fn eq(&self, other: &__c_anonymous_fp_reg_set) -> bool { unsafe { @@ -90,9 +88,7 @@ cfg_if! { } } } - #[cfg(libc_union)] impl Eq for __c_anonymous_fp_reg_set {} - #[cfg(libc_union)] impl ::fmt::Debug for __c_anonymous_fp_reg_set { fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { unsafe { diff --git a/src/vxworks/mod.rs b/src/vxworks/mod.rs index 314283410aed6..4edcc00e44021 100644 --- a/src/vxworks/mod.rs +++ b/src/vxworks/mod.rs @@ -1941,25 +1941,7 @@ pub fn posix_memalign(memptr: *mut *mut ::c_void, align: ::size_t, size: ::size_ } } -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 use ffi::c_void; cfg_if! { if #[cfg(target_arch = "aarch64")] { diff --git a/src/windows/gnu/mod.rs b/src/windows/gnu/mod.rs index 3e7d38b8e83c6..8923a531e7512 100644 --- a/src/windows/gnu/mod.rs +++ b/src/windows/gnu/mod.rs @@ -15,9 +15,5 @@ extern "C" { pub fn wmemchr(cx: *const ::wchar_t, c: ::wchar_t, n: ::size_t) -> *mut ::wchar_t; } -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; - } -} +mod align; +pub use self::align::*; diff --git a/src/windows/mod.rs b/src/windows/mod.rs index 196f1f2e4b743..df4f8047e22ad 100644 --- a/src/windows/mod.rs +++ b/src/windows/mod.rs @@ -568,25 +568,7 @@ extern "system" { pub fn socket(af: ::c_int, socket_type: ::c_int, protocol: ::c_int) -> SOCKET; } -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 use ffi::c_void; cfg_if! { if #[cfg(all(target_env = "gnu"))] { diff --git a/src/xous.rs b/src/xous.rs index e6c0c2573d07d..6731a94e20df7 100644 --- a/src/xous.rs +++ b/src/xous.rs @@ -28,22 +28,4 @@ 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, - } - } -} +pub use ffi::c_void;