Skip to content

Commit

Permalink
gnu: Update the stat* structs for 64-bit time
Browse files Browse the repository at this point in the history
Move the stat struct from gnu/b32/mod.rs to gnu/b32/time*.rs

For arm, mips, powerpc, riscv32, and x86, move stat64 to
time32.rs and add an stat64 = stat alias to time64.rs.

For sparc, do the same for statfs64 and statvfs64.
  • Loading branch information
snogge committed Aug 15, 2024
1 parent fefc83c commit d9a25a7
Show file tree
Hide file tree
Showing 19 changed files with 257 additions and 167 deletions.
2 changes: 2 additions & 0 deletions libc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3530,6 +3530,8 @@ fn test_linux(target: &str) {

// LFS64 types have been removed in musl 1.2.4+
"off64_t" if musl => "off_t".to_string(),
// In some gnu targets `stat64` is a typedef to `stat`
"stat64" if gnu => format!("struct {}", ty),

// typedefs don't need any keywords
t if t.ends_with("_t") => t.to_string(),
Expand Down
32 changes: 10 additions & 22 deletions src/unix/linux_like/linux/gnu/b32/arm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,28 +56,6 @@ s! {
__unused2: ::c_ulong
}

pub struct stat64 {
pub st_dev: ::dev_t,
__pad1: ::c_uint,
__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,
__pad2: ::c_uint,
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,
pub st_ino: ::ino64_t,
}

pub struct statfs64 {
pub f_type: ::__fsword_t,
pub f_bsize: ::__fsword_t,
Expand Down Expand Up @@ -871,3 +849,13 @@ pub const SYS_set_mempolicy_home_node: ::c_long = 450;

mod align;
pub use self::align::*;

cfg_if! {
if #[cfg(gnu_time64_abi)] {
mod time64;
pub use self::time64::*;
} else {
mod time32;
pub use self::time32::*;
}
}
24 changes: 24 additions & 0 deletions src/unix/linux_like/linux/gnu/b32/arm/time32.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
s! {
pub struct stat64 {
pub st_dev: ::dev_t,
__pad1: ::c_uint,
__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,
__pad2: ::c_uint,
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,
pub st_ino: ::ino64_t,
}

}
2 changes: 2 additions & 0 deletions src/unix/linux_like/linux/gnu/b32/arm/time64.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
use stat;
pub type stat64 = stat;
32 changes: 10 additions & 22 deletions src/unix/linux_like/linux/gnu/b32/mips/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,6 @@ pub type c_char = i8;
pub type wchar_t = i32;

s! {
pub struct stat64 {
pub st_dev: ::c_ulong,
st_pad1: [::c_long; 3],
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: ::c_ulong,
st_pad2: [::c_long; 2],
pub st_size: ::off64_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,
pub st_blksize: ::blksize_t,
st_pad3: ::c_long,
pub st_blocks: ::blkcnt64_t,
st_pad5: [::c_long; 14],
}

pub struct statfs {
pub f_type: ::c_long,
Expand Down Expand Up @@ -808,3 +786,13 @@ pub const EHWPOISON: ::c_int = 168;

mod align;
pub use self::align::*;

cfg_if! {
if #[cfg(gnu_time64_abi)] {
mod time64;
pub use self::time64::*;
} else {
mod time32;
pub use self::time32::*;
}
}
24 changes: 24 additions & 0 deletions src/unix/linux_like/linux/gnu/b32/mips/time32.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
s! {
pub struct stat64 {
pub st_dev: ::c_ulong,
st_pad1: [::c_long; 3],
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: ::c_ulong,
st_pad2: [::c_long; 2],
pub st_size: ::off64_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,
pub st_blksize: ::blksize_t,
st_pad3: ::c_long,
pub st_blocks: ::blkcnt64_t,
st_pad5: [::c_long; 14],
}
}
2 changes: 2 additions & 0 deletions src/unix/linux_like/linux/gnu/b32/mips/time64.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
use stat;
pub type stat64 = stat;
48 changes: 0 additions & 48 deletions src/unix/linux_like/linux/gnu/b32/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,54 +53,6 @@ cfg_if! {
}

s! {
pub struct stat {
#[cfg(not(any(target_arch = "mips", target_arch = "mips32r6")))]
pub st_dev: ::dev_t,
#[cfg(any(target_arch = "mips", target_arch = "mips32r6"))]
pub st_dev: ::c_ulong,

#[cfg(not(any(target_arch = "mips", target_arch = "mips32r6")))]
__pad1: ::c_short,
#[cfg(any(target_arch = "mips", target_arch = "mips32r6"))]
st_pad1: [::c_long; 3],
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,
#[cfg(not(any(target_arch = "mips", target_arch = "mips32r6")))]
pub st_rdev: ::dev_t,
#[cfg(any(target_arch = "mips", target_arch = "mips32r6"))]
pub st_rdev: ::c_ulong,
#[cfg(not(any(target_arch = "mips", target_arch = "mips32r6")))]
__pad2: ::c_short,
#[cfg(any(target_arch = "mips", target_arch = "mips32r6"))]
st_pad2: [::c_long; 2],
pub st_size: ::off_t,
#[cfg(any(target_arch = "mips", target_arch = "mips32r6"))]
st_pad3: ::c_long,
#[cfg(not(any(target_arch = "mips", target_arch = "mips32r6")))]
pub st_blksize: ::blksize_t,
#[cfg(not(any(target_arch = "mips", target_arch = "mips32r6")))]
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,
#[cfg(not(any(target_arch = "mips", target_arch = "mips32r6")))]
__unused4: ::c_long,
#[cfg(not(any(target_arch = "mips", target_arch = "mips32r6")))]
__unused5: ::c_long,
#[cfg(any(target_arch = "mips", target_arch = "mips32r6"))]
pub st_blksize: ::blksize_t,
#[cfg(any(target_arch = "mips", target_arch = "mips32r6"))]
pub st_blocks: ::blkcnt_t,
#[cfg(any(target_arch = "mips", target_arch = "mips32r6"))]
st_pad5: [::c_long; 14],
}

pub struct statvfs {
pub f_bsize: ::c_ulong,
pub f_frsize: ::c_ulong,
Expand Down
22 changes: 0 additions & 22 deletions src/unix/linux_like/linux/gnu/b32/powerpc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,28 +55,6 @@ s! {
__glibc_reserved2: u64,
}

pub struct stat64 {
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,
__glibc_reserved4: ::c_ulong,
__glibc_reserved5: ::c_ulong,
}

pub struct statfs64 {
pub f_type: ::__fsword_t,
pub f_bsize: ::__fsword_t,
Expand Down
23 changes: 22 additions & 1 deletion src/unix/linux_like/linux/gnu/b32/powerpc/time32.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,26 @@
s! {
pub struct stat64 {
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,
__glibc_reserved4: ::c_ulong,
__glibc_reserved5: ::c_ulong,
}

pub struct shmid_ds {
pub shm_perm: ::ipc_perm,
__glibc_reserved1: ::c_uint,
Expand All @@ -15,5 +37,4 @@ s! {
__glibc_reserved5: ::c_ulong,
__glibc_reserved6: ::c_ulong,
}

}
3 changes: 3 additions & 0 deletions src/unix/linux_like/linux/gnu/b32/powerpc/time64.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
use stat;
pub type stat64 = stat;

s! {
pub struct shmid_ds {
pub shm_perm: ::ipc_perm,
Expand Down
39 changes: 9 additions & 30 deletions src/unix/linux_like/linux/gnu/b32/sparc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,21 +100,6 @@ s! {
__reserved: [::c_long; 2],
}

pub struct statfs64 {
pub f_type: ::__fsword_t,
pub f_bsize: ::__fsword_t,
pub f_blocks: u64,
pub f_bfree: u64,
pub f_bavail: u64,
pub f_files: u64,
pub f_ffree: u64,
pub f_fsid: ::fsid_t,
pub f_namelen: ::__fsword_t,
pub f_frsize: ::__fsword_t,
pub f_flags: ::__fsword_t,
pub f_spare: [::__fsword_t; 4],
}

pub struct statvfs {
pub f_bsize: ::c_ulong,
pub f_frsize: ::c_ulong,
Expand All @@ -130,21 +115,6 @@ s! {
__f_spare: [::c_int; 6],
}

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 timex {
pub modes: ::c_uint,
pub offset: ::c_long,
Expand Down Expand Up @@ -885,3 +855,12 @@ pub const SYS_set_mempolicy_home_node: ::c_long = 450;

mod align;
pub use self::align::*;
cfg_if! {
if #[cfg(gnu_time64_abi)] {
mod time64;
pub use self::time64::*;
} else {
mod time32;
pub use self::time32::*;
}
}
31 changes: 31 additions & 0 deletions src/unix/linux_like/linux/gnu/b32/sparc/time32.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
s! {
pub struct statfs64 {
pub f_type: ::__fsword_t,
pub f_bsize: ::__fsword_t,
pub f_blocks: u64,
pub f_bfree: u64,
pub f_bavail: u64,
pub f_files: u64,
pub f_ffree: u64,
pub f_fsid: ::fsid_t,
pub f_namelen: ::__fsword_t,
pub f_frsize: ::__fsword_t,
pub f_flags: ::__fsword_t,
pub f_spare: [::__fsword_t; 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],
}
}
4 changes: 4 additions & 0 deletions src/unix/linux_like/linux/gnu/b32/sparc/time64.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
use statfs;
use statvfs;
pub type statfs64 = statfs;
pub type statvfs64 = statvfs;
Loading

0 comments on commit d9a25a7

Please sign in to comment.