From 5e313e8cceb388098e1bd40ceeab908ce6be48cc Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Mon, 11 Jul 2022 20:21:45 -0700 Subject: [PATCH] Require rust >= 1.25 and drop libc_align conditional This is mostly taken from Josh's work at [1], I just updated to account for conflicts and new uses of `libc_align`. [1]: https://github.com/rust-lang/libc/pull/2845 Co-authored-by: Josh Triplett --- Cargo.toml | 5 +- build.rs | 7 - libc-test/build.rs | 7 +- src/fuchsia/align.rs | 142 --------- src/fuchsia/mod.rs | 162 +++++++++-- src/fuchsia/no_align.rs | 129 --------- src/macros.rs | 18 -- src/unix/align.rs | 14 - src/unix/bsd/apple/b32/align.rs | 7 - src/unix/bsd/apple/b32/mod.rs | 13 +- src/unix/bsd/apple/b64/aarch64/align.rs | 55 ---- src/unix/bsd/apple/b64/aarch64/mod.rs | 54 +++- src/unix/bsd/apple/b64/align.rs | 7 - src/unix/bsd/apple/b64/mod.rs | 6 + src/unix/bsd/apple/b64/x86_64/align.rs | 7 - src/unix/bsd/apple/b64/x86_64/mod.rs | 9 +- src/unix/bsd/apple/mod.rs | 2 +- src/unix/bsd/freebsdlike/freebsd/mod.rs | 4 +- src/unix/bsd/freebsdlike/freebsd/powerpc.rs | 30 +- src/unix/bsd/freebsdlike/freebsd/powerpc64.rs | 30 +- src/unix/bsd/freebsdlike/freebsd/x86.rs | 72 +++-- .../bsd/freebsdlike/freebsd/x86_64/align.rs | 186 ------------ .../bsd/freebsdlike/freebsd/x86_64/mod.rs | 187 +++++++++++- src/unix/hurd/no_align.rs | 1 - src/unix/linux_like/android/b32/x86/align.rs | 7 - src/unix/linux_like/android/b32/x86/mod.rs | 13 +- .../linux_like/android/b64/aarch64/align.rs | 31 -- .../linux_like/android/b64/aarch64/mod.rs | 35 ++- .../linux_like/android/b64/riscv64/align.rs | 7 - .../linux_like/android/b64/riscv64/mod.rs | 15 +- .../linux_like/android/b64/x86_64/align.rs | 7 - src/unix/linux_like/android/b64/x86_64/mod.rs | 7 - src/unix/linux_like/emscripten/align.rs | 74 ----- src/unix/linux_like/emscripten/mod.rs | 93 ++++-- src/unix/linux_like/emscripten/no_align.rs | 63 ---- src/unix/linux_like/linux/align.rs | 223 -------------- src/unix/linux_like/linux/gnu/align.rs | 13 - .../linux_like/linux/gnu/b32/arm/align.rs | 53 ---- src/unix/linux_like/linux/gnu/b32/arm/mod.rs | 61 +++- .../linux_like/linux/gnu/b32/csky/align.rs | 7 - src/unix/linux_like/linux/gnu/b32/csky/mod.rs | 15 +- .../linux_like/linux/gnu/b32/m68k/align.rs | 7 - src/unix/linux_like/linux/gnu/b32/m68k/mod.rs | 8 + .../linux_like/linux/gnu/b32/mips/align.rs | 7 - src/unix/linux_like/linux/gnu/b32/mips/mod.rs | 15 +- src/unix/linux_like/linux/gnu/b32/mod.rs | 86 +++--- .../linux_like/linux/gnu/b32/riscv32/align.rs | 44 --- .../linux_like/linux/gnu/b32/riscv32/mod.rs | 52 +++- .../linux_like/linux/gnu/b32/sparc/align.rs | 7 - .../linux_like/linux/gnu/b32/sparc/mod.rs | 15 +- .../linux_like/linux/gnu/b32/x86/align.rs | 7 - src/unix/linux_like/linux/gnu/b32/x86/mod.rs | 13 +- .../linux_like/linux/gnu/b64/aarch64/align.rs | 51 ---- .../linux_like/linux/gnu/b64/aarch64/ilp32.rs | 92 +++--- .../linux_like/linux/gnu/b64/aarch64/lp64.rs | 98 +++---- .../linux_like/linux/gnu/b64/aarch64/mod.rs | 58 +++- .../linux/gnu/b64/loongarch64/align.rs | 40 --- .../linux/gnu/b64/loongarch64/mod.rs | 138 +++++---- .../linux_like/linux/gnu/b64/mips64/align.rs | 7 - .../linux_like/linux/gnu/b64/mips64/mod.rs | 107 ++++--- .../linux/gnu/b64/powerpc64/align.rs | 7 - .../linux_like/linux/gnu/b64/powerpc64/mod.rs | 107 ++++--- .../linux_like/linux/gnu/b64/riscv64/align.rs | 61 ---- .../linux_like/linux/gnu/b64/riscv64/mod.rs | 110 ++++++- src/unix/linux_like/linux/gnu/b64/s390x.rs | 41 ++- .../linux_like/linux/gnu/b64/sparc64/align.rs | 7 - .../linux_like/linux/gnu/b64/sparc64/mod.rs | 56 ++-- .../linux_like/linux/gnu/b64/x86_64/align.rs | 24 -- .../linux_like/linux/gnu/b64/x86_64/mod.rs | 28 +- .../linux/gnu/b64/x86_64/not_x32.rs | 92 +++--- .../linux_like/linux/gnu/b64/x86_64/x32.rs | 41 ++- src/unix/linux_like/linux/gnu/mod.rs | 10 - src/unix/linux_like/linux/gnu/no_align.rs | 10 - src/unix/linux_like/linux/mod.rs | 272 +++++++++++++++--- .../linux_like/linux/musl/b32/arm/align.rs | 7 - src/unix/linux_like/linux/musl/b32/arm/mod.rs | 13 +- .../linux_like/linux/musl/b32/mips/align.rs | 7 - .../linux_like/linux/musl/b32/mips/mod.rs | 15 +- .../linux/musl/b32/riscv32/align.rs | 7 - .../linux_like/linux/musl/b32/riscv32/mod.rs | 15 +- .../linux_like/linux/musl/b32/x86/align.rs | 7 - src/unix/linux_like/linux/musl/b32/x86/mod.rs | 13 +- .../linux/musl/b64/aarch64/align.rs | 42 --- .../linux_like/linux/musl/b64/aarch64/mod.rs | 48 +++- .../linux/musl/b64/loongarch64/align.rs | 40 --- .../linux/musl/b64/loongarch64/mod.rs | 46 ++- .../linux/musl/b64/riscv64/align.rs | 61 ---- .../linux_like/linux/musl/b64/riscv64/mod.rs | 67 ++++- .../linux_like/linux/musl/b64/x86_64/align.rs | 25 -- .../linux_like/linux/musl/b64/x86_64/mod.rs | 28 +- src/unix/linux_like/linux/no_align.rs | 162 ----------- src/unix/linux_like/linux/uclibc/align.rs | 28 -- src/unix/linux_like/linux/uclibc/arm/align.rs | 13 - src/unix/linux_like/linux/uclibc/arm/mod.rs | 10 - .../linux_like/linux/uclibc/arm/no_align.rs | 10 - .../linux/uclibc/mips/mips32/align.rs | 13 - .../linux/uclibc/mips/mips32/mod.rs | 22 +- .../linux/uclibc/mips/mips32/no_align.rs | 10 - .../linux/uclibc/mips/mips64/align.rs | 10 - .../linux/uclibc/mips/mips64/mod.rs | 19 +- .../linux/uclibc/mips/mips64/no_align.rs | 7 - src/unix/linux_like/linux/uclibc/mod.rs | 23 ++ src/unix/linux_like/linux/uclibc/no_align.rs | 53 ---- .../linux_like/linux/uclibc/x86_64/mod.rs | 2 - src/unix/mod.rs | 24 +- src/unix/newlib/align.rs | 61 ---- src/unix/newlib/mod.rs | 31 +- src/unix/newlib/no_align.rs | 51 ---- src/unix/no_align.rs | 16 -- src/unix/solarish/mod.rs | 6 +- src/windows/gnu/align.rs | 19 -- src/windows/gnu/mod.rs | 27 +- 112 files changed, 1795 insertions(+), 2859 deletions(-) delete mode 100644 src/fuchsia/align.rs delete mode 100644 src/fuchsia/no_align.rs delete mode 100644 src/unix/align.rs delete mode 100644 src/unix/bsd/apple/b32/align.rs delete mode 100644 src/unix/bsd/apple/b64/aarch64/align.rs delete mode 100644 src/unix/bsd/apple/b64/align.rs delete mode 100644 src/unix/bsd/apple/b64/x86_64/align.rs delete mode 100644 src/unix/bsd/freebsdlike/freebsd/x86_64/align.rs delete mode 100644 src/unix/hurd/no_align.rs delete mode 100644 src/unix/linux_like/android/b32/x86/align.rs delete mode 100644 src/unix/linux_like/android/b64/aarch64/align.rs delete mode 100644 src/unix/linux_like/android/b64/riscv64/align.rs delete mode 100644 src/unix/linux_like/android/b64/x86_64/align.rs delete mode 100644 src/unix/linux_like/emscripten/align.rs delete mode 100644 src/unix/linux_like/emscripten/no_align.rs delete mode 100644 src/unix/linux_like/linux/align.rs delete mode 100644 src/unix/linux_like/linux/gnu/align.rs delete mode 100644 src/unix/linux_like/linux/gnu/b32/arm/align.rs delete mode 100644 src/unix/linux_like/linux/gnu/b32/csky/align.rs delete mode 100644 src/unix/linux_like/linux/gnu/b32/m68k/align.rs delete mode 100644 src/unix/linux_like/linux/gnu/b32/mips/align.rs delete mode 100644 src/unix/linux_like/linux/gnu/b32/riscv32/align.rs delete mode 100644 src/unix/linux_like/linux/gnu/b32/sparc/align.rs delete mode 100644 src/unix/linux_like/linux/gnu/b32/x86/align.rs delete mode 100644 src/unix/linux_like/linux/gnu/b64/aarch64/align.rs delete mode 100644 src/unix/linux_like/linux/gnu/b64/loongarch64/align.rs delete mode 100644 src/unix/linux_like/linux/gnu/b64/mips64/align.rs delete mode 100644 src/unix/linux_like/linux/gnu/b64/powerpc64/align.rs delete mode 100644 src/unix/linux_like/linux/gnu/b64/riscv64/align.rs delete mode 100644 src/unix/linux_like/linux/gnu/b64/sparc64/align.rs delete mode 100644 src/unix/linux_like/linux/gnu/b64/x86_64/align.rs delete mode 100644 src/unix/linux_like/linux/gnu/no_align.rs delete mode 100644 src/unix/linux_like/linux/musl/b32/arm/align.rs delete mode 100644 src/unix/linux_like/linux/musl/b32/mips/align.rs delete mode 100644 src/unix/linux_like/linux/musl/b32/riscv32/align.rs delete mode 100644 src/unix/linux_like/linux/musl/b32/x86/align.rs delete mode 100644 src/unix/linux_like/linux/musl/b64/aarch64/align.rs delete mode 100644 src/unix/linux_like/linux/musl/b64/loongarch64/align.rs delete mode 100644 src/unix/linux_like/linux/musl/b64/riscv64/align.rs delete mode 100644 src/unix/linux_like/linux/musl/b64/x86_64/align.rs delete mode 100644 src/unix/linux_like/linux/no_align.rs delete mode 100644 src/unix/linux_like/linux/uclibc/align.rs delete mode 100644 src/unix/linux_like/linux/uclibc/arm/align.rs delete mode 100644 src/unix/linux_like/linux/uclibc/arm/no_align.rs delete mode 100644 src/unix/linux_like/linux/uclibc/mips/mips32/align.rs delete mode 100644 src/unix/linux_like/linux/uclibc/mips/mips32/no_align.rs delete mode 100644 src/unix/linux_like/linux/uclibc/mips/mips64/align.rs delete mode 100644 src/unix/linux_like/linux/uclibc/mips/mips64/no_align.rs delete mode 100644 src/unix/linux_like/linux/uclibc/no_align.rs delete mode 100644 src/unix/newlib/align.rs delete mode 100644 src/unix/newlib/no_align.rs delete mode 100644 src/unix/no_align.rs delete mode 100644 src/windows/gnu/align.rs diff --git a/Cargo.toml b/Cargo.toml index ccacab37e07d4..04aef685ed06d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -138,10 +138,13 @@ rustc-std-workspace-core = { version = "1.0.0", optional = true } [features] default = ["std"] std = [] -align = [] rustc-dep-of-std = ['align', 'rustc-std-workspace-core'] extra_traits = [] const-extern-fn = [] + +# `align` is deprecated and no longer does anything +align = [] + # use_std is deprecated, use `std` instead use_std = ['std'] diff --git a/build.rs b/build.rs index 241c489d9a183..4edad7f740077 100644 --- a/build.rs +++ b/build.rs @@ -14,7 +14,6 @@ const ALLOWED_CFGS: &'static [&'static str] = &[ "freebsd13", "freebsd14", "freebsd15", - "libc_align", "libc_cfg_target_vendor", "libc_const_extern_fn", "libc_const_extern_fn_unstable", @@ -51,7 +50,6 @@ fn main() { let (rustc_minor_ver, is_nightly) = rustc_minor_nightly(); let rustc_dep_of_std = env::var("CARGO_FEATURE_RUSTC_DEP_OF_STD").is_ok(); - let align_cargo_feature = env::var("CARGO_FEATURE_ALIGN").is_ok(); let const_extern_fn_cargo_feature = env::var("CARGO_FEATURE_CONST_EXTERN_FN").is_ok(); let libc_ci = env::var("LIBC_CI").is_ok(); let libc_check_cfg = env::var("LIBC_CHECK_CFG").is_ok() || rustc_minor_ver >= 80; @@ -96,11 +94,6 @@ fn main() { set_cfg("libc_deny_warnings"); } - // Rust >= 1.25 supports repr(align): - if rustc_minor_ver >= 25 || rustc_dep_of_std || align_cargo_feature { - set_cfg("libc_align"); - } - // Rust >= 1.26 supports i128 and u128: if rustc_minor_ver >= 26 || rustc_dep_of_std { set_cfg("libc_int128"); diff --git a/libc-test/build.rs b/libc-test/build.rs index d4a2d9cfaa3cd..01907dff90652 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -67,12 +67,7 @@ fn do_ctest() { fn ctest_cfg() -> ctest::TestGenerator { let mut cfg = ctest::TestGenerator::new(); - let libc_cfgs = [ - "libc_align", - "libc_core_cvoid", - "libc_packedN", - "libc_thread_local", - ]; + let libc_cfgs = ["libc_core_cvoid", "libc_packedN", "libc_thread_local"]; for f in &libc_cfgs { cfg.cfg(f, None); } 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 f3bba75e69b5f..f2f4de514a0e1 100644 --- a/src/fuchsia/mod.rs +++ b/src/fuchsia/mod.rs @@ -882,6 +882,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 +1008,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 +1371,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 +2446,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; @@ -4362,17 +4491,6 @@ cfg_if! { } } -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; 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/macros.rs b/src/macros.rs index 4124b8d7b4c7c..6d728d078d85f 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -278,24 +278,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/unix/align.rs b/src/unix/align.rs deleted file mode 100644 index 2e7c954ccff7a..0000000000000 --- a/src/unix/align.rs +++ /dev/null @@ -1,14 +0,0 @@ -s! { - #[repr(align(4))] - pub struct in6_addr { - pub s6_addr: [u8; 16], - } -} - -pub const IN6ADDR_LOOPBACK_INIT: in6_addr = in6_addr { - s6_addr: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], -}; - -pub const IN6ADDR_ANY_INIT: in6_addr = in6_addr { - s6_addr: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], -}; 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 4e45459c18101..a340b0f1350ab 100644 --- a/src/unix/bsd/apple/b32/mod.rs +++ b/src/unix/bsd/apple/b32/mod.rs @@ -59,6 +59,12 @@ s_no_extra_traits! { __sig: c_long, __opaque: [::c_char; ::__PTHREAD_ONCE_SIZE__], } + + #[allow(missing_debug_implementations)] + #[repr(align(16))] + pub struct max_align_t { + priv_: [f64; 2] + } } cfg_if! { @@ -145,10 +151,3 @@ extern "C" { options: ::c_ulong, ) -> ::c_int; } - -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; - } -} diff --git a/src/unix/bsd/apple/b64/aarch64/align.rs b/src/unix/bsd/apple/b64/aarch64/align.rs deleted file mode 100644 index 131e15b69ad94..0000000000000 --- a/src/unix/bsd/apple/b64/aarch64/align.rs +++ /dev/null @@ -1,55 +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, - } - - 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 79e9ac842f9ca..1d4a5590fbf36 100644 --- a/src/unix/bsd/apple/b64/aarch64/mod.rs +++ b/src/unix/bsd/apple/b64/aarch64/mod.rs @@ -1,14 +1,60 @@ 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 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, + } + + 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, + } } -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; +s_no_extra_traits! { + #[allow(missing_debug_implementations)] + pub struct max_align_t { + priv_: f64 } } diff --git a/src/unix/bsd/apple/b64/align.rs b/src/unix/bsd/apple/b64/align.rs deleted file mode 100644 index ca1fe1ce29944..0000000000000 --- a/src/unix/bsd/apple/b64/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/mod.rs b/src/unix/bsd/apple/b64/mod.rs index 2206210da5575..94c9f03d9acae 100644 --- a/src/unix/bsd/apple/b64/mod.rs +++ b/src/unix/bsd/apple/b64/mod.rs @@ -50,6 +50,12 @@ s! { } s_no_extra_traits! { + #[allow(missing_debug_implementations)] + #[repr(align(16))] + pub struct max_align_t { + priv_: [f64; 2] + } + pub struct pthread_attr_t { __sig: c_long, __opaque: [::c_char; 56] 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 efde59bc8d32e..efac489dcfc30 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -1143,7 +1143,7 @@ s! { pub nativeattr: attribute_set_t, } - #[cfg_attr(libc_align, repr(align(8)))] + #[repr(align(8))] pub struct tcp_connection_info { pub tcpi_state: u8, pub tcpi_snd_wscale: u8, diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs index 3f8dfea55665e..41bcc6f4be549 100644 --- a/src/unix/bsd/freebsdlike/freebsd/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs @@ -1632,7 +1632,6 @@ s_no_extra_traits! { pub struct ucontext_t { pub uc_sigmask: ::sigset_t, - #[cfg(libc_align)] pub uc_mcontext: ::mcontext_t, pub uc_link: *mut ::ucontext_t, pub uc_stack: ::stack_t, @@ -2597,8 +2596,7 @@ cfg_if! { fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { f.debug_struct("ucontext_t") .field("uc_sigmask", &self.uc_sigmask) - // FIXME: enable when libc_align is dropped - // .field("uc_mcontext", &self.uc_mcontext) + .field("uc_mcontext", &self.uc_mcontext) .field("uc_link", &self.uc_link) .field("uc_stack", &self.uc_stack) .field("uc_flags", &self.uc_flags) diff --git a/src/unix/bsd/freebsdlike/freebsd/powerpc.rs b/src/unix/bsd/freebsdlike/freebsd/powerpc.rs index 0f4f0dffee4cd..e37272680d43c 100644 --- a/src/unix/bsd/freebsdlike/freebsd/powerpc.rs +++ b/src/unix/bsd/freebsdlike/freebsd/powerpc.rs @@ -7,27 +7,23 @@ pub type time_t = i64; pub type suseconds_t = i32; pub type register_t = i32; -cfg_if! { - if #[cfg(libc_align)] { - s_no_extra_traits! { - #[repr(align(16))] - pub struct mcontext_t { - pub mc_vers: ::c_int, - pub mc_flags: ::c_int, - pub mc_onstack: ::c_int, - pub mc_len: ::c_int, - pub mc_avec: [u64; 64], - pub mc_av: [u32; 2], - pub mc_frame: [::register_t; 42], - pub mc_fpreg: [u64; 33], - pub mc_vsxfpreg: [u64; 32], - } - } +s_no_extra_traits! { + #[repr(align(16))] + pub struct mcontext_t { + pub mc_vers: ::c_int, + pub mc_flags: ::c_int, + pub mc_onstack: ::c_int, + pub mc_len: ::c_int, + pub mc_avec: [u64; 64], + pub mc_av: [u32; 2], + pub mc_frame: [::register_t; 42], + pub mc_fpreg: [u64; 33], + pub mc_vsxfpreg: [u64; 32], } } cfg_if! { - if #[cfg(all(libc_align, feature = "extra_traits"))] { + if #[cfg(feature = "extra_traits")] { impl PartialEq for mcontext_t { fn eq(&self, other: &mcontext_t) -> bool { self.mc_vers == other.mc_vers && diff --git a/src/unix/bsd/freebsdlike/freebsd/powerpc64.rs b/src/unix/bsd/freebsdlike/freebsd/powerpc64.rs index c1577f5194e57..372639f1d1cce 100644 --- a/src/unix/bsd/freebsdlike/freebsd/powerpc64.rs +++ b/src/unix/bsd/freebsdlike/freebsd/powerpc64.rs @@ -7,27 +7,23 @@ pub type time_t = i64; pub type suseconds_t = i64; pub type register_t = i64; -cfg_if! { - if #[cfg(libc_align)] { - s_no_extra_traits! { - #[repr(align(16))] - pub struct mcontext_t { - pub mc_vers: ::c_int, - pub mc_flags: ::c_int, - pub mc_onstack: ::c_int, - pub mc_len: ::c_int, - pub mc_avec: [u64; 64], - pub mc_av: [u32; 2], - pub mc_frame: [::register_t; 42], - pub mc_fpreg: [u64; 33], - pub mc_vsxfpreg: [u64; 32], - } - } +s_no_extra_traits! { + #[repr(align(16))] + pub struct mcontext_t { + pub mc_vers: ::c_int, + pub mc_flags: ::c_int, + pub mc_onstack: ::c_int, + pub mc_len: ::c_int, + pub mc_avec: [u64; 64], + pub mc_av: [u32; 2], + pub mc_frame: [::register_t; 42], + pub mc_fpreg: [u64; 33], + pub mc_vsxfpreg: [u64; 32], } } cfg_if! { - if #[cfg(all(libc_align, feature = "extra_traits"))] { + if #[cfg(feature = "extra_traits")] { impl PartialEq for mcontext_t { fn eq(&self, other: &mcontext_t) -> bool { self.mc_vers == other.mc_vers && diff --git a/src/unix/bsd/freebsdlike/freebsd/x86.rs b/src/unix/bsd/freebsdlike/freebsd/x86.rs index 9d5122846362d..fb995c635658d 100644 --- a/src/unix/bsd/freebsdlike/freebsd/x86.rs +++ b/src/unix/bsd/freebsdlike/freebsd/x86.rs @@ -7,48 +7,44 @@ pub type time_t = i32; pub type suseconds_t = i32; pub type register_t = i32; -cfg_if! { - if #[cfg(libc_align)] { - s_no_extra_traits! { - #[repr(align(16))] - pub struct mcontext_t { - pub mc_onstack: register_t, - pub mc_gs: register_t, - pub mc_fs: register_t, - pub mc_es: register_t, - pub mc_ds: register_t, - pub mc_edi: register_t, - pub mc_esi: register_t, - pub mc_ebp: register_t, - pub mc_isp: register_t, - pub mc_ebx: register_t, - pub mc_edx: register_t, - pub mc_ecx: register_t, - pub mc_eax: register_t, - pub mc_trapno: register_t, - pub mc_err: register_t, - pub mc_eip: register_t, - pub mc_cs: register_t, - pub mc_eflags: register_t, - pub mc_esp: register_t, - pub mc_ss: register_t, - pub mc_len: ::c_int, - pub mc_fpformat: ::c_int, - pub mc_ownedfp: ::c_int, - pub mc_flags: register_t, - pub mc_fpstate: [::c_int; 128], - pub mc_fsbase: register_t, - pub mc_gsbase: register_t, - pub mc_xfpustate: register_t, - pub mc_xfpustate_len: register_t, - pub mc_spare2: [::c_int; 4], - } - } +s_no_extra_traits! { + #[repr(align(16))] + pub struct mcontext_t { + pub mc_onstack: register_t, + pub mc_gs: register_t, + pub mc_fs: register_t, + pub mc_es: register_t, + pub mc_ds: register_t, + pub mc_edi: register_t, + pub mc_esi: register_t, + pub mc_ebp: register_t, + pub mc_isp: register_t, + pub mc_ebx: register_t, + pub mc_edx: register_t, + pub mc_ecx: register_t, + pub mc_eax: register_t, + pub mc_trapno: register_t, + pub mc_err: register_t, + pub mc_eip: register_t, + pub mc_cs: register_t, + pub mc_eflags: register_t, + pub mc_esp: register_t, + pub mc_ss: register_t, + pub mc_len: ::c_int, + pub mc_fpformat: ::c_int, + pub mc_ownedfp: ::c_int, + pub mc_flags: register_t, + pub mc_fpstate: [::c_int; 128], + pub mc_fsbase: register_t, + pub mc_gsbase: register_t, + pub mc_xfpustate: register_t, + pub mc_xfpustate_len: register_t, + pub mc_spare2: [::c_int; 4], } } cfg_if! { - if #[cfg(all(libc_align, feature = "extra_traits"))] { + if #[cfg(feature = "extra_traits")] { impl PartialEq for mcontext_t { fn eq(&self, other: &mcontext_t) -> bool { self.mc_onstack == other.mc_onstack && 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 208e7f2c90c0a..0000000000000 --- a/src/unix/bsd/freebsdlike/freebsd/x86_64/align.rs +++ /dev/null @@ -1,186 +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); - } - } - } -} diff --git a/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs b/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs index 327e0ad78fadb..1e61db61c7cd3 100644 --- a/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs @@ -92,6 +92,54 @@ s_no_extra_traits! { pub a_type: ::c_long, pub a_un: __c_anonymous_elf64_auxv_union, } + + #[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! { @@ -216,6 +264,138 @@ cfg_if! { .finish() } } + + + 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); + } + } } } @@ -241,10 +421,3 @@ pub const _MC_FPOWNED_PCB: c_long = 0x20002; pub const KINFO_FILE_SIZE: ::c_int = 1392; pub const TIOCTIMESTAMP: ::c_ulong = 0x40107459; - -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; - } -} diff --git a/src/unix/hurd/no_align.rs b/src/unix/hurd/no_align.rs deleted file mode 100644 index 1dd7d8e541d29..0000000000000 --- a/src/unix/hurd/no_align.rs +++ /dev/null @@ -1 +0,0 @@ -// Placeholder file diff --git a/src/unix/linux_like/android/b32/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 4b2adda3d5018..a6b9f4c6288a1 100644 --- a/src/unix/linux_like/android/b32/x86/mod.rs +++ b/src/unix/linux_like/android/b32/x86/mod.rs @@ -49,6 +49,12 @@ s_no_extra_traits! { __padding_rt_sigset: u32, __fpregs_mem: _libc_fpstate, } + + #[allow(missing_debug_implementations)] + #[repr(align(8))] + pub struct max_align_t { + priv_: [f64; 2] + } } cfg_if! { @@ -614,10 +620,3 @@ f! { ::syscall(SYS_socketcall, SYS_ACCEPT4, args[..].as_mut_ptr()) } } - -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; - } -} 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 9832303d7ac46..0000000000000 --- a/src/unix/linux_like/android/b64/aarch64/align.rs +++ /dev/null @@ -1,31 +0,0 @@ -s_no_extra_traits! { - #[allow(missing_debug_implementations)] - #[repr(align(16))] - pub struct max_align_t { - priv_: [f32; 8] - } - - #[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 __pad: [u8; 1024 / 8 - ::core::mem::size_of::<::sigset_t>()], - pub uc_mcontext: mcontext_t, - } -} - -s! { - #[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/mod.rs b/src/unix/linux_like/android/b64/aarch64/mod.rs index bd3146deb7f9f..d063c022bfb7e 100644 --- a/src/unix/linux_like/android/b64/aarch64/mod.rs +++ b/src/unix/linux_like/android/b64/aarch64/mod.rs @@ -55,6 +55,34 @@ 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, + // nested arrays to get the right size/length while being able to + // auto-derive traits like Debug + __reserved: [[u64; 32]; 16], + } +} + +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; @@ -421,13 +449,6 @@ pub const PROT_MTE: ::c_int = 0x20; pub const AT_SYSINFO_EHDR: ::c_ulong = 33; pub const AT_VECTOR_SIZE_ARCH: ::c_ulong = 2; -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; - } -} - cfg_if! { if #[cfg(libc_int128)] { mod int128; diff --git a/src/unix/linux_like/android/b64/riscv64/align.rs b/src/unix/linux_like/android/b64/riscv64/align.rs deleted file mode 100644 index 8e949963a637f..0000000000000 --- a/src/unix/linux_like/android/b64/riscv64/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_: [f32; 8] - } -} diff --git a/src/unix/linux_like/android/b64/riscv64/mod.rs b/src/unix/linux_like/android/b64/riscv64/mod.rs index 209f050f25ce5..6e8dfca0a6c50 100644 --- a/src/unix/linux_like/android/b64/riscv64/mod.rs +++ b/src/unix/linux_like/android/b64/riscv64/mod.rs @@ -51,6 +51,14 @@ s! { } } +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 = 0x40000; pub const O_DIRECTORY: ::c_int = 0x200000; pub const O_NOFOLLOW: ::c_int = 0x400000; @@ -356,10 +364,3 @@ pub const AT_L2_CACHEGEOMETRY: ::c_ulong = 45; pub const AT_L3_CACHESIZE: ::c_ulong = 46; pub const AT_L3_CACHEGEOMETRY: ::c_ulong = 47; pub const AT_VECTOR_SIZE_ARCH: ::c_ulong = 9; - -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; - } -} 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 4fcfb2c4d005b..32ef23e99de36 100644 --- a/src/unix/linux_like/android/b64/x86_64/mod.rs +++ b/src/unix/linux_like/android/b64/x86_64/mod.rs @@ -793,10 +793,3 @@ pub const REG_CR2: ::c_int = 22; // From NDK's asm/auxvec.h pub const AT_SYSINFO_EHDR: ::c_ulong = 33; pub const AT_VECTOR_SIZE_ARCH: ::c_ulong = 3; - -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; - } -} diff --git a/src/unix/linux_like/emscripten/align.rs b/src/unix/linux_like/emscripten/align.rs deleted file mode 100644 index 015690eedae45..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(8))] - pub struct max_align_t { - priv_: [f64; 3] - } - - } - - 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 5fe0ed0933012..6049dff3787d5 100644 --- a/src/unix/linux_like/emscripten/mod.rs +++ b/src/unix/linux_like/emscripten/mod.rs @@ -313,6 +313,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! { @@ -348,6 +374,20 @@ 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(8))] + pub struct max_align_t { + priv_: [f64; 3] + } } cfg_if! { @@ -476,6 +516,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); + } + } } } @@ -768,17 +830,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; @@ -1592,14 +1652,3 @@ extern "C" { // Alias to 64 to mimic glibc's LFS64 support mod lfs64; pub use self::lfs64::*; - -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 bd16e449bb22c..0000000000000 --- a/src/unix/linux_like/linux/align.rs +++ /dev/null @@ -1,223 +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 = "mips64r6", - 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 = "mips64r6", - 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_env = "ohos", target_pointer_width = "32"), - repr(align(4)))] - #[cfg_attr(all(not(target_env = "musl"), - not(target_env = "ohos"), - 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(4))] - pub struct pthread_barrierattr_t { - #[doc(hidden)] - size: [u8; ::__SIZEOF_PTHREAD_BARRIERATTR_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, - } - - #[repr(align(8))] - pub struct tpacket_rollover_stats { - pub tp_all: ::__u64, - pub tp_huge: ::__u64, - pub tp_failed: ::__u64, - } - - #[repr(align(8))] - pub struct tpacket_hdr_v1 { - pub block_status: ::__u32, - pub num_pkts: ::__u32, - pub offset_to_first_pkt: ::__u32, - pub blk_len: ::__u32, - pub seq_num: ::__u64, - pub ts_first_pkt: ::tpacket_bd_ts, - pub ts_last_pkt: ::tpacket_bd_ts, - } - } - - s_no_extra_traits! { - #[cfg_attr(all(any(target_env = "musl", target_env = "ohos"), - target_pointer_width = "32"), - repr(align(4)))] - #[cfg_attr(all(any(target_env = "musl", target_env = "ohos"), - target_pointer_width = "64"), - repr(align(8)))] - #[cfg_attr(all(not(any(target_env = "musl", target_env = "ohos")), - target_arch = "x86"), - repr(align(4)))] - #[cfg_attr(all(not(any(target_env = "musl", target_env = "ohos")), - 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 = "mips32r6", - target_arch = "arm", - target_arch = "hexagon", - target_arch = "m68k", - target_arch = "csky", - 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 = "mips32r6", - target_arch = "arm", - target_arch = "hexagon", - target_arch = "m68k", - target_arch = "csky", - 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 = "mips32r6", - target_arch = "arm", - target_arch = "hexagon", - target_arch = "m68k", - target_arch = "csky", - 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 = "mips32r6", - 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], - } - - #[cfg_attr(all(target_pointer_width = "32", - any(target_arch = "mips", - target_arch = "mips32r6", - target_arch = "arm", - target_arch = "hexagon", - target_arch = "m68k", - target_arch = "csky", - 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 = "mips32r6", - target_arch = "arm", - target_arch = "hexagon", - target_arch = "m68k", - target_arch = "csky", - target_arch = "powerpc", - target_arch = "sparc", - target_arch = "x86_64", - target_arch = "x86"))), - repr(align(8)))] - pub struct pthread_barrier_t { - size: [u8; ::__SIZEOF_PTHREAD_BARRIER_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], - } - - #[repr(align(8))] - #[allow(missing_debug_implementations)] - pub struct canxl_frame { - pub prio: canid_t, - pub flags: u8, - pub sdt: u8, - pub len: u16, - pub af: u32, - pub data: [u8; CANXL_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 4a14d692c8652..0037015a1821b 100644 --- a/src/unix/linux_like/linux/gnu/b32/arm/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/arm/mod.rs @@ -208,6 +208,60 @@ s! { } } +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); + } + } + } +} + pub const VEOF: usize = 4; pub const RTLD_DEEPBIND: ::c_int = 0x8; pub const RTLD_GLOBAL: ::c_int = 0x100; @@ -856,10 +910,3 @@ pub const SYS_process_mrelease: ::c_long = 448; pub const SYS_futex_waitv: ::c_long = 449; pub const SYS_set_mempolicy_home_node: ::c_long = 450; pub const SYS_mseal: ::c_long = 462; - -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; - } -} diff --git a/src/unix/linux_like/linux/gnu/b32/csky/align.rs b/src/unix/linux_like/linux/gnu/b32/csky/align.rs deleted file mode 100644 index 825546be90a91..0000000000000 --- a/src/unix/linux_like/linux/gnu/b32/csky/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; 2] - } -} diff --git a/src/unix/linux_like/linux/gnu/b32/csky/mod.rs b/src/unix/linux_like/linux/gnu/b32/csky/mod.rs index 5e92e30073bee..feaef00803dc0 100644 --- a/src/unix/linux_like/linux/gnu/b32/csky/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/csky/mod.rs @@ -163,6 +163,14 @@ s! { } } +s_no_extra_traits! { + #[allow(missing_debug_implementations)] + #[repr(align(8))] + pub struct max_align_t { + priv_: [i64; 2] + } +} + pub const VEOF: usize = 4; pub const RTLD_DEEPBIND: ::c_int = 0x8; pub const RTLD_GLOBAL: ::c_int = 0x100; @@ -732,10 +740,3 @@ pub const SYS_memfd_secret: ::c_long = 447; pub const SYS_process_mrelease: ::c_long = 448; pub const SYS_futex_waitv: ::c_long = 449; pub const SYS_set_mempolicy_home_node: ::c_long = 450; - -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; - } -} diff --git a/src/unix/linux_like/linux/gnu/b32/m68k/align.rs b/src/unix/linux_like/linux/gnu/b32/m68k/align.rs deleted file mode 100644 index 639394a309e3a..0000000000000 --- a/src/unix/linux_like/linux/gnu/b32/m68k/align.rs +++ /dev/null @@ -1,7 +0,0 @@ -s_no_extra_traits! { - #[allow(missing_debug_implementations)] - #[repr(align(2))] - pub struct max_align_t { - priv_: [i8; 20] - } -} diff --git a/src/unix/linux_like/linux/gnu/b32/m68k/mod.rs b/src/unix/linux_like/linux/gnu/b32/m68k/mod.rs index 8ca7d3d214094..9b7c8d92e9a0e 100644 --- a/src/unix/linux_like/linux/gnu/b32/m68k/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/m68k/mod.rs @@ -156,6 +156,14 @@ s! { } } +s_no_extra_traits! { + #[allow(missing_debug_implementations)] + #[repr(align(2))] + pub struct max_align_t { + priv_: [i8; 20] + } +} + pub const VEOF: usize = 4; pub const RTLD_DEEPBIND: ::c_int = 0x8; pub const RTLD_GLOBAL: ::c_int = 0x100; 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 fa2707500dbe4..80b509bc574b5 100644 --- a/src/unix/linux_like/linux/gnu/b32/mips/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/mips/mod.rs @@ -155,6 +155,14 @@ s! { } } +s_no_extra_traits! { + #[allow(missing_debug_implementations)] + #[repr(align(8))] + pub struct max_align_t { + priv_: [f32; 4] + } +} + pub const O_LARGEFILE: ::c_int = 0x2000; pub const SYS_syscall: ::c_long = 4000 + 0; @@ -810,10 +818,3 @@ pub const B3500000: ::speed_t = 0o010016; pub const B4000000: ::speed_t = 0o010017; pub const EHWPOISON: ::c_int = 168; - -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; - } -} diff --git a/src/unix/linux_like/linux/gnu/b32/mod.rs b/src/unix/linux_like/linux/gnu/b32/mod.rs index d5b11347eb8b7..54c84fa617c86 100644 --- a/src/unix/linux_like/linux/gnu/b32/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/mod.rs @@ -263,56 +263,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 65b7aaa783559..ad50112543fcd 100644 --- a/src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs @@ -233,6 +233,51 @@ s! { } } +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], + } +} + pub const O_LARGEFILE: ::c_int = 0; pub const VEOF: usize = 4; pub const RTLD_DEEPBIND: ::c_int = 0x8; @@ -804,10 +849,3 @@ pub const SYS_memfd_secret: ::c_long = 447; pub const SYS_process_mrelease: ::c_long = 448; pub const SYS_futex_waitv: ::c_long = 449; pub const SYS_set_mempolicy_home_node: ::c_long = 450; - -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; - } -} 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 da9cf29c48668..702d1e03224ee 100644 --- a/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs @@ -193,6 +193,14 @@ s! { } } +s_no_extra_traits! { + #[allow(missing_debug_implementations)] + #[repr(align(8))] + pub struct max_align_t { + priv_: [i64; 3] + } +} + pub const VEOF: usize = 4; pub const RTLD_DEEPBIND: ::c_int = 0x8; pub const RTLD_GLOBAL: ::c_int = 0x100; @@ -848,10 +856,3 @@ pub const SYS_memfd_secret: ::c_long = 447; pub const SYS_process_mrelease: ::c_long = 448; pub const SYS_futex_waitv: ::c_long = 449; pub const SYS_set_mempolicy_home_node: ::c_long = 450; - -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; - } -} 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 4391eb3fa7968..539e13bac9b3a 100644 --- a/src/unix/linux_like/linux/gnu/b32/x86/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/x86/mod.rs @@ -264,6 +264,12 @@ s_no_extra_traits! { __private: [u8; 112], __ssp: [::c_ulong; 4], } + + #[allow(missing_debug_implementations)] + #[repr(align(16))] + pub struct max_align_t { + priv_: [f64; 6] + } } cfg_if! { @@ -1093,10 +1099,3 @@ extern "C" { pub fn makecontext(ucp: *mut ucontext_t, func: extern "C" fn(), argc: ::c_int, ...); 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::*; - } -} 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 a035773c716fe..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(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, - } -} - -extern "C" { - pub fn getcontext(ucp: *mut ucontext_t) -> ::c_int; - pub fn setcontext(ucp: *const ucontext_t) -> ::c_int; - pub fn makecontext(ucp: *mut ucontext_t, func: extern "C" fn(), argc: ::c_int, ...); - pub fn swapcontext(uocp: *mut ucontext_t, ucp: *const ucontext_t) -> ::c_int; -} 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 0848fb5880138..5a0785c13c7a8 100644 --- a/src/unix/linux_like/linux/gnu/b64/aarch64/ilp32.rs +++ b/src/unix/linux_like/linux/gnu/b64/aarch64/ilp32.rs @@ -10,55 +10,47 @@ pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 48; pub const __SIZEOF_PTHREAD_BARRIERATTR_T: usize = 4; pub const __SIZEOF_PTHREAD_BARRIER_T: usize = 20; -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/lp64.rs b/src/unix/linux_like/linux/gnu/b64/aarch64/lp64.rs index 3802caf644fbe..efe3cc57e8a2f 100644 --- a/src/unix/linux_like/linux/gnu/b64/aarch64/lp64.rs +++ b/src/unix/linux_like/linux/gnu/b64/aarch64/lp64.rs @@ -10,62 +10,48 @@ pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56; pub const __SIZEOF_PTHREAD_BARRIERATTR_T: usize = 8; pub const __SIZEOF_PTHREAD_BARRIER_T: usize = 32; -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 c8a805cdd36cb..783200a6d6e9c 100644 --- a/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs @@ -197,6 +197,48 @@ s! { pub ss_size: ::size_t } + 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(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,6 +948,11 @@ extern "C" { newp: *mut ::c_void, newlen: ::size_t, ) -> ::c_int; + + pub fn getcontext(ucp: *mut ucontext_t) -> ::c_int; + pub fn setcontext(ucp: *const ucontext_t) -> ::c_int; + pub fn makecontext(ucp: *mut ucontext_t, func: extern "C" fn(), argc: ::c_int, ...); + pub fn swapcontext(uocp: *mut ucontext_t, ucp: *const ucontext_t) -> ::c_int; } cfg_if! { @@ -918,20 +965,11 @@ cfg_if! { } } -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; - } - - -} - cfg_if! { if #[cfg(libc_int128)] { mod int128; pub use self::int128::*; - } else if #[cfg(libc_align)] { + } else { mod fallback; pub use self::fallback::*; } 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 dc191f51fdb1c..0000000000000 --- a/src/unix/linux_like/linux/gnu/b64/loongarch64/align.rs +++ /dev/null @@ -1,40 +0,0 @@ -s_no_extra_traits! { - #[allow(missing_debug_implementations)] - #[repr(align(16))] - pub struct max_align_t { - priv_: [f64; 4] - } -} - -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 __pc: ::c_ulonglong, - pub __gregs: [::c_ulonglong; 32], - pub __flags: ::c_uint, - pub __extcontext: [::c_ulonglong; 0], - } - - #[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/loongarch64/mod.rs b/src/unix/linux_like/linux/gnu/b64/loongarch64/mod.rs index ac3f88905f38e..29d40cc91bc39 100644 --- a/src/unix/linux_like/linux/gnu/b64/loongarch64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/loongarch64/mod.rs @@ -204,6 +204,45 @@ s! { pub fcc: u64, pub fcsr: u32, } + + 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 __pc: ::c_ulonglong, + pub __gregs: [::c_ulonglong; 32], + pub __flags: ::c_uint, + pub __extcontext: [::c_ulonglong; 0], + } + + #[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_: [f64; 4] + } } pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4; @@ -213,56 +252,48 @@ pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40; pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56; pub const __SIZEOF_PTHREAD_BARRIER_T: usize = 32; -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 HWCAP_LOONGARCH_CPUCFG: ::c_ulong = 1 << 0; pub const HWCAP_LOONGARCH_LAM: ::c_ulong = 1 << 1; @@ -891,10 +922,3 @@ pub const EPOLL_CLOEXEC: ::c_int = 0x80000; pub const EFD_CLOEXEC: ::c_int = 0x80000; pub const EFD_NONBLOCK: ::c_int = 0x800; - -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; - } -} 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 f7b52be805cab..e1e2be19bc3ba 100644 --- a/src/unix/linux_like/linux/gnu/b64/mips64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/mips64/mod.rs @@ -186,6 +186,14 @@ s! { } } +s_no_extra_traits! { + #[allow(missing_debug_implementations)] + #[repr(align(16))] + pub struct max_align_t { + priv_: [f64; 4] + } +} + pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4; pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4; pub const __SIZEOF_PTHREAD_BARRIERATTR_T: usize = 4; @@ -193,56 +201,48 @@ pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40; pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56; pub const __SIZEOF_PTHREAD_BARRIER_T: usize = 32; -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; @@ -925,10 +925,3 @@ extern "C" { newlen: ::size_t, ) -> ::c_int; } - -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; - } -} 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 3088c25a2646f..495c0b37e16c0 100644 --- a/src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs @@ -193,6 +193,14 @@ s! { } } +s_no_extra_traits! { + #[allow(missing_debug_implementations)] + #[repr(align(16))] + pub struct max_align_t { + priv_: [i64; 4] + } +} + pub const POSIX_FADV_DONTNEED: ::c_int = 4; pub const POSIX_FADV_NOREUSE: ::c_int = 5; @@ -405,56 +413,48 @@ pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40; pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4; pub const __SIZEOF_PTHREAD_BARRIERATTR_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; @@ -970,10 +970,3 @@ extern "C" { newlen: ::size_t, ) -> ::c_int; } - -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; - } -} 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 5b33f2375d39c..0000000000000 --- a/src/unix/linux_like/linux/gnu/b64/riscv64/align.rs +++ /dev/null @@ -1,61 +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], - } -} - -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/riscv64/mod.rs b/src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs index 64f5cf10f8583..e42023c49584b 100644 --- a/src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs @@ -227,6 +227,109 @@ s! { pub t5: ::c_ulong, pub t6: ::c_ulong, } + + #[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)] + 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], + } + + #[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], + } } pub const POSIX_FADV_DONTNEED: ::c_int = 4; @@ -851,10 +954,3 @@ pub const SYS_memfd_secret: ::c_long = 447; pub const SYS_process_mrelease: ::c_long = 448; pub const SYS_futex_waitv: ::c_long = 449; pub const SYS_set_mempolicy_home_node: ::c_long = 450; - -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; - } -} diff --git a/src/unix/linux_like/linux/gnu/b64/s390x.rs b/src/unix/linux_like/linux/gnu/b64/s390x.rs index e85429ef97bf6..6bf730106e4c2 100644 --- a/src/unix/linux_like/linux/gnu/b64/s390x.rs +++ b/src/unix/linux_like/linux/gnu/b64/s390x.rs @@ -294,29 +294,24 @@ pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40; pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56; pub const __SIZEOF_PTHREAD_BARRIER_T: usize = 32; -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 de2f0d6e470f6..5d1f5e47415b2 100644 --- a/src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs @@ -196,6 +196,14 @@ s! { } } +s_no_extra_traits! { + #[allow(missing_debug_implementations)] + #[repr(align(16))] + pub struct max_align_t { + priv_: [i64; 4] + } +} + pub const POSIX_FADV_DONTNEED: ::c_int = 4; pub const POSIX_FADV_NOREUSE: ::c_int = 5; @@ -404,29 +412,24 @@ pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40; pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4; pub const __SIZEOF_PTHREAD_BARRIERATTR_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; @@ -922,10 +925,3 @@ extern "C" { newlen: ::size_t, ) -> ::c_int; } - -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; - } -} 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 f66eb0409c596..eda6d2c2caba3 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 @@ -267,6 +267,21 @@ s! { pub flags: ::__u32, pub pad: ::__u32, } + + #[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! { @@ -297,6 +312,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! { @@ -813,10 +834,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 9b37907bbb28a..0c83fa13b4e5e 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 @@ -24,56 +24,48 @@ pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40; pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56; pub const __SIZEOF_PTHREAD_BARRIER_T: usize = 32; -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 90745b1762335..55b85e9626807 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 @@ -24,29 +24,24 @@ pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 32; pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 44; pub const __SIZEOF_PTHREAD_BARRIER_T: usize = 20; -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 41a229ef9e83d..565b3d45085d3 100644 --- a/src/unix/linux_like/linux/gnu/mod.rs +++ b/src/unix/linux_like/linux/gnu/mod.rs @@ -1623,13 +1623,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 99f3f45a9950b..59b30d9ccfaa1 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -889,6 +889,88 @@ s! { pub prefer_busy_poll: u8, pub __pad: u8, // Must be zero } + + + #[cfg_attr(any(target_pointer_width = "32", + target_arch = "x86_64", + target_arch = "powerpc64", + target_arch = "mips64", + target_arch = "mips64r6", + 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 = "mips64r6", + 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_env = "ohos", target_pointer_width = "32"), + repr(align(4)))] + #[cfg_attr(all(not(target_env = "musl"), + not(target_env = "ohos"), + 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(4))] + pub struct pthread_barrierattr_t { + #[doc(hidden)] + size: [u8; ::__SIZEOF_PTHREAD_BARRIERATTR_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, + } + + #[repr(align(8))] + pub struct tpacket_rollover_stats { + pub tp_all: ::__u64, + pub tp_huge: ::__u64, + pub tp_failed: ::__u64, + } + + #[repr(align(8))] + pub struct tpacket_hdr_v1 { + pub block_status: ::__u32, + pub num_pkts: ::__u32, + pub offset_to_first_pkt: ::__u32, + pub blk_len: ::__u32, + pub seq_num: ::__u64, + pub ts_first_pkt: ::tpacket_bd_ts, + pub ts_last_pkt: ::tpacket_bd_ts, + } } s_no_extra_traits! { @@ -1049,16 +1131,148 @@ s_no_extra_traits! { } s_no_extra_traits! { + #[cfg_attr(all(any(target_env = "musl", target_env = "ohos"), + target_pointer_width = "32"), + repr(align(4)))] + #[cfg_attr(all(any(target_env = "musl", target_env = "ohos"), + target_pointer_width = "64"), + repr(align(8)))] + #[cfg_attr(all(not(any(target_env = "musl", target_env = "ohos")), + target_arch = "x86"), + repr(align(4)))] + #[cfg_attr(all(not(any(target_env = "musl", target_env = "ohos")), + 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 = "mips32r6", + target_arch = "arm", + target_arch = "hexagon", + target_arch = "m68k", + target_arch = "csky", + 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 = "mips32r6", + target_arch = "arm", + target_arch = "hexagon", + target_arch = "m68k", + target_arch = "csky", + 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 = "mips32r6", + target_arch = "arm", + target_arch = "hexagon", + target_arch = "m68k", + target_arch = "csky", + 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 = "mips32r6", + 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], + } + + #[cfg_attr(all(target_pointer_width = "32", + any(target_arch = "mips", + target_arch = "mips32r6", + target_arch = "arm", + target_arch = "hexagon", + target_arch = "m68k", + target_arch = "csky", + 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 = "mips32r6", + target_arch = "arm", + target_arch = "hexagon", + target_arch = "m68k", + target_arch = "csky", + target_arch = "powerpc", + target_arch = "sparc", + target_arch = "x86_64", + target_arch = "x86"))), + repr(align(8)))] + pub struct pthread_barrier_t { + size: [u8; ::__SIZEOF_PTHREAD_BARRIER_T], + } + // linux/net_tstamp.h #[allow(missing_debug_implementations)] pub struct sock_txtime { pub clockid: ::clockid_t, pub flags: ::__u32, } -} -s_no_extra_traits! { // 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], + } + + #[repr(align(8))] + #[allow(missing_debug_implementations)] + pub struct canxl_frame { + pub prio: canid_t, + pub flags: u8, + pub sdt: u8, + pub len: u16, + pub af: u32, + pub data: [u8; CANXL_MAX_DLEN], + } + #[allow(missing_debug_implementations)] pub union __c_anonymous_sockaddr_can_can_addr { pub tp: __c_anonymous_sockaddr_can_tp, @@ -2252,17 +2466,16 @@ pub const MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_SYNC_CORE: ::c_int = 1 << 6; pub const MEMBARRIER_CMD_PRIVATE_EXPEDITED_RSEQ: ::c_int = 1 << 7; pub const MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_RSEQ: ::c_int = 1 << 8; -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_BARRIER_SERIAL_THREAD: ::c_int = -1; pub const PTHREAD_ONCE_INIT: pthread_once_t = 0; pub const PTHREAD_MUTEX_NORMAL: ::c_int = 0; @@ -4572,19 +4785,15 @@ pub const CANXL_MAX_DLEN: usize = 2048; pub const CANXL_XLF: ::c_int = 0x80; pub const CANXL_SEC: ::c_int = 0x01; -cfg_if! { - if #[cfg(libc_align)] { - pub const CAN_MTU: usize = ::mem::size_of::(); - pub const CANFD_MTU: usize = ::mem::size_of::(); - pub const CANXL_MTU: usize = ::mem::size_of::(); - // FIXME: use `core::mem::offset_of!` once that is available - // https://github.com/rust-lang/rfcs/pull/3308 - // pub const CANXL_HDR_SIZE: usize = core::mem::offset_of!(canxl_frame, data); - pub const CANXL_HDR_SIZE: usize = 12; - pub const CANXL_MIN_MTU: usize = CANXL_HDR_SIZE + 64; - pub const CANXL_MAX_MTU: usize = CANXL_MTU; - } -} +pub const CAN_MTU: usize = ::mem::size_of::(); +pub const CANFD_MTU: usize = ::mem::size_of::(); +pub const CANXL_MTU: usize = ::mem::size_of::(); +// FIXME(offset_of): use `core::mem::offset_of!` once that is available +// https://github.com/rust-lang/rfcs/pull/3308 +// pub const CANXL_HDR_SIZE: usize = core::mem::offset_of!(canxl_frame, data); +pub const CANXL_HDR_SIZE: usize = 12; +pub const CANXL_MIN_MTU: usize = CANXL_HDR_SIZE + 64; +pub const CANXL_MAX_MTU: usize = CANXL_MTU; pub const CAN_RAW: ::c_int = 1; pub const CAN_BCM: ::c_int = 2; @@ -5978,17 +6187,6 @@ 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; 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 4ac3e60d43079..115f1085704b4 100644 --- a/src/unix/linux_like/linux/musl/b32/arm/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/arm/mod.rs @@ -186,6 +186,12 @@ s_no_extra_traits! { pub uc_sigmask: ::sigset_t, pub uc_regspace: [::c_ulonglong; 64], } + + #[allow(missing_debug_implementations)] + #[repr(align(8))] + pub struct max_align_t { + priv_: (i64, i64) + } } cfg_if! { @@ -845,10 +851,3 @@ pub const SYS_mseal: ::c_long = 462; 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::*; - } -} 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 2fb405bbc6ceb..a67fff7cfc728 100644 --- a/src/unix/linux_like/linux/musl/b32/mips/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/mips/mod.rs @@ -163,6 +163,14 @@ s! { } } +s_no_extra_traits! { + #[allow(missing_debug_implementations)] + #[repr(align(8))] + pub struct max_align_t { + priv_: [f32; 4] + } +} + pub const SIGSTKSZ: ::size_t = 8192; pub const MINSIGSTKSZ: ::size_t = 2048; @@ -779,10 +787,3 @@ pub const SYS_memfd_secret: ::c_long = 4000 + 447; pub const SYS_process_mrelease: ::c_long = 4000 + 448; pub const SYS_futex_waitv: ::c_long = 4000 + 449; pub const SYS_set_mempolicy_home_node: ::c_long = 4000 + 450; - -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; - } -} 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 f963f645a9f10..c71cc61584860 100644 --- a/src/unix/linux_like/linux/musl/b32/riscv32/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/riscv32/mod.rs @@ -186,6 +186,14 @@ s! { } } +s_no_extra_traits! { + #[allow(missing_debug_implementations)] + #[repr(align(8))] + pub struct max_align_t { + priv_: (i64, f64) + } +} + //pub const RLIM_INFINITY: ::rlim_t = !0; pub const VEOF: usize = 4; pub const RTLD_DEEPBIND: ::c_int = 0x8; @@ -789,10 +797,3 @@ pub const SYS_faccessat2: ::c_long = 439; 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::*; - } -} 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 7fad04677f8a4..f8bf2694f4b4c 100644 --- a/src/unix/linux_like/linux/musl/b32/x86/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/x86/mod.rs @@ -181,6 +181,12 @@ s_no_extra_traits! { pub uc_sigmask: ::sigset_t, __private: [u8; 112], } + + #[allow(missing_debug_implementations)] + #[repr(align(8))] + pub struct max_align_t { + priv_: [f64; 3] + } } cfg_if! { @@ -960,10 +966,3 @@ pub const SS: ::c_int = 16; 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::*; - } -} 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/mod.rs b/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs index 24e6b8419253a..7582676c3bfa6 100644 --- a/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs @@ -68,6 +68,47 @@ 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; 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, + } +} + +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; @@ -644,13 +685,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; diff --git a/src/unix/linux_like/linux/musl/b64/loongarch64/align.rs b/src/unix/linux_like/linux/musl/b64/loongarch64/align.rs deleted file mode 100644 index dc191f51fdb1c..0000000000000 --- a/src/unix/linux_like/linux/musl/b64/loongarch64/align.rs +++ /dev/null @@ -1,40 +0,0 @@ -s_no_extra_traits! { - #[allow(missing_debug_implementations)] - #[repr(align(16))] - pub struct max_align_t { - priv_: [f64; 4] - } -} - -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 __pc: ::c_ulonglong, - pub __gregs: [::c_ulonglong; 32], - pub __flags: ::c_uint, - pub __extcontext: [::c_ulonglong; 0], - } - - #[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/loongarch64/mod.rs b/src/unix/linux_like/linux/musl/b64/loongarch64/mod.rs index 59a824b237306..ac02803640e30 100644 --- a/src/unix/linux_like/linux/musl/b64/loongarch64/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/loongarch64/mod.rs @@ -116,6 +116,45 @@ s! { pub fcc: u64, pub fcsr: u32, } + + 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 __pc: ::c_ulonglong, + pub __gregs: [::c_ulonglong; 32], + pub __flags: ::c_uint, + pub __extcontext: [::c_ulonglong; 0], + } + + #[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_: [f64; 4] + } } pub const SYS_io_setup: ::c_long = 0; @@ -660,10 +699,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/b64/riscv64/align.rs b/src/unix/linux_like/linux/musl/b64/riscv64/align.rs deleted file mode 100644 index 5b33f2375d39c..0000000000000 --- a/src/unix/linux_like/linux/musl/b64/riscv64/align.rs +++ /dev/null @@ -1,61 +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], - } -} - -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/riscv64/mod.rs b/src/unix/linux_like/linux/musl/b64/riscv64/mod.rs index 393f54d3ff773..caa05ccc4f603 100644 --- a/src/unix/linux_like/linux/musl/b64/riscv64/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/riscv64/mod.rs @@ -173,6 +173,66 @@ s! { __unused5: ::c_ulong, __unused6: ::c_ulong, } + + #[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)] + 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], + } } pub const SYS_read: ::c_long = 63; @@ -718,10 +778,3 @@ pub const REG_S1: usize = 9; 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::*; - } -} 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 dc617d42fe0cc..fcf07379ee81a 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 @@ -120,6 +120,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! { @@ -145,6 +160,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! { @@ -908,10 +929,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/no_align.rs b/src/unix/linux_like/linux/no_align.rs deleted file mode 100644 index f81d046ccefb1..0000000000000 --- a/src/unix/linux_like/linux/no_align.rs +++ /dev/null @@ -1,162 +0,0 @@ -macro_rules! expand_align { - () => { - s! { - pub struct pthread_mutexattr_t { - #[cfg(any(target_arch = "x86_64", - target_arch = "powerpc64", - target_arch = "mips64", - target_arch = "mips64r6", - target_arch = "s390x", - target_arch = "sparc64", - target_arch = "riscv64", - target_arch = "riscv32", - target_arch = "loongarch64", - all(target_arch = "aarch64", - any(target_env = "musl", target_env = "ohos"))))] - __align: [::c_int; 0], - #[cfg(not(any(target_arch = "x86_64", - target_arch = "powerpc64", - target_arch = "mips64", - target_arch = "mips64r6", - target_arch = "s390x", - target_arch = "sparc64", - target_arch = "riscv64", - target_arch = "riscv32", - target_arch = "loongarch64", - all(target_arch = "aarch64", - any(target_env = "musl", target_env = "ohos")))))] - __align: [::c_long; 0], - size: [u8; ::__SIZEOF_PTHREAD_MUTEXATTR_T], - } - - pub struct pthread_rwlockattr_t { - #[cfg(any(target_env = "musl", target_env = "ohos"))] - __align: [::c_int; 0], - #[cfg(not(any(target_env = "musl", target_env = "ohos")))] - __align: [::c_long; 0], - size: [u8; ::__SIZEOF_PTHREAD_RWLOCKATTR_T], - } - - pub struct pthread_condattr_t { - __align: [::c_int; 0], - size: [u8; ::__SIZEOF_PTHREAD_CONDATTR_T], - } - - pub struct pthread_barrierattr_t { - __align: [::c_int; 0], - size: [u8; ::__SIZEOF_PTHREAD_BARRIERATTR_T], - } - - pub struct fanotify_event_metadata { - __align: [::c_long; 0], - pub event_len: __u32, - pub vers: __u8, - pub reserved: __u8, - pub metadata_len: __u16, - pub mask: __u64, - pub fd: ::c_int, - pub pid: ::c_int, - } - - pub struct tpacket_rollover_stats { - __align: [::c_long; 0], - pub tp_all: ::__u64, - pub tp_huge: ::__u64, - pub tp_failed: ::__u64, - } - - pub struct tpacket_hdr_v1 { - __align: [::c_long; 0], - pub block_status: ::__u32, - pub num_pkts: ::__u32, - pub offset_to_first_pkt: ::__u32, - pub blk_len: ::__u32, - pub seq_num: ::__u64, - pub ts_first_pkt: ::tpacket_bd_ts, - pub ts_last_pkt: ::tpacket_bd_ts, - } - } - - s_no_extra_traits! { - pub struct pthread_cond_t { - #[cfg(any(target_env = "musl", target_env = "ohos"))] - __align: [*const ::c_void; 0], - #[cfg(not(any(target_env = "musl", target_env = "ohos")))] - __align: [::c_longlong; 0], - size: [u8; ::__SIZEOF_PTHREAD_COND_T], - } - - pub struct pthread_mutex_t { - #[cfg(any(target_arch = "mips", - target_arch = "mips32r6", - target_arch = "arm", - target_arch = "m68k", - target_arch = "csky", - target_arch = "powerpc", - target_arch = "sparc", - all(target_arch = "x86_64", - target_pointer_width = "32")))] - __align: [::c_long; 0], - #[cfg(not(any(target_arch = "mips", - target_arch = "mips32r6", - target_arch = "arm", - target_arch = "m68k", - target_arch = "csky", - target_arch = "powerpc", - target_arch = "sparc", - all(target_arch = "x86_64", - target_pointer_width = "32"))))] - __align: [::c_longlong; 0], - size: [u8; ::__SIZEOF_PTHREAD_MUTEX_T], - } - - pub struct pthread_rwlock_t { - #[cfg(any(target_arch = "mips", - target_arch = "mips32r6", - target_arch = "arm", - target_arch = "m68k", - target_arch = "csky", - target_arch = "powerpc", - target_arch = "sparc", - all(target_arch = "x86_64", - target_pointer_width = "32")))] - __align: [::c_long; 0], - #[cfg(not(any(target_arch = "mips", - target_arch = "mips32r6", - target_arch = "arm", - target_arch = "m68k", - target_arch = "csky", - target_arch = "powerpc", - target_arch = "sparc", - all(target_arch = "x86_64", - target_pointer_width = "32"))))] - __align: [::c_longlong; 0], - size: [u8; ::__SIZEOF_PTHREAD_RWLOCK_T], - } - - pub struct pthread_barrier_t { - #[cfg(any(target_arch = "mips", - target_arch = "mips32r6", - target_arch = "arm", - target_arch = "m68k", - target_arch = "csky", - target_arch = "powerpc", - target_arch = "sparc", - all(target_arch = "x86_64", - target_pointer_width = "32")))] - __align: [::c_long; 0], - #[cfg(not(any(target_arch = "mips", - target_arch = "mips32r6", - target_arch = "arm", - target_arch = "m68k", - target_arch = "csky", - target_arch = "powerpc", - target_arch = "sparc", - all(target_arch = "x86_64", - target_pointer_width = "32"))))] - __align: [::c_longlong; 0], - size: [u8; ::__SIZEOF_PTHREAD_BARRIER_T], - } - } - }; -} diff --git a/src/unix/linux_like/linux/uclibc/align.rs b/src/unix/linux_like/linux/uclibc/align.rs deleted file mode 100644 index e6610bb7b985c..0000000000000 --- a/src/unix/linux_like/linux/uclibc/align.rs +++ /dev/null @@ -1,28 +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"), - 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 { - size: [u8; ::__SIZEOF_PTHREAD_MUTEXATTR_T], - } - - #[repr(align(4))] - pub struct pthread_condattr_t { - size: [u8; ::__SIZEOF_PTHREAD_CONDATTR_T], - } - } - }; -} 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 cff82f005acee..56629534ea22f 100644 --- a/src/unix/linux_like/linux/uclibc/arm/mod.rs +++ b/src/unix/linux_like/linux/uclibc/arm/mod.rs @@ -913,13 +913,3 @@ pub const SYS_memfd_secret: ::c_long = 447; pub const SYS_process_mrelease: ::c_long = 448; pub const SYS_futex_waitv: ::c_long = 449; pub const SYS_set_mempolicy_home_node: ::c_long = 450; - -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; - } else { - mod no_align; - pub use self::no_align::*; - } -} 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 a5aca85a3a741..f95003ea3ba14 100644 --- a/src/unix/linux_like/linux/uclibc/mips/mips32/mod.rs +++ b/src/unix/linux_like/linux/uclibc/mips/mips32/mod.rs @@ -254,6 +254,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; @@ -680,13 +692,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 8ca100fcd268f..4bb2788493b08 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; @@ -195,13 +204,3 @@ pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56; pub const __SIZEOF_PTHREAD_BARRIER_T: usize = 32; pub const SYS_gettid: ::c_long = 5178; // Valid for n64 - -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; - } else { - mod no_align; - pub use self::no_align::*; - } -} 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/mod.rs b/src/unix/linux_like/linux/uclibc/mod.rs index 32c65545a8905..07bf7833720d1 100644 --- a/src/unix/linux_like/linux/uclibc/mod.rs +++ b/src/unix/linux_like/linux/uclibc/mod.rs @@ -79,6 +79,29 @@ s! { pub flags: ::__u32, pub nr: ::__s32, } + + #[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 { + size: [u8; ::__SIZEOF_PTHREAD_MUTEXATTR_T], + } + + #[repr(align(4))] + pub struct pthread_condattr_t { + size: [u8; ::__SIZEOF_PTHREAD_CONDATTR_T], + } } impl siginfo_t { 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 c504202f6d984..bf1ae9a2cf186 100644 --- a/src/unix/linux_like/linux/uclibc/x86_64/mod.rs +++ b/src/unix/linux_like/linux/uclibc/x86_64/mod.rs @@ -117,8 +117,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 db60f8ef29ee4..1556c12726eb0 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -200,14 +200,28 @@ 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; pub const INT_MAX: c_int = 2147483647; +pub const IN6ADDR_LOOPBACK_INIT: in6_addr = in6_addr { + s6_addr: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], +}; + +pub const IN6ADDR_ANY_INIT: in6_addr = in6_addr { + s6_addr: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], +}; + pub const SIG_DFL: sighandler_t = 0 as sighandler_t; pub const SIG_IGN: sighandler_t = 1 as sighandler_t; pub const SIG_ERR: sighandler_t = !0 as sighandler_t; + cfg_if! { if #[cfg(not(target_os = "nto"))] { pub const DT_UNKNOWN: u8 = 0; @@ -1709,13 +1723,3 @@ cfg_if! { } } } - -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 37cfb8ed3afb2..6165cb949452f 100644 --- a/src/unix/newlib/mod.rs +++ b/src/unix/newlib/mod.rs @@ -260,17 +260,15 @@ s! { } // 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], +}; cfg_if! { if #[cfg(target_os = "espidf")] { @@ -919,14 +917,3 @@ cfg_if! { pub use self::rtems::*; } } - -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 b435d72aa7db0..0000000000000 --- a/src/unix/no_align.rs +++ /dev/null @@ -1,16 +0,0 @@ -s! { - pub struct in6_addr { - pub s6_addr: [u8; 16], - __align: [u32; 0], - } -} - -pub const IN6ADDR_LOOPBACK_INIT: in6_addr = in6_addr { - s6_addr: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], - __align: [0u32; 0], -}; - -pub const IN6ADDR_ANY_INIT: in6_addr = in6_addr { - s6_addr: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], - __align: [0u32; 0], -}; diff --git a/src/unix/solarish/mod.rs b/src/unix/solarish/mod.rs index 994fc76583b5c..a5190416836cd 100644 --- a/src/unix/solarish/mod.rs +++ b/src/unix/solarish/mod.rs @@ -525,7 +525,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, @@ -555,13 +555,13 @@ s_no_extra_traits! { __sigev_pad2: ::c_int, } - #[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_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], 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..740ea3fa548f3 100644 --- a/src/windows/gnu/mod.rs +++ b/src/windows/gnu/mod.rs @@ -1,3 +1,23 @@ +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] + } + } + } +} + pub const L_tmpnam: ::c_uint = 14; pub const TMP_MAX: ::c_uint = 0x7fff; @@ -14,10 +34,3 @@ extern "C" { // header file. We cannot find a way to link to that symbol from Rust. pub fn wmemchr(cx: *const ::wchar_t, c: ::wchar_t, n: ::size_t) -> *mut ::wchar_t; } - -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; - } -}