Skip to content

Commit

Permalink
gnu: Move struct timex to gnu/b64 and gnu/b32/time*.rs
Browse files Browse the repository at this point in the history
Do not use gnu/b32/time*.rs for riscv32 and sparc.  Add timex to
gnu/b32/(riscv32|sparc)/mod.rs instead.
  • Loading branch information
snogge committed Aug 15, 2024
1 parent 49d1137 commit fefc83c
Show file tree
Hide file tree
Showing 7 changed files with 210 additions and 82 deletions.
13 changes: 13 additions & 0 deletions src/unix/linux_like/linux/gnu/b32/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ pub type __fsword_t = i32;
pub type fsblkcnt64_t = u64;
pub type fsfilcnt64_t = u64;
pub type __syscall_ulong_t = ::c_ulong;
pub type __syscall_slong_t = ::c_long;

cfg_if! {
if #[cfg(target_arch = "riscv32")] {
Expand Down Expand Up @@ -383,3 +384,15 @@ cfg_if! {
// Unknown target_arch
}
}

cfg_if! {
if #[cfg(any(target_arch = "riscv32", target_arch = "sparc"))] {
// use the defs in self::riscv32 or self::sparc
} else if #[cfg(gnu_time64_abi)] {
mod time64;
pub use self::time64::*;
} else {
mod time32;
pub use self::time32::*;
}
}
34 changes: 34 additions & 0 deletions src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,40 @@ s! {
pub __f_spare: [::c_int; 6],
}

pub struct timex {
pub modes: ::c_uint,
pub offset: ::c_long,
pub freq: ::c_long,
pub maxerror: ::c_long,
pub esterror: ::c_long,
pub status: ::c_int,
pub constant: ::c_long,
pub precision: ::c_long,
pub tolerance: ::c_long,
pub time: ::timeval,
pub tick: ::c_long,
pub ppsfreq: ::c_long,
pub jitter: ::c_long,
pub shift: ::c_int,
pub stabil: ::c_long,
pub jitcnt: ::c_long,
pub calcnt: ::c_long,
pub errcnt: ::c_long,
pub stbcnt: ::c_long,
pub tai: ::c_int,
pub __unused1: i32,
pub __unused2: i32,
pub __unused3: i32,
pub __unused4: i32,
pub __unused5: i32,
pub __unused6: i32,
pub __unused7: i32,
pub __unused8: i32,
pub __unused9: i32,
pub __unused10: i32,
pub __unused11: i32,
}

pub struct siginfo_t {
pub si_signo: ::c_int,
pub si_errno: ::c_int,
Expand Down
34 changes: 34 additions & 0 deletions src/unix/linux_like/linux/gnu/b32/sparc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,40 @@ s! {
__f_spare: [::c_int; 6],
}

pub struct timex {
pub modes: ::c_uint,
pub offset: ::c_long,
pub freq: ::c_long,
pub maxerror: ::c_long,
pub esterror: ::c_long,
pub status: ::c_int,
pub constant: ::c_long,
pub precision: ::c_long,
pub tolerance: ::c_long,
pub time: ::timeval,
pub tick: ::c_long,
pub ppsfreq: ::c_long,
pub jitter: ::c_long,
pub shift: ::c_int,
pub stabil: ::c_long,
pub jitcnt: ::c_long,
pub calcnt: ::c_long,
pub errcnt: ::c_long,
pub stbcnt: ::c_long,
pub tai: ::c_int,
pub __unused1: i32,
pub __unused2: i32,
pub __unused3: i32,
pub __unused4: i32,
pub __unused5: i32,
pub __unused6: i32,
pub __unused7: i32,
pub __unused8: i32,
pub __unused9: i32,
pub __unused10: i32,
pub __unused11: i32,
}

pub struct ipc_perm {
pub __key: ::key_t,
pub uid: ::uid_t,
Expand Down
39 changes: 39 additions & 0 deletions src/unix/linux_like/linux/gnu/b32/time32.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//! 32-bit specific definitions for linux-like values when gnu_time64_abi is not set

s! {
pub struct timex {
pub modes: ::c_uint,

pub offset: ::__syscall_slong_t,
pub freq: ::__syscall_slong_t,
pub maxerror: ::__syscall_slong_t,
pub esterror: ::__syscall_slong_t,
pub status: ::c_int,
pub constant: ::__syscall_slong_t,
pub precision: ::__syscall_slong_t,
pub tolerance: ::__syscall_slong_t,
pub time: ::timeval,
pub tick: ::__syscall_slong_t,
pub ppsfreq: ::__syscall_slong_t,
pub jitter: ::__syscall_slong_t,
pub shift: ::c_int,
pub stabil: ::__syscall_slong_t,
pub jitcnt: ::__syscall_slong_t,
pub calcnt: ::__syscall_slong_t,
pub errcnt: ::__syscall_slong_t,
pub stbcnt: ::__syscall_slong_t,
pub tai: ::c_int,
pub __unused1: i32,
pub __unused2: i32,
pub __unused3: i32,
pub __unused4: i32,
pub __unused5: i32,
pub __unused6: i32,
pub __unused7: i32,
pub __unused8: i32,
pub __unused9: i32,
pub __unused10: i32,
pub __unused11: i32,
}

}
41 changes: 41 additions & 0 deletions src/unix/linux_like/linux/gnu/b32/time64.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
//! 32-bit specific definitions for linux-like values when gnu_time64_abi is set

s! {
pub struct timex {
pub modes: ::c_uint,

__unused_pad1: i32,
pub offset: ::c_longlong,
pub freq: ::c_longlong,
pub maxerror: ::c_longlong,
pub esterror: ::c_longlong,
pub status: ::c_int,
__unused_pad2: i32,
pub constant: ::c_longlong,
pub precision: ::c_longlong,
pub tolerance: ::c_longlong,
pub time: ::timeval,
pub tick: ::c_longlong,
pub ppsfreq: ::c_longlong,
pub jitter: ::c_longlong,
pub shift: ::c_int,
__unused_pad3: i32,
pub stabil: ::c_longlong,
pub jitcnt: ::c_longlong,
pub calcnt: ::c_longlong,
pub errcnt: ::c_longlong,
pub stbcnt: ::c_longlong,
pub tai: ::c_int,
__unused1: i32,
__unused2: i32,
__unused3: i32,
__unused4: i32,
__unused5: i32,
__unused6: i32,
__unused7: i32,
__unused8: i32,
__unused9: i32,
__unused10: i32,
__unused11: i32,
}
}
53 changes: 49 additions & 4 deletions src/unix/linux_like/linux/gnu/b64/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,16 @@ pub type msglen_t = u64;
pub type fsblkcnt_t = u64;
pub type fsfilcnt_t = u64;
pub type rlim_t = u64;
#[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
pub type __syscall_ulong_t = ::c_ulonglong;
#[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))]
pub type __syscall_ulong_t = ::c_ulong;

cfg_if! {
if #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] {
pub type __syscall_ulong_t = ::c_ulonglong;
pub type __syscall_slong_t = ::c_longlong;
} else {
pub type __syscall_ulong_t = ::c_ulong;
pub type __syscall_slong_t = ::c_long;
}
}
cfg_if! {
if #[cfg(all(target_arch = "aarch64", target_pointer_width = "32"))] {
pub type clock_t = i32;
Expand Down Expand Up @@ -91,6 +96,46 @@ s! {
__glibc_reserved3: ::__syscall_ulong_t,
__glibc_reserved4: ::__syscall_ulong_t,
}

pub struct timex {
pub modes: ::c_uint,
#[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
pub __unused_pad1: i32,
pub offset: ::__syscall_slong_t,
pub freq: ::__syscall_slong_t,
pub maxerror: ::__syscall_slong_t,
pub esterror: ::__syscall_slong_t,
pub status: ::c_int,
#[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
pub __unused_pad2: i32,
pub constant: ::__syscall_slong_t,
pub precision: ::__syscall_slong_t,
pub tolerance: ::__syscall_slong_t,
pub time: ::timeval,
pub tick: ::__syscall_slong_t,
pub ppsfreq: ::__syscall_slong_t,
pub jitter: ::__syscall_slong_t,
pub shift: ::c_int,
#[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
pub __unused_pad3: i32,
pub stabil: ::__syscall_slong_t,
pub jitcnt: ::__syscall_slong_t,
pub calcnt: ::__syscall_slong_t,
pub errcnt: ::__syscall_slong_t,
pub stbcnt: ::__syscall_slong_t,
pub tai: ::c_int,
pub __unused1: i32,
pub __unused2: i32,
pub __unused3: i32,
pub __unused4: i32,
pub __unused5: i32,
pub __unused6: i32,
pub __unused7: i32,
pub __unused8: i32,
pub __unused9: i32,
pub __unused10: i32,
pub __unused11: i32,
}
}

pub const __SIZEOF_PTHREAD_RWLOCKATTR_T: usize = 8;
Expand Down
78 changes: 0 additions & 78 deletions src/unix/linux_like/linux/gnu/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,84 +198,6 @@ s! {
pub rt_irtt: ::c_ushort,
}

pub struct timex {
pub modes: ::c_uint,
#[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
pub offset: i64,
#[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))]
pub offset: ::c_long,
#[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
pub freq: i64,
#[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))]
pub freq: ::c_long,
#[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
pub maxerror: i64,
#[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))]
pub maxerror: ::c_long,
#[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
pub esterror: i64,
#[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))]
pub esterror: ::c_long,
pub status: ::c_int,
#[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
pub constant: i64,
#[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))]
pub constant: ::c_long,
#[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
pub precision: i64,
#[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))]
pub precision: ::c_long,
#[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
pub tolerance: i64,
#[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))]
pub tolerance: ::c_long,
pub time: ::timeval,
#[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
pub tick: i64,
#[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))]
pub tick: ::c_long,
#[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
pub ppsfreq: i64,
#[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))]
pub ppsfreq: ::c_long,
#[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
pub jitter: i64,
#[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))]
pub jitter: ::c_long,
pub shift: ::c_int,
#[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
pub stabil: i64,
#[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))]
pub stabil: ::c_long,
#[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
pub jitcnt: i64,
#[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))]
pub jitcnt: ::c_long,
#[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
pub calcnt: i64,
#[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))]
pub calcnt: ::c_long,
#[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
pub errcnt: i64,
#[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))]
pub errcnt: ::c_long,
#[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
pub stbcnt: i64,
#[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))]
pub stbcnt: ::c_long,
pub tai: ::c_int,
pub __unused1: i32,
pub __unused2: i32,
pub __unused3: i32,
pub __unused4: i32,
pub __unused5: i32,
pub __unused6: i32,
pub __unused7: i32,
pub __unused8: i32,
pub __unused9: i32,
pub __unused10: i32,
pub __unused11: i32,
}

pub struct ntptimeval {
pub time: ::timeval,
Expand Down

0 comments on commit fefc83c

Please sign in to comment.