Skip to content

Commit dfcfcf8

Browse files
snoggetgross35
authored andcommitted
gnu: Update struct timespec for GNU _TIME_BITS=64
Use a GNU libc specific version of struct timespec in unix/linux_like/linux/gnu and keep the version in unix for all other unix libc's. 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 (backport <rust-lang#4433>) (cherry picked from commit bbaa017)
1 parent 70dcf6d commit dfcfcf8

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/unix/linux_like/linux/gnu/mod.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,18 @@ s! {
436436
__pos: off64_t,
437437
__state: crate::mbstate_t,
438438
}
439+
440+
// linux x32 compatibility
441+
// See https://sourceware.org/bugzilla/show_bug.cgi?id=16437
442+
pub struct timespec {
443+
pub tv_sec: time_t,
444+
#[cfg(all(gnu_time_bits64, target_endian = "big"))]
445+
__pad: i32,
446+
#[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))]
447+
pub tv_nsec: c_long,
448+
#[cfg(all(gnu_time_bits64, target_endian = "little"))]
449+
__pad: i32,
450+
}
439451
}
440452

441453
impl siginfo_t {

src/unix/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ s! {
6464

6565
// linux x32 compatibility
6666
// See https://sourceware.org/bugzilla/show_bug.cgi?id=16437
67+
#[cfg(not(target_env = "gnu"))]
6768
pub struct timespec {
6869
pub tv_sec: time_t,
6970
#[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]

0 commit comments

Comments
 (0)