diff --git a/.github/workflows/bors.yml b/.github/workflows/bors.yml index dbe80b4de4549..4dcd72bfbad84 100644 --- a/.github/workflows/bors.yml +++ b/.github/workflows/bors.yml @@ -204,11 +204,6 @@ jobs: stable, beta, nightly, - 1.13.0, - 1.19.0, - 1.24.0, - 1.25.0, - 1.30.0, ] steps: - uses: rust-lang/simpleinfra/github-actions/cancel-outdated-builds@master @@ -234,11 +229,6 @@ jobs: stable, beta, nightly, - 1.13.0, - 1.19.0, - 1.24.0, - 1.25.0, - 1.30.0, ] steps: - uses: rust-lang/simpleinfra/github-actions/cancel-outdated-builds@master @@ -259,10 +249,6 @@ jobs: fail-fast: true matrix: toolchain: [ - 1.19.0, - 1.24.0, - 1.25.0, - 1.30.0, stable, ] steps: diff --git a/Cargo.toml b/Cargo.toml index bace47fa63aec..7aa247ca626e1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,6 +14,7 @@ exclude = ["/ci/*", "/.github/*", "/.cirrus.yml", "/triagebot.toml"] description = """ Raw FFI bindings to platform libraries like libc. """ +rust-version = "1.47" [package.metadata.docs.rs] features = ["const-extern-fn", "extra_traits"] @@ -25,7 +26,7 @@ rustc-std-workspace-core = { version = "1.0.0", optional = true } default = ["std"] std = [] align = [] -rustc-dep-of-std = ['align', 'rustc-std-workspace-core'] +rustc-dep-of-std = ['rustc-std-workspace-core'] extra_traits = [] const-extern-fn = [] # use_std is deprecated, use `std` instead diff --git a/README.md b/README.md index bc5ad18f6b1b8..0b22dd4b641fe 100644 --- a/README.md +++ b/README.md @@ -40,23 +40,18 @@ libc = "0.2" * **deprecated**: `use_std` is deprecated, and is equivalent to `std`. +* **deprecated**: `align` is deprecated (and always enabled). + ## 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.47.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 | +| Feature | Version | +|-----------------------|---------| +| `const-extern-fn` | 1.62.0 | ## Platform support diff --git a/build.rs b/build.rs index 0a43b2a12ea96..38b0406b95eb4 100644 --- a/build.rs +++ b/build.rs @@ -8,17 +8,9 @@ fn main() { let (rustc_minor_ver, is_nightly) = rustc_minor_nightly().expect("Failed to get rustc version"); 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(); - if env::var("CARGO_FEATURE_USE_STD").is_ok() { - println!( - "cargo:warning=\"libc's use_std cargo feature is deprecated since libc 0.2.55; \ - please consider using the `std` cargo feature instead\"" - ); - } - // The ABI of libc used by libstd is backward compatible with FreeBSD 10. // The ABI of libc from crates.io is backward compatible with FreeBSD 11. // @@ -40,58 +32,10 @@ fn main() { println!("cargo:rustc-cfg=libc_deny_warnings"); } - // Rust >= 1.15 supports private module use: - if rustc_minor_ver >= 15 || rustc_dep_of_std { - println!("cargo:rustc-cfg=libc_priv_mod_use"); - } - - // Rust >= 1.19 supports unions: - if rustc_minor_ver >= 19 || rustc_dep_of_std { - println!("cargo:rustc-cfg=libc_union"); - } - - // Rust >= 1.24 supports const mem::size_of: - if rustc_minor_ver >= 24 || rustc_dep_of_std { - println!("cargo:rustc-cfg=libc_const_size_of"); - } - - // Rust >= 1.25 supports repr(align): - if rustc_minor_ver >= 25 || rustc_dep_of_std || align_cargo_feature { - println!("cargo:rustc-cfg=libc_align"); - } - - // Rust >= 1.26 supports i128 and u128: - if rustc_minor_ver >= 26 || rustc_dep_of_std { - println!("cargo:rustc-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 { - println!("cargo:rustc-cfg=libc_core_cvoid"); - } - - // Rust >= 1.33 supports repr(packed(N)) and cfg(target_vendor). - if rustc_minor_ver >= 33 || rustc_dep_of_std { - println!("cargo:rustc-cfg=libc_packedN"); - println!("cargo:rustc-cfg=libc_cfg_target_vendor"); - } - - // Rust >= 1.40 supports #[non_exhaustive]. - if rustc_minor_ver >= 40 || rustc_dep_of_std { - println!("cargo:rustc-cfg=libc_non_exhaustive"); - } - if rustc_minor_ver >= 51 || rustc_dep_of_std { println!("cargo:rustc-cfg=libc_ptr_addr_of"); } - // Rust >= 1.37.0 allows underscores as anonymous constant names. - if rustc_minor_ver >= 37 || rustc_dep_of_std { - println!("cargo:rustc-cfg=libc_underscore_const_names"); - } - // #[thread_local] is currently unstable if rustc_dep_of_std { println!("cargo:rustc-cfg=libc_thread_local"); diff --git a/ci/build.sh b/ci/build.sh index dba868fdd58e1..931a9b18ad89c 100644 --- a/ci/build.sh +++ b/ci/build.sh @@ -116,22 +116,15 @@ x86_64-unknown-freebsd \ x86_64-unknown-linux-gnu \ x86_64-unknown-linux-musl \ x86_64-unknown-netbsd \ -" - -RUST_GT_1_13_LINUX_TARGETS="\ arm-unknown-linux-musleabi \ arm-unknown-linux-musleabihf \ armv7-unknown-linux-musleabihf \ sparc64-unknown-linux-gnu \ wasm32-unknown-emscripten \ x86_64-linux-android \ -" -RUST_GT_1_19_LINUX_TARGETS="\ aarch64-unknown-linux-musl \ sparcv9-sun-solaris \ wasm32-unknown-unknown \ -" -RUST_GT_1_24_LINUX_TARGETS="\ i586-unknown-linux-musl \ " @@ -174,16 +167,6 @@ 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 - if [ "${RUST}" = "nightly" ]; then TARGETS="${TARGETS} ${RUST_NIGHTLY_LINUX_TARGETS}" fi diff --git a/libc-test/build.rs b/libc-test/build.rs index 7797ec6c66fbf..f26e332ef966a 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -58,15 +58,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_thread_local"]; for f in &libc_cfgs { cfg.cfg(f, None); } @@ -330,8 +322,6 @@ fn test_apple(target: &str) { // FIXME: the array size has been changed since macOS 10.15 ([8] -> [7]). ("statfs", "f_reserved") => true, ("__darwin_arm_neon_state64", "__v") => true, - // MAXPATHLEN is too big for auto-derive traits on arrays. - ("vnode_info_path", "vip_path") => true, _ => false, } }); @@ -2250,8 +2240,6 @@ fn test_freebsd(target: &str) { ("umutex", "m_owner") => true, // c_has_waiters field is a volatile int32_t ("ucond", "c_has_waiters") => true, - // is PATH_MAX long but tests can't accept multi array as equivalent. - ("kinfo_vmentry", "kve_path") => true, // a_un field is a union ("Elf32_Auxinfo", "a_un") => true, @@ -2280,10 +2268,6 @@ fn test_freebsd(target: &str) { // Anonymous type. ("filestat", "next") => true, - // We ignore this field because we needed to use a hack in order to make rust 1.19 - // happy... - ("kinfo_proc", "ki_sparestrings") => true, - // `__sem_base` is a private struct field ("semid_ds", "__sem_base") => true, diff --git a/src/fixed_width_ints.rs b/src/fixed_width_ints.rs index 999de8f54f194..6045d7e2d43d6 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. @@ -59,41 +59,37 @@ cfg_if! { /// C __uint128_t (alternate name for [__uint128][]) pub type __uint128_t = u128; - cfg_if! { - if #[cfg(libc_underscore_const_names)] { - macro_rules! static_assert_eq { - ($a:expr, $b:expr) => { - const _: [(); $a] = [(); $b]; - }; - } + macro_rules! static_assert_eq { + ($a:expr, $b:expr) => { + const _: [(); $a] = [(); $b]; + }; + } - // NOTE: if you add more platforms to here, you may need to cfg - // these consts. They should always match the platform's values - // for `sizeof(__int128)` and `_Alignof(__int128)`. - const _SIZE_128: usize = 16; - const _ALIGN_128: usize = 16; + // NOTE: if you add more platforms to here, you may need to cfg + // these consts. They should always match the platform's values + // for `sizeof(__int128)` and `_Alignof(__int128)`. + const _SIZE_128: usize = 16; + const _ALIGN_128: usize = 16; - // Since Rust doesn't officially guarantee that these types - // have compatible ABIs, we const assert that these values have the - // known size/align of the target platform's libc. If rustc ever - // tries to regress things, it will cause a compilation error. - // - // This isn't a bullet-proof solution because e.g. it doesn't - // catch the fact that llvm and gcc disagree on how x64 __int128 - // is actually *passed* on the stack (clang underaligns it for - // the same reason that rustc *never* properly aligns it). - static_assert_eq!(core::mem::size_of::<__int128>(), _SIZE_128); - static_assert_eq!(core::mem::align_of::<__int128>(), _ALIGN_128); + // Since Rust doesn't officially guarantee that these types + // have compatible ABIs, we const assert that these values have the + // known size/align of the target platform's libc. If rustc ever + // tries to regress things, it will cause a compilation error. + // + // This isn't a bullet-proof solution because e.g. it doesn't + // catch the fact that llvm and gcc disagree on how x64 __int128 + // is actually *passed* on the stack (clang underaligns it for + // the same reason that rustc *never* properly aligns it). + static_assert_eq!(core::mem::size_of::<__int128>(), _SIZE_128); + static_assert_eq!(core::mem::align_of::<__int128>(), _ALIGN_128); - static_assert_eq!(core::mem::size_of::<__uint128>(), _SIZE_128); - static_assert_eq!(core::mem::align_of::<__uint128>(), _ALIGN_128); + static_assert_eq!(core::mem::size_of::<__uint128>(), _SIZE_128); + static_assert_eq!(core::mem::align_of::<__uint128>(), _ALIGN_128); - static_assert_eq!(core::mem::size_of::<__int128_t>(), _SIZE_128); - static_assert_eq!(core::mem::align_of::<__int128_t>(), _ALIGN_128); + static_assert_eq!(core::mem::size_of::<__int128_t>(), _SIZE_128); + static_assert_eq!(core::mem::align_of::<__int128_t>(), _ALIGN_128); - static_assert_eq!(core::mem::size_of::<__uint128_t>(), _SIZE_128); - static_assert_eq!(core::mem::align_of::<__uint128_t>(), _ALIGN_128); - } - } + static_assert_eq!(core::mem::size_of::<__uint128_t>(), _SIZE_128); + static_assert_eq!(core::mem::align_of::<__uint128_t>(), _ALIGN_128); } } diff --git a/src/fuchsia/align.rs b/src/fuchsia/align.rs deleted file mode 100644 index 3409bf0c61955..0000000000000 --- a/src/fuchsia/align.rs +++ /dev/null @@ -1,142 +0,0 @@ -macro_rules! expand_align { - () => { - s! { - #[cfg_attr( - any( - target_pointer_width = "32", - target_arch = "x86_64" - ), - repr(align(4)))] - #[cfg_attr( - not(any( - target_pointer_width = "32", - target_arch = "x86_64" - )), - repr(align(8)))] - pub struct pthread_mutexattr_t { - size: [u8; ::__SIZEOF_PTHREAD_MUTEXATTR_T], - } - - #[cfg_attr(target_pointer_width = "32", - repr(align(4)))] - #[cfg_attr(target_pointer_width = "64", - repr(align(8)))] - pub struct pthread_rwlockattr_t { - size: [u8; ::__SIZEOF_PTHREAD_RWLOCKATTR_T], - } - - #[repr(align(4))] - pub struct pthread_condattr_t { - size: [u8; ::__SIZEOF_PTHREAD_CONDATTR_T], - } - } - - s_no_extra_traits! { - #[cfg_attr(all(target_pointer_width = "32", - any(target_arch = "arm", - target_arch = "x86_64")), - repr(align(4)))] - #[cfg_attr(any(target_pointer_width = "64", - not(any(target_arch = "arm", - target_arch = "x86_64"))), - repr(align(8)))] - pub struct pthread_mutex_t { - size: [u8; ::__SIZEOF_PTHREAD_MUTEX_T], - } - - #[cfg_attr(all(target_pointer_width = "32", - any(target_arch = "arm", - target_arch = "x86_64")), - repr(align(4)))] - #[cfg_attr(any(target_pointer_width = "64", - not(any(target_arch = "arm", - target_arch = "x86_64"))), - repr(align(8)))] - pub struct pthread_rwlock_t { - size: [u8; ::__SIZEOF_PTHREAD_RWLOCK_T], - } - - #[cfg_attr(target_pointer_width = "32", - repr(align(4)))] - #[cfg_attr(target_pointer_width = "64", - repr(align(8)))] - #[cfg_attr(target_arch = "x86", - repr(align(4)))] - #[cfg_attr(not(target_arch = "x86"), - repr(align(8)))] - pub struct pthread_cond_t { - 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); - } - } - - impl PartialEq for pthread_mutex_t { - fn eq(&self, other: &pthread_mutex_t) -> bool { - 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") - // FIXME: .field("size", &self.size) - .finish() - } - } - impl ::hash::Hash for pthread_mutex_t { - fn hash(&self, state: &mut H) { - self.size.hash(state); - } - } - - impl PartialEq for pthread_rwlock_t { - fn eq(&self, other: &pthread_rwlock_t) -> bool { - 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") - // FIXME: .field("size", &self.size) - .finish() - } - } - impl ::hash::Hash for pthread_rwlock_t { - fn hash(&self, state: &mut H) { - self.size.hash(state); - } - } - } - } - }; -} diff --git a/src/fuchsia/mod.rs b/src/fuchsia/mod.rs index 4a18a8daabc0c..7625cb17fa884 100644 --- a/src/fuchsia/mod.rs +++ b/src/fuchsia/mod.rs @@ -3,6 +3,8 @@ //! More functions and definitions can be found in the more specific modules //! according to the platform in question. +use c_void; + // PUB_TYPE pub type c_schar = i8; @@ -882,6 +884,35 @@ s! { pub ipi6_addr: ::in6_addr, pub ipi6_ifindex: ::c_uint, } + + #[cfg_attr( + any( + target_pointer_width = "32", + target_arch = "x86_64" + ), + repr(align(4)))] + #[cfg_attr( + not(any( + target_pointer_width = "32", + target_arch = "x86_64" + )), + repr(align(8)))] + pub struct pthread_mutexattr_t { + size: [u8; ::__SIZEOF_PTHREAD_MUTEXATTR_T], + } + + #[cfg_attr(target_pointer_width = "32", + repr(align(4)))] + #[cfg_attr(target_pointer_width = "64", + repr(align(8)))] + pub struct pthread_rwlockattr_t { + size: [u8; ::__SIZEOF_PTHREAD_RWLOCKATTR_T], + } + + #[repr(align(4))] + pub struct pthread_condattr_t { + size: [u8; ::__SIZEOF_PTHREAD_CONDATTR_T], + } } s_no_extra_traits! { @@ -979,6 +1010,42 @@ s_no_extra_traits! { pub sigev_notify_attributes: *mut pthread_attr_t, pub __pad: [::c_char; 56 - 3 * 8 /* 8 == sizeof(long) */], } + + #[cfg_attr(all(target_pointer_width = "32", + any(target_arch = "arm", + target_arch = "x86_64")), + repr(align(4)))] + #[cfg_attr(any(target_pointer_width = "64", + not(any(target_arch = "arm", + target_arch = "x86_64"))), + repr(align(8)))] + pub struct pthread_mutex_t { + size: [u8; ::__SIZEOF_PTHREAD_MUTEX_T], + } + + #[cfg_attr(all(target_pointer_width = "32", + any(target_arch = "arm", + target_arch = "x86_64")), + repr(align(4)))] + #[cfg_attr(any(target_pointer_width = "64", + not(any(target_arch = "arm", + target_arch = "x86_64"))), + repr(align(8)))] + pub struct pthread_rwlock_t { + size: [u8; ::__SIZEOF_PTHREAD_RWLOCK_T], + } + + #[cfg_attr(target_pointer_width = "32", + repr(align(4)))] + #[cfg_attr(target_pointer_width = "64", + repr(align(8)))] + #[cfg_attr(target_arch = "x86", + repr(align(4)))] + #[cfg_attr(not(target_arch = "x86"), + repr(align(8)))] + pub struct pthread_cond_t { + size: [u8; ::__SIZEOF_PTHREAD_COND_T], + } } cfg_if! { @@ -1306,6 +1373,72 @@ cfg_if! { self.sigev_notify_attributes.hash(state); } } + + 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); + } + } + + impl PartialEq for pthread_mutex_t { + fn eq(&self, other: &pthread_mutex_t) -> bool { + 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") + // FIXME: .field("size", &self.size) + .finish() + } + } + impl ::hash::Hash for pthread_mutex_t { + fn hash(&self, state: &mut H) { + self.size.hash(state); + } + } + + impl PartialEq for pthread_rwlock_t { + fn eq(&self, other: &pthread_rwlock_t) -> bool { + 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") + // FIXME: .field("size", &self.size) + .finish() + } + } + impl ::hash::Hash for pthread_rwlock_t { + fn hash(&self, state: &mut H) { + self.size.hash(state); + } + } } } @@ -2315,17 +2448,15 @@ pub const RTLD_NOW: ::c_int = 0x2; pub const TCP_MD5SIG: ::c_int = 14; -align_const! { - pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { - size: [0; __SIZEOF_PTHREAD_MUTEX_T], - }; - pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { - size: [0; __SIZEOF_PTHREAD_COND_T], - }; - pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { - size: [0; __SIZEOF_PTHREAD_RWLOCK_T], - }; -} +pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { + size: [0; __SIZEOF_PTHREAD_MUTEX_T], +}; +pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { + size: [0; __SIZEOF_PTHREAD_COND_T], +}; +pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { + size: [0; __SIZEOF_PTHREAD_RWLOCK_T], +}; pub const PTHREAD_MUTEX_NORMAL: ::c_int = 0; pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 1; pub const PTHREAD_MUTEX_ERRORCHECK: ::c_int = 2; @@ -4254,34 +4385,3 @@ cfg_if! { // Unknown target_arch } } - -cfg_if! { - if #[cfg(libc_align)] { - #[macro_use] - mod align; - } else { - #[macro_use] - mod no_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, - } - } -} 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/hermit/mod.rs b/src/hermit/mod.rs index bffcefdd89ce4..158401aef1edb 100644 --- a/src/hermit/mod.rs +++ b/src/hermit/mod.rs @@ -3,6 +3,8 @@ // Ported by Colin Fink // and Stefan Lankes +use c_void; + pub type c_schar = i8; pub type c_uchar = u8; pub type c_short = i16; @@ -42,23 +44,3 @@ cfg_if! { // Unknown target_arch } } - -cfg_if! { - if #[cfg(libc_core_cvoid)] { - pub use ::ffi::c_void; - } else { - // Use repr(u8) as LLVM expects `void*` to be the same as `i8*` to help - // enable more optimization opportunities around it recognizing things - // like malloc/free. - #[repr(u8)] - #[allow(missing_copy_implementations)] - #[allow(missing_debug_implementations)] - pub enum c_void { - // Two dummy variants so the #[repr] attribute can be used. - #[doc(hidden)] - __variant1, - #[doc(hidden)] - __variant2, - } - } -} diff --git a/src/lib.rs b/src/lib.rs index 3ad346a429353..df63b822c435c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -47,52 +47,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::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; + +pub use core::ffi::c_void; cfg_if! { if #[cfg(windows)] { diff --git a/src/macros.rs b/src/macros.rs index fd473702f72bd..00be73a1e8cfa 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)* }) => ( @@ -276,24 +272,6 @@ macro_rules! __item { }; } -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: [], - }; - )*) -} - // This macro is used to deprecate items that should be accessed via the mach2 crate macro_rules! deprecated_mach { (pub const $id:ident: $ty:ty = $expr:expr;) => { diff --git a/src/psp.rs b/src/psp.rs index 575232dad1f88..50f1e267b65a2 100644 --- a/src/psp.rs +++ b/src/psp.rs @@ -4,6 +4,8 @@ //! by the linker. Crates that use these definitions must, somewhere in the //! crate graph, include a stub provider crate such as the `psp` crate. +use c_void; + pub type c_schar = i8; pub type c_uchar = u8; pub type c_short = i16; @@ -27,26 +29,6 @@ pub type c_char = u8; pub type c_long = i64; pub type c_ulong = u64; -cfg_if! { - if #[cfg(libc_core_cvoid)] { - pub use ::ffi::c_void; - } else { - // Use repr(u8) as LLVM expects `void*` to be the same as `i8*` to help - // enable more optimization opportunities around it recognizing things - // like malloc/free. - #[repr(u8)] - #[allow(missing_copy_implementations)] - #[allow(missing_debug_implementations)] - pub enum c_void { - // Two dummy variants so the #[repr] attribute can be used. - #[doc(hidden)] - __variant1, - #[doc(hidden)] - __variant2, - } - } -} - pub type SceKernelVTimerHandler = unsafe extern "C" fn( uid: SceUid, arg1: *mut SceKernelSysClock, diff --git a/src/sgx.rs b/src/sgx.rs index 7da6269399d9e..dae860d2d443b 100644 --- a/src/sgx.rs +++ b/src/sgx.rs @@ -1,5 +1,7 @@ //! SGX C types definition +use c_void; + pub type c_schar = i8; pub type c_uchar = u8; pub type c_short = i16; @@ -25,23 +27,3 @@ pub type c_ulong = u64; pub const INT_MIN: c_int = -2147483648; pub const INT_MAX: c_int = 2147483647; - -cfg_if! { - if #[cfg(libc_core_cvoid)] { - pub use ::ffi::c_void; - } else { - // Use repr(u8) as LLVM expects `void*` to be the same as `i8*` to help - // enable more optimization opportunities around it recognizing things - // like malloc/free. - #[repr(u8)] - #[allow(missing_copy_implementations)] - #[allow(missing_debug_implementations)] - pub enum c_void { - // Two dummy variants so the #[repr] attribute can be used. - #[doc(hidden)] - __variant1, - #[doc(hidden)] - __variant2, - } - } -} diff --git a/src/solid/mod.rs b/src/solid/mod.rs index f0f2ae89bde90..4bd527741e22c 100644 --- a/src/solid/mod.rs +++ b/src/solid/mod.rs @@ -2,6 +2,8 @@ //! //! [SOLID]: https://solid.kmckk.com/ +use c_void; + pub type c_schar = i8; pub type c_uchar = u8; pub type c_short = i16; @@ -871,26 +873,6 @@ extern "C" { pub fn lseek(arg1: c_int, arg2: __off_t, arg3: c_int) -> __off_t; } -cfg_if! { - if #[cfg(libc_core_cvoid)] { - pub use ::ffi::c_void; - } else { - // Use repr(u8) as LLVM expects `void*` to be the same as `i8*` to help - // enable more optimization opportunities around it recognizing things - // like malloc/free. - #[repr(u8)] - #[allow(missing_copy_implementations)] - #[allow(missing_debug_implementations)] - pub enum c_void { - // Two dummy variants so the #[repr] attribute can be used. - #[doc(hidden)] - __variant1, - #[doc(hidden)] - __variant2, - } - } -} - cfg_if! { if #[cfg(target_arch = "aarch64")] { mod aarch64; diff --git a/src/switch.rs b/src/switch.rs index 030ab20d7bd8e..384c632f2578b 100644 --- a/src/switch.rs +++ b/src/switch.rs @@ -1,5 +1,7 @@ //! Switch C type definitions +use c_void; + pub type c_schar = i8; pub type c_uchar = u8; pub type c_short = i16; @@ -27,23 +29,3 @@ pub type wchar_t = u32; pub const INT_MIN: c_int = -2147483648; pub const INT_MAX: c_int = 2147483647; - -cfg_if! { - if #[cfg(libc_core_cvoid)] { - pub use ::ffi::c_void; - } else { - // Use repr(u8) as LLVM expects `void*` to be the same as `i8*` to help - // enable more optimization opportunities around it recognizing things - // like malloc/free. - #[repr(u8)] - #[allow(missing_copy_implementations)] - #[allow(missing_debug_implementations)] - pub enum c_void { - // Two dummy variants so the #[repr] attribute can be used. - #[doc(hidden)] - __variant1, - #[doc(hidden)] - __variant2, - } - } -} diff --git a/src/unix/align.rs b/src/unix/align.rs deleted file mode 100644 index 4fdba9a6aba69..0000000000000 --- a/src/unix/align.rs +++ /dev/null @@ -1,6 +0,0 @@ -s! { - #[repr(align(4))] - pub struct in6_addr { - pub s6_addr: [u8; 16], - } -} diff --git a/src/unix/bsd/apple/b32/align.rs b/src/unix/bsd/apple/b32/align.rs deleted file mode 100644 index ca1fe1ce29944..0000000000000 --- a/src/unix/bsd/apple/b32/align.rs +++ /dev/null @@ -1,7 +0,0 @@ -s_no_extra_traits! { - #[allow(missing_debug_implementations)] - #[repr(align(16))] - pub struct max_align_t { - priv_: [f64; 2] - } -} diff --git a/src/unix/bsd/apple/b32/mod.rs b/src/unix/bsd/apple/b32/mod.rs index 0f1722f975744..d1522db2e6d12 100644 --- a/src/unix/bsd/apple/b32/mod.rs +++ b/src/unix/bsd/apple/b32/mod.rs @@ -111,9 +111,10 @@ extern "C" { ) -> ::c_int; } -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; +s_no_extra_traits! { + #[allow(missing_debug_implementations)] + #[repr(align(16))] + pub struct max_align_t { + priv_: [f64; 2] } } diff --git a/src/unix/bsd/apple/b64/aarch64/align.rs b/src/unix/bsd/apple/b64/aarch64/align.rs deleted file mode 100644 index 29db97ec7c473..0000000000000 --- a/src/unix/bsd/apple/b64/aarch64/align.rs +++ /dev/null @@ -1,56 +0,0 @@ -pub type mcontext_t = *mut __darwin_mcontext64; - -s_no_extra_traits! { - #[allow(missing_debug_implementations)] - pub struct max_align_t { - priv_: f64 - } -} - -s! { - pub struct ucontext_t { - pub uc_onstack: ::c_int, - pub uc_sigmask: ::sigset_t, - pub uc_stack: ::stack_t, - pub uc_link: *mut ::ucontext_t, - pub uc_mcsize: usize, - pub uc_mcontext: mcontext_t, - __mcontext_data: __darwin_mcontext64, - } - - pub struct __darwin_mcontext64 { - pub __es: __darwin_arm_exception_state64, - pub __ss: __darwin_arm_thread_state64, - pub __ns: __darwin_arm_neon_state64, - } - - pub struct __darwin_arm_exception_state64 { - pub __far: u64, - pub __esr: u32, - pub __exception: u32, - } - - pub struct __darwin_arm_thread_state64 { - pub __x: [u64; 29], - pub __fp: u64, - pub __lr: u64, - pub __sp: u64, - pub __pc: u64, - pub __cpsr: u32, - 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 67f0f7032e9c0..de69e1d208a75 100644 --- a/src/unix/bsd/apple/b64/aarch64/mod.rs +++ b/src/unix/bsd/apple/b64/aarch64/mod.rs @@ -1,16 +1,55 @@ pub type boolean_t = ::c_int; +pub type mcontext_t = *mut __darwin_mcontext64; s! { pub struct malloc_zone_t { __private: [::uintptr_t; 18], // FIXME: needs arm64 auth pointers support } -} -pub const CLOCK_UPTIME_RAW: ::clockid_t = 8; + pub struct ucontext_t { + pub uc_onstack: ::c_int, + pub uc_sigmask: ::sigset_t, + pub uc_stack: ::stack_t, + pub uc_link: *mut ::ucontext_t, + pub uc_mcsize: usize, + pub uc_mcontext: mcontext_t, + __mcontext_data: __darwin_mcontext64, + } + + pub struct __darwin_mcontext64 { + pub __es: __darwin_arm_exception_state64, + pub __ss: __darwin_arm_thread_state64, + pub __ns: __darwin_arm_neon_state64, + } + + pub struct __darwin_arm_exception_state64 { + pub __far: u64, + pub __esr: u32, + pub __exception: u32, + } -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; + pub struct __darwin_arm_thread_state64 { + pub __x: [u64; 29], + pub __fp: u64, + pub __lr: u64, + pub __sp: u64, + pub __pc: u64, + pub __cpsr: u32, + pub __pad: u32, + } + + pub struct __darwin_arm_neon_state64 { + pub __v: [::__uint128_t; 32], + pub __fpsr: u32, + pub __fpcr: u32, } } + +s_no_extra_traits! { + #[allow(missing_debug_implementations)] + pub struct max_align_t { + priv_: f64 + } +} + +pub const CLOCK_UPTIME_RAW: ::clockid_t = 8; diff --git a/src/unix/bsd/apple/b64/x86_64/align.rs b/src/unix/bsd/apple/b64/x86_64/align.rs deleted file mode 100644 index ca1fe1ce29944..0000000000000 --- a/src/unix/bsd/apple/b64/x86_64/align.rs +++ /dev/null @@ -1,7 +0,0 @@ -s_no_extra_traits! { - #[allow(missing_debug_implementations)] - #[repr(align(16))] - pub struct max_align_t { - priv_: [f64; 2] - } -} diff --git a/src/unix/bsd/apple/b64/x86_64/mod.rs b/src/unix/bsd/apple/b64/x86_64/mod.rs index 653650c26289f..a613ccb389e45 100644 --- a/src/unix/bsd/apple/b64/x86_64/mod.rs +++ b/src/unix/bsd/apple/b64/x86_64/mod.rs @@ -172,9 +172,10 @@ s! { } } -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; +s_no_extra_traits! { + #[allow(missing_debug_implementations)] + #[repr(align(16))] + pub struct max_align_t { + priv_: [f64; 2] } } diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index a831ca850f4be..0e8e31c828259 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -818,9 +818,7 @@ s! { pub struct vnode_info_path { pub vip_vi: vnode_info, - // Normally it's `vip_path: [::c_char; MAXPATHLEN]` but because libc supports an old rustc - // version, we go around this limitation like this. - pub vip_path: [[::c_char; 32]; 32], + pub vip_path: [::c_char; ::MAXPATHLEN as usize], } pub struct proc_vnodepathinfo { @@ -984,7 +982,7 @@ s! { } s_no_extra_traits! { - #[cfg_attr(libc_packedN, repr(packed(4)))] + #[repr(packed(4))] pub struct kevent { pub ident: ::uintptr_t, pub filter: i16, @@ -994,7 +992,7 @@ s_no_extra_traits! { pub udata: *mut ::c_void, } - #[cfg_attr(libc_packedN, repr(packed(4)))] + #[repr(packed(4))] pub struct semid_ds { // Note the manpage shows different types than the system header. pub sem_perm: ipc_perm, @@ -1007,7 +1005,7 @@ s_no_extra_traits! { pub sem_pad3: [i32; 4], } - #[cfg_attr(libc_packedN, repr(packed(4)))] + #[repr(packed(4))] pub struct shmid_ds { pub shm_perm: ipc_perm, pub shm_segsz: ::size_t, @@ -1166,7 +1164,7 @@ s_no_extra_traits! { pub pth_name: [::c_char; MAXTHREADNAMESIZE], } - #[cfg_attr(libc_packedN, repr(packed(4)))] + #[repr(packed(4))] pub struct if_data64 { pub ifi_type: ::c_uchar, pub ifi_typelen: ::c_uchar, @@ -1198,7 +1196,7 @@ s_no_extra_traits! { pub ifi_lastchange: timeval32, } - #[cfg_attr(libc_packedN, repr(packed(4)))] + #[repr(packed(4))] pub struct if_msghdr2 { pub ifm_msglen: ::c_ushort, pub ifm_version: ::c_uchar, @@ -1213,7 +1211,7 @@ s_no_extra_traits! { pub ifm_data: if_data64, } - #[cfg_attr(libc_packedN, repr(packed(8)))] + #[repr(packed(8))] pub struct vm_statistics64 { pub free_count: natural_t, pub active_count: natural_t, @@ -1241,7 +1239,7 @@ s_no_extra_traits! { pub total_uncompressed_pages_in_compressor: u64, } - #[cfg_attr(libc_packedN, repr(packed(4)))] + #[repr(packed(4))] pub struct mach_task_basic_info { pub virtual_size: mach_vm_size_t, pub resident_size: mach_vm_size_t, @@ -1252,7 +1250,7 @@ s_no_extra_traits! { pub suspend_count: integer_t, } - #[cfg_attr(libc_packedN, repr(packed(4)))] + #[repr(packed(4))] pub struct log2phys { pub l2p_flags: ::c_uint, pub l2p_contigbytes: ::off_t, @@ -1294,37 +1292,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) }; } } } @@ -4684,76 +4678,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/dragonfly/mod.rs b/src/unix/bsd/freebsdlike/dragonfly/mod.rs index df7719b4b9c69..b4ee100cd646d 100644 --- a/src/unix/bsd/freebsdlike/dragonfly/mod.rs +++ b/src/unix/bsd/freebsdlike/dragonfly/mod.rs @@ -517,7 +517,7 @@ s_no_extra_traits! { pub mc_ownedfp: ::c_uint, __reserved: ::c_uint, __unused: [::c_uint; 8], - pub mc_fpregs: [[::c_uint; 8]; 32], + pub mc_fpregs: [::c_uint; 256], } pub struct ucontext_t { @@ -786,8 +786,7 @@ cfg_if! { self.mc_len == other.mc_len && self.mc_fpformat == other.mc_fpformat && self.mc_ownedfp == other.mc_ownedfp && - self.mc_fpregs.iter().zip(other.mc_fpregs.iter()). - all(|(a, b)| a == b) + self.mc_fpregs == other.mc_fpregs } } impl Eq for mcontext_t {} diff --git a/src/unix/bsd/freebsdlike/freebsd/aarch64.rs b/src/unix/bsd/freebsdlike/freebsd/aarch64.rs index d29a8d2c7f56c..cba3664812e8d 100644 --- a/src/unix/bsd/freebsdlike/freebsd/aarch64.rs +++ b/src/unix/bsd/freebsdlike/freebsd/aarch64.rs @@ -6,16 +6,7 @@ pub type time_t = i64; pub type suseconds_t = i64; pub type register_t = i64; -// 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; s_no_extra_traits! { pub struct gpregs { 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/freebsd11/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs index 1af555fa3655c..c192db962d1c4 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs @@ -166,7 +166,7 @@ s! { /// More thread name. pub ki_moretdname: [::c_char; ::MAXCOMLEN - ::TDNAMLEN + 1], /// Spare string space. - pub ki_sparestrings: [[::c_char; 23]; 2], // little hack to allow PartialEq + pub ki_sparestrings: [::c_char; 46], /// Spare room for growth. pub ki_spareints: [::c_int; ::KI_NSPARE_INT], /// Which cpu we are on. diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs index 848db33993556..f862dd36e595f 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs @@ -173,7 +173,7 @@ s! { /// More thread name. pub ki_moretdname: [::c_char; ::MAXCOMLEN - ::TDNAMLEN + 1], /// Spare string space. - pub ki_sparestrings: [[::c_char; 23]; 2], // little hack to allow PartialEq + pub ki_sparestrings: [::c_char; 46], /// Spare room for growth. pub ki_spareints: [::c_int; ::KI_NSPARE_INT], /// Controlling tty dev. diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs index a929f9d290e63..ef3179c27c7d4 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs @@ -180,7 +180,7 @@ s! { /// More thread name. pub ki_moretdname: [::c_char; ::MAXCOMLEN - ::TDNAMLEN + 1], /// Spare string space. - pub ki_sparestrings: [[::c_char; 23]; 2], // little hack to allow PartialEq + pub ki_sparestrings: [::c_char; 46], /// Spare room for growth. pub ki_spareints: [::c_int; ::KI_NSPARE_INT], /// Controlling tty dev. diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs index c655d555d9005..475420b80e616 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs @@ -180,7 +180,7 @@ s! { /// More thread name. pub ki_moretdname: [::c_char; ::MAXCOMLEN - ::TDNAMLEN + 1], /// Spare string space. - pub ki_sparestrings: [[::c_char; 23]; 2], // little hack to allow PartialEq + pub ki_sparestrings: [::c_char; 46], /// Spare room for growth. pub ki_spareints: [::c_int; ::KI_NSPARE_INT], /// Controlling tty dev. diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs index 84e43b23e5229..46dec748b3b17 100644 --- a/src/unix/bsd/freebsdlike/freebsd/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs @@ -442,7 +442,7 @@ s! { _kve_is_spare: [::c_int; 8], #[cfg(freebsd11)] _kve_is_spare: [::c_int; 12], - pub kve_path: [[::c_char; 32]; 32], + pub kve_path: [::c_char; ::PATH_MAX as usize], } pub struct __c_anonymous_filestat { @@ -954,7 +954,6 @@ s! { pub struct ifconf { pub ifc_len: ::c_int, - #[cfg(libc_union)] pub ifc_ifcu: __c_anonymous_ifc_ifcu, } @@ -1004,7 +1003,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, @@ -1015,10 +1013,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 { @@ -1060,24 +1055,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, @@ -1131,20 +1122,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, @@ -1166,13 +1148,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, @@ -1252,15 +1230,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") @@ -1268,7 +1243,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) }; @@ -1277,11 +1251,8 @@ 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 @@ -1298,7 +1269,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 @@ -1312,10 +1282,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); } } @@ -1449,15 +1416,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") @@ -1465,13 +1429,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 @@ -1479,15 +1436,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") @@ -1497,7 +1445,6 @@ cfg_if! { } } - #[cfg(libc_union)] impl PartialEq for __c_anonymous_ifr_ifru { fn eq(&self, other: &__c_anonymous_ifr_ifru) -> bool { unsafe { @@ -1519,9 +1466,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") @@ -1543,7 +1488,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) }; @@ -1585,10 +1529,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 { @@ -1598,7 +1540,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") @@ -1608,7 +1549,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) }; @@ -1711,7 +1651,6 @@ cfg_if! { } } - #[cfg(libc_union)] impl PartialEq for __c_anonymous_ifi_epoch { fn eq(&self, other: &__c_anonymous_ifi_epoch) -> bool { unsafe { @@ -1720,9 +1659,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") @@ -1731,7 +1668,6 @@ cfg_if! { .finish() } } - #[cfg(libc_union)] impl ::hash::Hash for __c_anonymous_ifi_epoch { fn hash(&self, state: &mut H) { unsafe { @@ -1741,7 +1677,6 @@ cfg_if! { } } - #[cfg(libc_union)] impl PartialEq for __c_anonymous_ifi_lastchange { fn eq(&self, other: &__c_anonymous_ifi_lastchange) -> bool { unsafe { @@ -1750,9 +1685,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") @@ -1761,7 +1694,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..7729bdd03f5b5 100644 --- a/src/unix/bsd/freebsdlike/freebsd/powerpc64.rs +++ b/src/unix/bsd/freebsdlike/freebsd/powerpc64.rs @@ -32,16 +32,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 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 c91a8dfb253f9..d4e000bdb706e 100644 --- a/src/unix/bsd/freebsdlike/freebsd/riscv64.rs +++ b/src/unix/bsd/freebsdlike/freebsd/riscv64.rs @@ -6,16 +6,7 @@ pub type time_t = i64; pub type suseconds_t = ::c_long; pub type register_t = i64; -// 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; s_no_extra_traits! { pub struct gpregs { diff --git a/src/unix/bsd/freebsdlike/freebsd/x86.rs b/src/unix/bsd/freebsdlike/freebsd/x86.rs index d3a3f34b0f61f..c1c53a166596e 100644 --- a/src/unix/bsd/freebsdlike/freebsd/x86.rs +++ b/src/unix/bsd/freebsdlike/freebsd/x86.rs @@ -33,14 +33,5 @@ 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; pub const MINSIGSTKSZ: ::size_t = 2048; // 512 * 4 diff --git a/src/unix/bsd/freebsdlike/freebsd/x86_64/align.rs b/src/unix/bsd/freebsdlike/freebsd/x86_64/align.rs deleted file mode 100644 index 3a016a0519852..0000000000000 --- a/src/unix/bsd/freebsdlike/freebsd/x86_64/align.rs +++ /dev/null @@ -1,197 +0,0 @@ -use {c_long, register_t}; - -s_no_extra_traits! { - #[allow(missing_debug_implementations)] - #[repr(align(16))] - pub struct max_align_t { - priv_: [f64; 4] - } - - #[repr(align(16))] - pub struct mcontext_t { - pub mc_onstack: register_t, - pub mc_rdi: register_t, - pub mc_rsi: register_t, - pub mc_rdx: register_t, - pub mc_rcx: register_t, - pub mc_r8: register_t, - pub mc_r9: register_t, - pub mc_rax: register_t, - pub mc_rbx: register_t, - pub mc_rbp: register_t, - pub mc_r10: register_t, - pub mc_r11: register_t, - pub mc_r12: register_t, - pub mc_r13: register_t, - pub mc_r14: register_t, - pub mc_r15: register_t, - pub mc_trapno: u32, - pub mc_fs: u16, - pub mc_gs: u16, - pub mc_addr: register_t, - pub mc_flags: u32, - pub mc_es: u16, - pub mc_ds: u16, - pub mc_err: register_t, - pub mc_rip: register_t, - pub mc_cs: register_t, - pub mc_rflags: register_t, - pub mc_rsp: register_t, - pub mc_ss: register_t, - pub mc_len: c_long, - pub mc_fpformat: c_long, - pub mc_ownedfp: c_long, - pub mc_fpstate: [c_long; 64], - pub mc_fsbase: register_t, - pub mc_gsbase: register_t, - pub mc_xfpustate: register_t, - pub mc_xfpustate_len: register_t, - pub mc_spare: [c_long; 4], - } -} - -cfg_if! { - if #[cfg(feature = "extra_traits")] { - impl PartialEq for mcontext_t { - fn eq(&self, other: &mcontext_t) -> bool { - self.mc_onstack == other.mc_onstack && - self.mc_rdi == other.mc_rdi && - self.mc_rsi == other.mc_rsi && - self.mc_rdx == other.mc_rdx && - self.mc_rcx == other.mc_rcx && - self.mc_r8 == other.mc_r8 && - self.mc_r9 == other.mc_r9 && - self.mc_rax == other.mc_rax && - self.mc_rbx == other.mc_rbx && - self.mc_rbp == other.mc_rbp && - self.mc_r10 == other.mc_r10 && - self.mc_r11 == other.mc_r11 && - self.mc_r12 == other.mc_r12 && - self.mc_r13 == other.mc_r13 && - self.mc_r14 == other.mc_r14 && - self.mc_r15 == other.mc_r15 && - self.mc_trapno == other.mc_trapno && - self.mc_fs == other.mc_fs && - self.mc_gs == other.mc_gs && - self.mc_addr == other.mc_addr && - self.mc_flags == other.mc_flags && - self.mc_es == other.mc_es && - self.mc_ds == other.mc_ds && - self.mc_err == other.mc_err && - self.mc_rip == other.mc_rip && - self.mc_cs == other.mc_cs && - self.mc_rflags == other.mc_rflags && - self.mc_rsp == other.mc_rsp && - self.mc_ss == other.mc_ss && - self.mc_len == other.mc_len && - self.mc_fpformat == other.mc_fpformat && - self.mc_ownedfp == other.mc_ownedfp && - self.mc_fpstate.iter().zip(other.mc_fpstate.iter()) - .all(|(a, b)| a == b) && - self.mc_fsbase == other.mc_fsbase && - self.mc_gsbase == other.mc_gsbase && - self.mc_xfpustate == other.mc_xfpustate && - self.mc_xfpustate_len == other.mc_xfpustate_len && - self.mc_spare == other.mc_spare - } - } - impl Eq for mcontext_t {} - impl ::fmt::Debug for mcontext_t { - fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { - f.debug_struct("mcontext_t") - .field("mc_onstack", &self.mc_onstack) - .field("mc_rdi", &self.mc_rdi) - .field("mc_rsi", &self.mc_rsi) - .field("mc_rdx", &self.mc_rdx) - .field("mc_rcx", &self.mc_rcx) - .field("mc_r8", &self.mc_r8) - .field("mc_r9", &self.mc_r9) - .field("mc_rax", &self.mc_rax) - .field("mc_rbx", &self.mc_rbx) - .field("mc_rbp", &self.mc_rbp) - .field("mc_r10", &self.mc_r10) - .field("mc_r11", &self.mc_r11) - .field("mc_r12", &self.mc_r12) - .field("mc_r13", &self.mc_r13) - .field("mc_r14", &self.mc_r14) - .field("mc_r15", &self.mc_r15) - .field("mc_trapno", &self.mc_trapno) - .field("mc_fs", &self.mc_fs) - .field("mc_gs", &self.mc_gs) - .field("mc_addr", &self.mc_addr) - .field("mc_flags", &self.mc_flags) - .field("mc_es", &self.mc_es) - .field("mc_ds", &self.mc_ds) - .field("mc_err", &self.mc_err) - .field("mc_rip", &self.mc_rip) - .field("mc_cs", &self.mc_cs) - .field("mc_rflags", &self.mc_rflags) - .field("mc_rsp", &self.mc_rsp) - .field("mc_ss", &self.mc_ss) - .field("mc_len", &self.mc_len) - .field("mc_fpformat", &self.mc_fpformat) - .field("mc_ownedfp", &self.mc_ownedfp) - // FIXME: .field("mc_fpstate", &self.mc_fpstate) - .field("mc_fsbase", &self.mc_fsbase) - .field("mc_gsbase", &self.mc_gsbase) - .field("mc_xfpustate", &self.mc_xfpustate) - .field("mc_xfpustate_len", &self.mc_xfpustate_len) - .field("mc_spare", &self.mc_spare) - .finish() - } - } - impl ::hash::Hash for mcontext_t { - fn hash(&self, state: &mut H) { - self.mc_onstack.hash(state); - self.mc_rdi.hash(state); - self.mc_rsi.hash(state); - self.mc_rdx.hash(state); - self.mc_rcx.hash(state); - self.mc_r8.hash(state); - self.mc_r9.hash(state); - self.mc_rax.hash(state); - self.mc_rbx.hash(state); - self.mc_rbp.hash(state); - self.mc_r10.hash(state); - self.mc_r11.hash(state); - self.mc_r12.hash(state); - self.mc_r13.hash(state); - self.mc_r14.hash(state); - self.mc_r15.hash(state); - self.mc_trapno.hash(state); - self.mc_fs.hash(state); - self.mc_gs.hash(state); - self.mc_addr.hash(state); - self.mc_flags.hash(state); - self.mc_es.hash(state); - self.mc_ds.hash(state); - self.mc_err.hash(state); - self.mc_rip.hash(state); - self.mc_cs.hash(state); - self.mc_rflags.hash(state); - self.mc_rsp.hash(state); - self.mc_ss.hash(state); - self.mc_len.hash(state); - self.mc_fpformat.hash(state); - self.mc_ownedfp.hash(state); - self.mc_fpstate.hash(state); - self.mc_fsbase.hash(state); - self.mc_gsbase.hash(state); - self.mc_xfpustate.hash(state); - self.mc_xfpustate_len.hash(state); - self.mc_spare.hash(state); - } - } - } -} - -s! { - pub struct ucontext_t { - pub uc_sigmask: ::sigset_t, - pub uc_mcontext: ::mcontext_t, - pub uc_link: *mut ::ucontext_t, - pub uc_stack: ::stack_t, - pub uc_flags: ::c_int, - __spare__: [::c_int; 4], - } -} diff --git a/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs b/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs index ae1fcf781047a..e7d2f4f42dce4 100644 --- a/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs @@ -57,6 +57,15 @@ s! { pub r_rsp: i64, pub r_ss: i64, } + + pub struct ucontext_t { + pub uc_sigmask: ::sigset_t, + pub uc_mcontext: ::mcontext_t, + pub uc_link: *mut ::ucontext_t, + pub uc_stack: ::stack_t, + pub uc_flags: ::c_int, + __spare__: [::c_int; 4], + } } s_no_extra_traits! { @@ -81,7 +90,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 +98,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, } @@ -204,7 +211,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 @@ -212,9 +218,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") @@ -222,13 +226,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 @@ -236,15 +233,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") @@ -302,16 +290,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 @@ -326,9 +305,187 @@ pub const _MC_FPOWNED_NONE: c_long = 0x20000; pub const _MC_FPOWNED_FPU: c_long = 0x20001; pub const _MC_FPOWNED_PCB: c_long = 0x20002; +s_no_extra_traits! { + #[allow(missing_debug_implementations)] + #[repr(align(16))] + pub struct max_align_t { + priv_: [f64; 4] + } + + #[repr(align(16))] + pub struct mcontext_t { + pub mc_onstack: register_t, + pub mc_rdi: register_t, + pub mc_rsi: register_t, + pub mc_rdx: register_t, + pub mc_rcx: register_t, + pub mc_r8: register_t, + pub mc_r9: register_t, + pub mc_rax: register_t, + pub mc_rbx: register_t, + pub mc_rbp: register_t, + pub mc_r10: register_t, + pub mc_r11: register_t, + pub mc_r12: register_t, + pub mc_r13: register_t, + pub mc_r14: register_t, + pub mc_r15: register_t, + pub mc_trapno: u32, + pub mc_fs: u16, + pub mc_gs: u16, + pub mc_addr: register_t, + pub mc_flags: u32, + pub mc_es: u16, + pub mc_ds: u16, + pub mc_err: register_t, + pub mc_rip: register_t, + pub mc_cs: register_t, + pub mc_rflags: register_t, + pub mc_rsp: register_t, + pub mc_ss: register_t, + pub mc_len: c_long, + pub mc_fpformat: c_long, + pub mc_ownedfp: c_long, + pub mc_fpstate: [c_long; 64], + pub mc_fsbase: register_t, + pub mc_gsbase: register_t, + pub mc_xfpustate: register_t, + pub mc_xfpustate_len: register_t, + pub mc_spare: [c_long; 4], + } +} + cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; + if #[cfg(feature = "extra_traits")] { + impl PartialEq for mcontext_t { + fn eq(&self, other: &mcontext_t) -> bool { + self.mc_onstack == other.mc_onstack && + self.mc_rdi == other.mc_rdi && + self.mc_rsi == other.mc_rsi && + self.mc_rdx == other.mc_rdx && + self.mc_rcx == other.mc_rcx && + self.mc_r8 == other.mc_r8 && + self.mc_r9 == other.mc_r9 && + self.mc_rax == other.mc_rax && + self.mc_rbx == other.mc_rbx && + self.mc_rbp == other.mc_rbp && + self.mc_r10 == other.mc_r10 && + self.mc_r11 == other.mc_r11 && + self.mc_r12 == other.mc_r12 && + self.mc_r13 == other.mc_r13 && + self.mc_r14 == other.mc_r14 && + self.mc_r15 == other.mc_r15 && + self.mc_trapno == other.mc_trapno && + self.mc_fs == other.mc_fs && + self.mc_gs == other.mc_gs && + self.mc_addr == other.mc_addr && + self.mc_flags == other.mc_flags && + self.mc_es == other.mc_es && + self.mc_ds == other.mc_ds && + self.mc_err == other.mc_err && + self.mc_rip == other.mc_rip && + self.mc_cs == other.mc_cs && + self.mc_rflags == other.mc_rflags && + self.mc_rsp == other.mc_rsp && + self.mc_ss == other.mc_ss && + self.mc_len == other.mc_len && + self.mc_fpformat == other.mc_fpformat && + self.mc_ownedfp == other.mc_ownedfp && + self.mc_fpstate.iter().zip(other.mc_fpstate.iter()) + .all(|(a, b)| a == b) && + self.mc_fsbase == other.mc_fsbase && + self.mc_gsbase == other.mc_gsbase && + self.mc_xfpustate == other.mc_xfpustate && + self.mc_xfpustate_len == other.mc_xfpustate_len && + self.mc_spare == other.mc_spare + } + } + impl Eq for mcontext_t {} + impl ::fmt::Debug for mcontext_t { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("mcontext_t") + .field("mc_onstack", &self.mc_onstack) + .field("mc_rdi", &self.mc_rdi) + .field("mc_rsi", &self.mc_rsi) + .field("mc_rdx", &self.mc_rdx) + .field("mc_rcx", &self.mc_rcx) + .field("mc_r8", &self.mc_r8) + .field("mc_r9", &self.mc_r9) + .field("mc_rax", &self.mc_rax) + .field("mc_rbx", &self.mc_rbx) + .field("mc_rbp", &self.mc_rbp) + .field("mc_r10", &self.mc_r10) + .field("mc_r11", &self.mc_r11) + .field("mc_r12", &self.mc_r12) + .field("mc_r13", &self.mc_r13) + .field("mc_r14", &self.mc_r14) + .field("mc_r15", &self.mc_r15) + .field("mc_trapno", &self.mc_trapno) + .field("mc_fs", &self.mc_fs) + .field("mc_gs", &self.mc_gs) + .field("mc_addr", &self.mc_addr) + .field("mc_flags", &self.mc_flags) + .field("mc_es", &self.mc_es) + .field("mc_ds", &self.mc_ds) + .field("mc_err", &self.mc_err) + .field("mc_rip", &self.mc_rip) + .field("mc_cs", &self.mc_cs) + .field("mc_rflags", &self.mc_rflags) + .field("mc_rsp", &self.mc_rsp) + .field("mc_ss", &self.mc_ss) + .field("mc_len", &self.mc_len) + .field("mc_fpformat", &self.mc_fpformat) + .field("mc_ownedfp", &self.mc_ownedfp) + // FIXME: .field("mc_fpstate", &self.mc_fpstate) + .field("mc_fsbase", &self.mc_fsbase) + .field("mc_gsbase", &self.mc_gsbase) + .field("mc_xfpustate", &self.mc_xfpustate) + .field("mc_xfpustate_len", &self.mc_xfpustate_len) + .field("mc_spare", &self.mc_spare) + .finish() + } + } + impl ::hash::Hash for mcontext_t { + fn hash(&self, state: &mut H) { + self.mc_onstack.hash(state); + self.mc_rdi.hash(state); + self.mc_rsi.hash(state); + self.mc_rdx.hash(state); + self.mc_rcx.hash(state); + self.mc_r8.hash(state); + self.mc_r9.hash(state); + self.mc_rax.hash(state); + self.mc_rbx.hash(state); + self.mc_rbp.hash(state); + self.mc_r10.hash(state); + self.mc_r11.hash(state); + self.mc_r12.hash(state); + self.mc_r13.hash(state); + self.mc_r14.hash(state); + self.mc_r15.hash(state); + self.mc_trapno.hash(state); + self.mc_fs.hash(state); + self.mc_gs.hash(state); + self.mc_addr.hash(state); + self.mc_flags.hash(state); + self.mc_es.hash(state); + self.mc_ds.hash(state); + self.mc_err.hash(state); + self.mc_rip.hash(state); + self.mc_cs.hash(state); + self.mc_rflags.hash(state); + self.mc_rsp.hash(state); + self.mc_ss.hash(state); + self.mc_len.hash(state); + self.mc_fpformat.hash(state); + self.mc_ownedfp.hash(state); + self.mc_fpstate.hash(state); + self.mc_fsbase.hash(state); + self.mc_gsbase.hash(state); + self.mc_xfpustate.hash(state); + self.mc_xfpustate_len.hash(state); + self.mc_spare.hash(state); + } + } } } diff --git a/src/unix/bsd/freebsdlike/mod.rs b/src/unix/bsd/freebsdlike/mod.rs index b314b68568c84..10dc9ee7ad236 100644 --- a/src/unix/bsd/freebsdlike/mod.rs +++ b/src/unix/bsd/freebsdlike/mod.rs @@ -284,7 +284,7 @@ s! { pub struct accept_filter_arg { pub af_name: [::c_char; 16], - af_arg: [[::c_char; 10]; 24], + af_arg: [::c_char; 240], } pub struct ptrace_io_desc { @@ -428,15 +428,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 7b895f63238d0..02c73037d046e 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,17 +80,7 @@ cfg_if! { } } -// should be pub(crate), but that requires Rust 1.18.0 -cfg_if! { - if #[cfg(libc_const_size_of)] { - #[doc(hidden)] - pub const _ALIGNBYTES: usize = ::mem::size_of::<::c_int>() - 1; - } else { - #[doc(hidden)] - pub const _ALIGNBYTES: usize = 4 - 1; - } -} - +pub(crate) const _ALIGNBYTES: usize = ::mem::size_of::<::c_int>() - 1; pub const PT_GETREGS: ::c_int = PT_FIRSTMACH + 0; pub const PT_SETREGS: ::c_int = PT_FIRSTMACH + 1; pub const PT_GETFPREGS: ::c_int = PT_FIRSTMACH + 2; diff --git a/src/unix/bsd/netbsdlike/netbsd/arm.rs b/src/unix/bsd/netbsdlike/netbsd/arm.rs index 4bf3ccd02b2c4..9e988476718f8 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/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index d12fd073019be..76792287e37c1 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -635,7 +635,7 @@ s! { pub kve_vn_rdev: u64, pub kve_vn_type: u32, pub kve_vn_mode: u32, - pub kve_path: [[::c_char; 32]; 32], + pub kve_path: [::c_char; ::PATH_MAX as usize], } pub struct __c_anonymous_posix_spawn_fae_open { @@ -660,14 +660,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, } @@ -706,7 +704,6 @@ s! { pub struct ifconf { pub ifc_len: ::c_int, - #[cfg(libc_union)] pub ifc_ifcu: __c_anonymous_ifc_ifcu, } } @@ -822,13 +819,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, @@ -1261,10 +1256,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 { @@ -1274,7 +1267,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 { @@ -1286,7 +1278,6 @@ cfg_if! { } } - #[cfg(libc_union)] impl ::hash::Hash for __c_anonymous_posix_spawn_fae { fn hash(&self, state: &mut H) { unsafe { @@ -1296,10 +1287,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 { @@ -1309,7 +1298,6 @@ cfg_if! { } } - #[cfg(libc_union)] impl ::fmt::Debug for __c_anonymous_ifc_ifcu { fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { unsafe { @@ -1321,7 +1309,6 @@ cfg_if! { } } - #[cfg(libc_union)] impl ::hash::Hash for __c_anonymous_ifc_ifcu { fn hash(&self, state: &mut H) { unsafe { 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/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 2f6e4454577a0..0c7b52ff17e5a 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 1910f24a46bf6..f7e036b13e1a0 100644 --- a/src/unix/bsd/netbsdlike/openbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/openbsd/mod.rs @@ -815,135 +815,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); } } } @@ -1864,14 +1860,10 @@ 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; - } - } +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; } 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 99350ec8dc3d4..df0cdd6d1ac53 100644 --- a/src/unix/bsd/netbsdlike/openbsd/riscv64.rs +++ b/src/unix/bsd/netbsdlike/openbsd/riscv64.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/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 44bcc1e3b75f4..d37213a09eb27 100644 --- a/src/unix/haiku/native.rs +++ b/src/unix/haiku/native.rs @@ -403,7 +403,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, @@ -416,7 +415,6 @@ s_no_extra_traits! { cfg_if! { if #[cfg(feature = "extra_traits")] { - #[cfg(libc_union)] impl PartialEq for cpuid_info { fn eq(&self, other: &cpuid_info) -> bool { unsafe { @@ -429,9 +427,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 { @@ -1218,12 +1214,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/linux_like/android/b32/arm.rs b/src/unix/linux_like/android/b32/arm.rs index 33d2fa07078d3..9fb9ae598c938 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/align.rs b/src/unix/linux_like/android/b32/x86/align.rs deleted file mode 100644 index 04df4a05d19b7..0000000000000 --- a/src/unix/linux_like/android/b32/x86/align.rs +++ /dev/null @@ -1,7 +0,0 @@ -s_no_extra_traits! { - #[allow(missing_debug_implementations)] - #[repr(align(8))] - pub struct max_align_t { - priv_: [f64; 2] - } -} diff --git a/src/unix/linux_like/android/b32/x86/mod.rs b/src/unix/linux_like/android/b32/x86/mod.rs index 6507cb4e07da3..8e076d039ac1c 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 } } } @@ -603,9 +599,10 @@ f! { } } -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; +s_no_extra_traits! { + #[allow(missing_debug_implementations)] + #[repr(align(8))] + pub struct max_align_t { + priv_: [f64; 2] } } diff --git a/src/unix/linux_like/android/b64/aarch64/align.rs b/src/unix/linux_like/android/b64/aarch64/align.rs deleted file mode 100644 index 154c2c54ce6de..0000000000000 --- a/src/unix/linux_like/android/b64/aarch64/align.rs +++ /dev/null @@ -1,29 +0,0 @@ -s_no_extra_traits! { - #[allow(missing_debug_implementations)] - #[repr(align(16))] - pub struct max_align_t { - priv_: [f32; 8] - } -} - -s! { - pub struct ucontext_t { - pub uc_flags: ::c_ulong, - pub uc_link: *mut ucontext_t, - pub uc_stack: ::stack_t, - pub uc_sigmask: ::sigset_t, - pub uc_mcontext: mcontext_t, - } - - #[repr(align(16))] - pub struct mcontext_t { - pub fault_address: ::c_ulonglong, - pub regs: [::c_ulonglong; 31], - pub sp: ::c_ulonglong, - pub pc: ::c_ulonglong, - pub pstate: ::c_ulonglong, - // nested arrays to get the right size/length while being able to - // auto-derive traits like Debug - __reserved: [[u64; 32]; 16], - } -} diff --git a/src/unix/linux_like/android/b64/aarch64/int128.rs b/src/unix/linux_like/android/b64/aarch64/int128.rs deleted file mode 100644 index 4535e73eeddf1..0000000000000 --- a/src/unix/linux_like/android/b64/aarch64/int128.rs +++ /dev/null @@ -1,7 +0,0 @@ -s! { - pub struct user_fpsimd_struct { - pub vregs: [::__uint128_t; 32], - pub fpsr: u32, - pub fpcr: u32, - } -} diff --git a/src/unix/linux_like/android/b64/aarch64/mod.rs b/src/unix/linux_like/android/b64/aarch64/mod.rs index c4d4420600283..67dcf1beb39a9 100644 --- a/src/unix/linux_like/android/b64/aarch64/mod.rs +++ b/src/unix/linux_like/android/b64/aarch64/mod.rs @@ -55,6 +55,38 @@ s! { pub pc: u64, pub pstate: u64, } + + pub struct ucontext_t { + pub uc_flags: ::c_ulong, + pub uc_link: *mut ucontext_t, + pub uc_stack: ::stack_t, + pub uc_sigmask: ::sigset_t, + pub uc_mcontext: mcontext_t, + } + + #[repr(align(16))] + pub struct mcontext_t { + pub fault_address: ::c_ulonglong, + pub regs: [::c_ulonglong; 31], + pub sp: ::c_ulonglong, + pub pc: ::c_ulonglong, + pub pstate: ::c_ulonglong, + __reserved: [u64; 512], + } + + pub struct user_fpsimd_struct { + pub vregs: [::__uint128_t; 32], + pub fpsr: u32, + pub fpcr: u32, + } +} + +s_no_extra_traits! { + #[allow(missing_debug_implementations)] + #[repr(align(16))] + pub struct max_align_t { + priv_: [f32; 8] + } } pub const O_DIRECT: ::c_int = 0x10000; @@ -375,17 +407,3 @@ pub const SYS_pkey_mprotect: ::c_long = 288; pub const SYS_pkey_alloc: ::c_long = 289; pub const SYS_pkey_free: ::c_long = 290; pub const SYS_syscalls: ::c_long = 436; - -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; - } -} - -cfg_if! { - if #[cfg(libc_int128)] { - mod int128; - pub use self::int128::*; - } -} diff --git a/src/unix/linux_like/android/b64/x86_64/align.rs b/src/unix/linux_like/android/b64/x86_64/align.rs deleted file mode 100644 index 7ca870fd02b71..0000000000000 --- a/src/unix/linux_like/android/b64/x86_64/align.rs +++ /dev/null @@ -1,7 +0,0 @@ -s_no_extra_traits! { - #[allow(missing_debug_implementations)] - #[repr(align(16))] - pub struct max_align_t { - priv_: [f64; 4] - } -} 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 d25b50775537c..01e24a2765fc7 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) } } } } @@ -783,9 +779,10 @@ pub const REG_TRAPNO: ::c_int = 20; pub const REG_OLDMASK: ::c_int = 21; pub const REG_CR2: ::c_int = 22; -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; +s_no_extra_traits! { + #[allow(missing_debug_implementations)] + #[repr(align(16))] + pub struct max_align_t { + priv_: [f64; 4] } } diff --git a/src/unix/linux_like/android/mod.rs b/src/unix/linux_like/android/mod.rs index cfd229a474a92..489d9b4469b31 100644 --- a/src/unix/linux_like/android/mod.rs +++ b/src/unix/linux_like/android/mod.rs @@ -432,7 +432,7 @@ s_no_extra_traits! { pub struct prop_info { __name: [::c_char; 32], __serial: ::c_uint, - __value: [[::c_char; 4]; 23], + __value: [::c_char; 92], } } @@ -3253,64 +3253,60 @@ 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/emscripten/align.rs b/src/unix/linux_like/emscripten/align.rs deleted file mode 100644 index b9ea3f39efdf5..0000000000000 --- a/src/unix/linux_like/emscripten/align.rs +++ /dev/null @@ -1,74 +0,0 @@ -macro_rules! expand_align { - () => { - s! { - #[allow(missing_debug_implementations)] - #[repr(align(4))] - pub struct pthread_mutex_t { - size: [u8; ::__SIZEOF_PTHREAD_MUTEX_T], - } - - #[repr(align(4))] - pub struct pthread_rwlock_t { - size: [u8; ::__SIZEOF_PTHREAD_RWLOCK_T], - } - - #[repr(align(4))] - pub struct pthread_mutexattr_t { - size: [u8; ::__SIZEOF_PTHREAD_MUTEXATTR_T], - } - - #[repr(align(4))] - pub struct pthread_rwlockattr_t { - size: [u8; ::__SIZEOF_PTHREAD_RWLOCKATTR_T], - } - - #[repr(align(4))] - pub struct pthread_condattr_t { - size: [u8; ::__SIZEOF_PTHREAD_CONDATTR_T], - } - } - - s_no_extra_traits! { - #[cfg_attr(target_pointer_width = "32", - repr(align(4)))] - #[cfg_attr(target_pointer_width = "64", - repr(align(8)))] - pub struct pthread_cond_t { - size: [u8; ::__SIZEOF_PTHREAD_COND_T], - } - - #[allow(missing_debug_implementations)] - #[repr(align(16))] - pub struct max_align_t { - priv_: [f64; 4] - } - - } - - 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/emscripten/mod.rs b/src/unix/linux_like/emscripten/mod.rs index 31d0ebf25b104..57e3147b1236a 100644 --- a/src/unix/linux_like/emscripten/mod.rs +++ b/src/unix/linux_like/emscripten/mod.rs @@ -403,6 +403,32 @@ s! { pub updated: ::c_ulong, pub ha: [::c_uchar; ::MAX_ADDR_LEN], } + + #[allow(missing_debug_implementations)] + #[repr(align(4))] + pub struct pthread_mutex_t { + size: [u8; ::__SIZEOF_PTHREAD_MUTEX_T], + } + + #[repr(align(4))] + pub struct pthread_rwlock_t { + size: [u8; ::__SIZEOF_PTHREAD_RWLOCK_T], + } + + #[repr(align(4))] + pub struct pthread_mutexattr_t { + size: [u8; ::__SIZEOF_PTHREAD_MUTEXATTR_T], + } + + #[repr(align(4))] + pub struct pthread_rwlockattr_t { + size: [u8; ::__SIZEOF_PTHREAD_RWLOCKATTR_T], + } + + #[repr(align(4))] + pub struct pthread_condattr_t { + size: [u8; ::__SIZEOF_PTHREAD_CONDATTR_T], + } } s_no_extra_traits! { @@ -446,6 +472,21 @@ s_no_extra_traits! { pub mq_curmsgs: ::c_long, pad: [::c_long; 4] } + + #[cfg_attr(target_pointer_width = "32", + repr(align(4)))] + #[cfg_attr(target_pointer_width = "64", + repr(align(8)))] + pub struct pthread_cond_t { + size: [u8; ::__SIZEOF_PTHREAD_COND_T], + } + + #[allow(missing_debug_implementations)] + #[repr(align(16))] + pub struct max_align_t { + priv_: [f64; 4] + } + } cfg_if! { @@ -609,6 +650,28 @@ cfg_if! { self.mq_curmsgs.hash(state); } } + + 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); + } + } } } @@ -899,17 +962,15 @@ pub const RTLD_DEFAULT: *mut ::c_void = 0i64 as *mut ::c_void; pub const RTLD_NODELETE: ::c_int = 0x1000; pub const RTLD_NOW: ::c_int = 0x2; -align_const! { - pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { - size: [0; __SIZEOF_PTHREAD_MUTEX_T], - }; - pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { - size: [0; __SIZEOF_PTHREAD_COND_T], - }; - pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { - size: [0; __SIZEOF_PTHREAD_RWLOCK_T], - }; -} +pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { + size: [0; __SIZEOF_PTHREAD_MUTEX_T], +}; +pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { + size: [0; __SIZEOF_PTHREAD_COND_T], +}; +pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { + size: [0; __SIZEOF_PTHREAD_RWLOCK_T], +}; pub const PTHREAD_MUTEX_NORMAL: ::c_int = 0; pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 1; @@ -1882,14 +1943,3 @@ extern "C" { value: *mut ::c_void, ) -> ::c_int; } - -cfg_if! { - if #[cfg(libc_align)] { - #[macro_use] - mod align; - } else { - #[macro_use] - mod no_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/align.rs b/src/unix/linux_like/linux/align.rs deleted file mode 100644 index 3a3277f29cf47..0000000000000 --- a/src/unix/linux_like/linux/align.rs +++ /dev/null @@ -1,150 +0,0 @@ -macro_rules! expand_align { - () => { - s! { - #[cfg_attr(any(target_pointer_width = "32", - target_arch = "x86_64", - target_arch = "powerpc64", - target_arch = "mips64", - target_arch = "s390x", - target_arch = "sparc64", - target_arch = "aarch64", - target_arch = "riscv64", - target_arch = "riscv32", - target_arch = "loongarch64"), - repr(align(4)))] - #[cfg_attr(not(any(target_pointer_width = "32", - target_arch = "x86_64", - target_arch = "powerpc64", - target_arch = "mips64", - target_arch = "s390x", - target_arch = "sparc64", - target_arch = "aarch64", - target_arch = "riscv64", - target_arch = "riscv32", - target_arch = "loongarch64")), - repr(align(8)))] - pub struct pthread_mutexattr_t { - #[doc(hidden)] - size: [u8; ::__SIZEOF_PTHREAD_MUTEXATTR_T], - } - - #[cfg_attr(any(target_env = "musl", target_pointer_width = "32"), - repr(align(4)))] - #[cfg_attr(all(not(target_env = "musl"), - target_pointer_width = "64"), - repr(align(8)))] - pub struct pthread_rwlockattr_t { - #[doc(hidden)] - size: [u8; ::__SIZEOF_PTHREAD_RWLOCKATTR_T], - } - - #[repr(align(4))] - pub struct pthread_condattr_t { - #[doc(hidden)] - size: [u8; ::__SIZEOF_PTHREAD_CONDATTR_T], - } - - #[repr(align(8))] - pub struct fanotify_event_metadata { - 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! { - #[cfg_attr(all(target_env = "musl", - target_pointer_width = "32"), - repr(align(4)))] - #[cfg_attr(all(target_env = "musl", - target_pointer_width = "64"), - repr(align(8)))] - #[cfg_attr(all(not(target_env = "musl"), - target_arch = "x86"), - repr(align(4)))] - #[cfg_attr(all(not(target_env = "musl"), - not(target_arch = "x86")), - repr(align(8)))] - pub struct pthread_cond_t { - #[doc(hidden)] - size: [u8; ::__SIZEOF_PTHREAD_COND_T], - } - - #[cfg_attr(all(target_pointer_width = "32", - any(target_arch = "mips", - target_arch = "arm", - target_arch = "hexagon", - target_arch = "m68k", - target_arch = "powerpc", - target_arch = "sparc", - target_arch = "x86_64", - target_arch = "x86")), - repr(align(4)))] - #[cfg_attr(any(target_pointer_width = "64", - not(any(target_arch = "mips", - target_arch = "arm", - target_arch = "hexagon", - target_arch = "m68k", - target_arch = "powerpc", - target_arch = "sparc", - target_arch = "x86_64", - target_arch = "x86"))), - repr(align(8)))] - pub struct pthread_mutex_t { - #[doc(hidden)] - size: [u8; ::__SIZEOF_PTHREAD_MUTEX_T], - } - - #[cfg_attr(all(target_pointer_width = "32", - any(target_arch = "mips", - target_arch = "arm", - target_arch = "hexagon", - target_arch = "m68k", - target_arch = "powerpc", - target_arch = "sparc", - target_arch = "x86_64", - target_arch = "x86")), - repr(align(4)))] - #[cfg_attr(any(target_pointer_width = "64", - not(any(target_arch = "mips", - target_arch = "arm", - target_arch = "hexagon", - target_arch = "m68k", - target_arch = "powerpc", - target_arch = "sparc", - target_arch = "x86_64", - target_arch = "x86"))), - repr(align(8)))] - pub struct pthread_rwlock_t { - size: [u8; ::__SIZEOF_PTHREAD_RWLOCK_T], - } - - // linux/can.h - #[repr(align(8))] - #[allow(missing_debug_implementations)] - pub struct can_frame { - pub can_id: canid_t, - pub can_dlc: u8, - __pad: u8, - __res0: u8, - __res1: u8, - pub data: [u8; CAN_MAX_DLEN], - } - - #[repr(align(8))] - #[allow(missing_debug_implementations)] - pub struct canfd_frame { - pub can_id: canid_t, - pub len: u8, - pub flags: u8, - __res0: u8, - __res1: u8, - pub data: [u8; CANFD_MAX_DLEN], - } - } - }; -} diff --git a/src/unix/linux_like/linux/gnu/align.rs b/src/unix/linux_like/linux/gnu/align.rs deleted file mode 100644 index 4a0e07460ebb1..0000000000000 --- a/src/unix/linux_like/linux/gnu/align.rs +++ /dev/null @@ -1,13 +0,0 @@ -s! { - // FIXME this is actually a union - #[cfg_attr(target_pointer_width = "32", - repr(align(4)))] - #[cfg_attr(target_pointer_width = "64", - repr(align(8)))] - pub struct sem_t { - #[cfg(target_pointer_width = "32")] - __size: [::c_char; 16], - #[cfg(target_pointer_width = "64")] - __size: [::c_char; 32], - } -} diff --git a/src/unix/linux_like/linux/gnu/b32/arm/align.rs b/src/unix/linux_like/linux/gnu/b32/arm/align.rs deleted file mode 100644 index 2645ec4c3d4f1..0000000000000 --- a/src/unix/linux_like/linux/gnu/b32/arm/align.rs +++ /dev/null @@ -1,53 +0,0 @@ -s_no_extra_traits! { - #[allow(missing_debug_implementations)] - #[repr(align(8))] - pub struct max_align_t { - priv_: [i64; 2] - } - - #[allow(missing_debug_implementations)] - #[repr(align(8))] - 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: ::sigset_t, - pub uc_regspace: [::c_ulong; 128], - } -} - -cfg_if! { - if #[cfg(feature = "extra_traits")] { - impl PartialEq for ucontext_t { - fn eq(&self, other: &ucontext_t) -> 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 == other.uc_sigmask - } - } - 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_link) - .field("uc_link", &self.uc_link) - .field("uc_stack", &self.uc_stack) - .field("uc_mcontext", &self.uc_mcontext) - .field("uc_sigmask", &self.uc_sigmask) - .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.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 2a064974d41b1..20740b7361a77 100644 --- a/src/unix/linux_like/linux/gnu/b32/arm/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/arm/mod.rs @@ -836,9 +836,56 @@ pub const SYS_process_madvise: ::c_long = 440; pub const SYS_epoll_pwait2: ::c_long = 441; pub const SYS_mount_setattr: ::c_long = 442; +s_no_extra_traits! { + #[allow(missing_debug_implementations)] + #[repr(align(8))] + pub struct max_align_t { + priv_: [i64; 2] + } + + #[allow(missing_debug_implementations)] + #[repr(align(8))] + 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: ::sigset_t, + pub uc_regspace: [::c_ulong; 128], + } +} + cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; + if #[cfg(feature = "extra_traits")] { + impl PartialEq for ucontext_t { + fn eq(&self, other: &ucontext_t) -> 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 == other.uc_sigmask + } + } + 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_link) + .field("uc_link", &self.uc_link) + .field("uc_stack", &self.uc_stack) + .field("uc_mcontext", &self.uc_mcontext) + .field("uc_sigmask", &self.uc_sigmask) + .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.hash(state); + } + } } } diff --git a/src/unix/linux_like/linux/gnu/b32/mips/align.rs b/src/unix/linux_like/linux/gnu/b32/mips/align.rs deleted file mode 100644 index 8c228ebab72ce..0000000000000 --- a/src/unix/linux_like/linux/gnu/b32/mips/align.rs +++ /dev/null @@ -1,7 +0,0 @@ -s_no_extra_traits! { - #[allow(missing_debug_implementations)] - #[repr(align(8))] - pub struct max_align_t { - priv_: [f32; 4] - } -} 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 eb3886fbcd115..1b2e8517ea91f 100644 --- a/src/unix/linux_like/linux/gnu/b32/mips/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/mips/mod.rs @@ -802,9 +802,10 @@ pub const B4000000: ::speed_t = 0o010017; pub const EHWPOISON: ::c_int = 168; -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; +s_no_extra_traits! { + #[allow(missing_debug_implementations)] + #[repr(align(8))] + pub struct max_align_t { + priv_: [f32; 4] } } diff --git a/src/unix/linux_like/linux/gnu/b32/mod.rs b/src/unix/linux_like/linux/gnu/b32/mod.rs index ad0d64c51d5b4..25f551b341093 100644 --- a/src/unix/linux_like/linux/gnu/b32/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/mod.rs @@ -261,56 +261,42 @@ cfg_if! { } } -align_const! { - #[cfg(target_endian = "little")] - pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = - pthread_mutex_t { - size: [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, - ], - }; - #[cfg(target_endian = "little")] - pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = - pthread_mutex_t { - size: [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, - ], - }; - #[cfg(target_endian = "little")] - pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = - pthread_mutex_t { - size: [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, - ], - }; - #[cfg(target_endian = "big")] - pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = - pthread_mutex_t { - size: [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, - 0, 0, 0, - ], - }; - #[cfg(target_endian = "big")] - pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = - pthread_mutex_t { - size: [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, - 0, 0, 0, - ], - }; - #[cfg(target_endian = "big")] - pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = - pthread_mutex_t { - size: [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, - 0, 0, 0, - ], - }; -} +#[cfg(target_endian = "little")] +pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; +#[cfg(target_endian = "little")] +pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; +#[cfg(target_endian = "little")] +pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; +#[cfg(target_endian = "big")] +pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; +#[cfg(target_endian = "big")] +pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; +#[cfg(target_endian = "big")] +pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; pub const PTRACE_GETFPREGS: ::c_uint = 14; pub const PTRACE_SETFPREGS: ::c_uint = 15; diff --git a/src/unix/linux_like/linux/gnu/b32/riscv32/align.rs b/src/unix/linux_like/linux/gnu/b32/riscv32/align.rs deleted file mode 100644 index 48d152a5721ec..0000000000000 --- a/src/unix/linux_like/linux/gnu/b32/riscv32/align.rs +++ /dev/null @@ -1,44 +0,0 @@ -s_no_extra_traits! { - #[allow(missing_debug_implementations)] - pub struct ucontext_t { - pub __uc_flags: ::c_ulong, - pub uc_link: *mut ucontext_t, - pub uc_stack: ::stack_t, - pub uc_sigmask: ::sigset_t, - pub uc_mcontext: mcontext_t, - } - - #[allow(missing_debug_implementations)] - #[repr(align(16))] - pub struct mcontext_t { - pub __gregs: [::c_ulong; 32], - pub __fpregs: __riscv_mc_fp_state, - } - - #[allow(missing_debug_implementations)] - pub union __riscv_mc_fp_state { - pub __f: __riscv_mc_f_ext_state, - pub __d: __riscv_mc_d_ext_state, - pub __q: __riscv_mc_q_ext_state, - } - - #[allow(missing_debug_implementations)] - pub struct __riscv_mc_f_ext_state { - pub __f: [::c_uint; 32], - pub __fcsr: ::c_uint, - } - - #[allow(missing_debug_implementations)] - pub struct __riscv_mc_d_ext_state { - pub __f: [::c_ulonglong; 32], - pub __fcsr: ::c_uint, - } - - #[allow(missing_debug_implementations)] - #[repr(align(16))] - pub struct __riscv_mc_q_ext_state { - pub __f: [::c_ulonglong; 64], - pub __fcsr: ::c_uint, - pub __glibc_reserved: [::c_uint; 3], - } -} 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 def90d6d1947a..92b14ab78b037 100644 --- a/src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs @@ -759,9 +759,47 @@ 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::*; +s_no_extra_traits! { + #[allow(missing_debug_implementations)] + pub struct ucontext_t { + pub __uc_flags: ::c_ulong, + pub uc_link: *mut ucontext_t, + pub uc_stack: ::stack_t, + pub uc_sigmask: ::sigset_t, + pub uc_mcontext: mcontext_t, + } + + #[allow(missing_debug_implementations)] + #[repr(align(16))] + pub struct mcontext_t { + pub __gregs: [::c_ulong; 32], + pub __fpregs: __riscv_mc_fp_state, + } + + #[allow(missing_debug_implementations)] + pub union __riscv_mc_fp_state { + pub __f: __riscv_mc_f_ext_state, + pub __d: __riscv_mc_d_ext_state, + pub __q: __riscv_mc_q_ext_state, + } + + #[allow(missing_debug_implementations)] + pub struct __riscv_mc_f_ext_state { + pub __f: [::c_uint; 32], + pub __fcsr: ::c_uint, + } + + #[allow(missing_debug_implementations)] + pub struct __riscv_mc_d_ext_state { + pub __f: [::c_ulonglong; 32], + pub __fcsr: ::c_uint, + } + + #[allow(missing_debug_implementations)] + #[repr(align(16))] + pub struct __riscv_mc_q_ext_state { + pub __f: [::c_ulonglong; 64], + pub __fcsr: ::c_uint, + pub __glibc_reserved: [::c_uint; 3], } } diff --git a/src/unix/linux_like/linux/gnu/b32/sparc/align.rs b/src/unix/linux_like/linux/gnu/b32/sparc/align.rs deleted file mode 100644 index 98fda883cd374..0000000000000 --- a/src/unix/linux_like/linux/gnu/b32/sparc/align.rs +++ /dev/null @@ -1,7 +0,0 @@ -s_no_extra_traits! { - #[allow(missing_debug_implementations)] - #[repr(align(8))] - pub struct max_align_t { - priv_: [i64; 3] - } -} 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 5dd2302dbfaaf..1700060d71ac8 100644 --- a/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs @@ -840,9 +840,10 @@ 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::*; +s_no_extra_traits! { + #[allow(missing_debug_implementations)] + #[repr(align(8))] + pub struct max_align_t { + priv_: [i64; 3] } } diff --git a/src/unix/linux_like/linux/gnu/b32/x86/align.rs b/src/unix/linux_like/linux/gnu/b32/x86/align.rs deleted file mode 100644 index 96634749f53b2..0000000000000 --- a/src/unix/linux_like/linux/gnu/b32/x86/align.rs +++ /dev/null @@ -1,7 +0,0 @@ -s_no_extra_traits! { - #[allow(missing_debug_implementations)] - #[repr(align(16))] - pub struct max_align_t { - priv_: [f64; 6] - } -} 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 e42e9ebd6ebe0..b6f15a813ef87 100644 --- a/src/unix/linux_like/linux/gnu/b32/x86/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/x86/mod.rs @@ -1093,9 +1093,10 @@ 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::*; +s_no_extra_traits! { + #[allow(missing_debug_implementations)] + #[repr(align(16))] + pub struct max_align_t { + priv_: [f64; 6] } } diff --git a/src/unix/linux_like/linux/gnu/b64/aarch64/align.rs b/src/unix/linux_like/linux/gnu/b64/aarch64/align.rs deleted file mode 100644 index cb2df378cf5ea..0000000000000 --- a/src/unix/linux_like/linux/gnu/b64/aarch64/align.rs +++ /dev/null @@ -1,51 +0,0 @@ -s_no_extra_traits! { - #[allow(missing_debug_implementations)] - #[repr(align(16))] - pub struct max_align_t { - priv_: [f32; 8] - } -} - -s! { - pub struct ucontext_t { - pub uc_flags: ::c_ulong, - pub uc_link: *mut ucontext_t, - pub uc_stack: ::stack_t, - pub uc_sigmask: ::sigset_t, - pub uc_mcontext: mcontext_t, - } - - #[repr(align(16))] - pub struct mcontext_t { - pub fault_address: ::c_ulonglong, - pub regs: [::c_ulonglong; 31], - pub sp: ::c_ulonglong, - pub pc: ::c_ulonglong, - pub pstate: ::c_ulonglong, - // nested arrays to get the right size/length while being able to - // auto-derive traits like Debug - __reserved: [[u64; 32]; 16], - } - - #[repr(align(16))] - pub struct user_fpsimd_struct { - pub vregs: [[u64; 2]; 32], - pub fpsr: ::c_uint, - pub fpcr: ::c_uint, - } - - #[repr(align(8))] - pub struct clone_args { - pub flags: ::c_ulonglong, - pub pidfd: ::c_ulonglong, - pub child_tid: ::c_ulonglong, - pub parent_tid: ::c_ulonglong, - pub exit_signal: ::c_ulonglong, - pub stack: ::c_ulonglong, - pub stack_size: ::c_ulonglong, - pub tls: ::c_ulonglong, - pub set_tid: ::c_ulonglong, - pub set_tid_size: ::c_ulonglong, - pub cgroup: ::c_ulonglong, - } -} diff --git a/src/unix/linux_like/linux/gnu/b64/aarch64/ilp32.rs b/src/unix/linux_like/linux/gnu/b64/aarch64/ilp32.rs index 24b7f4e6b90cf..c95e30f71d3d6 100644 --- a/src/unix/linux_like/linux/gnu/b64/aarch64/ilp32.rs +++ b/src/unix/linux_like/linux/gnu/b64/aarch64/ilp32.rs @@ -8,55 +8,47 @@ pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 32; pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4; pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 48; -align_const! { - #[cfg(target_endian = "little")] - pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = - pthread_mutex_t { - size: [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - ], - }; - #[cfg(target_endian = "little")] - pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = - pthread_mutex_t { - size: [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - ], - }; - #[cfg(target_endian = "little")] - pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = - pthread_mutex_t { - size: [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - ], - }; - #[cfg(target_endian = "big")] - pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = - pthread_mutex_t { - size: [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - ], - }; - #[cfg(target_endian = "big")] - pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = - pthread_mutex_t { - size: [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - ], - }; - #[cfg(target_endian = "big")] - pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = - pthread_mutex_t { - size: [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - ], - }; -} +#[cfg(target_endian = "little")] +pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, + ], +}; +#[cfg(target_endian = "little")] +pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, + ], +}; +#[cfg(target_endian = "little")] +pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, + ], +}; +#[cfg(target_endian = "big")] +pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, + ], +}; +#[cfg(target_endian = "big")] +pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, + ], +}; +#[cfg(target_endian = "big")] +pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, + ], +}; pub const SYS_sync_file_range2: ::c_long = 84; diff --git a/src/unix/linux_like/linux/gnu/b64/aarch64/int128.rs b/src/unix/linux_like/linux/gnu/b64/aarch64/int128.rs deleted file mode 100644 index 4535e73eeddf1..0000000000000 --- a/src/unix/linux_like/linux/gnu/b64/aarch64/int128.rs +++ /dev/null @@ -1,7 +0,0 @@ -s! { - pub struct user_fpsimd_struct { - pub vregs: [::__uint128_t; 32], - pub fpsr: u32, - pub fpcr: u32, - } -} diff --git a/src/unix/linux_like/linux/gnu/b64/aarch64/lp64.rs b/src/unix/linux_like/linux/gnu/b64/aarch64/lp64.rs index 14d39e543dc44..7e929170bcd22 100644 --- a/src/unix/linux_like/linux/gnu/b64/aarch64/lp64.rs +++ b/src/unix/linux_like/linux/gnu/b64/aarch64/lp64.rs @@ -8,62 +8,48 @@ pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 48; pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 8; pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56; -align_const! { - #[cfg(target_endian = "little")] - pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = - pthread_mutex_t { - size: [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - ], - }; - #[cfg(target_endian = "little")] - pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = - pthread_mutex_t { - size: [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - ], - }; - #[cfg(target_endian = "little")] - pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = - pthread_mutex_t { - size: [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - ], - }; - #[cfg(target_endian = "big")] - pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = - pthread_mutex_t { - size: [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - ], - }; - #[cfg(target_endian = "big")] - pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = - pthread_mutex_t { - size: [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - ], - }; - #[cfg(target_endian = "big")] - pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = - pthread_mutex_t { - size: [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - ], - }; -} +#[cfg(target_endian = "little")] +pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; +#[cfg(target_endian = "little")] +pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; +#[cfg(target_endian = "little")] +pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; +#[cfg(target_endian = "big")] +pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; +#[cfg(target_endian = "big")] +pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; +#[cfg(target_endian = "big")] +pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; pub const SYS_renameat: ::c_long = 38; pub const SYS_sync_file_range: ::c_long = 84; 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 60a1b69323cf7..ec0bb079d31c1 100644 --- a/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs @@ -202,6 +202,53 @@ s! { pub seccomp_notif_resp: ::__u16, pub seccomp_data: ::__u16, } + + pub struct ucontext_t { + pub uc_flags: ::c_ulong, + pub uc_link: *mut ucontext_t, + pub uc_stack: ::stack_t, + pub uc_sigmask: ::sigset_t, + pub uc_mcontext: mcontext_t, + } + + #[repr(align(16))] + pub struct mcontext_t { + pub fault_address: ::c_ulonglong, + pub regs: [::c_ulonglong; 31], + pub sp: ::c_ulonglong, + pub pc: ::c_ulonglong, + pub pstate: ::c_ulonglong, + __reserved: [u64; 512], + } + + pub struct user_fpsimd_struct { + pub vregs: [::__uint128_t; 32], + pub fpsr: ::c_uint, + pub fpcr: ::c_uint, + } + + #[repr(align(8))] + pub struct clone_args { + pub flags: ::c_ulonglong, + pub pidfd: ::c_ulonglong, + pub child_tid: ::c_ulonglong, + pub parent_tid: ::c_ulonglong, + pub exit_signal: ::c_ulonglong, + pub stack: ::c_ulonglong, + pub stack_size: ::c_ulonglong, + pub tls: ::c_ulonglong, + pub set_tid: ::c_ulonglong, + pub set_tid_size: ::c_ulonglong, + pub cgroup: ::c_ulonglong, + } +} + +s_no_extra_traits! { + #[allow(missing_debug_implementations)] + #[repr(align(16))] + pub struct max_align_t { + priv_: [f32; 8] + } } pub const VEOF: usize = 4; @@ -906,17 +953,3 @@ cfg_if! { pub use self::lp64::*; } } - -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; - } -} - -cfg_if! { - if #[cfg(libc_int128)] { - mod int128; - pub use self::int128::*; - } -} diff --git a/src/unix/linux_like/linux/gnu/b64/loongarch64/align.rs b/src/unix/linux_like/linux/gnu/b64/loongarch64/align.rs deleted file mode 100644 index 7ca870fd02b71..0000000000000 --- a/src/unix/linux_like/linux/gnu/b64/loongarch64/align.rs +++ /dev/null @@ -1,7 +0,0 @@ -s_no_extra_traits! { - #[allow(missing_debug_implementations)] - #[repr(align(16))] - pub struct max_align_t { - priv_: [f64; 4] - } -} 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 2ed6a9156df2a..f46e6b9172a15 100644 --- a/src/unix/linux_like/linux/gnu/b64/loongarch64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/loongarch64/mod.rs @@ -196,56 +196,48 @@ pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4; pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40; pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56; -align_const! { - #[cfg(target_endian = "little")] - pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = - pthread_mutex_t { - size: [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - ], - }; - #[cfg(target_endian = "little")] - pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = - pthread_mutex_t { - size: [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - ], - }; - #[cfg(target_endian = "little")] - pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = - pthread_mutex_t { - size: [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - ], - }; - #[cfg(target_endian = "big")] - pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = - pthread_mutex_t { - size: [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - ], - }; - #[cfg(target_endian = "big")] - pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = - pthread_mutex_t { - size: [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - ], - }; - #[cfg(target_endian = "big")] - pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = - pthread_mutex_t { - size: [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - ], - }; -} +#[cfg(target_endian = "little")] +pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; +#[cfg(target_endian = "little")] +pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; +#[cfg(target_endian = "little")] +pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; +#[cfg(target_endian = "big")] +pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; +#[cfg(target_endian = "big")] +pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; +#[cfg(target_endian = "big")] +pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; pub const SYS_io_setup: ::c_long = 0; pub const SYS_io_destroy: ::c_long = 1; @@ -869,9 +861,10 @@ extern "C" { ) -> ::c_int; } -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; +s_no_extra_traits! { + #[allow(missing_debug_implementations)] + #[repr(align(16))] + pub struct max_align_t { + priv_: [f64; 4] } } diff --git a/src/unix/linux_like/linux/gnu/b64/mips64/align.rs b/src/unix/linux_like/linux/gnu/b64/mips64/align.rs deleted file mode 100644 index 7ca870fd02b71..0000000000000 --- a/src/unix/linux_like/linux/gnu/b64/mips64/align.rs +++ /dev/null @@ -1,7 +0,0 @@ -s_no_extra_traits! { - #[allow(missing_debug_implementations)] - #[repr(align(16))] - pub struct max_align_t { - priv_: [f64; 4] - } -} 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 cac215dc43ebc..c04dfcb09d98a 100644 --- a/src/unix/linux_like/linux/gnu/b64/mips64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/mips64/mod.rs @@ -191,56 +191,48 @@ pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4; pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40; pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56; -align_const! { - #[cfg(target_endian = "little")] - pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = - pthread_mutex_t { - size: [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - ], - }; - #[cfg(target_endian = "little")] - pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = - pthread_mutex_t { - size: [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - ], - }; - #[cfg(target_endian = "little")] - pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = - pthread_mutex_t { - size: [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - ], - }; - #[cfg(target_endian = "big")] - pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = - pthread_mutex_t { - size: [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - ], - }; - #[cfg(target_endian = "big")] - pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = - pthread_mutex_t { - size: [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - ], - }; - #[cfg(target_endian = "big")] - pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = - pthread_mutex_t { - size: [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - ], - }; -} +#[cfg(target_endian = "little")] +pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; +#[cfg(target_endian = "little")] +pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; +#[cfg(target_endian = "little")] +pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; +#[cfg(target_endian = "big")] +pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; +#[cfg(target_endian = "big")] +pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; +#[cfg(target_endian = "big")] +pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; pub const SYS_read: ::c_long = 5000 + 0; pub const SYS_write: ::c_long = 5000 + 1; @@ -915,9 +907,10 @@ extern "C" { ) -> ::c_int; } -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; +s_no_extra_traits! { + #[allow(missing_debug_implementations)] + #[repr(align(16))] + pub struct max_align_t { + priv_: [f64; 4] } } diff --git a/src/unix/linux_like/linux/gnu/b64/powerpc64/align.rs b/src/unix/linux_like/linux/gnu/b64/powerpc64/align.rs deleted file mode 100644 index 29d1e1c7b8a55..0000000000000 --- a/src/unix/linux_like/linux/gnu/b64/powerpc64/align.rs +++ /dev/null @@ -1,7 +0,0 @@ -s_no_extra_traits! { - #[allow(missing_debug_implementations)] - #[repr(align(16))] - pub struct max_align_t { - priv_: [i64; 4] - } -} 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 b5c2687061907..ff3f04ab149f6 100644 --- a/src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs @@ -403,56 +403,48 @@ pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4; pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40; pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4; -align_const! { - #[cfg(target_endian = "little")] - pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = - pthread_mutex_t { - size: [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - ], - }; - #[cfg(target_endian = "little")] - pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = - pthread_mutex_t { - size: [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - ], - }; - #[cfg(target_endian = "little")] - pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = - pthread_mutex_t { - size: [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - ], - }; - #[cfg(target_endian = "big")] - pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = - pthread_mutex_t { - size: [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - ], - }; - #[cfg(target_endian = "big")] - pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = - pthread_mutex_t { - size: [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - ], - }; - #[cfg(target_endian = "big")] - pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = - pthread_mutex_t { - size: [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - ], - }; -} +#[cfg(target_endian = "little")] +pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; +#[cfg(target_endian = "little")] +pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; +#[cfg(target_endian = "little")] +pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; +#[cfg(target_endian = "big")] +pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; +#[cfg(target_endian = "big")] +pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; +#[cfg(target_endian = "big")] +pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; pub const O_DIRECTORY: ::c_int = 0x4000; pub const O_NOFOLLOW: ::c_int = 0x8000; @@ -960,9 +952,10 @@ extern "C" { ) -> ::c_int; } -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; +s_no_extra_traits! { + #[allow(missing_debug_implementations)] + #[repr(align(16))] + pub struct max_align_t { + priv_: [i64; 4] } } diff --git a/src/unix/linux_like/linux/gnu/b64/riscv64/align.rs b/src/unix/linux_like/linux/gnu/b64/riscv64/align.rs deleted file mode 100644 index 48d152a5721ec..0000000000000 --- a/src/unix/linux_like/linux/gnu/b64/riscv64/align.rs +++ /dev/null @@ -1,44 +0,0 @@ -s_no_extra_traits! { - #[allow(missing_debug_implementations)] - pub struct ucontext_t { - pub __uc_flags: ::c_ulong, - pub uc_link: *mut ucontext_t, - pub uc_stack: ::stack_t, - pub uc_sigmask: ::sigset_t, - pub uc_mcontext: mcontext_t, - } - - #[allow(missing_debug_implementations)] - #[repr(align(16))] - pub struct mcontext_t { - pub __gregs: [::c_ulong; 32], - pub __fpregs: __riscv_mc_fp_state, - } - - #[allow(missing_debug_implementations)] - pub union __riscv_mc_fp_state { - pub __f: __riscv_mc_f_ext_state, - pub __d: __riscv_mc_d_ext_state, - pub __q: __riscv_mc_q_ext_state, - } - - #[allow(missing_debug_implementations)] - pub struct __riscv_mc_f_ext_state { - pub __f: [::c_uint; 32], - pub __fcsr: ::c_uint, - } - - #[allow(missing_debug_implementations)] - pub struct __riscv_mc_d_ext_state { - pub __f: [::c_ulonglong; 32], - pub __fcsr: ::c_uint, - } - - #[allow(missing_debug_implementations)] - #[repr(align(16))] - pub struct __riscv_mc_q_ext_state { - pub __f: [::c_ulonglong; 64], - pub __fcsr: ::c_uint, - pub __glibc_reserved: [::c_uint; 3], - } -} 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 f8073902a74d5..1924bb2bcf584 100644 --- a/src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs @@ -798,9 +798,47 @@ 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::*; +s_no_extra_traits! { + #[allow(missing_debug_implementations)] + pub struct ucontext_t { + pub __uc_flags: ::c_ulong, + pub uc_link: *mut ucontext_t, + pub uc_stack: ::stack_t, + pub uc_sigmask: ::sigset_t, + pub uc_mcontext: mcontext_t, + } + + #[allow(missing_debug_implementations)] + #[repr(align(16))] + pub struct mcontext_t { + pub __gregs: [::c_ulong; 32], + pub __fpregs: __riscv_mc_fp_state, + } + + #[allow(missing_debug_implementations)] + pub union __riscv_mc_fp_state { + pub __f: __riscv_mc_f_ext_state, + pub __d: __riscv_mc_d_ext_state, + pub __q: __riscv_mc_q_ext_state, + } + + #[allow(missing_debug_implementations)] + pub struct __riscv_mc_f_ext_state { + pub __f: [::c_uint; 32], + pub __fcsr: ::c_uint, + } + + #[allow(missing_debug_implementations)] + pub struct __riscv_mc_d_ext_state { + pub __f: [::c_ulonglong; 32], + pub __fcsr: ::c_uint, + } + + #[allow(missing_debug_implementations)] + #[repr(align(16))] + pub struct __riscv_mc_q_ext_state { + pub __f: [::c_ulonglong; 64], + pub __fcsr: ::c_uint, + pub __glibc_reserved: [::c_uint; 3], } } diff --git a/src/unix/linux_like/linux/gnu/b64/s390x.rs b/src/unix/linux_like/linux/gnu/b64/s390x.rs index 212dc898cfc4b..f12fe751ff3f8 100644 --- a/src/unix/linux_like/linux/gnu/b64/s390x.rs +++ b/src/unix/linux_like/linux/gnu/b64/s390x.rs @@ -292,29 +292,24 @@ pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4; pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40; pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56; -align_const! { - pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = - pthread_mutex_t { - size: [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - ], - }; - pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = - pthread_mutex_t { - size: [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - ], - }; - pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = - pthread_mutex_t { - size: [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - ], - }; -} +pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; +pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; +pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; pub const EUCLEAN: ::c_int = 117; pub const ENOTNAM: ::c_int = 118; diff --git a/src/unix/linux_like/linux/gnu/b64/sparc64/align.rs b/src/unix/linux_like/linux/gnu/b64/sparc64/align.rs deleted file mode 100644 index 29d1e1c7b8a55..0000000000000 --- a/src/unix/linux_like/linux/gnu/b64/sparc64/align.rs +++ /dev/null @@ -1,7 +0,0 @@ -s_no_extra_traits! { - #[allow(missing_debug_implementations)] - #[repr(align(16))] - pub struct max_align_t { - priv_: [i64; 4] - } -} 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 8d065e6a3b534..2c3fd0ec17e80 100644 --- a/src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs @@ -402,29 +402,24 @@ pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4; pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40; pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4; -align_const! { - pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = - pthread_mutex_t { - size: [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - ], - }; - pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = - pthread_mutex_t { - size: [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - ], - }; - pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = - pthread_mutex_t { - size: [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - ], - }; -} +pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; +pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; +pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; pub const O_DIRECTORY: ::c_int = 0o200000; pub const O_NOFOLLOW: ::c_int = 0o400000; @@ -912,9 +907,10 @@ extern "C" { ) -> ::c_int; } -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; +s_no_extra_traits! { + #[allow(missing_debug_implementations)] + #[repr(align(16))] + pub struct max_align_t { + priv_: [i64; 4] } } diff --git a/src/unix/linux_like/linux/gnu/b64/x86_64/align.rs b/src/unix/linux_like/linux/gnu/b64/x86_64/align.rs deleted file mode 100644 index ba3075edd7e36..0000000000000 --- a/src/unix/linux_like/linux/gnu/b64/x86_64/align.rs +++ /dev/null @@ -1,24 +0,0 @@ -s_no_extra_traits! { - #[allow(missing_debug_implementations)] - #[repr(align(16))] - pub struct max_align_t { - priv_: [f64; 4] - } -} - -s! { - #[repr(align(8))] - pub struct clone_args { - pub flags: ::c_ulonglong, - pub pidfd: ::c_ulonglong, - pub child_tid: ::c_ulonglong, - pub parent_tid: ::c_ulonglong, - pub exit_signal: ::c_ulonglong, - pub stack: ::c_ulonglong, - pub stack_size: ::c_ulonglong, - pub tls: ::c_ulonglong, - pub set_tid: ::c_ulonglong, - pub set_tid_size: ::c_ulonglong, - pub cgroup: ::c_ulonglong, - } -} 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 7e876f2d86c87..5b73c635fcf1f 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 @@ -265,6 +265,21 @@ s! { pub seccomp_notif_resp: ::__u16, pub seccomp_data: ::__u16, } + + #[repr(align(8))] + pub struct clone_args { + pub flags: ::c_ulonglong, + pub pidfd: ::c_ulonglong, + pub child_tid: ::c_ulonglong, + pub parent_tid: ::c_ulonglong, + pub exit_signal: ::c_ulonglong, + pub stack: ::c_ulonglong, + pub stack_size: ::c_ulonglong, + pub tls: ::c_ulonglong, + pub set_tid: ::c_ulonglong, + pub set_tid_size: ::c_ulonglong, + pub cgroup: ::c_ulonglong, + } } s_no_extra_traits! { @@ -295,6 +310,12 @@ s_no_extra_traits! { // // __ssp: [::c_ulonglong; 4], } + + #[allow(missing_debug_implementations)] + #[repr(align(16))] + pub struct max_align_t { + priv_: [f64; 4] + } } cfg_if! { @@ -815,10 +836,3 @@ cfg_if! { pub use self::not_x32::*; } } - -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; - } -} diff --git a/src/unix/linux_like/linux/gnu/b64/x86_64/not_x32.rs b/src/unix/linux_like/linux/gnu/b64/x86_64/not_x32.rs index f840f9f443ca0..6c0523edf719c 100644 --- a/src/unix/linux_like/linux/gnu/b64/x86_64/not_x32.rs +++ b/src/unix/linux_like/linux/gnu/b64/x86_64/not_x32.rs @@ -23,56 +23,48 @@ s! { pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40; pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56; -align_const! { - #[cfg(target_endian = "little")] - pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = - pthread_mutex_t { - size: [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - ], - }; - #[cfg(target_endian = "little")] - pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = - pthread_mutex_t { - size: [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - ], - }; - #[cfg(target_endian = "little")] - pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = - pthread_mutex_t { - size: [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - ], - }; - #[cfg(target_endian = "big")] - pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = - pthread_mutex_t { - size: [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - ], - }; - #[cfg(target_endian = "big")] - pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = - pthread_mutex_t { - size: [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - ], - }; - #[cfg(target_endian = "big")] - pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = - pthread_mutex_t { - size: [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - ], - }; -} +#[cfg(target_endian = "little")] +pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; +#[cfg(target_endian = "little")] +pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; +#[cfg(target_endian = "little")] +pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; +#[cfg(target_endian = "big")] +pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; +#[cfg(target_endian = "big")] +pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; +#[cfg(target_endian = "big")] +pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; // Syscall table diff --git a/src/unix/linux_like/linux/gnu/b64/x86_64/x32.rs b/src/unix/linux_like/linux/gnu/b64/x86_64/x32.rs index de1a8b94b9cc9..d793f7c33f687 100644 --- a/src/unix/linux_like/linux/gnu/b64/x86_64/x32.rs +++ b/src/unix/linux_like/linux/gnu/b64/x86_64/x32.rs @@ -23,29 +23,24 @@ s! { pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 32; pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 44; -align_const! { - pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = - pthread_mutex_t { - size: [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - ], - }; - pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = - pthread_mutex_t { - size: [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - ], - }; - pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = - pthread_mutex_t { - size: [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - ], - }; -} +pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, + ], +}; +pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, + ], +}; +pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, + ], +}; // Syscall table diff --git a/src/unix/linux_like/linux/gnu/mod.rs b/src/unix/linux_like/linux/gnu/mod.rs index 64ca4156de512..6c9d16382aecd 100644 --- a/src/unix/linux_like/linux/gnu/mod.rs +++ b/src/unix/linux_like/linux/gnu/mod.rs @@ -347,9 +347,20 @@ s! { pub arch: ::__u32, pub instruction_pointer: ::__u64, pub stack_pointer: ::__u64, - #[cfg(libc_union)] pub u: __c_anonymous_ptrace_syscall_info_data, } + + // FIXME this is actually a union + #[cfg_attr(target_pointer_width = "32", + repr(align(4)))] + #[cfg_attr(target_pointer_width = "64", + repr(align(8)))] + pub struct sem_t { + #[cfg(target_pointer_width = "32")] + __size: [::c_char; 16], + #[cfg(target_pointer_width = "64")] + __size: [::c_char; 32], + } } impl siginfo_t { @@ -378,77 +389,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 } } @@ -552,7 +559,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 { @@ -563,10 +569,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 { @@ -579,7 +583,6 @@ cfg_if! { } } - #[cfg(libc_union)] impl ::hash::Hash for __c_anonymous_ptrace_syscall_info_data { fn hash(&self, state: &mut H) { unsafe { @@ -1350,13 +1353,3 @@ cfg_if! { // Unknown target_arch } } - -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; - } else { - mod no_align; - pub use self::no_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 68a69110263a2..4148ff822f9c3 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -596,6 +596,159 @@ s! { pub nla_len: u16, pub nla_type: u16, } + + #[cfg_attr(any(target_pointer_width = "32", + target_arch = "x86_64", + target_arch = "powerpc64", + target_arch = "mips64", + target_arch = "s390x", + target_arch = "sparc64", + target_arch = "aarch64", + target_arch = "riscv64", + target_arch = "riscv32", + target_arch = "loongarch64"), + repr(align(4)))] + #[cfg_attr(not(any(target_pointer_width = "32", + target_arch = "x86_64", + target_arch = "powerpc64", + target_arch = "mips64", + target_arch = "s390x", + target_arch = "sparc64", + target_arch = "aarch64", + target_arch = "riscv64", + target_arch = "riscv32", + target_arch = "loongarch64")), + repr(align(8)))] + pub struct pthread_mutexattr_t { + #[doc(hidden)] + size: [u8; ::__SIZEOF_PTHREAD_MUTEXATTR_T], + } + + #[cfg_attr(any(target_env = "musl", target_pointer_width = "32"), + repr(align(4)))] + #[cfg_attr(all(not(target_env = "musl"), + target_pointer_width = "64"), + repr(align(8)))] + pub struct pthread_rwlockattr_t { + #[doc(hidden)] + size: [u8; ::__SIZEOF_PTHREAD_RWLOCKATTR_T], + } + + #[repr(align(4))] + pub struct pthread_condattr_t { + #[doc(hidden)] + size: [u8; ::__SIZEOF_PTHREAD_CONDATTR_T], + } + + #[repr(align(8))] + pub struct fanotify_event_metadata { + 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, + } + + // linux/openat2.h + #[non_exhaustive] + pub struct open_how { + pub flags: ::__u64, + pub mode: ::__u64, + pub resolve: ::__u64, + } +} + +s_no_extra_traits! { + #[cfg_attr(all(target_env = "musl", + target_pointer_width = "32"), + repr(align(4)))] + #[cfg_attr(all(target_env = "musl", + target_pointer_width = "64"), + repr(align(8)))] + #[cfg_attr(all(not(target_env = "musl"), + target_arch = "x86"), + repr(align(4)))] + #[cfg_attr(all(not(target_env = "musl"), + not(target_arch = "x86")), + repr(align(8)))] + pub struct pthread_cond_t { + #[doc(hidden)] + size: [u8; ::__SIZEOF_PTHREAD_COND_T], + } + + #[cfg_attr(all(target_pointer_width = "32", + any(target_arch = "mips", + target_arch = "arm", + target_arch = "hexagon", + target_arch = "m68k", + target_arch = "powerpc", + target_arch = "sparc", + target_arch = "x86_64", + target_arch = "x86")), + repr(align(4)))] + #[cfg_attr(any(target_pointer_width = "64", + not(any(target_arch = "mips", + target_arch = "arm", + target_arch = "hexagon", + target_arch = "m68k", + target_arch = "powerpc", + target_arch = "sparc", + target_arch = "x86_64", + target_arch = "x86"))), + repr(align(8)))] + pub struct pthread_mutex_t { + #[doc(hidden)] + size: [u8; ::__SIZEOF_PTHREAD_MUTEX_T], + } + + #[cfg_attr(all(target_pointer_width = "32", + any(target_arch = "mips", + target_arch = "arm", + target_arch = "hexagon", + target_arch = "m68k", + target_arch = "powerpc", + target_arch = "sparc", + target_arch = "x86_64", + target_arch = "x86")), + repr(align(4)))] + #[cfg_attr(any(target_pointer_width = "64", + not(any(target_arch = "mips", + target_arch = "arm", + target_arch = "hexagon", + target_arch = "m68k", + target_arch = "powerpc", + target_arch = "sparc", + target_arch = "x86_64", + target_arch = "x86"))), + repr(align(8)))] + pub struct pthread_rwlock_t { + size: [u8; ::__SIZEOF_PTHREAD_RWLOCK_T], + } + + // linux/can.h + #[repr(align(8))] + #[allow(missing_debug_implementations)] + pub struct can_frame { + pub can_id: canid_t, + pub can_dlc: u8, + __pad: u8, + __res0: u8, + __res1: u8, + pub data: [u8; CAN_MAX_DLEN], + } + + #[repr(align(8))] + #[allow(missing_debug_implementations)] + pub struct canfd_frame { + pub can_id: canid_t, + pub len: u8, + pub flags: u8, + __res0: u8, + __res1: u8, + pub data: [u8; CANFD_MAX_DLEN], + } } s_no_extra_traits! { @@ -694,23 +847,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, } } @@ -1498,17 +1647,15 @@ pub const MPOL_F_NUMA_BALANCING: ::c_int = 1 << 13; pub const MPOL_F_RELATIVE_NODES: ::c_int = 1 << 14; pub const MPOL_F_STATIC_NODES: ::c_int = 1 << 15; -align_const! { - pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { - size: [0; __SIZEOF_PTHREAD_MUTEX_T], - }; - pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { - size: [0; __SIZEOF_PTHREAD_COND_T], - }; - pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { - size: [0; __SIZEOF_PTHREAD_RWLOCK_T], - }; -} +pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { + size: [0; __SIZEOF_PTHREAD_MUTEX_T], +}; +pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { + size: [0; __SIZEOF_PTHREAD_COND_T], +}; +pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { + size: [0; __SIZEOF_PTHREAD_RWLOCK_T], +}; pub const PTHREAD_MUTEX_NORMAL: ::c_int = 0; pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 1; pub const PTHREAD_MUTEX_ERRORCHECK: ::c_int = 2; @@ -3182,12 +3329,8 @@ pub const CANFD_MAX_DLEN: usize = 64; pub const CANFD_BRS: ::c_int = 0x01; pub const CANFD_ESI: ::c_int = 0x02; -cfg_if! { - if #[cfg(libc_align)] { - pub const CAN_MTU: usize = ::mem::size_of::(); - pub const CANFD_MTU: usize = ::mem::size_of::(); - } -} +pub const CAN_MTU: usize = ::mem::size_of::(); +pub const CANFD_MTU: usize = ::mem::size_of::(); pub const CAN_RAW: ::c_int = 1; pub const CAN_BCM: ::c_int = 2; @@ -4123,21 +4266,3 @@ cfg_if! { mod arch; pub use self::arch::*; - -cfg_if! { - if #[cfg(libc_align)] { - #[macro_use] - mod align; - } else { - #[macro_use] - mod no_align; - } -} -expand_align!(); - -cfg_if! { - if #[cfg(libc_non_exhaustive)] { - mod non_exhaustive; - pub use self::non_exhaustive::*; - } -} diff --git a/src/unix/linux_like/linux/musl/b32/arm/align.rs b/src/unix/linux_like/linux/musl/b32/arm/align.rs deleted file mode 100644 index aedbf7a99eb1b..0000000000000 --- a/src/unix/linux_like/linux/musl/b32/arm/align.rs +++ /dev/null @@ -1,7 +0,0 @@ -s_no_extra_traits! { - #[allow(missing_debug_implementations)] - #[repr(align(8))] - pub struct max_align_t { - priv_: (i64, i64) - } -} 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 7e4868b854631..44ab5b59a020c 100644 --- a/src/unix/linux_like/linux/musl/b32/arm/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/arm/mod.rs @@ -842,9 +842,10 @@ 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::*; +s_no_extra_traits! { + #[allow(missing_debug_implementations)] + #[repr(align(8))] + pub struct max_align_t { + priv_: (i64, i64) } } diff --git a/src/unix/linux_like/linux/musl/b32/mips/align.rs b/src/unix/linux_like/linux/musl/b32/mips/align.rs deleted file mode 100644 index 8c228ebab72ce..0000000000000 --- a/src/unix/linux_like/linux/musl/b32/mips/align.rs +++ /dev/null @@ -1,7 +0,0 @@ -s_no_extra_traits! { - #[allow(missing_debug_implementations)] - #[repr(align(8))] - pub struct max_align_t { - priv_: [f32; 4] - } -} 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 7443a09edcd37..922dc8b0069a4 100644 --- a/src/unix/linux_like/linux/musl/b32/mips/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/mips/mod.rs @@ -778,9 +778,10 @@ pub const SYS_process_madvise: ::c_long = 4000 + 440; pub const SYS_epoll_pwait2: ::c_long = 4000 + 441; pub const SYS_mount_setattr: ::c_long = 4000 + 442; -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; +s_no_extra_traits! { + #[allow(missing_debug_implementations)] + #[repr(align(8))] + pub struct max_align_t { + priv_: [f32; 4] } } diff --git a/src/unix/linux_like/linux/musl/b32/riscv32/align.rs b/src/unix/linux_like/linux/musl/b32/riscv32/align.rs deleted file mode 100644 index 048268c96b7a7..0000000000000 --- a/src/unix/linux_like/linux/musl/b32/riscv32/align.rs +++ /dev/null @@ -1,7 +0,0 @@ -s_no_extra_traits! { - #[allow(missing_debug_implementations)] - #[repr(align(8))] - pub struct max_align_t { - priv_: (i64, f64) - } -} 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 9b68ce2585679..f55a76665ae59 100644 --- a/src/unix/linux_like/linux/musl/b32/riscv32/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/riscv32/mod.rs @@ -799,9 +799,10 @@ 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::*; +s_no_extra_traits! { + #[allow(missing_debug_implementations)] + #[repr(align(8))] + pub struct max_align_t { + priv_: (i64, f64) } } diff --git a/src/unix/linux_like/linux/musl/b32/x86/align.rs b/src/unix/linux_like/linux/musl/b32/x86/align.rs deleted file mode 100644 index 79544176a88c9..0000000000000 --- a/src/unix/linux_like/linux/musl/b32/x86/align.rs +++ /dev/null @@ -1,7 +0,0 @@ -s_no_extra_traits! { - #[allow(missing_debug_implementations)] - #[repr(align(8))] - pub struct max_align_t { - priv_: [f64; 3] - } -} 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 a6efea13b9d1d..925faa65bc684 100644 --- a/src/unix/linux_like/linux/musl/b32/x86/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/x86/mod.rs @@ -880,9 +880,10 @@ 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::*; +s_no_extra_traits! { + #[allow(missing_debug_implementations)] + #[repr(align(8))] + pub struct max_align_t { + priv_: [f64; 3] } } diff --git a/src/unix/linux_like/linux/musl/b64/aarch64/align.rs b/src/unix/linux_like/linux/musl/b64/aarch64/align.rs deleted file mode 100644 index a4bf9bff4f147..0000000000000 --- a/src/unix/linux_like/linux/musl/b64/aarch64/align.rs +++ /dev/null @@ -1,42 +0,0 @@ -s_no_extra_traits! { - #[allow(missing_debug_implementations)] - #[repr(align(16))] - pub struct max_align_t { - priv_: [f32; 8] - } -} - -s! { - pub struct ucontext_t { - pub uc_flags: ::c_ulong, - pub uc_link: *mut ucontext_t, - pub uc_stack: ::stack_t, - pub uc_sigmask: ::sigset_t, - pub uc_mcontext: mcontext_t, - } - - #[repr(align(16))] - pub struct mcontext_t { - pub fault_address: ::c_ulong, - pub regs: [::c_ulong; 31], - pub sp: ::c_ulong, - pub pc: ::c_ulong, - pub pstate: ::c_ulong, - __reserved: [[u64; 32]; 16], - } - - #[repr(align(8))] - pub struct clone_args { - pub flags: ::c_ulonglong, - pub pidfd: ::c_ulonglong, - pub child_tid: ::c_ulonglong, - pub parent_tid: ::c_ulonglong, - pub exit_signal: ::c_ulonglong, - pub stack: ::c_ulonglong, - pub stack_size: ::c_ulonglong, - pub tls: ::c_ulonglong, - pub set_tid: ::c_ulonglong, - pub set_tid_size: ::c_ulonglong, - pub cgroup: ::c_ulonglong, - } -} diff --git a/src/unix/linux_like/linux/musl/b64/aarch64/int128.rs b/src/unix/linux_like/linux/musl/b64/aarch64/int128.rs deleted file mode 100644 index 4535e73eeddf1..0000000000000 --- a/src/unix/linux_like/linux/musl/b64/aarch64/int128.rs +++ /dev/null @@ -1,7 +0,0 @@ -s! { - pub struct user_fpsimd_struct { - pub vregs: [::__uint128_t; 32], - pub fpsr: u32, - pub fpcr: u32, - } -} 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 845707dcd9ab5..2cad1fb342a34 100644 --- a/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs @@ -67,6 +67,53 @@ s! { __unused1: ::c_ulong, __unused2: ::c_ulong, } + + pub struct ucontext_t { + pub uc_flags: ::c_ulong, + pub uc_link: *mut ucontext_t, + pub uc_stack: ::stack_t, + pub uc_sigmask: ::sigset_t, + pub uc_mcontext: mcontext_t, + } + + #[repr(align(16))] + pub struct mcontext_t { + pub fault_address: ::c_ulong, + pub regs: [::c_ulong; 31], + pub sp: ::c_ulong, + pub pc: ::c_ulong, + pub pstate: ::c_ulong, + __reserved: [u64; 512], + } + + #[repr(align(8))] + pub struct clone_args { + pub flags: ::c_ulonglong, + pub pidfd: ::c_ulonglong, + pub child_tid: ::c_ulonglong, + pub parent_tid: ::c_ulonglong, + pub exit_signal: ::c_ulonglong, + pub stack: ::c_ulonglong, + pub stack_size: ::c_ulonglong, + pub tls: ::c_ulonglong, + pub set_tid: ::c_ulonglong, + pub set_tid_size: ::c_ulonglong, + pub cgroup: ::c_ulonglong, + } + + pub struct user_fpsimd_struct { + pub vregs: [::__uint128_t; 32], + pub fpsr: u32, + pub fpcr: u32, + } +} + +s_no_extra_traits! { + #[allow(missing_debug_implementations)] + #[repr(align(16))] + pub struct max_align_t { + priv_: [f32; 8] + } } pub const O_APPEND: ::c_int = 1024; @@ -635,17 +682,3 @@ pub const VMIN: usize = 6; 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::*; - } -} - -cfg_if! { - if #[cfg(libc_int128)] { - mod int128; - pub use self::int128::*; - } -} diff --git a/src/unix/linux_like/linux/musl/b64/riscv64/align.rs b/src/unix/linux_like/linux/musl/b64/riscv64/align.rs deleted file mode 100644 index 48d152a5721ec..0000000000000 --- a/src/unix/linux_like/linux/musl/b64/riscv64/align.rs +++ /dev/null @@ -1,44 +0,0 @@ -s_no_extra_traits! { - #[allow(missing_debug_implementations)] - pub struct ucontext_t { - pub __uc_flags: ::c_ulong, - pub uc_link: *mut ucontext_t, - pub uc_stack: ::stack_t, - pub uc_sigmask: ::sigset_t, - pub uc_mcontext: mcontext_t, - } - - #[allow(missing_debug_implementations)] - #[repr(align(16))] - pub struct mcontext_t { - pub __gregs: [::c_ulong; 32], - pub __fpregs: __riscv_mc_fp_state, - } - - #[allow(missing_debug_implementations)] - pub union __riscv_mc_fp_state { - pub __f: __riscv_mc_f_ext_state, - pub __d: __riscv_mc_d_ext_state, - pub __q: __riscv_mc_q_ext_state, - } - - #[allow(missing_debug_implementations)] - pub struct __riscv_mc_f_ext_state { - pub __f: [::c_uint; 32], - pub __fcsr: ::c_uint, - } - - #[allow(missing_debug_implementations)] - pub struct __riscv_mc_d_ext_state { - pub __f: [::c_ulonglong; 32], - pub __fcsr: ::c_uint, - } - - #[allow(missing_debug_implementations)] - #[repr(align(16))] - pub struct __riscv_mc_q_ext_state { - pub __f: [::c_ulonglong; 64], - pub __fcsr: ::c_uint, - pub __glibc_reserved: [::c_uint; 3], - } -} 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 fcb28c3cf29f5..ad0afcaa469f3 100644 --- a/src/unix/linux_like/linux/musl/b64/riscv64/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/riscv64/mod.rs @@ -733,9 +733,47 @@ 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::*; +s_no_extra_traits! { + #[allow(missing_debug_implementations)] + pub struct ucontext_t { + pub __uc_flags: ::c_ulong, + pub uc_link: *mut ucontext_t, + pub uc_stack: ::stack_t, + pub uc_sigmask: ::sigset_t, + pub uc_mcontext: mcontext_t, + } + + #[allow(missing_debug_implementations)] + #[repr(align(16))] + pub struct mcontext_t { + pub __gregs: [::c_ulong; 32], + pub __fpregs: __riscv_mc_fp_state, + } + + #[allow(missing_debug_implementations)] + pub union __riscv_mc_fp_state { + pub __f: __riscv_mc_f_ext_state, + pub __d: __riscv_mc_d_ext_state, + pub __q: __riscv_mc_q_ext_state, + } + + #[allow(missing_debug_implementations)] + pub struct __riscv_mc_f_ext_state { + pub __f: [::c_uint; 32], + pub __fcsr: ::c_uint, + } + + #[allow(missing_debug_implementations)] + pub struct __riscv_mc_d_ext_state { + pub __f: [::c_ulonglong; 32], + pub __fcsr: ::c_uint, + } + + #[allow(missing_debug_implementations)] + #[repr(align(16))] + pub struct __riscv_mc_q_ext_state { + pub __f: [::c_ulonglong; 64], + pub __fcsr: ::c_uint, + pub __glibc_reserved: [::c_uint; 3], } } diff --git a/src/unix/linux_like/linux/musl/b64/x86_64/align.rs b/src/unix/linux_like/linux/musl/b64/x86_64/align.rs deleted file mode 100644 index 94391a01a727e..0000000000000 --- a/src/unix/linux_like/linux/musl/b64/x86_64/align.rs +++ /dev/null @@ -1,25 +0,0 @@ -s_no_extra_traits! { - #[allow(missing_debug_implementations)] - #[repr(align(16))] - pub struct max_align_t { - priv_: [f64; 4] - } - -} - -s! { - #[repr(align(8))] - pub struct clone_args { - pub flags: ::c_ulonglong, - pub pidfd: ::c_ulonglong, - pub child_tid: ::c_ulonglong, - pub parent_tid: ::c_ulonglong, - pub exit_signal: ::c_ulonglong, - pub stack: ::c_ulonglong, - pub stack_size: ::c_ulonglong, - pub tls: ::c_ulonglong, - pub set_tid: ::c_ulonglong, - pub set_tid_size: ::c_ulonglong, - pub cgroup: ::c_ulonglong, - } -} 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 3429c2c1a7822..3d481fabfcc36 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 @@ -119,6 +119,21 @@ s! { __unused1: ::c_long, __unused2: ::c_long } + + #[repr(align(8))] + pub struct clone_args { + pub flags: ::c_ulonglong, + pub pidfd: ::c_ulonglong, + pub child_tid: ::c_ulonglong, + pub parent_tid: ::c_ulonglong, + pub exit_signal: ::c_ulonglong, + pub stack: ::c_ulonglong, + pub stack_size: ::c_ulonglong, + pub tls: ::c_ulonglong, + pub set_tid: ::c_ulonglong, + pub set_tid_size: ::c_ulonglong, + pub cgroup: ::c_ulonglong, + } } s_no_extra_traits! { @@ -144,6 +159,12 @@ s_no_extra_traits! { pub uc_sigmask: ::sigset_t, __private: [u8; 512], } + + #[allow(missing_debug_implementations)] + #[repr(align(16))] + pub struct max_align_t { + priv_: [f64; 4] + } } cfg_if! { @@ -896,10 +917,3 @@ pub const VMIN: usize = 6; 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::*; - } -} diff --git a/src/unix/linux_like/linux/musl/mod.rs b/src/unix/linux_like/linux/musl/mod.rs index 6cdc313881dbb..2685071463e2a 100644 --- a/src/unix/linux_like/linux/musl/mod.rs +++ b/src/unix/linux_like/linux/musl/mod.rs @@ -60,65 +60,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 2b5abb3bed4b3..0000000000000 --- a/src/unix/linux_like/linux/no_align.rs +++ /dev/null @@ -1,105 +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 = "s390x", - target_arch = "sparc64", - target_arch = "riscv64", - target_arch = "riscv32", - target_arch = "loongarch64", - all(target_arch = "aarch64", - target_env = "musl")))] - __align: [::c_int; 0], - #[cfg(not(any(target_arch = "x86_64", - target_arch = "powerpc64", - target_arch = "mips64", - target_arch = "s390x", - target_arch = "sparc64", - target_arch = "riscv64", - target_arch = "riscv32", - target_arch = "loongarch64", - all(target_arch = "aarch64", - target_env = "musl"))))] - __align: [::c_long; 0], - size: [u8; ::__SIZEOF_PTHREAD_MUTEXATTR_T], - } - - pub struct pthread_rwlockattr_t { - #[cfg(target_env = "musl")] - __align: [::c_int; 0], - #[cfg(not(target_env = "musl"))] - __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 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(target_env = "musl")] - __align: [*const ::c_void; 0], - #[cfg(not(target_env = "musl"))] - __align: [::c_longlong; 0], - size: [u8; ::__SIZEOF_PTHREAD_COND_T], - } - - pub struct pthread_mutex_t { - #[cfg(any(target_arch = "mips", - target_arch = "arm", - target_arch = "m68k", - 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 = "arm", - target_arch = "m68k", - 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 = "arm", - target_arch = "m68k", - 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 = "arm", - target_arch = "m68k", - 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], - } - } - }; -} diff --git a/src/unix/linux_like/linux/non_exhaustive.rs b/src/unix/linux_like/linux/non_exhaustive.rs deleted file mode 100644 index e2e2cb847ac65..0000000000000 --- a/src/unix/linux_like/linux/non_exhaustive.rs +++ /dev/null @@ -1,9 +0,0 @@ -s! { - // linux/openat2.h - #[non_exhaustive] - pub struct open_how { - pub flags: ::__u64, - pub mode: ::__u64, - pub resolve: ::__u64, - } -} diff --git a/src/unix/linux_like/linux/uclibc/arm/align.rs b/src/unix/linux_like/linux/uclibc/arm/align.rs deleted file mode 100644 index 4a0e07460ebb1..0000000000000 --- a/src/unix/linux_like/linux/uclibc/arm/align.rs +++ /dev/null @@ -1,13 +0,0 @@ -s! { - // FIXME this is actually a union - #[cfg_attr(target_pointer_width = "32", - repr(align(4)))] - #[cfg_attr(target_pointer_width = "64", - repr(align(8)))] - pub struct sem_t { - #[cfg(target_pointer_width = "32")] - __size: [::c_char; 16], - #[cfg(target_pointer_width = "64")] - __size: [::c_char; 32], - } -} diff --git a/src/unix/linux_like/linux/uclibc/arm/mod.rs b/src/unix/linux_like/linux/uclibc/arm/mod.rs index e0279574b9921..2699bd35e2ed5 100644 --- a/src/unix/linux_like/linux/uclibc/arm/mod.rs +++ b/src/unix/linux_like/linux/uclibc/arm/mod.rs @@ -240,6 +240,18 @@ s! { __unused4: ::c_ulong, __unused5: ::c_ulong, } + + // FIXME this is actually a union + #[cfg_attr(target_pointer_width = "32", + repr(align(4)))] + #[cfg_attr(target_pointer_width = "64", + repr(align(8)))] + pub struct sem_t { + #[cfg(target_pointer_width = "32")] + __size: [::c_char; 16], + #[cfg(target_pointer_width = "64")] + __size: [::c_char; 32], + } } pub const O_CLOEXEC: ::c_int = 0o2000000; @@ -885,13 +897,3 @@ pub const SYS_pkey_free: ::c_long = 396; pub const SYS_statx: ::c_int = 397; pub const SYS_pidfd_open: ::c_long = 434; pub const SYS_clone3: ::c_long = 435; - -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; - } else { - mod no_align; - pub use self::no_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/align.rs b/src/unix/linux_like/linux/uclibc/mips/mips32/align.rs deleted file mode 100644 index 4a0e07460ebb1..0000000000000 --- a/src/unix/linux_like/linux/uclibc/mips/mips32/align.rs +++ /dev/null @@ -1,13 +0,0 @@ -s! { - // FIXME this is actually a union - #[cfg_attr(target_pointer_width = "32", - repr(align(4)))] - #[cfg_attr(target_pointer_width = "64", - repr(align(8)))] - pub struct sem_t { - #[cfg(target_pointer_width = "32")] - __size: [::c_char; 16], - #[cfg(target_pointer_width = "64")] - __size: [::c_char; 32], - } -} 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 e11dc6145e63f..1e38cb57d0b2c 100644 --- a/src/unix/linux_like/linux/uclibc/mips/mips32/mod.rs +++ b/src/unix/linux_like/linux/uclibc/mips/mips32/mod.rs @@ -253,6 +253,18 @@ s! { pub mem_unit: ::c_uint, pub _f: [::c_char; 8], } + + // FIXME this is actually a union + #[cfg_attr(target_pointer_width = "32", + repr(align(4)))] + #[cfg_attr(target_pointer_width = "64", + repr(align(8)))] + pub struct sem_t { + #[cfg(target_pointer_width = "32")] + __size: [::c_char; 16], + #[cfg(target_pointer_width = "64")] + __size: [::c_char; 32], + } } pub const __SIZEOF_PTHREAD_ATTR_T: usize = 36; @@ -652,13 +664,3 @@ extern "C" { cpuset: *const ::cpu_set_t, ) -> ::c_int; } - -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; - } else { - mod no_align; - pub use self::no_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/align.rs b/src/unix/linux_like/linux/uclibc/mips/mips64/align.rs deleted file mode 100644 index 21e21907d4a70..0000000000000 --- a/src/unix/linux_like/linux/uclibc/mips/mips64/align.rs +++ /dev/null @@ -1,10 +0,0 @@ -s! { - // FIXME this is actually a union - #[cfg_attr(target_pointer_width = "32", - repr(align(4)))] - #[cfg_attr(target_pointer_width = "64", - repr(align(8)))] - pub struct sem_t { - __size: [::c_char; 32], - } -} 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 be6d2813d52fa..5b4c7d7ae038f 100644 --- a/src/unix/linux_like/linux/uclibc/mips/mips64/mod.rs +++ b/src/unix/linux_like/linux/uclibc/mips/mips64/mod.rs @@ -185,6 +185,15 @@ s! { pub mem_unit: ::c_uint, pub _f: [::c_char; 0], } + + // FIXME this is actually a union + #[cfg_attr(target_pointer_width = "32", + repr(align(4)))] + #[cfg_attr(target_pointer_width = "64", + repr(align(8)))] + pub struct sem_t { + __size: [::c_char; 32], + } } pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4; @@ -193,13 +202,3 @@ pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40; pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56; 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::*; - } -} 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/linux_like/linux/uclibc/x86_64/mod.rs b/src/unix/linux_like/linux/uclibc/x86_64/mod.rs index 529711fcec127..3a018d203c05d 100644 --- a/src/unix/linux_like/linux/uclibc/x86_64/mod.rs +++ b/src/unix/linux_like/linux/uclibc/x86_64/mod.rs @@ -116,8 +116,6 @@ s! { // // pub struct in6_addr { // pub s6_addr: [u8; 16], -// #[cfg(not(libc_align))] -// __align: [u32; 0], // } pub struct stat { diff --git a/src/unix/mod.rs b/src/unix/mod.rs index 1d57f28b2112d..51726e792dc9f 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -3,6 +3,8 @@ //! More functions and definitions can be found in the more specific modules //! according to the platform in question. +use c_void; + pub type c_schar = i8; pub type c_uchar = u8; pub type c_short = i16; @@ -201,6 +203,11 @@ s! { pub p_aliases: *mut *mut ::c_char, pub p_proto: ::c_int, } + + #[repr(align(4))] + pub struct in6_addr { + pub s6_addr: [u8; 16], + } } pub const INT_MIN: c_int = -2147483648; @@ -573,20 +580,12 @@ extern "C" { pub fn getchar_unlocked() -> ::c_int; pub fn putchar_unlocked(c: ::c_int) -> ::c_int; - #[cfg(not(all( - libc_cfg_target_vendor, - target_arch = "powerpc", - target_vendor = "nintendo" - )))] + #[cfg(not(all(target_arch = "powerpc", target_vendor = "nintendo")))] #[cfg_attr(target_os = "netbsd", link_name = "__socket30")] #[cfg_attr(target_os = "illumos", link_name = "__xnet_socket")] #[cfg_attr(target_os = "espidf", link_name = "lwip_socket")] pub fn socket(domain: ::c_int, ty: ::c_int, protocol: ::c_int) -> ::c_int; - #[cfg(not(all( - libc_cfg_target_vendor, - target_arch = "powerpc", - target_vendor = "nintendo" - )))] + #[cfg(not(all(target_arch = "powerpc", target_vendor = "nintendo")))] #[cfg_attr( all(target_os = "macos", target_arch = "x86"), link_name = "connect$UNIX2003" @@ -600,22 +599,14 @@ extern "C" { )] #[cfg_attr(target_os = "espidf", link_name = "lwip_listen")] pub fn listen(socket: ::c_int, backlog: ::c_int) -> ::c_int; - #[cfg(not(all( - libc_cfg_target_vendor, - target_arch = "powerpc", - target_vendor = "nintendo" - )))] + #[cfg(not(all(target_arch = "powerpc", target_vendor = "nintendo")))] #[cfg_attr( all(target_os = "macos", target_arch = "x86"), link_name = "accept$UNIX2003" )] #[cfg_attr(target_os = "espidf", link_name = "lwip_accept")] pub fn accept(socket: ::c_int, address: *mut sockaddr, address_len: *mut socklen_t) -> ::c_int; - #[cfg(not(all( - libc_cfg_target_vendor, - target_arch = "powerpc", - target_vendor = "nintendo" - )))] + #[cfg(not(all(target_arch = "powerpc", target_vendor = "nintendo")))] #[cfg_attr( all(target_os = "macos", target_arch = "x86"), link_name = "getpeername$UNIX2003" @@ -626,11 +617,7 @@ extern "C" { address: *mut sockaddr, address_len: *mut socklen_t, ) -> ::c_int; - #[cfg(not(all( - libc_cfg_target_vendor, - target_arch = "powerpc", - target_vendor = "nintendo" - )))] + #[cfg(not(all(target_arch = "powerpc", target_vendor = "nintendo")))] #[cfg_attr( all(target_os = "macos", target_arch = "x86"), link_name = "getsockname$UNIX2003" @@ -660,11 +647,7 @@ extern "C" { protocol: ::c_int, socket_vector: *mut ::c_int, ) -> ::c_int; - #[cfg(not(all( - libc_cfg_target_vendor, - target_arch = "powerpc", - target_vendor = "nintendo" - )))] + #[cfg(not(all(target_arch = "powerpc", target_vendor = "nintendo")))] #[cfg_attr( all(target_os = "macos", target_arch = "x86"), link_name = "sendto$UNIX2003" @@ -1157,11 +1140,7 @@ extern "C" { pub fn dlclose(handle: *mut ::c_void) -> ::c_int; pub fn dladdr(addr: *const ::c_void, info: *mut Dl_info) -> ::c_int; - #[cfg(not(all( - libc_cfg_target_vendor, - target_arch = "powerpc", - target_vendor = "nintendo" - )))] + #[cfg(not(all(target_arch = "powerpc", target_vendor = "nintendo")))] #[cfg_attr(target_os = "illumos", link_name = "__xnet_getaddrinfo")] #[cfg_attr(target_os = "espidf", link_name = "lwip_getaddrinfo")] pub fn getaddrinfo( @@ -1170,11 +1149,7 @@ extern "C" { hints: *const addrinfo, res: *mut *mut addrinfo, ) -> ::c_int; - #[cfg(not(all( - libc_cfg_target_vendor, - target_arch = "powerpc", - target_vendor = "nintendo" - )))] + #[cfg(not(all(target_arch = "powerpc", target_vendor = "nintendo")))] #[cfg_attr(target_os = "espidf", link_name = "lwip_freeaddrinfo")] pub fn freeaddrinfo(res: *mut addrinfo); pub fn hstrerror(errcode: ::c_int) -> *const ::c_char; @@ -1499,33 +1474,3 @@ cfg_if! { // Unknown target_os } } - -cfg_if! { - if #[cfg(libc_core_cvoid)] { - pub use ::ffi::c_void; - } else { - // Use repr(u8) as LLVM expects `void*` to be the same as `i8*` to help - // enable more optimization opportunities around it recognizing things - // like malloc/free. - #[repr(u8)] - #[allow(missing_copy_implementations)] - #[allow(missing_debug_implementations)] - pub enum c_void { - // Two dummy variants so the #[repr] attribute can be used. - #[doc(hidden)] - __variant1, - #[doc(hidden)] - __variant2, - } - } -} - -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; - } else { - mod no_align; - pub use self::no_align::*; - } -} diff --git a/src/unix/newlib/align.rs b/src/unix/newlib/align.rs deleted file mode 100644 index db9beb83523c2..0000000000000 --- a/src/unix/newlib/align.rs +++ /dev/null @@ -1,61 +0,0 @@ -macro_rules! expand_align { - () => { - s! { - #[cfg_attr(all(target_pointer_width = "32", - any(target_arch = "mips", - target_arch = "arm", - target_arch = "powerpc")), - repr(align(4)))] - #[cfg_attr(any(target_pointer_width = "64", - not(any(target_arch = "mips", - target_arch = "arm", - target_arch = "powerpc"))), - repr(align(8)))] - pub struct pthread_mutex_t { // Unverified - size: [u8; ::__SIZEOF_PTHREAD_MUTEX_T], - } - - #[cfg_attr(all(target_pointer_width = "32", - any(target_arch = "mips", - target_arch = "arm", - target_arch = "powerpc")), - repr(align(4)))] - #[cfg_attr(any(target_pointer_width = "64", - not(any(target_arch = "mips", - target_arch = "arm", - target_arch = "powerpc"))), - repr(align(8)))] - pub struct pthread_rwlock_t { // Unverified - size: [u8; ::__SIZEOF_PTHREAD_RWLOCK_T], - } - - #[cfg_attr(any(target_pointer_width = "32", - target_arch = "x86_64", - target_arch = "powerpc64", - target_arch = "mips64", - target_arch = "s390x", - target_arch = "sparc64"), - repr(align(4)))] - #[cfg_attr(not(any(target_pointer_width = "32", - target_arch = "x86_64", - target_arch = "powerpc64", - target_arch = "mips64", - target_arch = "s390x", - target_arch = "sparc64")), - repr(align(8)))] - pub struct pthread_mutexattr_t { // Unverified - size: [u8; ::__SIZEOF_PTHREAD_MUTEXATTR_T], - } - - #[repr(align(8))] - pub struct pthread_cond_t { // Unverified - size: [u8; ::__SIZEOF_PTHREAD_COND_T], - } - - #[repr(align(4))] - pub struct pthread_condattr_t { // Unverified - size: [u8; ::__SIZEOF_PTHREAD_CONDATTR_T], - } - } - }; -} diff --git a/src/unix/newlib/mod.rs b/src/unix/newlib/mod.rs index 34a63a81a03f7..7e4ea054147d3 100644 --- a/src/unix/newlib/mod.rs +++ b/src/unix/newlib/mod.rs @@ -65,7 +65,7 @@ s! { #[cfg(not(any( target_os = "espidf", - all(libc_cfg_target_vendor, target_arch = "powerpc", target_vendor = "nintendo"))))] + all(target_arch = "powerpc", target_vendor = "nintendo"))))] pub ai_addr: *mut sockaddr, pub ai_next: *mut addrinfo, @@ -226,20 +226,74 @@ s! { __lockkind: ::c_int, __pshared: ::c_int, } + + #[cfg_attr(all(target_pointer_width = "32", + any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc")), + repr(align(4)))] + #[cfg_attr(any(target_pointer_width = "64", + not(any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc"))), + repr(align(8)))] + pub struct pthread_mutex_t { // Unverified + size: [u8; ::__SIZEOF_PTHREAD_MUTEX_T], + } + + #[cfg_attr(all(target_pointer_width = "32", + any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc")), + repr(align(4)))] + #[cfg_attr(any(target_pointer_width = "64", + not(any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc"))), + repr(align(8)))] + pub struct pthread_rwlock_t { // Unverified + size: [u8; ::__SIZEOF_PTHREAD_RWLOCK_T], + } + + #[cfg_attr(any(target_pointer_width = "32", + target_arch = "x86_64", + target_arch = "powerpc64", + target_arch = "mips64", + target_arch = "s390x", + target_arch = "sparc64"), + repr(align(4)))] + #[cfg_attr(not(any(target_pointer_width = "32", + target_arch = "x86_64", + target_arch = "powerpc64", + target_arch = "mips64", + target_arch = "s390x", + target_arch = "sparc64")), + repr(align(8)))] + pub struct pthread_mutexattr_t { // Unverified + size: [u8; ::__SIZEOF_PTHREAD_MUTEXATTR_T], + } + + #[repr(align(8))] + pub struct pthread_cond_t { // Unverified + size: [u8; ::__SIZEOF_PTHREAD_COND_T], + } + + #[repr(align(4))] + pub struct pthread_condattr_t { // Unverified + size: [u8; ::__SIZEOF_PTHREAD_CONDATTR_T], + } } // unverified constants -align_const! { - pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { - size: [__PTHREAD_INITIALIZER_BYTE; __SIZEOF_PTHREAD_MUTEX_T], - }; - pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { - size: [__PTHREAD_INITIALIZER_BYTE; __SIZEOF_PTHREAD_COND_T], - }; - pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { - size: [__PTHREAD_INITIALIZER_BYTE; __SIZEOF_PTHREAD_RWLOCK_T], - }; -} +pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { + size: [__PTHREAD_INITIALIZER_BYTE; __SIZEOF_PTHREAD_MUTEX_T], +}; +pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { + size: [__PTHREAD_INITIALIZER_BYTE; __SIZEOF_PTHREAD_COND_T], +}; +pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { + size: [__PTHREAD_INITIALIZER_BYTE; __SIZEOF_PTHREAD_RWLOCK_T], +}; pub const NCCS: usize = 32; cfg_if! { if #[cfg(target_os = "espidf")] { @@ -626,11 +680,7 @@ extern "C" { pub fn rand() -> ::c_int; pub fn srand(seed: ::c_uint); - #[cfg(not(all( - libc_cfg_target_vendor, - target_arch = "powerpc", - target_vendor = "nintendo" - )))] + #[cfg(not(all(target_arch = "powerpc", target_vendor = "nintendo")))] #[cfg_attr(target_os = "espidf", link_name = "lwip_bind")] pub fn bind(fd: ::c_int, addr: *const sockaddr, len: socklen_t) -> ::c_int; pub fn clock_settime(clock_id: ::clockid_t, tp: *const ::timespec) -> ::c_int; @@ -639,11 +689,7 @@ extern "C" { #[cfg_attr(target_os = "espidf", link_name = "lwip_close")] pub fn closesocket(sockfd: ::c_int) -> ::c_int; pub fn ioctl(fd: ::c_int, request: ::c_ulong, ...) -> ::c_int; - #[cfg(not(all( - libc_cfg_target_vendor, - target_arch = "powerpc", - target_vendor = "nintendo" - )))] + #[cfg(not(all(target_arch = "powerpc", target_vendor = "nintendo")))] #[cfg_attr(target_os = "espidf", link_name = "lwip_recvfrom")] pub fn recvfrom( fd: ::c_int, @@ -653,11 +699,7 @@ extern "C" { addr: *mut sockaddr, addr_len: *mut socklen_t, ) -> isize; - #[cfg(not(all( - libc_cfg_target_vendor, - target_arch = "powerpc", - target_vendor = "nintendo" - )))] + #[cfg(not(all(target_arch = "powerpc", target_vendor = "nintendo")))] pub fn getnameinfo( sa: *const sockaddr, salen: socklen_t, @@ -746,14 +788,3 @@ cfg_if! { pub use target_arch_not_implemented; } } - -cfg_if! { - if #[cfg(libc_align)] { - #[macro_use] - mod align; - } else { - #[macro_use] - mod no_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 f6b9f4c12d4ba..0000000000000 --- a/src/unix/no_align.rs +++ /dev/null @@ -1,6 +0,0 @@ -s! { - pub struct in6_addr { - pub s6_addr: [u8; 16], - __align: [u32; 0], - } -} diff --git a/src/unix/solarish/mod.rs b/src/unix/solarish/mod.rs index fef08d08f4b6d..ec9fd8ab351ba 100644 --- a/src/unix/solarish/mod.rs +++ b/src/unix/solarish/mod.rs @@ -469,14 +469,7 @@ s! { } s_no_extra_traits! { - #[cfg_attr(all( - any(target_arch = "x86", target_arch = "x86_64"), - libc_packedN - ), repr(packed(4)))] - #[cfg_attr(all( - any(target_arch = "x86", target_arch = "x86_64"), - not(libc_packedN) - ), repr(packed))] + #[cfg_attr(any(target_arch = "x86", target_arch = "x86_64"), repr(packed(4)))] pub struct epoll_event { pub events: u32, pub u64: u64, @@ -523,7 +516,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, @@ -553,15 +546,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], @@ -929,7 +920,6 @@ cfg_if! { } } - #[cfg(libc_union)] impl PartialEq for pad128_t { fn eq(&self, other: &pad128_t) -> bool { unsafe { @@ -938,9 +928,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 { @@ -951,7 +939,6 @@ cfg_if! { } } } - #[cfg(libc_union)] impl ::hash::Hash for pad128_t { fn hash(&self, state: &mut H) { unsafe { @@ -960,7 +947,6 @@ cfg_if! { } } } - #[cfg(libc_union)] impl PartialEq for upad128_t { fn eq(&self, other: &upad128_t) -> bool { unsafe { @@ -969,9 +955,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 { @@ -982,7 +966,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 5f75bdb79624a..b331cf9258d0a 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 2772d68d2f4b1..a5f9a911ef481 100644 --- a/src/vxworks/mod.rs +++ b/src/vxworks/mod.rs @@ -1,5 +1,6 @@ //! Interface to VxWorks C library +use c_void; use core::mem::size_of; use core::ptr::null_mut; @@ -1880,26 +1881,6 @@ 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, - } - } -} - cfg_if! { if #[cfg(target_arch = "aarch64")] { mod aarch64; diff --git a/src/wasi.rs b/src/wasi.rs index ef88fac75dcac..780913d2a7f36 100644 --- a/src/wasi.rs +++ b/src/wasi.rs @@ -1,6 +1,5 @@ use super::{Send, Sync}; - -pub use ffi::c_void; +use c_void; pub type c_char = i8; pub type c_uchar = u8; diff --git a/src/windows/gnu/align.rs b/src/windows/gnu/align.rs deleted file mode 100644 index 3af99e3ca149b..0000000000000 --- a/src/windows/gnu/align.rs +++ /dev/null @@ -1,19 +0,0 @@ -cfg_if! { - if #[cfg(target_pointer_width = "64")] { - s_no_extra_traits! { - #[allow(missing_debug_implementations)] - #[repr(align(16))] - pub struct max_align_t { - priv_: [f64; 4] - } - } - } else if #[cfg(target_pointer_width = "32")] { - s_no_extra_traits! { - #[allow(missing_debug_implementations)] - #[repr(align(16))] - pub struct max_align_t { - priv_: [i64; 6] - } - } - } -} diff --git a/src/windows/gnu/mod.rs b/src/windows/gnu/mod.rs index 3e7d38b8e83c6..a16d17a3ca06a 100644 --- a/src/windows/gnu/mod.rs +++ b/src/windows/gnu/mod.rs @@ -16,8 +16,21 @@ extern "C" { } cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; + if #[cfg(target_pointer_width = "64")] { + s_no_extra_traits! { + #[allow(missing_debug_implementations)] + #[repr(align(16))] + pub struct max_align_t { + priv_: [f64; 4] + } + } + } else if #[cfg(target_pointer_width = "32")] { + s_no_extra_traits! { + #[allow(missing_debug_implementations)] + #[repr(align(16))] + pub struct max_align_t { + priv_: [i64; 6] + } + } } } diff --git a/src/windows/mod.rs b/src/windows/mod.rs index 08cba4edd094b..0720c8bd1effb 100644 --- a/src/windows/mod.rs +++ b/src/windows/mod.rs @@ -1,5 +1,7 @@ //! Windows CRT definitions +use c_void; + pub type c_schar = i8; pub type c_uchar = u8; pub type c_short = i16; @@ -543,26 +545,6 @@ 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, - } - } -} - cfg_if! { if #[cfg(all(target_env = "gnu"))] { mod gnu;