Skip to content

Commit 1dc6e64

Browse files
committed
gnu: Update struct timespec for _TIME_BITS=64
Big-endian platforms wants 32 bits of padding before tv_nsec, little-endian after. GNU libc always uses long for tv_nsec. References: https://github.com/bminor/glibc/blob/e78caeb4ff812ae19d24d65f4d4d48508154277b/time/bits/types/struct_timespec.h
1 parent 7437769 commit 1dc6e64

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/unix/mod.rs

+13-2
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,21 @@ s! {
6666
// See https://sourceware.org/bugzilla/show_bug.cgi?id=16437
6767
pub struct timespec {
6868
pub tv_sec: time_t,
69-
#[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
69+
#[cfg(all(gnu_time_bits64, target_endian = "big"))]
70+
__pad: i32,
71+
#[cfg(all(
72+
not(target_env = "gnu"),
73+
target_arch = "x86_64",
74+
target_pointer_width = "32"
75+
))]
7076
pub tv_nsec: i64,
71-
#[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))]
77+
#[cfg(any(
78+
target_env = "gnu",
79+
not(all(target_arch = "x86_64", target_pointer_width = "32"))
80+
))]
7281
pub tv_nsec: c_long,
82+
#[cfg(all(gnu_time_bits64, target_endian = "little"))]
83+
__pad: i32,
7384
}
7485

7586
pub struct rlimit {

0 commit comments

Comments
 (0)