From fefc83c15a52f6bf4272c3de9cfc92ba068baadf Mon Sep 17 00:00:00 2001 From: Ola x Nilsson Date: Fri, 17 Mar 2023 15:20:29 +0100 Subject: [PATCH] gnu: Move struct timex to gnu/b64 and gnu/b32/time*.rs Do not use gnu/b32/time*.rs for riscv32 and sparc. Add timex to gnu/b32/(riscv32|sparc)/mod.rs instead. --- src/unix/linux_like/linux/gnu/b32/mod.rs | 13 ++++ .../linux_like/linux/gnu/b32/riscv32/mod.rs | 34 ++++++++ .../linux_like/linux/gnu/b32/sparc/mod.rs | 34 ++++++++ src/unix/linux_like/linux/gnu/b32/time32.rs | 39 ++++++++++ src/unix/linux_like/linux/gnu/b32/time64.rs | 41 ++++++++++ src/unix/linux_like/linux/gnu/b64/mod.rs | 53 ++++++++++++- src/unix/linux_like/linux/gnu/mod.rs | 78 ------------------- 7 files changed, 210 insertions(+), 82 deletions(-) create mode 100644 src/unix/linux_like/linux/gnu/b32/time32.rs create mode 100644 src/unix/linux_like/linux/gnu/b32/time64.rs diff --git a/src/unix/linux_like/linux/gnu/b32/mod.rs b/src/unix/linux_like/linux/gnu/b32/mod.rs index 896e97685e6fe..45be39de96e96 100644 --- a/src/unix/linux_like/linux/gnu/b32/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/mod.rs @@ -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")] { @@ -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::*; + } +} 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..95a95ea59a591 100644 --- a/src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs @@ -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, 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..a948b0bc5a443 100644 --- a/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs @@ -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, diff --git a/src/unix/linux_like/linux/gnu/b32/time32.rs b/src/unix/linux_like/linux/gnu/b32/time32.rs new file mode 100644 index 0000000000000..d23149582e8e3 --- /dev/null +++ b/src/unix/linux_like/linux/gnu/b32/time32.rs @@ -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, + } + +} diff --git a/src/unix/linux_like/linux/gnu/b32/time64.rs b/src/unix/linux_like/linux/gnu/b32/time64.rs new file mode 100644 index 0000000000000..5e762b37b8967 --- /dev/null +++ b/src/unix/linux_like/linux/gnu/b32/time64.rs @@ -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, + } +} diff --git a/src/unix/linux_like/linux/gnu/b64/mod.rs b/src/unix/linux_like/linux/gnu/b64/mod.rs index ff394e33a2136..705365efd3253 100644 --- a/src/unix/linux_like/linux/gnu/b64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/mod.rs @@ -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; @@ -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; diff --git a/src/unix/linux_like/linux/gnu/mod.rs b/src/unix/linux_like/linux/gnu/mod.rs index 8895df8a31d25..a39a7297f11d5 100644 --- a/src/unix/linux_like/linux/gnu/mod.rs +++ b/src/unix/linux_like/linux/gnu/mod.rs @@ -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,