Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unify definitions of siginfo_t, statvfs and statfs in musl targets #3261

Merged
merged 7 commits into from
Nov 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 0 additions & 41 deletions src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs
Original file line number Diff line number Diff line change
@@ -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,
36 changes: 0 additions & 36 deletions src/unix/linux_like/linux/gnu/b32/sparc/mod.rs
Original file line number Diff line number Diff line change
@@ -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,
54 changes: 0 additions & 54 deletions src/unix/linux_like/linux/musl/b32/arm/mod.rs
Original file line number Diff line number Diff line change
@@ -97,60 +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 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,
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,
__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,
54 changes: 0 additions & 54 deletions src/unix/linux_like/linux/musl/b32/hexagon.rs
Original file line number Diff line number Diff line change
@@ -74,60 +74,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 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,
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,
__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;
27 changes: 0 additions & 27 deletions src/unix/linux_like/linux/musl/b32/mips/mod.rs
Original file line number Diff line number Diff line change
@@ -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,
@@ -142,25 +134,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],
}
}

s_no_extra_traits! {
57 changes: 0 additions & 57 deletions src/unix/linux_like/linux/musl/b32/powerpc.rs
Original file line number Diff line number Diff line change
@@ -96,63 +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 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,
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,
#[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;
162 changes: 0 additions & 162 deletions src/unix/linux_like/linux/musl/b32/riscv32/mod.rs
Original file line number Diff line number Diff line change
@@ -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,
@@ -52,95 +48,12 @@ 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 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,
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,
__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,
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<unsafe extern "C" fn()>,
}

pub struct ipc_perm {
pub __key: ::key_t,
pub uid: ::uid_t,
@@ -197,12 +110,6 @@ s_no_extra_traits! {
//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;
@@ -329,38 +236,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;
@@ -369,7 +250,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;
@@ -382,9 +262,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;
@@ -441,24 +318,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;
@@ -481,27 +340,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;
62 changes: 4 additions & 58 deletions src/unix/linux_like/linux/musl/b32/x86/mod.rs
Original file line number Diff line number Diff line change
@@ -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,64 +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 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,
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,
__f_unused: ::c_int,
pub f_flag: ::c_ulong,
pub f_namemax: ::c_ulong,
__f_spare: [::c_int; 6],
}
}

s_no_extra_traits! {
15 changes: 0 additions & 15 deletions src/unix/linux_like/linux/musl/b64/loongarch64/mod.rs
Original file line number Diff line number Diff line change
@@ -55,21 +55,6 @@ s! {
__unused: [::c_int; 2],
}

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,
30 changes: 0 additions & 30 deletions src/unix/linux_like/linux/musl/b64/mips64.rs
Original file line number Diff line number Diff line change
@@ -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,
53 changes: 0 additions & 53 deletions src/unix/linux_like/linux/musl/b64/mod.rs
Original file line number Diff line number Diff line change
@@ -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,
@@ -74,21 +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 msghdr {
pub msg_name: *mut ::c_void,
pub msg_namelen: ::socklen_t,
@@ -120,14 +75,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;
107 changes: 0 additions & 107 deletions src/unix/linux_like/linux/musl/b64/riscv64/mod.rs
Original file line number Diff line number Diff line change
@@ -5,16 +5,10 @@ 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;

s! {
pub struct pthread_attr_t {
__size: [::c_ulong; 7],
}

pub struct stat {
pub st_dev: ::dev_t,
pub st_ino: ::ino_t,
@@ -59,94 +53,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,
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<unsafe extern "C" fn()>,
}

pub struct ipc_perm {
pub __key: ::key_t,
pub uid: ::uid_t,
@@ -161,19 +67,6 @@ s! {
__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,
}

#[repr(align(8))]
pub struct clone_args {
pub flags: ::c_ulonglong,
30 changes: 0 additions & 30 deletions src/unix/linux_like/linux/musl/b64/s390x.rs
Original file line number Diff line number Diff line change
@@ -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! {
81 changes: 79 additions & 2 deletions src/unix/linux_like/linux/musl/mod.rs
Original file line number Diff line number Diff line change
@@ -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! {
@@ -144,6 +146,27 @@ s! {
pub sa_restorer: ::Option<extern "C" fn()>,
}

// `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)
//
// FIXME(union): C implementation uses unions
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",
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],
bossmc marked this conversation as resolved.
Show resolved Hide resolved
_align: [usize; 0],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could probably make the struct #[repr(align(...))] to get ride of the old hack

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately sizeof::<usize>() is 4 on 32-bit systems and 8 on 64-bit systems, so the #[repr(align(...))] needs to be different between those two bit-sizes. You can't write #[repr(align(usize))] (which would be cool) so you'd have to do some conditional attrs and the hack feels easier to parse.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough. align = usize would be nice, that seems worth proposing at some point.

}

pub struct statvfs {
pub f_bsize: ::c_ulong,
pub f_frsize: ::c_ulong,
@@ -156,12 +179,32 @@ s! {
#[cfg(target_endian = "little")]
pub f_fsid: ::c_ulong,
#[cfg(target_pointer_width = "32")]
__f_unused: ::c_int,
__pad: ::c_int,
#[cfg(target_endian = "big")]
pub f_fsid: ::c_ulong,
pub f_flag: ::c_ulong,
pub f_namemax: ::c_ulong,
__f_reserved: [::c_int; 6],
}

pub struct statvfs64 {
tgross35 marked this conversation as resolved.
Show resolved Hide resolved
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")]
__pad: ::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],
__f_reserved: [::c_int; 6],
}

pub struct termios {
@@ -416,6 +459,40 @@ s! {
#[cfg(target_arch = "loongarch64")]
pub tcpi_snd_wnd: u32,
}

// MIPS implementation is special (see mips arch folders)
#[cfg(not(target_arch = "mips"))]
Comment on lines +463 to +464
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like s390x actually has its own implementation too, unsigned vs unsigned long https://github.com/kraj/musl/blob/ffb23aef7b5339b8c3234f4c6a93c488dc873919/arch/s390x/bits/statfs.h#L4

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, 32-bit seems to have padding fields https://github.com/kraj/musl/blob/ffb23aef7b5339b8c3234f4c6a93c488dc873919/arch/x32/bits/statfs.h#L4. Any idea why this isn't a problem for us currently?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The s390x case is simple, https://refspecs.linuxbase.org/ELF/zSeries/lzsabi0_s390.html#SCALAR shows that unsigned int and unsigned long are the same size on that platform.

Copy link
Contributor Author

@bossmc bossmc Nov 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The x32 target is not the intel/AMD 32-bit target (that's in i386 and other folders in musl), it's this https://sites.google.com/site/x32abi/. Rust supports gnux32 but doesn't support muslx32 (yet?) so we don't need to worry about this weird architecture. The padding fields are necessary on the x32 target since we're passing this structure to a 64-bit kernel so we need to shuffle the 32-bit user-space fields into the appropriate places in the kernel structure.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, thanks for the clarification!

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 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! {