From 6ab19868f9cda29e36f614e2afed5f6ec1d60c86 Mon Sep 17 00:00:00 2001 From: Andy Caldwell Date: Thu, 1 Jun 2023 17:52:34 +0100 Subject: [PATCH 1/7] Unify definitions of statvfs and statfs in musl target --- src/unix/linux_like/linux/musl/b32/arm/mod.rs | 16 ----- src/unix/linux_like/linux/musl/b32/hexagon.rs | 16 ----- .../linux_like/linux/musl/b32/mips/mod.rs | 19 ------ src/unix/linux_like/linux/musl/b32/powerpc.rs | 19 ------ .../linux_like/linux/musl/b32/riscv32/mod.rs | 31 ---------- src/unix/linux_like/linux/musl/b32/x86/mod.rs | 16 ----- src/unix/linux_like/linux/musl/b64/mips64.rs | 30 --------- src/unix/linux_like/linux/musl/b64/mod.rs | 45 +++++--------- .../linux_like/linux/musl/b64/riscv64/mod.rs | 62 ------------------- src/unix/linux_like/linux/musl/b64/s390x.rs | 30 --------- src/unix/linux_like/linux/musl/mod.rs | 22 +++++++ 11 files changed, 37 insertions(+), 269 deletions(-) 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..5079d8c597af6 100644 --- a/src/unix/linux_like/linux/musl/b32/arm/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/arm/mod.rs @@ -135,22 +135,6 @@ s! { pub f_spare: [::c_ulong; 4], } - pub struct statvfs64 { - pub f_bsize: ::c_ulong, - pub f_frsize: ::c_ulong, - pub f_blocks: u64, - pub f_bfree: u64, - pub f_bavail: u64, - pub f_files: u64, - pub f_ffree: u64, - pub f_favail: u64, - pub f_fsid: ::c_ulong, - __f_unused: ::c_int, - pub f_flag: ::c_ulong, - pub f_namemax: ::c_ulong, - __f_spare: [::c_int; 6], - } - pub struct mcontext_t { pub trap_no: ::c_ulong, pub error_code: ::c_ulong, diff --git a/src/unix/linux_like/linux/musl/b32/hexagon.rs b/src/unix/linux_like/linux/musl/b32/hexagon.rs index 089c06f859e6b..0b7297abd4883 100644 --- a/src/unix/linux_like/linux/musl/b32/hexagon.rs +++ b/src/unix/linux_like/linux/musl/b32/hexagon.rs @@ -113,22 +113,6 @@ s! { pub f_flags: ::c_ulong, pub f_spare: [::c_ulong; 4], } - - pub struct statvfs64 { - pub f_bsize: ::c_ulong, - pub f_frsize: ::c_ulong, - pub f_blocks: u64, - pub f_bfree: u64, - pub f_bavail: u64, - pub f_files: u64, - pub f_ffree: u64, - pub f_favail: u64, - pub f_fsid: ::c_ulong, - __f_unused: ::c_int, - pub f_flag: ::c_ulong, - pub f_namemax: ::c_ulong, - __f_spare: [::c_int; 6], - } } pub const AF_FILE: ::c_int = 1; 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..1687a390e441a 100644 --- a/src/unix/linux_like/linux/musl/b32/mips/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/mips/mod.rs @@ -142,25 +142,6 @@ s! { pub f_flags: ::c_ulong, pub f_spare: [::c_ulong; 5], } - - pub struct statvfs64 { - pub f_bsize: ::c_ulong, - pub f_frsize: ::c_ulong, - pub f_blocks: u64, - pub f_bfree: u64, - pub f_bavail: u64, - pub f_files: u64, - pub f_ffree: u64, - pub f_favail: u64, - #[cfg(target_endian = "little")] - pub f_fsid: ::c_ulong, - __f_unused: ::c_int, - #[cfg(target_endian = "big")] - pub f_fsid: ::c_ulong, - pub f_flag: ::c_ulong, - pub f_namemax: ::c_ulong, - __f_spare: [::c_int; 6], - } } pub const SIGSTKSZ: ::size_t = 8192; diff --git a/src/unix/linux_like/linux/musl/b32/powerpc.rs b/src/unix/linux_like/linux/musl/b32/powerpc.rs index 834a442802b27..8c100ccb68a80 100644 --- a/src/unix/linux_like/linux/musl/b32/powerpc.rs +++ b/src/unix/linux_like/linux/musl/b32/powerpc.rs @@ -134,25 +134,6 @@ s! { pub f_flags: ::c_ulong, pub f_spare: [::c_ulong; 4], } - - pub struct statvfs64 { - pub f_bsize: ::c_ulong, - pub f_frsize: ::c_ulong, - pub f_blocks: u64, - pub f_bfree: u64, - pub f_bavail: u64, - pub f_files: u64, - pub f_ffree: u64, - pub f_favail: u64, - #[cfg(target_endian = "little")] - pub f_fsid: ::c_ulong, - __f_unused: ::c_int, - #[cfg(target_endian = "big")] - pub f_fsid: ::c_ulong, - pub f_flag: ::c_ulong, - pub f_namemax: ::c_ulong, - __f_spare: [::c_int; 6], - } } pub const MADV_SOFT_OFFLINE: ::c_int = 101; 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..96fed4e113ead 100644 --- a/src/unix/linux_like/linux/musl/b32/riscv32/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/riscv32/mod.rs @@ -67,21 +67,6 @@ s! { pub f_spare: [::c_long; 4], } - pub struct statvfs { - pub f_bsize: ::c_ulong, - pub f_frsize: ::c_ulong, - pub f_blocks: ::fsblkcnt_t, - pub f_bfree: ::fsblkcnt_t, - pub f_bavail: ::fsblkcnt_t, - pub f_files: ::fsfilcnt_t, - pub f_ffree: ::fsfilcnt_t, - pub f_favail: ::fsfilcnt_t, - pub f_fsid: ::c_ulong, - pub f_flag: ::c_ulong, - pub f_namemax: ::c_ulong, - pub __f_spare: [::c_int; 6], - } - pub struct statfs64 { pub f_type: ::c_ulong, pub f_bsize: ::c_ulong, @@ -97,22 +82,6 @@ s! { pub f_spare: [::c_ulong; 4], } - pub struct statvfs64 { - pub f_bsize: ::c_ulong, - pub f_frsize: ::c_ulong, - pub f_blocks: u64, - pub f_bfree: u64, - pub f_bavail: u64, - pub f_files: u64, - pub f_ffree: u64, - pub f_favail: u64, - pub f_fsid: ::c_ulong, - __f_unused: ::c_int, - pub f_flag: ::c_ulong, - pub f_namemax: ::c_ulong, - __f_spare: [::c_int; 6], - } - pub struct siginfo_t { pub si_signo: ::c_int, pub si_errno: ::c_int, 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..a6938d064aef9 100644 --- a/src/unix/linux_like/linux/musl/b32/x86/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/x86/mod.rs @@ -138,22 +138,6 @@ s! { pub f_flags: ::c_ulong, pub f_spare: [::c_ulong; 4], } - - pub struct statvfs64 { - pub f_bsize: ::c_ulong, - pub f_frsize: ::c_ulong, - pub f_blocks: u64, - pub f_bfree: u64, - pub f_bavail: u64, - pub f_files: u64, - pub f_ffree: u64, - pub f_favail: u64, - pub f_fsid: ::c_ulong, - __f_unused: ::c_int, - pub f_flag: ::c_ulong, - pub f_namemax: ::c_ulong, - __f_spare: [::c_int; 6], - } } s_no_extra_traits! { diff --git a/src/unix/linux_like/linux/musl/b64/mips64.rs b/src/unix/linux_like/linux/musl/b64/mips64.rs index 18fa6c664c81d..cb576e24dd590 100644 --- a/src/unix/linux_like/linux/musl/b64/mips64.rs +++ b/src/unix/linux_like/linux/musl/b64/mips64.rs @@ -54,36 +54,6 @@ s! { __pad5: [::c_int; 14], } - pub struct statfs { - pub f_type: ::c_ulong, - pub f_bsize: ::c_ulong, - pub f_blocks: ::fsblkcnt_t, - pub f_bfree: ::fsblkcnt_t, - pub f_bavail: ::fsblkcnt_t, - pub f_files: ::fsfilcnt_t, - pub f_ffree: ::fsfilcnt_t, - pub f_fsid: ::fsid_t, - pub f_namelen: ::c_ulong, - pub f_frsize: ::c_ulong, - pub f_flags: ::c_ulong, - pub f_spare: [::c_ulong; 5], - } - - pub struct statfs64 { - pub f_type: ::c_ulong, - pub f_bsize: ::c_ulong, - pub f_blocks: ::fsblkcnt_t, - pub f_bfree: ::fsblkcnt_t, - pub f_bavail: ::fsblkcnt_t, - pub f_files: ::fsfilcnt_t, - pub f_ffree: ::fsfilcnt_t, - pub f_fsid: ::fsid_t, - pub f_namelen: ::c_ulong, - pub f_frsize: ::c_ulong, - pub f_flags: ::c_ulong, - pub f_spare: [::c_ulong; 5], - } - pub struct ipc_perm { pub __ipc_perm_key: ::key_t, pub uid: ::uid_t, diff --git a/src/unix/linux_like/linux/musl/b64/mod.rs b/src/unix/linux_like/linux/musl/b64/mod.rs index d59343064c52e..55207497370ab 100644 --- a/src/unix/linux_like/linux/musl/b64/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/mod.rs @@ -3,36 +3,6 @@ pub type c_ulong = u64; pub type regoff_t = ::c_long; s! { - pub struct statfs64 { - pub f_type: ::c_ulong, - pub f_bsize: ::c_ulong, - pub f_blocks: ::fsblkcnt_t, - pub f_bfree: ::fsblkcnt_t, - pub f_bavail: ::fsblkcnt_t, - pub f_files: ::fsfilcnt_t, - pub f_ffree: ::fsfilcnt_t, - pub f_fsid: ::fsid_t, - pub f_namelen: ::c_ulong, - pub f_frsize: ::c_ulong, - pub f_flags: ::c_ulong, - pub f_spare: [::c_ulong; 4], - } - - pub struct statvfs64 { - pub f_bsize: ::c_ulong, - pub f_frsize: ::c_ulong, - pub f_blocks: u64, - pub f_bfree: u64, - pub f_bavail: u64, - pub f_files: u64, - pub f_ffree: u64, - pub f_favail: u64, - pub f_fsid: ::c_ulong, - pub f_flag: ::c_ulong, - pub f_namemax: ::c_ulong, - __f_spare: [::c_int; 6], - } - pub struct stack_t { pub ss_sp: *mut ::c_void, pub ss_flags: ::c_int, @@ -89,6 +59,21 @@ s! { pub f_spare: [::c_ulong; 4], } + pub struct statfs64 { + pub f_type: ::c_ulong, + pub f_bsize: ::c_ulong, + pub f_blocks: ::fsblkcnt64_t, + pub f_bfree: ::fsblkcnt64_t, + pub f_bavail: ::fsblkcnt64_t, + pub f_files: ::fsfilcnt64_t, + pub f_ffree: ::fsfilcnt64_t, + pub f_fsid: ::fsid_t, + pub f_namelen: ::c_ulong, + pub f_frsize: ::c_ulong, + pub f_flags: ::c_ulong, + pub f_spare: [::c_ulong; 4], + } + pub struct msghdr { pub msg_name: *mut ::c_void, pub msg_namelen: ::socklen_t, 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 2a37bd976bc7c..557c6d7959077 100644 --- a/src/unix/linux_like/linux/musl/b64/riscv64/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/riscv64/mod.rs @@ -5,8 +5,6 @@ pub type wchar_t = ::c_int; pub type nlink_t = ::c_uint; pub type blksize_t = ::c_int; -pub type fsblkcnt64_t = ::c_ulong; -pub type fsfilcnt64_t = ::c_ulong; pub type __u64 = ::c_ulonglong; pub type __s64 = ::c_longlong; @@ -59,66 +57,6 @@ s! { __unused: [::c_int; 2], } - pub struct statfs { - pub f_type: ::c_long, - pub f_bsize: ::c_long, - pub f_blocks: ::fsblkcnt_t, - pub f_bfree: ::fsblkcnt_t, - pub f_bavail: ::fsblkcnt_t, - pub f_files: ::fsfilcnt_t, - pub f_ffree: ::fsfilcnt_t, - pub f_fsid: ::fsid_t, - pub f_namelen: ::c_long, - pub f_frsize: ::c_long, - pub f_flags: ::c_long, - pub f_spare: [::c_long; 4], - } - - pub struct statfs64 { - pub f_type: ::c_long, - pub f_bsize: ::c_long, - pub f_blocks: ::fsblkcnt64_t, - pub f_bfree: ::fsblkcnt64_t, - pub f_bavail: ::fsblkcnt64_t, - pub f_files: ::fsfilcnt64_t, - pub f_ffree: ::fsfilcnt64_t, - pub f_fsid: ::fsid_t, - pub f_namelen: ::c_long, - pub f_frsize: ::c_long, - pub f_flags: ::c_long, - pub f_spare: [::c_long; 4], - } - - pub struct statvfs { - pub f_bsize: ::c_ulong, - pub f_frsize: ::c_ulong, - pub f_blocks: ::fsblkcnt_t, - pub f_bfree: ::fsblkcnt_t, - pub f_bavail: ::fsblkcnt_t, - pub f_files: ::fsfilcnt_t, - pub f_ffree: ::fsfilcnt_t, - pub f_favail: ::fsfilcnt_t, - pub f_fsid: ::c_ulong, - pub f_flag: ::c_ulong, - pub f_namemax: ::c_ulong, - pub __f_spare: [::c_int; 6], - } - - pub struct statvfs64 { - pub f_bsize: ::c_ulong, - pub f_frsize: ::c_ulong, - pub f_blocks: ::fsblkcnt64_t, - pub f_bfree: ::fsblkcnt64_t, - pub f_bavail: ::fsblkcnt64_t, - pub f_files: ::fsfilcnt64_t, - pub f_ffree: ::fsfilcnt64_t, - pub f_favail: ::fsfilcnt64_t, - pub f_fsid: ::c_ulong, - pub f_flag: ::c_ulong, - pub f_namemax: ::c_ulong, - pub __f_spare: [::c_int; 6], - } - pub struct siginfo_t { pub si_signo: ::c_int, pub si_errno: ::c_int, diff --git a/src/unix/linux_like/linux/musl/b64/s390x.rs b/src/unix/linux_like/linux/musl/b64/s390x.rs index 567914f7b8cd5..0111681eaf298 100644 --- a/src/unix/linux_like/linux/musl/b64/s390x.rs +++ b/src/unix/linux_like/linux/musl/b64/s390x.rs @@ -58,36 +58,6 @@ s! { pub st_blocks: ::blkcnt64_t, __unused: [::c_long; 3], } - - pub struct statfs { - pub f_type: ::c_uint, - pub f_bsize: ::c_uint, - pub f_blocks: ::fsblkcnt_t, - pub f_bfree: ::fsblkcnt_t, - pub f_bavail: ::fsblkcnt_t, - pub f_files: ::fsfilcnt_t, - pub f_ffree: ::fsfilcnt_t, - pub f_fsid: ::fsid_t, - pub f_namelen: ::c_uint, - pub f_frsize: ::c_uint, - pub f_flags: ::c_uint, - pub f_spare: [::c_uint; 4], - } - - pub struct statfs64 { - pub f_type: ::c_uint, - pub f_bsize: ::c_uint, - pub f_blocks: ::fsblkcnt_t, - pub f_bfree: ::fsblkcnt_t, - pub f_bavail: ::fsblkcnt_t, - pub f_files: ::fsfilcnt_t, - pub f_ffree: ::fsfilcnt_t, - pub f_fsid: ::fsid_t, - pub f_namelen: ::c_uint, - pub f_frsize: ::c_uint, - pub f_flags: ::c_uint, - pub f_spare: [::c_uint; 4], - } } s_no_extra_traits! { diff --git a/src/unix/linux_like/linux/musl/mod.rs b/src/unix/linux_like/linux/musl/mod.rs index a37da7d24c314..f2af23d8bdeb8 100644 --- a/src/unix/linux_like/linux/musl/mod.rs +++ b/src/unix/linux_like/linux/musl/mod.rs @@ -19,7 +19,9 @@ pub type shmatt_t = ::c_ulong; pub type msgqnum_t = ::c_ulong; pub type msglen_t = ::c_ulong; pub type fsblkcnt_t = ::c_ulonglong; +pub type fsblkcnt64_t = ::c_ulonglong; pub type fsfilcnt_t = ::c_ulonglong; +pub type fsfilcnt64_t = ::c_ulonglong; pub type rlim_t = ::c_ulonglong; cfg_if! { @@ -164,6 +166,26 @@ s! { __f_spare: [::c_int; 6], } + pub struct statvfs64 { + pub f_bsize: ::c_ulong, + pub f_frsize: ::c_ulong, + pub f_blocks: ::fsblkcnt64_t, + pub f_bfree: ::fsblkcnt64_t, + pub f_bavail: ::fsblkcnt64_t, + pub f_files: ::fsfilcnt64_t, + pub f_ffree: ::fsfilcnt64_t, + pub f_favail: ::fsfilcnt64_t, + #[cfg(target_endian = "little")] + pub f_fsid: ::c_ulong, + #[cfg(target_pointer_width = "32")] + __f_unused: ::c_int, + #[cfg(target_endian = "big")] + pub f_fsid: ::c_ulong, + pub f_flag: ::c_ulong, + pub f_namemax: ::c_ulong, + __f_spare: [::c_int; 6], + } + pub struct termios { pub c_iflag: ::tcflag_t, pub c_oflag: ::tcflag_t, From 86b0b827620a4d569a2894968c072d33f39e975c Mon Sep 17 00:00:00 2001 From: Andy Caldwell Date: Thu, 1 Jun 2023 19:01:34 +0100 Subject: [PATCH 2/7] Remove all redundant definitions in musl backend --- src/unix/linux_like/linux/musl/b32/arm/mod.rs | 8 -- src/unix/linux_like/linux/musl/b32/hexagon.rs | 8 -- .../linux_like/linux/musl/b32/mips/mod.rs | 8 -- src/unix/linux_like/linux/musl/b32/powerpc.rs | 8 -- .../linux_like/linux/musl/b32/riscv32/mod.rs | 101 ------------------ src/unix/linux_like/linux/musl/b32/x86/mod.rs | 8 -- src/unix/linux_like/linux/musl/b64/mod.rs | 8 -- .../linux_like/linux/musl/b64/riscv64/mod.rs | 45 -------- src/unix/linux_like/linux/musl/mod.rs | 15 +++ 9 files changed, 15 insertions(+), 194 deletions(-) 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 5079d8c597af6..9e8721f02d657 100644 --- a/src/unix/linux_like/linux/musl/b32/arm/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/arm/mod.rs @@ -112,14 +112,6 @@ s! { pub f_spare: [::c_ulong; 4], } - pub struct siginfo_t { - pub si_signo: ::c_int, - pub si_errno: ::c_int, - pub si_code: ::c_int, - pub _pad: [::c_int; 29], - _align: [usize; 0], - } - pub struct statfs64 { pub f_type: ::c_ulong, pub f_bsize: ::c_ulong, diff --git a/src/unix/linux_like/linux/musl/b32/hexagon.rs b/src/unix/linux_like/linux/musl/b32/hexagon.rs index 0b7297abd4883..5aec89bc6d088 100644 --- a/src/unix/linux_like/linux/musl/b32/hexagon.rs +++ b/src/unix/linux_like/linux/musl/b32/hexagon.rs @@ -91,14 +91,6 @@ s! { pub f_spare: [::c_ulong; 4], } - pub struct siginfo_t { - pub si_signo: ::c_int, - pub si_errno: ::c_int, - pub si_code: ::c_int, - pub _pad: [::c_int; 29], - _align: [usize; 0], - } - pub struct statfs64 { pub f_type: ::c_ulong, pub f_bsize: ::c_ulong, 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 1687a390e441a..dbb60e3e24d30 100644 --- a/src/unix/linux_like/linux/musl/b32/mips/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/mips/mod.rs @@ -120,14 +120,6 @@ s! { pub f_spare: [::c_ulong; 5], } - pub struct siginfo_t { - pub si_signo: ::c_int, - pub si_code: ::c_int, - pub si_errno: ::c_int, - pub _pad: [::c_int; 29], - _align: [usize; 0], - } - pub struct statfs64 { pub f_type: ::c_ulong, pub f_bsize: ::c_ulong, diff --git a/src/unix/linux_like/linux/musl/b32/powerpc.rs b/src/unix/linux_like/linux/musl/b32/powerpc.rs index 8c100ccb68a80..45958e65ab7b5 100644 --- a/src/unix/linux_like/linux/musl/b32/powerpc.rs +++ b/src/unix/linux_like/linux/musl/b32/powerpc.rs @@ -112,14 +112,6 @@ s! { pub f_spare: [::c_ulong; 4], } - pub struct siginfo_t { - pub si_signo: ::c_int, - pub si_errno: ::c_int, - pub si_code: ::c_int, - pub _pad: [::c_int; 29], - _align: [usize; 0], - } - pub struct statfs64 { pub f_type: ::c_ulong, pub f_bsize: ::c_ulong, 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 96fed4e113ead..8f1ee6b0bbe35 100644 --- a/src/unix/linux_like/linux/musl/b32/riscv32/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/riscv32/mod.rs @@ -4,10 +4,6 @@ pub type c_char = u8; pub type wchar_t = ::c_int; s! { - pub struct pthread_attr_t { - __size: [::c_ulong; 7], - } - pub struct stat { pub st_dev: ::dev_t, pub st_ino: ::ino_t, @@ -82,34 +78,12 @@ s! { pub f_spare: [::c_ulong; 4], } - pub struct siginfo_t { - pub si_signo: ::c_int, - pub si_errno: ::c_int, - pub si_code: ::c_int, - #[doc(hidden)] - #[deprecated( - since="0.2.54", - note="Please leave a comment on \ - https://github.com/rust-lang/libc/pull/1316 if you're using \ - this field" - )] - pub _pad: [::c_int; 29], - _align: [u64; 0], - } - pub struct stack_t { pub ss_sp: *mut ::c_void, pub ss_flags: ::c_int, pub ss_size: ::size_t, } - pub struct sigaction { - pub sa_sigaction: ::sighandler_t, - pub sa_mask: ::sigset_t, - pub sa_flags: ::c_int, - pub sa_restorer: ::Option, - } - pub struct ipc_perm { pub __key: ::key_t, pub uid: ::uid_t, @@ -158,12 +132,6 @@ s! { //pub const RLIM_INFINITY: ::rlim_t = !0; pub const VEOF: usize = 4; pub const RTLD_DEEPBIND: ::c_int = 0x8; -pub const RTLD_GLOBAL: ::c_int = 0x100; -pub const RTLD_NOLOAD: ::c_int = 0x4; -pub const TIOCGSOFTCAR: ::c_ulong = 21529; -pub const TIOCSSOFTCAR: ::c_ulong = 21530; -pub const TIOCGRS485: ::c_int = 21550; -pub const TIOCSRS485: ::c_int = 21551; //pub const RLIMIT_RSS: ::__rlimit_resource_t = 5; //pub const RLIMIT_AS: ::__rlimit_resource_t = 9; //pub const RLIMIT_MEMLOCK: ::__rlimit_resource_t = 8; @@ -290,38 +258,12 @@ pub const SIG_UNBLOCK: ::c_int = 1; pub const POLLWRNORM: ::c_short = 256; pub const POLLWRBAND: ::c_short = 512; pub const O_ASYNC: ::c_int = 8192; -pub const O_NDELAY: ::c_int = 2048; -pub const EFD_NONBLOCK: ::c_int = 2048; pub const F_SETOWN: ::c_int = 8; pub const F_GETOWN: ::c_int = 9; pub const F_GETLK: ::c_int = 12; pub const F_SETLK: ::c_int = 13; pub const F_SETLKW: ::c_int = 14; -pub const SFD_NONBLOCK: ::c_int = 2048; -pub const TCSANOW: ::c_int = 0; -pub const TCSADRAIN: ::c_int = 1; -pub const TCSAFLUSH: ::c_int = 2; -pub const TIOCLINUX: ::c_ulong = 21532; -pub const TIOCGSERIAL: ::c_ulong = 21534; -pub const TIOCEXCL: ::c_ulong = 21516; -pub const TIOCNXCL: ::c_ulong = 21517; -pub const TIOCSCTTY: ::c_ulong = 21518; -pub const TIOCSTI: ::c_ulong = 21522; -pub const TIOCMGET: ::c_ulong = 21525; -pub const TIOCMBIS: ::c_ulong = 21526; -pub const TIOCMBIC: ::c_ulong = 21527; -pub const TIOCMSET: ::c_ulong = 21528; -pub const TIOCCONS: ::c_ulong = 21533; -pub const TIOCM_ST: ::c_int = 8; -pub const TIOCM_SR: ::c_int = 16; -pub const TIOCM_CTS: ::c_int = 32; -pub const TIOCM_CAR: ::c_int = 64; -pub const TIOCM_RNG: ::c_int = 128; -pub const TIOCM_DSR: ::c_int = 256; -pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4; -pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4; -pub const __SIZEOF_PTHREAD_BARRIERATTR_T: usize = 4; pub const O_DIRECT: ::c_int = 16384; pub const O_DIRECTORY: ::c_int = 65536; pub const O_LARGEFILE: ::c_int = 0o0100000; @@ -330,7 +272,6 @@ pub const MAP_HUGETLB: ::c_int = 262144; pub const MAP_LOCKED: ::c_int = 8192; pub const MAP_NORESERVE: ::c_int = 16384; pub const MAP_ANON: ::c_int = 32; -pub const MAP_ANONYMOUS: ::c_int = 32; pub const MAP_DENYWRITE: ::c_int = 2048; pub const MAP_EXECUTABLE: ::c_int = 4096; pub const MAP_POPULATE: ::c_int = 32768; @@ -343,9 +284,6 @@ pub const ENOTNAM: ::c_int = 118; pub const ENAVAIL: ::c_int = 119; pub const EISNAM: ::c_int = 120; pub const EREMOTEIO: ::c_int = 121; -pub const FIOCLEX: ::c_int = 21585; -pub const FIONCLEX: ::c_int = 21584; -pub const FIONBIO: ::c_int = 21537; pub const MCL_CURRENT: ::c_int = 1; pub const MCL_FUTURE: ::c_int = 2; pub const MCL_ONFAULT: ::c_int = 4; @@ -402,24 +340,6 @@ pub const BSDLY: ::tcflag_t = 8192; pub const FFDLY: ::tcflag_t = 32768; pub const VTDLY: ::tcflag_t = 16384; pub const XTABS: ::tcflag_t = 6144; -pub const B0: ::speed_t = 0; -pub const B50: ::speed_t = 1; -pub const B75: ::speed_t = 2; -pub const B110: ::speed_t = 3; -pub const B134: ::speed_t = 4; -pub const B150: ::speed_t = 5; -pub const B200: ::speed_t = 6; -pub const B300: ::speed_t = 7; -pub const B600: ::speed_t = 8; -pub const B1200: ::speed_t = 9; -pub const B1800: ::speed_t = 10; -pub const B2400: ::speed_t = 11; -pub const B4800: ::speed_t = 12; -pub const B9600: ::speed_t = 13; -pub const B19200: ::speed_t = 14; -pub const B38400: ::speed_t = 15; -pub const EXTA: ::speed_t = 14; -pub const EXTB: ::speed_t = 15; pub const B57600: ::speed_t = 4097; pub const B115200: ::speed_t = 4098; pub const B230400: ::speed_t = 4099; @@ -442,27 +362,6 @@ pub const IEXTEN: ::tcflag_t = 32768; pub const TOSTOP: ::tcflag_t = 256; pub const FLUSHO: ::tcflag_t = 4096; pub const EXTPROC: ::tcflag_t = 65536; -pub const TCGETS: ::c_int = 21505; -pub const TCSETS: ::c_int = 21506; -pub const TCSETSW: ::c_int = 21507; -pub const TCSETSF: ::c_int = 21508; -pub const TCGETA: ::c_int = 21509; -pub const TCSETA: ::c_int = 21510; -pub const TCSETAW: ::c_int = 21511; -pub const TCSETAF: ::c_int = 21512; -pub const TCSBRK: ::c_int = 21513; -pub const TCXONC: ::c_int = 21514; -pub const TCFLSH: ::c_int = 21515; -pub const TIOCINQ: ::c_int = 21531; -pub const TIOCGPGRP: ::c_int = 21519; -pub const TIOCSPGRP: ::c_int = 21520; -pub const TIOCOUTQ: ::c_int = 21521; -pub const TIOCGWINSZ: ::c_int = 21523; -pub const TIOCSWINSZ: ::c_int = 21524; -pub const FIONREAD: ::c_int = 21531; -pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40; -pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56; -pub const __SIZEOF_PTHREAD_BARRIER_T: usize = 32; pub const SYS_read: ::c_long = 63; pub const SYS_write: ::c_long = 64; 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 a6938d064aef9..dbb2349ed4d90 100644 --- a/src/unix/linux_like/linux/musl/b32/x86/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/x86/mod.rs @@ -116,14 +116,6 @@ s! { __private: [u32; 22] } - pub struct siginfo_t { - pub si_signo: ::c_int, - pub si_errno: ::c_int, - pub si_code: ::c_int, - pub _pad: [::c_int; 29], - _align: [usize; 0], - } - pub struct statfs64 { pub f_type: ::c_ulong, pub f_bsize: ::c_ulong, diff --git a/src/unix/linux_like/linux/musl/b64/mod.rs b/src/unix/linux_like/linux/musl/b64/mod.rs index 55207497370ab..effd78d2ccdd4 100644 --- a/src/unix/linux_like/linux/musl/b64/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/mod.rs @@ -105,14 +105,6 @@ s! { pub struct sem_t { __val: [::c_int; 8], } - - pub struct siginfo_t { - pub si_signo: ::c_int, - pub si_errno: ::c_int, - pub si_code: ::c_int, - pub _pad: [::c_int; 29], - _align: [usize; 0], - } } pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56; 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 557c6d7959077..927a132b3012c 100644 --- a/src/unix/linux_like/linux/musl/b64/riscv64/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/riscv64/mod.rs @@ -9,10 +9,6 @@ pub type __u64 = ::c_ulonglong; pub type __s64 = ::c_longlong; s! { - pub struct pthread_attr_t { - __size: [::c_ulong; 7], - } - pub struct stat { pub st_dev: ::dev_t, pub st_ino: ::ino_t, @@ -57,34 +53,6 @@ s! { __unused: [::c_int; 2], } - pub struct siginfo_t { - pub si_signo: ::c_int, - pub si_errno: ::c_int, - pub si_code: ::c_int, - #[doc(hidden)] - #[deprecated( - since="0.2.54", - note="Please leave a comment on \ - https://github.com/rust-lang/libc/pull/1316 if you're using \ - this field" - )] - pub _pad: [::c_int; 29], - _align: [u64; 0], - } - - pub struct stack_t { - pub ss_sp: *mut ::c_void, - pub ss_flags: ::c_int, - pub ss_size: ::size_t, - } - - pub struct sigaction { - pub sa_sigaction: ::sighandler_t, - pub sa_mask: ::sigset_t, - pub sa_flags: ::c_int, - pub sa_restorer: ::Option, - } - pub struct ipc_perm { pub __key: ::key_t, pub uid: ::uid_t, @@ -98,19 +66,6 @@ s! { __unused1: ::c_ulong, __unused2: ::c_ulong, } - - pub struct shmid_ds { - pub shm_perm: ::ipc_perm, - pub shm_segsz: ::size_t, - pub shm_atime: ::time_t, - pub shm_dtime: ::time_t, - pub shm_ctime: ::time_t, - pub shm_cpid: ::pid_t, - pub shm_lpid: ::pid_t, - pub shm_nattch: ::shmatt_t, - __unused5: ::c_ulong, - __unused6: ::c_ulong, - } } pub const SYS_read: ::c_long = 63; diff --git a/src/unix/linux_like/linux/musl/mod.rs b/src/unix/linux_like/linux/musl/mod.rs index f2af23d8bdeb8..40126771b54d0 100644 --- a/src/unix/linux_like/linux/musl/mod.rs +++ b/src/unix/linux_like/linux/musl/mod.rs @@ -146,6 +146,21 @@ s! { pub sa_restorer: ::Option, } + pub struct siginfo_t { + pub si_signo: ::c_int, + pub si_errno: ::c_int, + pub si_code: ::c_int, + #[doc(hidden)] + #[deprecated( + since="0.2.54", + note="Please leave a comment on \ + https://github.com/rust-lang/libc/pull/1316 if you're using \ + this field" + )] + pub _pad: [::c_int; 29], + _align: [usize; 0], + } + pub struct statvfs { pub f_bsize: ::c_ulong, pub f_frsize: ::c_ulong, From 50d9fd29ee702756aa7ba598996028c4b248f0d3 Mon Sep 17 00:00:00 2001 From: Andy Caldwell Date: Mon, 5 Jun 2023 21:19:55 +0100 Subject: [PATCH 3/7] Fix up siginfo_t for mips targets --- src/unix/linux_like/linux/musl/mod.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/unix/linux_like/linux/musl/mod.rs b/src/unix/linux_like/linux/musl/mod.rs index 40126771b54d0..183702010bc1d 100644 --- a/src/unix/linux_like/linux/musl/mod.rs +++ b/src/unix/linux_like/linux/musl/mod.rs @@ -146,10 +146,15 @@ s! { pub sa_restorer: ::Option, } + // `mips*` targets swap the `s_errno` and `s_code` fields otherwise this struct is + // target-agnostic (see https://www.openwall.com/lists/musl/2016/01/27/1/2) pub struct siginfo_t { pub si_signo: ::c_int, + #[cfg(not(target_arch = "mips"))] pub si_errno: ::c_int, pub si_code: ::c_int, + #[cfg(target_arch = "mips")] + pub si_errno: ::c_int, #[doc(hidden)] #[deprecated( since="0.2.54", From 04c09ae1b178bae882dbfd337fdb11565482c175 Mon Sep 17 00:00:00 2001 From: Andy Caldwell Date: Tue, 6 Jun 2023 22:48:38 +0100 Subject: [PATCH 4/7] Only mips uses a special statfs(64) --- src/unix/linux_like/linux/musl/b32/arm/mod.rs | 30 --------------- src/unix/linux_like/linux/musl/b32/hexagon.rs | 30 --------------- src/unix/linux_like/linux/musl/b32/powerpc.rs | 30 --------------- .../linux_like/linux/musl/b32/riscv32/mod.rs | 30 --------------- src/unix/linux_like/linux/musl/b32/x86/mod.rs | 38 ++----------------- src/unix/linux_like/linux/musl/b64/mips64.rs | 30 +++++++++++++++ src/unix/linux_like/linux/musl/b64/mod.rs | 30 --------------- src/unix/linux_like/linux/musl/mod.rs | 36 ++++++++++++++++++ 8 files changed, 70 insertions(+), 184 deletions(-) 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 9e8721f02d657..d001b879a0546 100644 --- a/src/unix/linux_like/linux/musl/b32/arm/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/arm/mod.rs @@ -97,36 +97,6 @@ s! { __pad2: ::c_ulong, } - pub struct statfs { - pub f_type: ::c_ulong, - pub f_bsize: ::c_ulong, - pub f_blocks: ::fsblkcnt_t, - pub f_bfree: ::fsblkcnt_t, - pub f_bavail: ::fsblkcnt_t, - pub f_files: ::fsfilcnt_t, - pub f_ffree: ::fsfilcnt_t, - pub f_fsid: ::fsid_t, - pub f_namelen: ::c_ulong, - pub f_frsize: ::c_ulong, - pub f_flags: ::c_ulong, - pub f_spare: [::c_ulong; 4], - } - - pub struct statfs64 { - pub f_type: ::c_ulong, - pub f_bsize: ::c_ulong, - pub f_blocks: ::fsblkcnt_t, - pub f_bfree: ::fsblkcnt_t, - pub f_bavail: ::fsblkcnt_t, - pub f_files: ::fsfilcnt_t, - pub f_ffree: ::fsfilcnt_t, - pub f_fsid: ::fsid_t, - pub f_namelen: ::c_ulong, - pub f_frsize: ::c_ulong, - pub f_flags: ::c_ulong, - pub f_spare: [::c_ulong; 4], - } - pub struct mcontext_t { pub trap_no: ::c_ulong, pub error_code: ::c_ulong, diff --git a/src/unix/linux_like/linux/musl/b32/hexagon.rs b/src/unix/linux_like/linux/musl/b32/hexagon.rs index 5aec89bc6d088..7a89ca00f2041 100644 --- a/src/unix/linux_like/linux/musl/b32/hexagon.rs +++ b/src/unix/linux_like/linux/musl/b32/hexagon.rs @@ -75,36 +75,6 @@ s! { __pad1: ::c_ulong, __pad2: ::c_ulong, } - - pub struct statfs { - pub f_type: ::c_ulong, - pub f_bsize: ::c_ulong, - pub f_blocks: ::fsblkcnt_t, - pub f_bfree: ::fsblkcnt_t, - pub f_bavail: ::fsblkcnt_t, - pub f_files: ::fsfilcnt_t, - pub f_ffree: ::fsfilcnt_t, - pub f_fsid: ::fsid_t, - pub f_namelen: ::c_ulong, - pub f_frsize: ::c_ulong, - pub f_flags: ::c_ulong, - pub f_spare: [::c_ulong; 4], - } - - pub struct statfs64 { - pub f_type: ::c_ulong, - pub f_bsize: ::c_ulong, - pub f_blocks: ::fsblkcnt_t, - pub f_bfree: ::fsblkcnt_t, - pub f_bavail: ::fsblkcnt_t, - pub f_files: ::fsfilcnt_t, - pub f_ffree: ::fsfilcnt_t, - pub f_fsid: ::fsid_t, - pub f_namelen: ::c_ulong, - pub f_frsize: ::c_ulong, - pub f_flags: ::c_ulong, - pub f_spare: [::c_ulong; 4], - } } pub const AF_FILE: ::c_int = 1; diff --git a/src/unix/linux_like/linux/musl/b32/powerpc.rs b/src/unix/linux_like/linux/musl/b32/powerpc.rs index 45958e65ab7b5..95d837e9fcb73 100644 --- a/src/unix/linux_like/linux/musl/b32/powerpc.rs +++ b/src/unix/linux_like/linux/musl/b32/powerpc.rs @@ -96,36 +96,6 @@ s! { __pad1: ::c_ulong, __pad2: ::c_ulong, } - - pub struct statfs { - pub f_type: ::c_ulong, - pub f_bsize: ::c_ulong, - pub f_blocks: ::fsblkcnt_t, - pub f_bfree: ::fsblkcnt_t, - pub f_bavail: ::fsblkcnt_t, - pub f_files: ::fsfilcnt_t, - pub f_ffree: ::fsfilcnt_t, - pub f_fsid: ::fsid_t, - pub f_namelen: ::c_ulong, - pub f_frsize: ::c_ulong, - pub f_flags: ::c_ulong, - pub f_spare: [::c_ulong; 4], - } - - pub struct statfs64 { - pub f_type: ::c_ulong, - pub f_bsize: ::c_ulong, - pub f_blocks: ::fsblkcnt_t, - pub f_bfree: ::fsblkcnt_t, - pub f_bavail: ::fsblkcnt_t, - pub f_files: ::fsfilcnt_t, - pub f_ffree: ::fsfilcnt_t, - pub f_fsid: ::fsid_t, - pub f_namelen: ::c_ulong, - pub f_frsize: ::c_ulong, - pub f_flags: ::c_ulong, - pub f_spare: [::c_ulong; 4], - } } pub const MADV_SOFT_OFFLINE: ::c_int = 101; 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 8f1ee6b0bbe35..675e21369f0ca 100644 --- a/src/unix/linux_like/linux/musl/b32/riscv32/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/riscv32/mod.rs @@ -48,36 +48,6 @@ s! { __unused: [::c_int; 2], } - pub struct statfs { - pub f_type: ::c_long, - pub f_bsize: ::c_long, - pub f_blocks: ::fsblkcnt_t, - pub f_bfree: ::fsblkcnt_t, - pub f_bavail: ::fsblkcnt_t, - pub f_files: ::fsfilcnt_t, - pub f_ffree: ::fsfilcnt_t, - pub f_fsid: ::fsid_t, - pub f_namelen: ::c_long, - pub f_frsize: ::c_long, - pub f_flags: ::c_long, - pub f_spare: [::c_long; 4], - } - - pub struct statfs64 { - pub f_type: ::c_ulong, - pub f_bsize: ::c_ulong, - pub f_blocks: ::fsblkcnt_t, - pub f_bfree: ::fsblkcnt_t, - pub f_bavail: ::fsblkcnt_t, - pub f_files: ::fsfilcnt_t, - pub f_ffree: ::fsfilcnt_t, - pub f_fsid: ::fsid_t, - pub f_namelen: ::c_ulong, - pub f_frsize: ::c_ulong, - pub f_flags: ::c_ulong, - pub f_spare: [::c_ulong; 4], - } - pub struct stack_t { pub ss_sp: *mut ::c_void, pub ss_flags: ::c_int, 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 dbb2349ed4d90..ba0c6758739a1 100644 --- a/src/unix/linux_like/linux/musl/b32/x86/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/x86/mod.rs @@ -46,6 +46,10 @@ s! { pub st_ino: ::ino_t, } + pub struct mcontext_t { + __private: [u32; 22] + } + pub struct stack_t { pub ss_sp: *mut ::c_void, pub ss_flags: ::c_int, @@ -96,40 +100,6 @@ s! { __pad1: ::c_ulong, __pad2: ::c_ulong, } - - pub struct statfs { - pub f_type: ::c_ulong, - pub f_bsize: ::c_ulong, - pub f_blocks: ::fsblkcnt_t, - pub f_bfree: ::fsblkcnt_t, - pub f_bavail: ::fsblkcnt_t, - pub f_files: ::fsfilcnt_t, - pub f_ffree: ::fsfilcnt_t, - pub f_fsid: ::fsid_t, - pub f_namelen: ::c_ulong, - pub f_frsize: ::c_ulong, - pub f_flags: ::c_ulong, - pub f_spare: [::c_ulong; 4], - } - - pub struct mcontext_t { - __private: [u32; 22] - } - - pub struct statfs64 { - pub f_type: ::c_ulong, - pub f_bsize: ::c_ulong, - pub f_blocks: ::fsblkcnt_t, - pub f_bfree: ::fsblkcnt_t, - pub f_bavail: ::fsblkcnt_t, - pub f_files: ::fsfilcnt_t, - pub f_ffree: ::fsfilcnt_t, - pub f_fsid: ::fsid_t, - pub f_namelen: ::c_ulong, - pub f_frsize: ::c_ulong, - pub f_flags: ::c_ulong, - pub f_spare: [::c_ulong; 4], - } } s_no_extra_traits! { diff --git a/src/unix/linux_like/linux/musl/b64/mips64.rs b/src/unix/linux_like/linux/musl/b64/mips64.rs index cb576e24dd590..c39024f195fe7 100644 --- a/src/unix/linux_like/linux/musl/b64/mips64.rs +++ b/src/unix/linux_like/linux/musl/b64/mips64.rs @@ -54,6 +54,36 @@ s! { __pad5: [::c_int; 14], } + pub struct statfs { + pub f_type: ::c_ulong, + pub f_bsize: ::c_ulong, + pub f_frsize: ::c_ulong, + pub f_blocks: ::fsblkcnt_t, + pub f_bfree: ::fsblkcnt_t, + pub f_files: ::fsfilcnt_t, + pub f_ffree: ::fsfilcnt_t, + pub f_bavail: ::fsblkcnt_t, + pub f_fsid: ::fsid_t, + pub f_namelen: ::c_ulong, + pub f_flags: ::c_ulong, + pub f_spare: [::c_ulong; 5], + } + + pub struct statfs64 { + pub f_type: ::c_ulong, + pub f_bsize: ::c_ulong, + pub f_frsize: ::c_ulong, + pub f_blocks: ::fsblkcnt64_t, + pub f_bfree: ::fsblkcnt64_t, + pub f_files: ::fsfilcnt64_t, + pub f_ffree: ::fsfilcnt64_t, + pub f_bavail: ::fsblkcnt64_t, + pub f_fsid: ::fsid_t, + pub f_namelen: ::c_ulong, + pub f_flags: ::c_ulong, + pub f_spare: [::c_ulong; 5], + } + pub struct ipc_perm { pub __ipc_perm_key: ::key_t, pub uid: ::uid_t, diff --git a/src/unix/linux_like/linux/musl/b64/mod.rs b/src/unix/linux_like/linux/musl/b64/mod.rs index effd78d2ccdd4..0077fb79b069a 100644 --- a/src/unix/linux_like/linux/musl/b64/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/mod.rs @@ -44,36 +44,6 @@ s! { __pad2: ::c_ulong, } - pub struct statfs { - pub f_type: ::c_ulong, - pub f_bsize: ::c_ulong, - pub f_blocks: ::fsblkcnt_t, - pub f_bfree: ::fsblkcnt_t, - pub f_bavail: ::fsblkcnt_t, - pub f_files: ::fsfilcnt_t, - pub f_ffree: ::fsfilcnt_t, - pub f_fsid: ::fsid_t, - pub f_namelen: ::c_ulong, - pub f_frsize: ::c_ulong, - pub f_flags: ::c_ulong, - pub f_spare: [::c_ulong; 4], - } - - pub struct statfs64 { - pub f_type: ::c_ulong, - pub f_bsize: ::c_ulong, - pub f_blocks: ::fsblkcnt64_t, - pub f_bfree: ::fsblkcnt64_t, - pub f_bavail: ::fsblkcnt64_t, - pub f_files: ::fsfilcnt64_t, - pub f_ffree: ::fsfilcnt64_t, - pub f_fsid: ::fsid_t, - pub f_namelen: ::c_ulong, - pub f_frsize: ::c_ulong, - pub f_flags: ::c_ulong, - pub f_spare: [::c_ulong; 4], - } - pub struct msghdr { pub msg_name: *mut ::c_void, pub msg_namelen: ::socklen_t, diff --git a/src/unix/linux_like/linux/musl/mod.rs b/src/unix/linux_like/linux/musl/mod.rs index 183702010bc1d..0c1c851b49732 100644 --- a/src/unix/linux_like/linux/musl/mod.rs +++ b/src/unix/linux_like/linux/musl/mod.rs @@ -455,6 +455,42 @@ s! { } } +cfg_if! { + if #[cfg(not(target_arch = "mips"))] { + s! { + pub struct statfs { + pub f_type: ::c_ulong, + pub f_bsize: ::c_ulong, + pub f_blocks: ::fsblkcnt_t, + pub f_bfree: ::fsblkcnt_t, + pub f_bavail: ::fsblkcnt_t, + pub f_files: ::fsfilcnt_t, + pub f_ffree: ::fsfilcnt_t, + pub f_fsid: ::fsid_t, + pub f_namelen: ::c_ulong, + pub f_frsize: ::c_ulong, + pub f_flags: ::c_ulong, + pub f_spare: [::c_ulong; 4], + } + + pub struct statfs64 { + pub f_type: ::c_ulong, + pub f_bsize: ::c_ulong, + pub f_blocks: ::fsblkcnt64_t, + pub f_bfree: ::fsblkcnt64_t, + pub f_bavail: ::fsblkcnt64_t, + pub f_files: ::fsfilcnt64_t, + pub f_ffree: ::fsfilcnt64_t, + pub f_fsid: ::fsid_t, + pub f_namelen: ::c_ulong, + pub f_frsize: ::c_ulong, + pub f_flags: ::c_ulong, + pub f_spare: [::c_ulong; 4], + } + } + } +} + s_no_extra_traits! { pub struct sysinfo { pub uptime: ::c_ulong, From 2199836191055a58a6d07fc97a6332e44f04f94f Mon Sep 17 00:00:00 2001 From: Andy Caldwell Date: Fri, 27 Sep 2024 18:37:13 +0100 Subject: [PATCH 5/7] Add fanotify_event_info_fid to FAM-exempt types --- libc-test/build.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index 938294717eee3..dcbb6508bbefa 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -4488,11 +4488,11 @@ fn test_linux(target: &str) { true } - // The `inotify_event` and `cmsghdr` types contain Flexible Array Member fields (the - // `name` and `data` fields respectively) which have unspecified calling convention. - // The roundtripping tests deliberately pass the structs by value to check "by value" - // layout consistency, but this would be UB for the these types. + // The following types contain Flexible Array Member fields which have unspecified calling + // convention. The roundtripping tests deliberately pass the structs by value to check "by + // value" layout consistency, but this would be UB for the these types. "inotify_event" => true, + "fanotify_event_info_fid" => true, "cmsghdr" => true, // FIXME: the call ABI of max_align_t is incorrect on these platforms: From 1cf4443a7f146565536968754d9ce83ea7cbf91c Mon Sep 17 00:00:00 2001 From: Andy Caldwell Date: Fri, 27 Sep 2024 18:37:56 +0100 Subject: [PATCH 6/7] Allow cfg attributes in s! and use it for mips-special statfs structure --- src/macros.rs | 25 ++--------- src/unix/linux_like/linux/musl/mod.rs | 64 +++++++++++++-------------- 2 files changed, 35 insertions(+), 54 deletions(-) diff --git a/src/macros.rs b/src/macros.rs index 7090e6d1d1538..49104d640b939 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -82,16 +82,11 @@ macro_rules! s { __item! { #[repr(C)] #[cfg_attr(feature = "extra_traits", derive(Debug, Eq, Hash, PartialEq))] + #[derive(Copy, Clone)] #[allow(deprecated)] $(#[$attr])* pub struct $i { $($field)* } } - #[allow(deprecated)] - impl ::Copy for $i {} - #[allow(deprecated)] - impl ::Clone for $i { - fn clone(&self) -> $i { *self } - } ); } @@ -106,13 +101,10 @@ macro_rules! s_paren { )*) => ($( __item! { #[cfg_attr(feature = "extra_traits", derive(Debug, Eq, Hash, PartialEq))] + #[derive(Copy, Clone)] $(#[$attr])* pub struct $i ( $($field)* ); } - impl ::Copy for $i {} - impl ::Clone for $i { - fn clone(&self) -> $i { *self } - } )*); } @@ -131,27 +123,18 @@ macro_rules! s_no_extra_traits { __item! { #[repr(C)] $(#[$attr])* + #[derive(Copy, Clone)] pub union $i { $($field)* } } - - impl ::Copy for $i {} - impl ::Clone for $i { - fn clone(&self) -> $i { *self } - } ); (it: $(#[$attr:meta])* pub struct $i:ident { $($field:tt)* }) => ( __item! { #[repr(C)] $(#[$attr])* + #[derive(Copy, Clone)] pub struct $i { $($field)* } } - #[allow(deprecated)] - impl ::Copy for $i {} - #[allow(deprecated)] - impl ::Clone for $i { - fn clone(&self) -> $i { *self } - } ); } diff --git a/src/unix/linux_like/linux/musl/mod.rs b/src/unix/linux_like/linux/musl/mod.rs index 0c1c851b49732..499d7edfa811e 100644 --- a/src/unix/linux_like/linux/musl/mod.rs +++ b/src/unix/linux_like/linux/musl/mod.rs @@ -453,41 +453,39 @@ s! { //pub tcpi_rcv_ooopack: u32, //pub tcpi_snd_wnd: u32, } -} -cfg_if! { - if #[cfg(not(target_arch = "mips"))] { - s! { - pub struct statfs { - pub f_type: ::c_ulong, - pub f_bsize: ::c_ulong, - pub f_blocks: ::fsblkcnt_t, - pub f_bfree: ::fsblkcnt_t, - pub f_bavail: ::fsblkcnt_t, - pub f_files: ::fsfilcnt_t, - pub f_ffree: ::fsfilcnt_t, - pub f_fsid: ::fsid_t, - pub f_namelen: ::c_ulong, - pub f_frsize: ::c_ulong, - pub f_flags: ::c_ulong, - pub f_spare: [::c_ulong; 4], - } + // MIPS implementation is special (see mips arch folders) + #[cfg(not(target_arch = "mips"))] + pub struct statfs { + pub f_type: ::c_ulong, + pub f_bsize: ::c_ulong, + pub f_blocks: ::fsblkcnt_t, + pub f_bfree: ::fsblkcnt_t, + pub f_bavail: ::fsblkcnt_t, + pub f_files: ::fsfilcnt_t, + pub f_ffree: ::fsfilcnt_t, + pub f_fsid: ::fsid_t, + pub f_namelen: ::c_ulong, + pub f_frsize: ::c_ulong, + pub f_flags: ::c_ulong, + pub f_spare: [::c_ulong; 4], + } - pub struct statfs64 { - pub f_type: ::c_ulong, - pub f_bsize: ::c_ulong, - pub f_blocks: ::fsblkcnt64_t, - pub f_bfree: ::fsblkcnt64_t, - pub f_bavail: ::fsblkcnt64_t, - pub f_files: ::fsfilcnt64_t, - pub f_ffree: ::fsfilcnt64_t, - pub f_fsid: ::fsid_t, - pub f_namelen: ::c_ulong, - pub f_frsize: ::c_ulong, - pub f_flags: ::c_ulong, - pub f_spare: [::c_ulong; 4], - } - } + // MIPS implementation is special (see mips arch folders) + #[cfg(not(target_arch = "mips"))] + pub struct statfs64 { + pub f_type: ::c_ulong, + pub f_bsize: ::c_ulong, + pub f_blocks: ::fsblkcnt64_t, + pub f_bfree: ::fsblkcnt64_t, + pub f_bavail: ::fsblkcnt64_t, + pub f_files: ::fsfilcnt64_t, + pub f_ffree: ::fsfilcnt64_t, + pub f_fsid: ::fsid_t, + pub f_namelen: ::c_ulong, + pub f_frsize: ::c_ulong, + pub f_flags: ::c_ulong, + pub f_spare: [::c_ulong; 4], } } From d7887af698930758749e9c81b06a7e804bb67f97 Mon Sep 17 00:00:00 2001 From: Andy Caldwell Date: Sun, 6 Oct 2024 04:12:33 +0100 Subject: [PATCH 7/7] Remove new redundant definitions --- .../linux_like/linux/gnu/b32/riscv32/mod.rs | 41 ------------------- .../linux_like/linux/gnu/b32/sparc/mod.rs | 36 ---------------- .../linux/musl/b64/loongarch64/mod.rs | 34 --------------- src/unix/linux_like/linux/musl/b64/mips64.rs | 30 -------------- 4 files changed, 141 deletions(-) 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..fae2e72230464 100644 --- a/src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs @@ -4,10 +4,6 @@ pub type c_char = u8; pub type wchar_t = ::c_int; s! { - pub struct pthread_attr_t { - __size: [::c_ulong; 7], - } - pub struct msqid_ds { pub msg_perm: ::ipc_perm, pub msg_stime: ::time_t, @@ -22,28 +18,6 @@ s! { __glibc_reserved5: ::c_ulong, } - pub struct stat { - pub st_dev: ::dev_t, - pub st_ino: ::ino_t, - pub st_mode: ::mode_t, - pub st_nlink: ::nlink_t, - pub st_uid: ::uid_t, - pub st_gid: ::gid_t, - pub st_rdev: ::dev_t, - pub __pad1: ::dev_t, - pub st_size: ::off_t, - pub st_blksize: ::blksize_t, - pub __pad2: ::c_int, - pub st_blocks: ::blkcnt_t, - pub st_atime: ::time_t, - pub st_atime_nsec: ::c_long, - pub st_mtime: ::time_t, - pub st_mtime_nsec: ::c_long, - pub st_ctime: ::time_t, - pub st_ctime_nsec: ::c_long, - __unused: [::c_int; 2usize], - } - pub struct stat64 { pub st_dev: ::dev_t, pub st_ino: ::ino64_t, @@ -96,21 +70,6 @@ s! { pub f_spare: [::c_long; 4], } - pub struct statvfs { - pub f_bsize: ::c_ulong, - pub f_frsize: ::c_ulong, - pub f_blocks: ::fsblkcnt_t, - pub f_bfree: ::fsblkcnt_t, - pub f_bavail: ::fsblkcnt_t, - pub f_files: ::fsfilcnt_t, - pub f_ffree: ::fsfilcnt_t, - pub f_favail: ::fsfilcnt_t, - pub f_fsid: ::c_ulong, - pub f_flag: ::c_ulong, - pub f_namemax: ::c_ulong, - pub __f_spare: [::c_int; 6], - } - pub struct statvfs64 { pub f_bsize: ::c_ulong, pub f_frsize: ::c_ulong, 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..3fff11ba3d1bc 100644 --- a/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs @@ -58,27 +58,6 @@ s! { pub ss_size: ::size_t } - pub struct stat { - pub st_dev: ::dev_t, - pub st_ino: ::ino64_t, - pub st_mode: ::mode_t, - pub st_nlink: ::nlink_t, - pub st_uid: ::uid_t, - pub st_gid: ::gid_t, - pub st_rdev: ::dev_t, - __pad2: ::c_ushort, - pub st_size: ::off64_t, - pub st_blksize: ::blksize_t, - pub st_blocks: ::blkcnt64_t, - pub st_atime: ::time_t, - pub st_atime_nsec: ::c_long, - pub st_mtime: ::time_t, - pub st_mtime_nsec: ::c_long, - pub st_ctime: ::time_t, - pub st_ctime_nsec: ::c_long, - __unused: [::c_long; 2], - } - pub struct stat64 { pub st_dev: ::dev_t, pub st_ino: ::ino64_t, @@ -115,21 +94,6 @@ s! { pub f_spare: [::__fsword_t; 4], } - pub struct statvfs { - pub f_bsize: ::c_ulong, - pub f_frsize: ::c_ulong, - pub f_blocks: ::fsblkcnt_t, - pub f_bfree: ::fsblkcnt_t, - pub f_bavail: ::fsblkcnt_t, - pub f_files: ::fsfilcnt_t, - pub f_ffree: ::fsfilcnt_t, - pub f_favail: ::fsfilcnt_t, - pub f_fsid: ::c_ulong, - pub f_flag: ::c_ulong, - pub f_namemax: ::c_ulong, - __f_spare: [::c_int; 6], - } - pub struct statvfs64 { pub f_bsize: ::c_ulong, pub f_frsize: ::c_ulong, 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..5aac893571864 100644 --- a/src/unix/linux_like/linux/musl/b64/loongarch64/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/loongarch64/mod.rs @@ -11,10 +11,6 @@ pub type __u64 = ::c_ulonglong; pub type __s64 = ::c_longlong; s! { - pub struct pthread_attr_t { - __size: [::c_ulong; 7], - } - pub struct stat { pub st_dev: ::dev_t, pub st_ino: ::ino_t, @@ -59,36 +55,6 @@ s! { __unused: [::c_int; 2], } - pub struct statfs { - pub f_type: ::c_long, - pub f_bsize: ::c_long, - pub f_blocks: ::fsblkcnt_t, - pub f_bfree: ::fsblkcnt_t, - pub f_bavail: ::fsblkcnt_t, - pub f_files: ::fsfilcnt_t, - pub f_ffree: ::fsfilcnt_t, - pub f_fsid: ::fsid_t, - pub f_namelen: ::c_long, - pub f_frsize: ::c_long, - pub f_flags: ::c_long, - pub f_spare: [::c_long; 4], - } - - pub struct statfs64 { - pub f_type: ::c_long, - pub f_bsize: ::c_long, - pub f_blocks: ::fsblkcnt64_t, - pub f_bfree: ::fsblkcnt64_t, - pub f_bavail: ::fsblkcnt64_t, - pub f_files: ::fsfilcnt64_t, - pub f_ffree: ::fsfilcnt64_t, - pub f_fsid: ::fsid_t, - pub f_namelen: ::c_long, - pub f_frsize: ::c_long, - pub f_flags: ::c_long, - pub f_spare: [::c_long; 4], - } - pub struct ipc_perm { pub __key: ::key_t, pub uid: ::uid_t, diff --git a/src/unix/linux_like/linux/musl/b64/mips64.rs b/src/unix/linux_like/linux/musl/b64/mips64.rs index c39024f195fe7..cb576e24dd590 100644 --- a/src/unix/linux_like/linux/musl/b64/mips64.rs +++ b/src/unix/linux_like/linux/musl/b64/mips64.rs @@ -54,36 +54,6 @@ s! { __pad5: [::c_int; 14], } - pub struct statfs { - pub f_type: ::c_ulong, - pub f_bsize: ::c_ulong, - pub f_frsize: ::c_ulong, - pub f_blocks: ::fsblkcnt_t, - pub f_bfree: ::fsblkcnt_t, - pub f_files: ::fsfilcnt_t, - pub f_ffree: ::fsfilcnt_t, - pub f_bavail: ::fsblkcnt_t, - pub f_fsid: ::fsid_t, - pub f_namelen: ::c_ulong, - pub f_flags: ::c_ulong, - pub f_spare: [::c_ulong; 5], - } - - pub struct statfs64 { - pub f_type: ::c_ulong, - pub f_bsize: ::c_ulong, - pub f_frsize: ::c_ulong, - pub f_blocks: ::fsblkcnt64_t, - pub f_bfree: ::fsblkcnt64_t, - pub f_files: ::fsfilcnt64_t, - pub f_ffree: ::fsfilcnt64_t, - pub f_bavail: ::fsblkcnt64_t, - pub f_fsid: ::fsid_t, - pub f_namelen: ::c_ulong, - pub f_flags: ::c_ulong, - pub f_spare: [::c_ulong; 5], - } - pub struct ipc_perm { pub __ipc_perm_key: ::key_t, pub uid: ::uid_t,