From e2dd1710b0c40bc1e35b980dab957fddfd7700a8 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Sat, 16 Nov 2024 05:31:59 -0600 Subject: [PATCH 01/10] Explicitly set the edition to 2015 This just suppresses a warning. Ideally this should go to 2021 but that requires quite a bit of refactoring, so hold off until the rest of the 0.2 cleanup is complete. (apply to `main`) (cherry picked from commit 1e88f41eb16bd5151f6fdad26fe2b3ed8c8f898e) --- Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/Cargo.toml b/Cargo.toml index b967efa1c2d19..48488b42ba31d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,6 +4,7 @@ version = "0.2.151" authors = ["The Rust Project Developers"] license = "MIT OR Apache-2.0" readme = "README.md" +edition = "2015" repository = "https://github.com/rust-lang/libc" homepage = "https://github.com/rust-lang/libc" documentation = "https://docs.rs/libc/" From e703c8595d47050236562bea644cfeb1ea5c03ea Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Mon, 11 Jul 2022 20:21:45 -0700 Subject: [PATCH 02/10] 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 (apply to `main`) (cherry picked from commit b5b553d0ee7de0d4781432a9a9a0a6445dd7f34f) As part of this update, drop the `align` feature from Cargo.toml and libc-test. Changes are reduced in this cherry pick compared to the original commit because some of this was already applied to `main`. --- Cargo.toml | 3 +- libc-test/Cargo.toml | 1 - src/fuchsia/align.rs | 142 ------------ src/fuchsia/mod.rs | 138 +++++++++++- src/unix/align.rs | 6 - src/unix/bsd/apple/b32/align.rs | 7 - src/unix/bsd/apple/b32/mod.rs | 9 +- src/unix/bsd/apple/b64/aarch64/align.rs | 47 ---- src/unix/bsd/apple/b64/aarch64/mod.rs | 46 +++- src/unix/bsd/apple/b64/align.rs | 7 - src/unix/bsd/apple/b64/x86_64/align.rs | 7 - src/unix/bsd/apple/b64/x86_64/mod.rs | 9 +- .../bsd/freebsdlike/freebsd/x86_64/align.rs | 186 ---------------- .../bsd/freebsdlike/freebsd/x86_64/mod.rs | 183 +++++++++++++++- src/unix/linux_like/android/b32/x86/align.rs | 7 - src/unix/linux_like/android/b32/x86/mod.rs | 9 +- .../linux_like/android/b64/aarch64/align.rs | 30 --- .../linux_like/android/b64/aarch64/mod.rs | 31 ++- .../linux_like/android/b64/riscv64/align.rs | 7 - .../linux_like/android/b64/riscv64/mod.rs | 11 +- .../linux_like/android/b64/x86_64/align.rs | 7 - src/unix/linux_like/android/b64/x86_64/mod.rs | 9 +- src/unix/linux_like/android/mod.rs | 2 +- src/unix/linux_like/emscripten/align.rs | 74 ------- src/unix/linux_like/emscripten/mod.rs | 66 +++++- src/unix/linux_like/linux/align.rs | 205 ------------------ 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 | 57 ++++- .../linux_like/linux/gnu/b32/csky/align.rs | 7 - src/unix/linux_like/linux/gnu/b32/csky/mod.rs | 11 +- .../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 | 11 +- .../linux_like/linux/gnu/b32/riscv32/align.rs | 44 ---- .../linux_like/linux/gnu/b32/riscv32/mod.rs | 48 +++- .../linux_like/linux/gnu/b32/sparc/align.rs | 7 - .../linux_like/linux/gnu/b32/sparc/mod.rs | 11 +- .../linux_like/linux/gnu/b32/x86/align.rs | 7 - src/unix/linux_like/linux/gnu/b32/x86/mod.rs | 9 +- .../linux_like/linux/gnu/b64/aarch64/align.rs | 51 ----- .../linux_like/linux/gnu/b64/aarch64/mod.rs | 50 ++++- .../linux/gnu/b64/loongarch64/align.rs | 40 ---- .../linux/gnu/b64/loongarch64/mod.rs | 42 +++- .../linux_like/linux/gnu/b64/mips64/align.rs | 7 - .../linux_like/linux/gnu/b64/mips64/mod.rs | 11 +- .../linux/gnu/b64/powerpc64/align.rs | 7 - .../linux_like/linux/gnu/b64/powerpc64/mod.rs | 11 +- .../linux_like/linux/gnu/b64/riscv64/align.rs | 61 ------ .../linux_like/linux/gnu/b64/riscv64/mod.rs | 63 +++++- .../linux_like/linux/gnu/b64/sparc64/align.rs | 7 - .../linux_like/linux/gnu/b64/sparc64/mod.rs | 11 +- .../linux_like/linux/gnu/b64/x86_64/align.rs | 24 -- .../linux_like/linux/gnu/b64/x86_64/mod.rs | 24 +- src/unix/linux_like/linux/gnu/mod.rs | 15 +- src/unix/linux_like/linux/mod.rs | 203 ++++++++++++++++- .../linux_like/linux/musl/b32/arm/align.rs | 7 - src/unix/linux_like/linux/musl/b32/arm/mod.rs | 9 +- .../linux_like/linux/musl/b32/mips/align.rs | 7 - .../linux_like/linux/musl/b32/mips/mod.rs | 11 +- .../linux/musl/b32/riscv32/align.rs | 7 - .../linux_like/linux/musl/b32/riscv32/mod.rs | 11 +- .../linux_like/linux/musl/b32/x86/align.rs | 7 - src/unix/linux_like/linux/musl/b32/x86/mod.rs | 9 +- .../linux/musl/b64/aarch64/align.rs | 42 ---- .../linux_like/linux/musl/b64/aarch64/mod.rs | 44 +++- .../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 | 63 +++++- .../linux_like/linux/musl/b64/x86_64/align.rs | 25 --- .../linux_like/linux/musl/b64/x86_64/mod.rs | 24 +- 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 | 15 +- .../linux/uclibc/mips/mips32/align.rs | 13 -- .../linux/uclibc/mips/mips32/mod.rs | 15 +- .../linux/uclibc/mips/mips64/align.rs | 10 - .../linux/uclibc/mips/mips64/mod.rs | 12 +- src/unix/linux_like/linux/uclibc/mod.rs | 23 ++ .../linux_like/linux/uclibc/x86_64/mod.rs | 2 +- src/unix/mod.rs | 9 +- src/unix/newlib/align.rs | 61 ------ src/unix/newlib/mod.rs | 60 ++++- src/windows/gnu/align.rs | 19 -- src/windows/gnu/mod.rs | 23 +- 87 files changed, 1348 insertions(+), 1544 deletions(-) delete mode 100644 src/fuchsia/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/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/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/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/uclibc/align.rs delete mode 100644 src/unix/linux_like/linux/uclibc/arm/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/mips64/align.rs delete mode 100644 src/unix/newlib/align.rs delete mode 100644 src/windows/gnu/align.rs diff --git a/Cargo.toml b/Cargo.toml index 48488b42ba31d..a707e9b74de8d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -139,8 +139,7 @@ rustc-std-workspace-core = { version = "1.0.0", optional = true } [features] default = ["std"] std = [] -align = [] -rustc-dep-of-std = ['align', 'rustc-std-workspace-core'] +rustc-dep-of-std = ["rustc-std-workspace-core"] extra_traits = [] const-extern-fn = [] diff --git a/libc-test/Cargo.toml b/libc-test/Cargo.toml index 883dc3d43d8e9..6a92569f8101d 100644 --- a/libc-test/Cargo.toml +++ b/libc-test/Cargo.toml @@ -24,7 +24,6 @@ ctest2 = "0.4.3" [features] default = ["std"] std = ["libc/std"] -align = ["libc/align"] extra_traits = ["libc/extra_traits"] [[test]] 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 bf4250c974106..9f3c6d94d270c 100644 --- a/src/fuchsia/mod.rs +++ b/src/fuchsia/mod.rs @@ -697,7 +697,7 @@ s! { pub direction: ::__u16, pub trigger: ff_trigger, pub replay: ff_replay, - // FIXME this is actually a union + // FIXME(1.0): this is actually a union #[cfg(target_pointer_width = "64")] pub u: [u64; 4], #[cfg(target_pointer_width = "32")] @@ -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); + } + } } } @@ -4356,9 +4487,4 @@ cfg_if! { } } -#[macro_use] -mod align; - -expand_align!(); - pub use ffi::c_void; diff --git a/src/unix/align.rs b/src/unix/align.rs deleted file mode 100644 index 4fdba9a6aba69..0000000000000 --- a/src/unix/align.rs +++ /dev/null @@ -1,6 +0,0 @@ -s! { - #[repr(align(4))] - pub struct in6_addr { - pub s6_addr: [u8; 16], - } -} diff --git a/src/unix/bsd/apple/b32/align.rs b/src/unix/bsd/apple/b32/align.rs deleted file mode 100644 index ca1fe1ce29944..0000000000000 --- a/src/unix/bsd/apple/b32/align.rs +++ /dev/null @@ -1,7 +0,0 @@ -s_no_extra_traits! { - #[allow(missing_debug_implementations)] - #[repr(align(16))] - pub struct max_align_t { - priv_: [f64; 2] - } -} diff --git a/src/unix/bsd/apple/b32/mod.rs b/src/unix/bsd/apple/b32/mod.rs index c28ad931b4c3c..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,6 +151,3 @@ extern "C" { options: ::c_ulong, ) -> ::c_int; } - -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 7f86a134649cf..0000000000000 --- a/src/unix/bsd/apple/b64/aarch64/align.rs +++ /dev/null @@ -1,47 +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, - } - - pub struct __darwin_arm_neon_state64 { - pub __v: [::__uint128_t; 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 a32abf17008fd..ce34e78c87ca7 100644 --- a/src/unix/bsd/apple/b64/aarch64/mod.rs +++ b/src/unix/bsd/apple/b64/aarch64/mod.rs @@ -1,10 +1,52 @@ 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, + } + + pub struct __darwin_arm_neon_state64 { + pub __v: [::__uint128_t; 32], + pub __fpsr: u32, + pub __fpcr: u32, + } } -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/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 a15d6cfe47c31..a613ccb389e45 100644 --- a/src/unix/bsd/apple/b64/x86_64/mod.rs +++ b/src/unix/bsd/apple/b64/x86_64/mod.rs @@ -172,5 +172,10 @@ s! { } } -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/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 4ff9469086cb6..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,6 +421,3 @@ pub const _MC_FPOWNED_PCB: c_long = 0x20002; pub const KINFO_FILE_SIZE: ::c_int = 1392; pub const TIOCTIMESTAMP: ::c_ulong = 0x40107459; - -mod align; -pub use self::align::*; 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 2ec6093f488d6..902016fda3ec8 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! { @@ -631,6 +637,3 @@ f! { ::syscall(SYS_socketcall, SYS_ACCEPT4, args[..].as_mut_ptr()) } } - -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 6891c14e90fa0..0000000000000 --- a/src/unix/linux_like/android/b64/aarch64/align.rs +++ /dev/null @@ -1,30 +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 __pad: [u8; 1024 / 8 - core::mem::size_of::<::sigset_t>()], - pub uc_mcontext: mcontext_t, - } - - #[repr(align(16))] - pub struct mcontext_t { - pub fault_address: ::c_ulonglong, - pub regs: [::c_ulonglong; 31], - pub sp: ::c_ulonglong, - pub pc: ::c_ulonglong, - pub pstate: ::c_ulonglong, - // nested arrays to get the right size/length while being able to - // auto-derive traits like Debug - __reserved: [[u64; 32]; 16], - } -} diff --git a/src/unix/linux_like/android/b64/aarch64/mod.rs b/src/unix/linux_like/android/b64/aarch64/mod.rs index 718bf779bb908..6fdcca6fe1b1b 100644 --- a/src/unix/linux_like/android/b64/aarch64/mod.rs +++ b/src/unix/linux_like/android/b64/aarch64/mod.rs @@ -56,6 +56,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; @@ -439,8 +467,5 @@ pub const PROT_MTE: ::c_int = 0x20; pub const AT_SYSINFO_EHDR: ::c_ulong = 33; pub const AT_VECTOR_SIZE_ARCH: ::c_ulong = 2; -mod align; -pub use self::align::*; - mod int128; pub use self::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 bf4c8988fae93..82a3aa62f51a5 100644 --- a/src/unix/linux_like/android/b64/riscv64/mod.rs +++ b/src/unix/linux_like/android/b64/riscv64/mod.rs @@ -52,6 +52,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; @@ -373,6 +381,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; - -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 780dae6103491..57a41a224fe2c 100644 --- a/src/unix/linux_like/android/b64/x86_64/mod.rs +++ b/src/unix/linux_like/android/b64/x86_64/mod.rs @@ -110,6 +110,12 @@ s_no_extra_traits! { uc_sigmask: ::sigset_t, uc_sigmask64: ::sigset64_t, } + + #[allow(missing_debug_implementations)] + #[repr(align(16))] + pub struct max_align_t { + priv_: [f64; 4] + } } cfg_if! { @@ -811,6 +817,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; - -mod align; -pub use self::align::*; diff --git a/src/unix/linux_like/android/mod.rs b/src/unix/linux_like/android/mod.rs index b367a22f3ed89..4dbd25d2b214b 100644 --- a/src/unix/linux_like/android/mod.rs +++ b/src/unix/linux_like/android/mod.rs @@ -468,7 +468,7 @@ s! { pub direction: ::__u16, pub trigger: ff_trigger, pub replay: ff_replay, - // FIXME this is actually a union + // FIXME(1.0): this is actually a union #[cfg(target_pointer_width = "64")] pub u: [u64; 4], #[cfg(target_pointer_width = "32")] 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 9207999b6b1e1..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); + } + } } } @@ -1590,7 +1652,3 @@ extern "C" { // Alias to 64 to mimic glibc's LFS64 support mod lfs64; pub use self::lfs64::*; - -#[macro_use] -mod align; -expand_align!(); diff --git a/src/unix/linux_like/linux/align.rs b/src/unix/linux_like/linux/align.rs deleted file mode 100644 index 1036e23dc8f09..0000000000000 --- a/src/unix/linux_like/linux/align.rs +++ /dev/null @@ -1,205 +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, - } - } - - 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 947384f76e557..c58dd6d45b690 100644 --- a/src/unix/linux_like/linux/gnu/b32/arm/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/arm/mod.rs @@ -209,6 +209,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; @@ -857,6 +911,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; - -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 16b2f9b84034e..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,6 +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; - -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 6f9560334c164..6655fc9c4faf4 100644 --- a/src/unix/linux_like/linux/gnu/b32/mips/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/mips/mod.rs @@ -156,6 +156,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; @@ -811,6 +819,3 @@ pub const B3500000: ::speed_t = 0o010016; pub const B4000000: ::speed_t = 0o010017; pub const EHWPOISON: ::c_int = 168; - -mod align; -pub use self::align::*; 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 8a75e6d42b32b..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,6 +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; - -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 16b836f7e6128..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,6 +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; - -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 9c54fb5a2e5f7..4592013b8ddcb 100644 --- a/src/unix/linux_like/linux/gnu/b32/x86/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/x86/mod.rs @@ -265,6 +265,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! { @@ -1094,6 +1100,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; } - -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/mod.rs b/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs index 96b5b532f74d2..1e6e768de2852 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,8 +965,5 @@ cfg_if! { } } -mod align; -pub use self::align::*; - mod int128; pub use self::int128::*; diff --git a/src/unix/linux_like/linux/gnu/b64/loongarch64/align.rs b/src/unix/linux_like/linux/gnu/b64/loongarch64/align.rs deleted file mode 100644 index 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 eccbeff79f6c6..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; @@ -883,6 +922,3 @@ pub const EPOLL_CLOEXEC: ::c_int = 0x80000; pub const EFD_CLOEXEC: ::c_int = 0x80000; pub const EFD_NONBLOCK: ::c_int = 0x800; - -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 ac4d205c7f7a2..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; @@ -917,6 +925,3 @@ extern "C" { newlen: ::size_t, ) -> ::c_int; } - -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 3a06d26143a2b..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; @@ -962,6 +970,3 @@ extern "C" { newlen: ::size_t, ) -> ::c_int; } - -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 750ee8f8436e8..ff001a86ff800 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,66 @@ 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], + } } pub const POSIX_FADV_DONTNEED: ::c_int = 4; @@ -851,6 +911,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; - -mod align; -pub use self::align::*; 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 4ea00510f0aa1..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; @@ -917,6 +925,3 @@ extern "C" { newlen: ::size_t, ) -> ::c_int; } - -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 88d70d7deb5da..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,6 +834,3 @@ cfg_if! { pub use self::not_x32::*; } } - -mod align; -pub use self::align::*; diff --git a/src/unix/linux_like/linux/gnu/mod.rs b/src/unix/linux_like/linux/gnu/mod.rs index f68efbe85bbf5..6c2d95593155f 100644 --- a/src/unix/linux_like/linux/gnu/mod.rs +++ b/src/unix/linux_like/linux/gnu/mod.rs @@ -502,6 +502,18 @@ s! { pub error: ::__s32, pub error_count: ::__u32, } + + // FIXME(1.0) this is actually a union + #[cfg_attr(target_pointer_width = "32", + repr(align(4)))] + #[cfg_attr(target_pointer_width = "64", + repr(align(8)))] + pub struct sem_t { + #[cfg(target_pointer_width = "32")] + __size: [::c_char; 16], + #[cfg(target_pointer_width = "64")] + __size: [::c_char; 32], + } } impl siginfo_t { @@ -1624,6 +1636,3 @@ cfg_if! { // Unknown target_arch } } - -mod align; -pub use self::align::*; diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index 9401949b4f124..d03cf2c3bd9ed 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -1045,6 +1045,69 @@ 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, + } } cfg_if! { @@ -1080,6 +1143,7 @@ cfg_if! { } } } + s_no_extra_traits! { pub struct sockaddr_nl { pub nl_family: ::sa_family_t, @@ -1226,6 +1290,141 @@ s_no_extra_traits! { pub offset_to_priv: ::__u32, pub hdr: ::tpacket_bd_header_u, } + + #[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], + } } s_no_extra_traits! { @@ -6263,9 +6462,5 @@ cfg_if! { mod arch; pub use self::arch::*; -#[macro_use] -mod align; -expand_align!(); - mod non_exhaustive; pub use self::non_exhaustive::*; diff --git a/src/unix/linux_like/linux/musl/b32/arm/align.rs b/src/unix/linux_like/linux/musl/b32/arm/align.rs deleted file mode 100644 index aedbf7a99eb1b..0000000000000 --- a/src/unix/linux_like/linux/musl/b32/arm/align.rs +++ /dev/null @@ -1,7 +0,0 @@ -s_no_extra_traits! { - #[allow(missing_debug_implementations)] - #[repr(align(8))] - pub struct max_align_t { - priv_: (i64, i64) - } -} diff --git a/src/unix/linux_like/linux/musl/b32/arm/mod.rs b/src/unix/linux_like/linux/musl/b32/arm/mod.rs index 58097f1434015..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,6 +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; } - -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 ab7a55b754c5e..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,6 +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; - -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 8568f2f338094..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,6 +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; - -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 f43c7ea60f8c7..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,6 +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; } - -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 a052b56bdcf6e..4a85e6f771ee0 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; @@ -646,8 +687,5 @@ pub const IEXTEN: ::tcflag_t = 0x00008000; pub const TOSTOP: ::tcflag_t = 0x00000100; pub const FLUSHO: ::tcflag_t = 0x00001000; -mod align; -pub use self::align::*; - mod int128; pub use self::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 a84d33409d19d..b48f7ac56b095 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; @@ -720,6 +780,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; - -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 5da3038a1855c..81c9772cdbb44 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! { @@ -910,6 +931,3 @@ pub const VMIN: usize = 6; pub const IEXTEN: ::tcflag_t = 0x00008000; pub const TOSTOP: ::tcflag_t = 0x00000100; pub const FLUSHO: ::tcflag_t = 0x00001000; - -mod align; -pub use self::align::*; 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 69187670587d6..70b890d3eeab0 100644 --- a/src/unix/linux_like/linux/uclibc/arm/mod.rs +++ b/src/unix/linux_like/linux/uclibc/arm/mod.rs @@ -241,6 +241,18 @@ s! { __unused4: ::c_ulong, __unused5: ::c_ulong, } + + // FIXME(1.0) this is actually a union + #[cfg_attr(target_pointer_width = "32", + repr(align(4)))] + #[cfg_attr(target_pointer_width = "64", + repr(align(8)))] + pub struct sem_t { + #[cfg(target_pointer_width = "32")] + __size: [::c_char; 16], + #[cfg(target_pointer_width = "64")] + __size: [::c_char; 32], + } } pub const O_CLOEXEC: ::c_int = 0o2000000; @@ -913,6 +925,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; - -mod align; -pub use self::align::*; 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 9e5765e9568f1..0052ddb3d9597 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(1.0): 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,6 +692,3 @@ extern "C" { cpuset: *const ::cpu_set_t, ) -> ::c_int; } - -mod align; -pub use self::align::*; 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 4ac13f5c77866..458dce029cd59 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(1.0): 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,6 +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 - -mod align; -pub use self::align::*; 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/x86_64/mod.rs b/src/unix/linux_like/linux/uclibc/x86_64/mod.rs index fe657b70542ab..a52711d0243a3 100644 --- a/src/unix/linux_like/linux/uclibc/x86_64/mod.rs +++ b/src/unix/linux_like/linux/uclibc/x86_64/mod.rs @@ -252,7 +252,7 @@ s! { __val: [::c_int; 2], } - // FIXME this is actually a union + // FIXME(1.0): this is actually a union pub struct sem_t { #[cfg(target_pointer_width = "32")] __size: [::c_char; 16], diff --git a/src/unix/mod.rs b/src/unix/mod.rs index 3ade3f50f16a3..6b2df6bcee381 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -200,6 +200,11 @@ s! { pub p_aliases: *mut *mut ::c_char, pub p_proto: ::c_int, } + + #[repr(align(4))] + pub struct in6_addr { + pub s6_addr: [u8; 16], + } } pub const INT_MIN: c_int = -2147483648; @@ -208,6 +213,7 @@ pub const INT_MAX: c_int = 2147483647; 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; @@ -1684,6 +1690,3 @@ cfg_if! { } pub use ffi::c_void; - -mod align; -pub use self::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 e52361f56bdf6..e3440e485771c 100644 --- a/src/unix/newlib/mod.rs +++ b/src/unix/newlib/mod.rs @@ -257,6 +257,62 @@ s! { pub struct pthread_rwlockattr_t { // Unverified __size: [u8; __SIZEOF_PTHREAD_RWLOCKATTR_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_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], + } } pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { @@ -900,7 +956,3 @@ cfg_if! { pub use self::rtems::*; } } - -#[macro_use] -mod align; -expand_align!(); 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 8923a531e7512..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,6 +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; } - -mod align; -pub use self::align::*; From a26e54b2daf5faff3f69ac181679ba17696453f0 Mon Sep 17 00:00:00 2001 From: Josh Triplett Date: Mon, 11 Jul 2022 20:29:19 -0700 Subject: [PATCH 03/10] Require rust >= 1.26 and drop libc_int128 conditional [ resolve conflicts and add test skips that seem to be needed now - Trevor ] (apply to `main`) (cherry picked from commit 23a0d01d9e10666096c360f2f1e8105fc0f8cfb1) Changes are reduced in this cherry pick compared to the original commit because some of this was already applied to `main`. --- libc-test/build.rs | 12 ++++++++---- src/unix/linux_like/android/b64/aarch64/int128.rs | 7 ------- src/unix/linux_like/android/b64/aarch64/mod.rs | 9 ++++++--- .../linux_like/linux/gnu/b64/aarch64/fallback.rs | 8 -------- src/unix/linux_like/linux/gnu/b64/aarch64/int128.rs | 7 ------- src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs | 9 ++++++--- src/unix/linux_like/linux/musl/b64/aarch64/int128.rs | 7 ------- src/unix/linux_like/linux/musl/b64/aarch64/mod.rs | 9 ++++++--- 8 files changed, 26 insertions(+), 42 deletions(-) delete mode 100644 src/unix/linux_like/android/b64/aarch64/int128.rs delete mode 100644 src/unix/linux_like/linux/gnu/b64/aarch64/fallback.rs delete mode 100644 src/unix/linux_like/linux/gnu/b64/aarch64/int128.rs delete mode 100644 src/unix/linux_like/linux/musl/b64/aarch64/int128.rs diff --git a/libc-test/build.rs b/libc-test/build.rs index b56a97135cb98..fe1fc18a33e0f 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -318,6 +318,9 @@ fn test_apple(target: &str) { // FIXME: Requires the macOS 14.4 SDK. "os_sync_wake_by_address_flags_t" | "os_sync_wait_on_address_flags_t" => true, + // FIXME: "'__uint128' undeclared" in C + "__uint128" => true, + _ => false, } }); @@ -1798,12 +1801,13 @@ fn test_android(target: &str) { // These are tested in the `linux_elf.rs` file. "Elf64_Phdr" | "Elf32_Phdr" => true, - // FIXME: Somehow fails to test after removing cfg hacks: - "__uint128" => true, - // These are intended to be opaque "posix_spawn_file_actions_t" => true, "posix_spawnattr_t" => true, + + // FIXME: "'__uint128' undeclared" in C + "__uint128" => true, + _ => false, } }); @@ -3659,7 +3663,7 @@ fn test_linux(target: &str) { "priority_t" if musl => true, "name_t" if musl => true, - // FIXME: Somehow fails to test after removing cfg hacks: + // FIXME: "'__uint128' undeclared" in C "__uint128" => true, t => { diff --git a/src/unix/linux_like/android/b64/aarch64/int128.rs b/src/unix/linux_like/android/b64/aarch64/int128.rs deleted file mode 100644 index 4535e73eeddf1..0000000000000 --- a/src/unix/linux_like/android/b64/aarch64/int128.rs +++ /dev/null @@ -1,7 +0,0 @@ -s! { - pub struct user_fpsimd_struct { - pub vregs: [::__uint128_t; 32], - pub fpsr: u32, - pub fpcr: u32, - } -} diff --git a/src/unix/linux_like/android/b64/aarch64/mod.rs b/src/unix/linux_like/android/b64/aarch64/mod.rs index 6fdcca6fe1b1b..c7f08340e4eed 100644 --- a/src/unix/linux_like/android/b64/aarch64/mod.rs +++ b/src/unix/linux_like/android/b64/aarch64/mod.rs @@ -76,6 +76,12 @@ s! { // auto-derive traits like Debug __reserved: [[u64; 32]; 16], } + + pub struct user_fpsimd_struct { + pub vregs: [::__uint128_t; 32], + pub fpsr: u32, + pub fpcr: u32, + } } s_no_extra_traits! { @@ -466,6 +472,3 @@ pub const PROT_MTE: ::c_int = 0x20; // From NDK's asm/auxvec.h pub const AT_SYSINFO_EHDR: ::c_ulong = 33; pub const AT_VECTOR_SIZE_ARCH: ::c_ulong = 2; - -mod int128; -pub use self::int128::*; diff --git a/src/unix/linux_like/linux/gnu/b64/aarch64/fallback.rs b/src/unix/linux_like/linux/gnu/b64/aarch64/fallback.rs deleted file mode 100644 index 398fbb53755c8..0000000000000 --- a/src/unix/linux_like/linux/gnu/b64/aarch64/fallback.rs +++ /dev/null @@ -1,8 +0,0 @@ -s! { - #[repr(align(16))] - pub struct user_fpsimd_struct { - pub vregs: [[u64; 2]; 32], - pub fpsr: ::c_uint, - pub fpcr: ::c_uint, - } -} diff --git a/src/unix/linux_like/linux/gnu/b64/aarch64/int128.rs b/src/unix/linux_like/linux/gnu/b64/aarch64/int128.rs deleted file mode 100644 index 4535e73eeddf1..0000000000000 --- a/src/unix/linux_like/linux/gnu/b64/aarch64/int128.rs +++ /dev/null @@ -1,7 +0,0 @@ -s! { - pub struct user_fpsimd_struct { - pub vregs: [::__uint128_t; 32], - pub fpsr: u32, - pub fpcr: u32, - } -} diff --git a/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs b/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs index 1e6e768de2852..5ee559190a8a2 100644 --- a/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs @@ -217,6 +217,12 @@ s! { __reserved: [[u64; 32]; 16], } + pub struct user_fpsimd_struct { + pub vregs: [::__uint128_t; 32], + pub fpsr: ::c_uint, + pub fpcr: ::c_uint, + } + #[repr(align(8))] pub struct clone_args { pub flags: ::c_ulonglong, @@ -964,6 +970,3 @@ cfg_if! { pub use self::lp64::*; } } - -mod int128; -pub use self::int128::*; diff --git a/src/unix/linux_like/linux/musl/b64/aarch64/int128.rs b/src/unix/linux_like/linux/musl/b64/aarch64/int128.rs deleted file mode 100644 index 4535e73eeddf1..0000000000000 --- a/src/unix/linux_like/linux/musl/b64/aarch64/int128.rs +++ /dev/null @@ -1,7 +0,0 @@ -s! { - pub struct user_fpsimd_struct { - pub vregs: [::__uint128_t; 32], - pub fpsr: u32, - pub fpcr: u32, - } -} diff --git a/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs b/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs index 4a85e6f771ee0..74f6af0df169b 100644 --- a/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs @@ -101,6 +101,12 @@ s! { pub set_tid_size: ::c_ulonglong, pub cgroup: ::c_ulonglong, } + + pub struct user_fpsimd_struct { + pub vregs: [::__uint128_t; 32], + pub fpsr: u32, + pub fpcr: u32, + } } s_no_extra_traits! { @@ -686,6 +692,3 @@ pub const VMIN: usize = 6; pub const IEXTEN: ::tcflag_t = 0x00008000; pub const TOSTOP: ::tcflag_t = 0x00000100; pub const FLUSHO: ::tcflag_t = 0x00001000; - -mod int128; -pub use self::int128::*; From 6d894f1380e4295a1fc74c4261a9d0e2647cfa86 Mon Sep 17 00:00:00 2001 From: Josh Triplett Date: Mon, 11 Jul 2022 20:42:11 -0700 Subject: [PATCH 04/10] Require rust >= 1.30 and drop libc_core_cvoid conditional Move the `c_void` re-export to the top-level `lib.rs`. (apply to `main`) (cherry picked from commit e22188720ee261809fccd3b19d15d4e1a404c1dc) Changes are reduced in this cherry pick compared to the original commit because some of this was already applied to `main`. --- src/fuchsia/mod.rs | 4 ++-- src/hermit.rs | 4 ++-- src/lib.rs | 2 ++ src/sgx.rs | 2 -- src/solid/mod.rs | 4 ++-- src/switch.rs | 2 -- src/unix/mod.rs | 4 ++-- src/vxworks/mod.rs | 3 +-- src/wasi/mod.rs | 3 +-- src/windows/mod.rs | 4 ++-- src/xous.rs | 2 -- 11 files changed, 14 insertions(+), 20 deletions(-) diff --git a/src/fuchsia/mod.rs b/src/fuchsia/mod.rs index 9f3c6d94d270c..74234399be918 100644 --- a/src/fuchsia/mod.rs +++ b/src/fuchsia/mod.rs @@ -3,6 +3,8 @@ //! More functions and definitions can be found in the more specific modules //! according to the platform in question. +use c_void; + // PUB_TYPE pub type c_schar = i8; @@ -4486,5 +4488,3 @@ cfg_if! { // Unknown target_arch } } - -pub use ffi::c_void; diff --git a/src/hermit.rs b/src/hermit.rs index 77df54ae12d8d..8e630c38f6b65 100644 --- a/src/hermit.rs +++ b/src/hermit.rs @@ -1,5 +1,7 @@ //! Hermit C type definitions +use c_void; + cfg_if! { if #[cfg(any(target_arch = "aarch64", target_arch = "riscv64"))] { pub type c_char = u8; @@ -576,5 +578,3 @@ extern "C" { #[link_name = "sys_poll"] pub fn poll(fds: *mut pollfd, nfds: nfds_t, timeout: i32) -> i32; } - -pub use ffi::c_void; diff --git a/src/lib.rs b/src/lib.rs index 015b17594545f..488b698556df3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -61,6 +61,8 @@ use core::num; #[allow(unused_imports)] use core::option::Option; +pub use core::ffi::c_void; + cfg_if! { if #[cfg(windows)] { mod fixed_width_ints; diff --git a/src/sgx.rs b/src/sgx.rs index 09cc33eb73589..e37ccd79c3a55 100644 --- a/src/sgx.rs +++ b/src/sgx.rs @@ -25,5 +25,3 @@ pub type c_ulong = u64; pub const INT_MIN: c_int = -2147483648; pub const INT_MAX: c_int = 2147483647; - -pub use ffi::c_void; diff --git a/src/solid/mod.rs b/src/solid/mod.rs index 4c880796340eb..da1ce150b0330 100644 --- a/src/solid/mod.rs +++ b/src/solid/mod.rs @@ -2,6 +2,8 @@ //! //! [SOLID]: https://solid.kmckk.com/ +use c_void; + pub type c_schar = i8; pub type c_uchar = u8; pub type c_short = i16; @@ -871,8 +873,6 @@ extern "C" { pub fn lseek(arg1: c_int, arg2: __off_t, arg3: c_int) -> __off_t; } -pub use ffi::c_void; - cfg_if! { if #[cfg(target_arch = "aarch64")] { mod aarch64; diff --git a/src/switch.rs b/src/switch.rs index 1e8962823af84..4a8b16e15f568 100644 --- a/src/switch.rs +++ b/src/switch.rs @@ -27,5 +27,3 @@ pub type wchar_t = u32; pub const INT_MIN: c_int = -2147483648; pub const INT_MAX: c_int = 2147483647; - -pub use ffi::c_void; diff --git a/src/unix/mod.rs b/src/unix/mod.rs index 6b2df6bcee381..17ee6e591088b 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -3,6 +3,8 @@ //! More functions and definitions can be found in the more specific modules //! according to the platform in question. +use c_void; + pub type c_schar = i8; pub type c_uchar = u8; pub type c_short = i16; @@ -1688,5 +1690,3 @@ cfg_if! { // Unknown target_os } } - -pub use ffi::c_void; diff --git a/src/vxworks/mod.rs b/src/vxworks/mod.rs index 3280eeb7e5a2f..2a8e3b0a60d01 100644 --- a/src/vxworks/mod.rs +++ b/src/vxworks/mod.rs @@ -1,5 +1,6 @@ //! Interface to VxWorks C library +use c_void; use core::mem::size_of; use core::ptr::null_mut; @@ -2013,8 +2014,6 @@ pub unsafe fn posix_memalign( } } -pub use ffi::c_void; - cfg_if! { if #[cfg(target_arch = "aarch64")] { mod aarch64; diff --git a/src/wasi/mod.rs b/src/wasi/mod.rs index 5caf72a1cf9aa..3200442bb761c 100644 --- a/src/wasi/mod.rs +++ b/src/wasi/mod.rs @@ -2,10 +2,9 @@ // `wasi-libc` project provides multiple libraries including emulated features, but we list only basic features with `libc.a` here. use super::{Send, Sync}; +use c_void; use core::iter::Iterator; -pub use ffi::c_void; - pub type c_char = i8; pub type c_uchar = u8; pub type c_schar = i8; diff --git a/src/windows/mod.rs b/src/windows/mod.rs index 8fcdfbede0866..27ecd08822345 100644 --- a/src/windows/mod.rs +++ b/src/windows/mod.rs @@ -1,5 +1,7 @@ //! Windows CRT definitions +use c_void; + pub type c_schar = i8; pub type c_uchar = u8; pub type c_short = i16; @@ -565,8 +567,6 @@ extern "system" { pub fn socket(af: ::c_int, socket_type: ::c_int, protocol: ::c_int) -> SOCKET; } -pub use ffi::c_void; - cfg_if! { if #[cfg(all(target_env = "gnu"))] { mod gnu; diff --git a/src/xous.rs b/src/xous.rs index 6731a94e20df7..4073349306fb9 100644 --- a/src/xous.rs +++ b/src/xous.rs @@ -27,5 +27,3 @@ pub type wchar_t = u32; pub const INT_MIN: c_int = -2147483648; pub const INT_MAX: c_int = 2147483647; - -pub use ffi::c_void; From 5e23131367d9b9ff43db4cf2ec874370fa00477c Mon Sep 17 00:00:00 2001 From: Josh Triplett Date: Mon, 11 Jul 2022 20:46:23 -0700 Subject: [PATCH 05/10] Require rust >= 1.33 and drop libc_packedN conditional [ resolve conflicts, update to latest - Trevor ] (apply to `main`) (cherry picked from commit 9dac79f5a458704180b261cc164920f4cf8cd9d1) Changes are reduced in this cherry pick compared to the original commit because some of this was already applied to `main`. --- src/unix/solarish/illumos.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/unix/solarish/illumos.rs b/src/unix/solarish/illumos.rs index 62a07f6279030..07cc583f43f3d 100644 --- a/src/unix/solarish/illumos.rs +++ b/src/unix/solarish/illumos.rs @@ -46,10 +46,7 @@ s! { } s_no_extra_traits! { - #[cfg_attr(any( - target_arch = "x86", target_arch = "x86_64"), - repr(packed(4)) - )] + #[cfg_attr(any(target_arch = "x86", target_arch = "x86_64"), repr(packed(4)))] pub struct epoll_event { pub events: u32, pub u64: u64, From c75403122839718a0a6be43b88189a451f6663fb Mon Sep 17 00:00:00 2001 From: Josh Triplett Date: Mon, 11 Jul 2022 20:51:02 -0700 Subject: [PATCH 06/10] Require rust >= 1.33 and drop libc_cfg_target_vendor conditional [ resolve conflicts - Trevor ] (apply to `main`) (cherry picked from commit 3d97cdf13383fe93bd1e77ca8a0eed0caac5db18) No changes in this cherry pick, `main` is already up to date. From 45583395c8be2613ad1e7a0db65633c0cd89d9b0 Mon Sep 17 00:00:00 2001 From: Josh Triplett Date: Mon, 11 Jul 2022 20:54:38 -0700 Subject: [PATCH 07/10] Require rust >= 1.40 and drop libc_non_exhaustive conditional [ resolve conflicts - Trevor ] (apply to `main`) (cherry picked from commit d00d1de4ccd1061d30463f361aac777da2796fd6) --- src/unix/linux_like/linux/mod.rs | 11 ++++++++--- src/unix/linux_like/linux/non_exhaustive.rs | 9 --------- 2 files changed, 8 insertions(+), 12 deletions(-) delete mode 100644 src/unix/linux_like/linux/non_exhaustive.rs diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index d03cf2c3bd9ed..cfd0c14cfe91e 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -821,6 +821,14 @@ s! { pub val: ::c_int, } + // linux/openat2.h + #[non_exhaustive] + pub struct open_how { + pub flags: ::__u64, + pub mode: ::__u64, + pub resolve: ::__u64, + } + // linux/sctp.h pub struct sctp_initmsg { @@ -6461,6 +6469,3 @@ cfg_if! { mod arch; pub use self::arch::*; - -mod non_exhaustive; -pub use self::non_exhaustive::*; diff --git a/src/unix/linux_like/linux/non_exhaustive.rs b/src/unix/linux_like/linux/non_exhaustive.rs deleted file mode 100644 index e2e2cb847ac65..0000000000000 --- a/src/unix/linux_like/linux/non_exhaustive.rs +++ /dev/null @@ -1,9 +0,0 @@ -s! { - // linux/openat2.h - #[non_exhaustive] - pub struct open_how { - pub flags: ::__u64, - pub mode: ::__u64, - pub resolve: ::__u64, - } -} From f4bbbc87edb2671c6a23a34b640fc16aa0505808 Mon Sep 17 00:00:00 2001 From: Josh Triplett Date: Mon, 11 Jul 2022 22:34:44 -0700 Subject: [PATCH 08/10] Remove array size hacks for Rust < 1.47 Rust >= 1.47 supports traits for arrays of arbitrary size, so remove the various hacks using nested arrays when the native platform definition uses a single array. (apply to `main`) (cherry picked from commit 27ee6fe02ca0848b2af3cd747536264e4c7b697d) --- libc-test/build.rs | 9 +-------- src/unix/bsd/apple/mod.rs | 4 +--- src/unix/bsd/freebsdlike/dragonfly/mod.rs | 5 ++--- src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs | 2 +- src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs | 2 +- src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs | 2 +- src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs | 2 +- src/unix/bsd/freebsdlike/freebsd/freebsd15/mod.rs | 2 +- src/unix/bsd/freebsdlike/freebsd/mod.rs | 2 +- src/unix/bsd/freebsdlike/mod.rs | 2 +- src/unix/bsd/netbsdlike/netbsd/mod.rs | 2 +- src/unix/linux_like/android/b64/aarch64/mod.rs | 4 +--- src/unix/linux_like/android/mod.rs | 2 +- src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs | 4 +--- src/unix/linux_like/linux/musl/b64/aarch64/mod.rs | 2 +- 15 files changed, 16 insertions(+), 30 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index fe1fc18a33e0f..5c5bba2d360e3 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -382,8 +382,7 @@ fn test_apple(target: &str) { // FIXME: the array size has been changed since macOS 10.15 ([8] -> [7]). ("statfs", "f_reserved") => true, ("__darwin_arm_neon_state64", "__v") => true, - // MAXPATHLEN is too big for auto-derive traits on arrays. - ("vnode_info_path", "vip_path") => true, + ("ifreq", "ifr_ifru") => true, ("in6_ifreq", "ifr_ifru") => true, ("ifkpi", "ifk_data") => true, @@ -2692,8 +2691,6 @@ fn test_freebsd(target: &str) { ("umutex", "m_owner") => true, // c_has_waiters field is a volatile int32_t ("ucond", "c_has_waiters") => true, - // is PATH_MAX long but tests can't accept multi array as equivalent. - ("kinfo_vmentry", "kve_path") => true, // a_un field is a union ("Elf32_Auxinfo", "a_un") => true, @@ -2722,10 +2719,6 @@ fn test_freebsd(target: &str) { // Anonymous type. ("filestat", "next") => true, - // We ignore this field because we needed to use a hack in order to make rust 1.19 - // happy... - ("kinfo_proc", "ki_sparestrings") => true, - // `__sem_base` is a private struct field ("semid_ds", "__sem_base") => true, diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index 1350a0949fd5a..d4be06056291e 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -903,9 +903,7 @@ s! { pub struct vnode_info_path { pub vip_vi: vnode_info, - // Normally it's `vip_path: [::c_char; MAXPATHLEN]` but because libc supports an old rustc - // version, we go around this limitation like this. - pub vip_path: [[::c_char; 32]; 32], + pub vip_path: [::c_char; ::MAXPATHLEN as usize], } pub struct proc_vnodepathinfo { diff --git a/src/unix/bsd/freebsdlike/dragonfly/mod.rs b/src/unix/bsd/freebsdlike/dragonfly/mod.rs index d887b9dcb5cdb..66c81a71b1ca5 100644 --- a/src/unix/bsd/freebsdlike/dragonfly/mod.rs +++ b/src/unix/bsd/freebsdlike/dragonfly/mod.rs @@ -517,7 +517,7 @@ s_no_extra_traits! { pub mc_ownedfp: ::c_uint, __reserved: ::c_uint, __unused: [::c_uint; 8], - pub mc_fpregs: [[::c_uint; 8]; 32], + pub mc_fpregs: [::c_uint; 256], } pub struct ucontext_t { @@ -786,8 +786,7 @@ cfg_if! { self.mc_len == other.mc_len && self.mc_fpformat == other.mc_fpformat && self.mc_ownedfp == other.mc_ownedfp && - self.mc_fpregs.iter().zip(other.mc_fpregs.iter()). - all(|(a, b)| a == b) + self.mc_fpregs == other.mc_fpregs } } impl Eq for mcontext_t {} diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs index e416ebf745841..44f48ab5ceb47 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs @@ -166,7 +166,7 @@ s! { /// More thread name. pub ki_moretdname: [::c_char; ::MAXCOMLEN - ::TDNAMLEN + 1], /// Spare string space. - pub ki_sparestrings: [[::c_char; 23]; 2], // little hack to allow PartialEq + pub ki_sparestrings: [::c_char; 46], /// Spare room for growth. pub ki_spareints: [::c_int; ::KI_NSPARE_INT], /// Which cpu we are on. diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs index c4431a6458e8f..a16f1d13915c8 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs @@ -173,7 +173,7 @@ s! { /// More thread name. pub ki_moretdname: [::c_char; ::MAXCOMLEN - ::TDNAMLEN + 1], /// Spare string space. - pub ki_sparestrings: [[::c_char; 23]; 2], // little hack to allow PartialEq + pub ki_sparestrings: [::c_char; 46], /// Spare room for growth. pub ki_spareints: [::c_int; ::KI_NSPARE_INT], /// Controlling tty dev. diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs index e6cc1fad0b591..d97606787b67e 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs @@ -183,7 +183,7 @@ s! { /// More thread name. pub ki_moretdname: [::c_char; ::MAXCOMLEN - ::TDNAMLEN + 1], /// Spare string space. - pub ki_sparestrings: [[::c_char; 23]; 2], // little hack to allow PartialEq + pub ki_sparestrings: [::c_char; 46], /// Spare room for growth. pub ki_spareints: [::c_int; ::KI_NSPARE_INT], /// Controlling tty dev. diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs index 1c58bb4b5afcf..6a46efaa6144c 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs @@ -183,7 +183,7 @@ s! { /// More thread name. pub ki_moretdname: [::c_char; ::MAXCOMLEN - ::TDNAMLEN + 1], /// Spare string space. - pub ki_sparestrings: [[::c_char; 23]; 2], // little hack to allow PartialEq + pub ki_sparestrings: [::c_char; 46], /// Spare room for growth. pub ki_spareints: [::c_int; ::KI_NSPARE_INT], /// Controlling tty dev. diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd15/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd15/mod.rs index 00ea22a041a7d..ac8e33382dd57 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd15/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd15/mod.rs @@ -183,7 +183,7 @@ s! { /// More thread name. pub ki_moretdname: [::c_char; ::MAXCOMLEN - ::TDNAMLEN + 1], /// Spare string space. - pub ki_sparestrings: [[::c_char; 23]; 2], // little hack to allow PartialEq + pub ki_sparestrings: [::c_char; 46], /// Spare room for growth. pub ki_spareints: [::c_int; ::KI_NSPARE_INT], /// Controlling tty dev. diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs index 408487c6308c7..780c7df7d44e1 100644 --- a/src/unix/bsd/freebsdlike/freebsd/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs @@ -458,7 +458,7 @@ s! { _kve_is_spare: [::c_int; 8], #[cfg(freebsd11)] _kve_is_spare: [::c_int; 12], - pub kve_path: [[::c_char; 32]; 32], + pub kve_path: [::c_char; ::PATH_MAX as usize], } pub struct __c_anonymous_filestat { diff --git a/src/unix/bsd/freebsdlike/mod.rs b/src/unix/bsd/freebsdlike/mod.rs index 6ef1e33fef207..48cd60a917333 100644 --- a/src/unix/bsd/freebsdlike/mod.rs +++ b/src/unix/bsd/freebsdlike/mod.rs @@ -284,7 +284,7 @@ s! { pub struct accept_filter_arg { pub af_name: [::c_char; 16], - af_arg: [[::c_char; 10]; 24], + af_arg: [::c_char; 240], } pub struct ptrace_io_desc { diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index 0921d56912cd2..4997a19af49ae 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -663,7 +663,7 @@ s! { pub kve_vn_rdev: u64, pub kve_vn_type: u32, pub kve_vn_mode: u32, - pub kve_path: [[::c_char; 32]; 32], + pub kve_path: [::c_char; ::PATH_MAX as usize], } pub struct __c_anonymous_posix_spawn_fae_open { diff --git a/src/unix/linux_like/android/b64/aarch64/mod.rs b/src/unix/linux_like/android/b64/aarch64/mod.rs index c7f08340e4eed..9587770e8cb2c 100644 --- a/src/unix/linux_like/android/b64/aarch64/mod.rs +++ b/src/unix/linux_like/android/b64/aarch64/mod.rs @@ -72,9 +72,7 @@ s! { 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], + __reserved: [u64; 512], } pub struct user_fpsimd_struct { diff --git a/src/unix/linux_like/android/mod.rs b/src/unix/linux_like/android/mod.rs index 4dbd25d2b214b..b543bb739e0e5 100644 --- a/src/unix/linux_like/android/mod.rs +++ b/src/unix/linux_like/android/mod.rs @@ -635,7 +635,7 @@ s_no_extra_traits! { pub struct prop_info { __name: [::c_char; 32], __serial: ::c_uint, - __value: [[::c_char; 4]; 23], + __value: [::c_char; 92], } pub union __c_anonymous_ifr_ifru { 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 5ee559190a8a2..f0babb8d3d71f 100644 --- a/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs @@ -212,9 +212,7 @@ s! { 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], + __reserved: [u64; 512], } pub struct user_fpsimd_struct { 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 74f6af0df169b..d5c02419135e0 100644 --- a/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs @@ -84,7 +84,7 @@ s! { pub sp: ::c_ulong, pub pc: ::c_ulong, pub pstate: ::c_ulong, - __reserved: [[u64; 32]; 16], + __reserved: [u64; 512], } #[repr(align(8))] From f41e395f943a849dda1d23e309ab73fb447ac5aa Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Sat, 16 Nov 2024 14:30:02 -0600 Subject: [PATCH 09/10] Fix a few other array size hacks Sources: * FreeBSD `__reserve_pad`: [1] * NetBSD `accept_filter_arg`: https://man.netbsd.org/setsockopt.2 [1]: https://github.com/freebsd/freebsd-src/blob/4b4e88d9425b59a377a71ffeb553376b1c60a80e/sys/netinet/sctp_uio.h#L110-L146 (apply to `main`) (cherry picked from commit d63be8b69b0736753213f5d933767866a5801ee7) --- src/unix/bsd/freebsdlike/freebsd/mod.rs | 9 +++++++-- src/unix/bsd/netbsdlike/netbsd/mod.rs | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs index 780c7df7d44e1..fd176ce9efab7 100644 --- a/src/unix/bsd/freebsdlike/freebsd/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs @@ -1153,7 +1153,7 @@ s! { pub sinfo_assoc_id: ::sctp_assoc_t, pub sinfo_keynumber: u16, pub sinfo_keynumber_valid: u16, - pub __reserve_pad: [[u8; 23]; 4], + pub __reserve_pad: [u8; SCTP_ALIGN_RESV_PAD], } pub struct sctp_extrcvinfo { @@ -1173,7 +1173,7 @@ s! { pub serinfo_next_ppid: u32, pub sinfo_keynumber: u16, pub sinfo_keynumber_valid: u16, - pub __reserve_pad: [[u8; 19]; 4], + pub __reserve_pad: [u8; SCTP_ALIGN_RESV_PAD_SHORT], } pub struct sctp_sndinfo { @@ -4881,6 +4881,11 @@ pub const SCTP_ASSOC_RESET_FAILED: ::c_int = 0x0008; pub const SCTP_STREAM_CHANGE_DENIED: ::c_int = 0x0004; pub const SCTP_STREAM_CHANGE_FAILED: ::c_int = 0x0008; +// sctp_uio.h + +pub const SCTP_ALIGN_RESV_PAD: usize = 92; +pub const SCTP_ALIGN_RESV_PAD_SHORT: usize = 76; + pub const KENV_DUMP_LOADER: ::c_int = 4; pub const KENV_DUMP_STATIC: ::c_int = 5; diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index 4997a19af49ae..f9bf0e51258c2 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -512,7 +512,7 @@ s! { pub struct accept_filter_arg { pub af_name: [::c_char; 16], - af_arg: [[::c_char; 10]; 24], + pub af_arg: [::c_char; 256 - 16], } pub struct ki_sigset_t { From e855f2fb37277c0ef3202fdae45efa818592594e Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Sat, 16 Nov 2024 14:51:42 -0600 Subject: [PATCH 10/10] Drop the `ptr_addr_of` conditional This is possible since increasing the MSRV to 1.63 (apply to `main`) (cherry picked from commit 85eac5f1ed25df02b99787a1a13eb6269fbf836d) --- src/macros.rs | 6 ------ src/wasi/mod.rs | 8 ++++---- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/macros.rs b/src/macros.rs index 2344551840f26..e64f035576e60 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -273,9 +273,3 @@ macro_rules! __item { $i }; } - -macro_rules! ptr_addr_of { - ($place:expr) => { - ::core::ptr::addr_of!($place) - }; -} diff --git a/src/wasi/mod.rs b/src/wasi/mod.rs index 3200442bb761c..a7d05919195f4 100644 --- a/src/wasi/mod.rs +++ b/src/wasi/mod.rs @@ -382,16 +382,16 @@ cfg_if! { // unsafe code here is required in the stable, but not in nightly #[allow(unused_unsafe)] pub static CLOCK_MONOTONIC: clockid_t = - unsafe { clockid_t(ptr_addr_of!(_CLOCK_MONOTONIC)) }; + clockid_t(core::ptr::addr_of!(_CLOCK_MONOTONIC)); #[allow(unused_unsafe)] pub static CLOCK_PROCESS_CPUTIME_ID: clockid_t = - unsafe { clockid_t(ptr_addr_of!(_CLOCK_PROCESS_CPUTIME_ID)) }; + clockid_t(core::ptr::addr_of!(_CLOCK_PROCESS_CPUTIME_ID)); #[allow(unused_unsafe)] pub static CLOCK_REALTIME: clockid_t = - unsafe { clockid_t(ptr_addr_of!(_CLOCK_REALTIME)) }; + clockid_t(core::ptr::addr_of!(_CLOCK_REALTIME)); #[allow(unused_unsafe)] pub static CLOCK_THREAD_CPUTIME_ID: clockid_t = - unsafe { clockid_t(ptr_addr_of!(_CLOCK_THREAD_CPUTIME_ID)) }; + clockid_t(core::ptr::addr_of!(_CLOCK_THREAD_CPUTIME_ID)); } }