summaryrefslogtreecommitdiffstats
path: root/vendor/rustix/src/backend/libc/time
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:59:35 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:59:35 +0000
commitd1b2d29528b7794b41e66fc2136e395a02f8529b (patch)
treea4a17504b260206dec3cf55b2dca82929a348ac2 /vendor/rustix/src/backend/libc/time
parentReleasing progress-linux version 1.72.1+dfsg1-1~progress7.99u1. (diff)
downloadrustc-d1b2d29528b7794b41e66fc2136e395a02f8529b.tar.xz
rustc-d1b2d29528b7794b41e66fc2136e395a02f8529b.zip
Merging upstream version 1.73.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/rustix/src/backend/libc/time')
-rw-r--r--vendor/rustix/src/backend/libc/time/syscalls.rs401
-rw-r--r--vendor/rustix/src/backend/libc/time/types.rs46
2 files changed, 201 insertions, 246 deletions
diff --git a/vendor/rustix/src/backend/libc/time/syscalls.rs b/vendor/rustix/src/backend/libc/time/syscalls.rs
index 14ca22b2d..603a3b108 100644
--- a/vendor/rustix/src/backend/libc/time/syscalls.rs
+++ b/vendor/rustix/src/backend/libc/time/syscalls.rs
@@ -2,13 +2,14 @@
use crate::backend::c;
use crate::backend::conv::ret;
+#[cfg(any(linux_kernel, target_os = "fuchsia"))]
+#[cfg(feature = "time")]
+#[cfg(any(all(target_env = "gnu", fix_y2038), not(fix_y2038)))]
+use crate::backend::time::types::LibcItimerspec;
#[cfg(not(target_os = "wasi"))]
use crate::clockid::{ClockId, DynamicClockId};
use crate::io;
-#[cfg(all(
- any(target_arch = "arm", target_arch = "mips", target_arch = "x86"),
- target_env = "gnu",
-))]
+#[cfg(all(target_env = "gnu", fix_y2038))]
use crate::timespec::LibcTimespec;
use crate::timespec::Timespec;
use core::mem::MaybeUninit;
@@ -16,36 +17,22 @@ use core::mem::MaybeUninit;
#[cfg(feature = "time")]
use {
crate::backend::conv::{borrowed_fd, ret_owned_fd},
- crate::backend::time::types::LibcItimerspec,
crate::fd::{BorrowedFd, OwnedFd},
crate::time::{Itimerspec, TimerfdClockId, TimerfdFlags, TimerfdTimerFlags},
};
-#[cfg(all(
- any(target_arch = "arm", target_arch = "mips", target_arch = "x86"),
- target_env = "gnu",
-))]
+#[cfg(all(target_env = "gnu", fix_y2038))]
weak!(fn __clock_gettime64(c::clockid_t, *mut LibcTimespec) -> c::c_int);
-#[cfg(all(
- any(target_arch = "arm", target_arch = "mips", target_arch = "x86"),
- target_env = "gnu",
-))]
+#[cfg(all(target_env = "gnu", fix_y2038))]
weak!(fn __clock_settime64(c::clockid_t, *const LibcTimespec) -> c::c_int);
-#[cfg(all(
- any(target_arch = "arm", target_arch = "mips", target_arch = "x86"),
- target_env = "gnu",
-))]
+#[cfg(all(target_env = "gnu", fix_y2038))]
weak!(fn __clock_getres64(c::clockid_t, *mut LibcTimespec) -> c::c_int);
-#[cfg(all(
- any(target_arch = "arm", target_arch = "mips", target_arch = "x86"),
- target_env = "gnu",
-))]
+#[cfg(any(linux_kernel, target_os = "fuchsia"))]
+#[cfg(all(target_env = "gnu", fix_y2038))]
#[cfg(feature = "time")]
weak!(fn __timerfd_gettime64(c::c_int, *mut LibcItimerspec) -> c::c_int);
-#[cfg(all(
- any(target_arch = "arm", target_arch = "mips", target_arch = "x86"),
- target_env = "gnu",
-))]
+#[cfg(any(linux_kernel, target_os = "fuchsia"))]
+#[cfg(all(target_env = "gnu", fix_y2038))]
#[cfg(feature = "time")]
weak!(fn __timerfd_settime64(c::c_int, c::c_int, *const LibcItimerspec, *mut LibcItimerspec) -> c::c_int);
@@ -53,28 +40,24 @@ weak!(fn __timerfd_settime64(c::c_int, c::c_int, *const LibcItimerspec, *mut Lib
#[inline]
#[must_use]
pub(crate) fn clock_getres(id: ClockId) -> Timespec {
- // 32-bit gnu version: libc has `clock_getres` but it is not y2038 safe by
- // default.
- #[cfg(all(
- any(target_arch = "arm", target_arch = "mips", target_arch = "x86"),
- target_env = "gnu",
- ))]
- unsafe {
- let mut timespec = MaybeUninit::<LibcTimespec>::uninit();
-
+ // Old 32-bit version: libc has `clock_getres` but it is not y2038 safe by
+ // default. But there may be a `__clock_getres64` we can use.
+ #[cfg(fix_y2038)]
+ {
+ #[cfg(target_env = "gnu")]
if let Some(libc_clock_getres) = __clock_getres64.get() {
- ret(libc_clock_getres(id as c::clockid_t, timespec.as_mut_ptr())).unwrap();
- timespec.assume_init().into()
- } else {
- clock_getres_old(id)
+ let mut timespec = MaybeUninit::<LibcTimespec>::uninit();
+ unsafe {
+ ret(libc_clock_getres(id as c::clockid_t, timespec.as_mut_ptr())).unwrap();
+ return timespec.assume_init().into();
+ }
}
+
+ clock_getres_old(id)
}
// Main version: libc is y2038 safe and has `clock_getres`.
- #[cfg(not(all(
- any(target_arch = "arm", target_arch = "mips", target_arch = "x86"),
- target_env = "gnu",
- )))]
+ #[cfg(not(fix_y2038))]
unsafe {
let mut timespec = MaybeUninit::<Timespec>::uninit();
let _ = c::clock_getres(id as c::clockid_t, timespec.as_mut_ptr());
@@ -82,19 +65,20 @@ pub(crate) fn clock_getres(id: ClockId) -> Timespec {
}
}
-#[cfg(all(
- any(target_arch = "arm", target_arch = "mips", target_arch = "x86"),
- target_env = "gnu",
-))]
+#[cfg(fix_y2038)]
#[must_use]
-unsafe fn clock_getres_old(id: ClockId) -> Timespec {
+fn clock_getres_old(id: ClockId) -> Timespec {
let mut old_timespec = MaybeUninit::<c::timespec>::uninit();
- ret(c::clock_getres(
- id as c::clockid_t,
- old_timespec.as_mut_ptr(),
- ))
- .unwrap();
- let old_timespec = old_timespec.assume_init();
+
+ let old_timespec = unsafe {
+ ret(c::clock_getres(
+ id as c::clockid_t,
+ old_timespec.as_mut_ptr(),
+ ))
+ .unwrap();
+ old_timespec.assume_init()
+ };
+
Timespec {
tv_sec: old_timespec.tv_sec.into(),
tv_nsec: old_timespec.tv_nsec.into(),
@@ -105,33 +89,31 @@ unsafe fn clock_getres_old(id: ClockId) -> Timespec {
#[inline]
#[must_use]
pub(crate) fn clock_gettime(id: ClockId) -> Timespec {
- #[cfg(all(
- any(target_arch = "arm", target_arch = "mips", target_arch = "x86"),
- target_env = "gnu",
- ))]
- unsafe {
- let mut timespec = MaybeUninit::<LibcTimespec>::uninit();
-
+ // Old 32-bit version: libc has `clock_gettime` but it is not y2038 safe by
+ // default. But there may be a `__clock_gettime64` we can use.
+ #[cfg(fix_y2038)]
+ {
+ #[cfg(target_env = "gnu")]
if let Some(libc_clock_gettime) = __clock_gettime64.get() {
- ret(libc_clock_gettime(
- id as c::clockid_t,
- timespec.as_mut_ptr(),
- ))
- .unwrap();
- timespec.assume_init().into()
- } else {
- clock_gettime_old(id)
+ let mut timespec = MaybeUninit::<LibcTimespec>::uninit();
+ unsafe {
+ ret(libc_clock_gettime(
+ id as c::clockid_t,
+ timespec.as_mut_ptr(),
+ ))
+ .unwrap();
+ return timespec.assume_init().into();
+ }
}
+
+ clock_gettime_old(id)
}
// Use `unwrap()` here because `clock_getres` can fail if the clock itself
// overflows a number of seconds, but if that happens, the monotonic clocks
// can't maintain their invariants, or the realtime clocks aren't properly
// configured.
- #[cfg(not(all(
- any(target_arch = "arm", target_arch = "mips", target_arch = "x86"),
- target_env = "gnu",
- )))]
+ #[cfg(not(fix_y2038))]
unsafe {
let mut timespec = MaybeUninit::<Timespec>::uninit();
ret(c::clock_gettime(id as c::clockid_t, timespec.as_mut_ptr())).unwrap();
@@ -139,19 +121,20 @@ pub(crate) fn clock_gettime(id: ClockId) -> Timespec {
}
}
-#[cfg(all(
- any(target_arch = "arm", target_arch = "mips", target_arch = "x86"),
- target_env = "gnu",
-))]
+#[cfg(fix_y2038)]
#[must_use]
-unsafe fn clock_gettime_old(id: ClockId) -> Timespec {
+fn clock_gettime_old(id: ClockId) -> Timespec {
let mut old_timespec = MaybeUninit::<c::timespec>::uninit();
- ret(c::clock_gettime(
- id as c::clockid_t,
- old_timespec.as_mut_ptr(),
- ))
- .unwrap();
- let old_timespec = old_timespec.assume_init();
+
+ let old_timespec = unsafe {
+ ret(c::clock_gettime(
+ id as c::clockid_t,
+ old_timespec.as_mut_ptr(),
+ ))
+ .unwrap();
+ old_timespec.assume_init()
+ };
+
Timespec {
tv_sec: old_timespec.tv_sec.into(),
tv_nsec: old_timespec.tv_nsec.into(),
@@ -161,83 +144,85 @@ unsafe fn clock_gettime_old(id: ClockId) -> Timespec {
#[cfg(not(target_os = "wasi"))]
#[inline]
pub(crate) fn clock_gettime_dynamic(id: DynamicClockId<'_>) -> io::Result<Timespec> {
- unsafe {
- let id: c::clockid_t = match id {
- DynamicClockId::Known(id) => id as c::clockid_t,
-
- #[cfg(linux_kernel)]
- DynamicClockId::Dynamic(fd) => {
- use crate::fd::AsRawFd;
- const CLOCKFD: i32 = 3;
- (!fd.as_raw_fd() << 3) | CLOCKFD
- }
+ let id: c::clockid_t = match id {
+ DynamicClockId::Known(id) => id as c::clockid_t,
+
+ #[cfg(linux_kernel)]
+ DynamicClockId::Dynamic(fd) => {
+ use crate::fd::AsRawFd;
+ const CLOCKFD: i32 = 3;
+ (!fd.as_raw_fd() << 3) | CLOCKFD
+ }
- #[cfg(not(linux_kernel))]
- DynamicClockId::Dynamic(_fd) => {
- // Dynamic clocks are not supported on this platform.
- return Err(io::Errno::INVAL);
- }
+ #[cfg(not(linux_kernel))]
+ DynamicClockId::Dynamic(_fd) => {
+ // Dynamic clocks are not supported on this platform.
+ return Err(io::Errno::INVAL);
+ }
- #[cfg(linux_kernel)]
- DynamicClockId::RealtimeAlarm => c::CLOCK_REALTIME_ALARM,
+ #[cfg(linux_kernel)]
+ DynamicClockId::RealtimeAlarm => c::CLOCK_REALTIME_ALARM,
- #[cfg(linux_kernel)]
- DynamicClockId::Tai => c::CLOCK_TAI,
+ #[cfg(linux_kernel)]
+ DynamicClockId::Tai => c::CLOCK_TAI,
- #[cfg(any(linux_kernel, target_os = "openbsd"))]
- DynamicClockId::Boottime => c::CLOCK_BOOTTIME,
+ #[cfg(any(
+ freebsdlike,
+ linux_kernel,
+ target_os = "fuchsia",
+ target_os = "openbsd"
+ ))]
+ DynamicClockId::Boottime => c::CLOCK_BOOTTIME,
- #[cfg(linux_kernel)]
- DynamicClockId::BoottimeAlarm => c::CLOCK_BOOTTIME_ALARM,
- };
+ #[cfg(any(linux_kernel, target_os = "fuchsia"))]
+ DynamicClockId::BoottimeAlarm => c::CLOCK_BOOTTIME_ALARM,
+ };
- #[cfg(all(
- any(target_arch = "arm", target_arch = "mips", target_arch = "x86"),
- target_env = "gnu",
- ))]
- {
+ // Old 32-bit version: libc has `clock_gettime` but it is not y2038
+ // safe by default. But there may be a `__clock_gettime64` we can use.
+ #[cfg(fix_y2038)]
+ {
+ #[cfg(target_env = "gnu")]
+ if let Some(libc_clock_gettime) = __clock_gettime64.get() {
let mut timespec = MaybeUninit::<LibcTimespec>::uninit();
-
- if let Some(libc_clock_gettime) = __clock_gettime64.get() {
+ unsafe {
ret(libc_clock_gettime(
id as c::clockid_t,
timespec.as_mut_ptr(),
))?;
- Ok(timespec.assume_init().into())
- } else {
- clock_gettime_dynamic_old(id)
+ return Ok(timespec.assume_init().into());
}
}
- #[cfg(not(all(
- any(target_arch = "arm", target_arch = "mips", target_arch = "x86"),
- target_env = "gnu",
- )))]
- {
- let mut timespec = MaybeUninit::<Timespec>::uninit();
+ clock_gettime_dynamic_old(id)
+ }
+
+ // Main version: libc is y2038 safe and has `clock_gettime`.
+ #[cfg(not(fix_y2038))]
+ unsafe {
+ let mut timespec = MaybeUninit::<Timespec>::uninit();
- ret(c::clock_gettime(id as c::clockid_t, timespec.as_mut_ptr()))?;
+ ret(c::clock_gettime(id as c::clockid_t, timespec.as_mut_ptr()))?;
- Ok(timespec.assume_init())
- }
+ Ok(timespec.assume_init())
}
}
-#[cfg(all(
- any(target_arch = "arm", target_arch = "mips", target_arch = "x86"),
- target_env = "gnu",
-))]
+#[cfg(fix_y2038)]
#[inline]
-unsafe fn clock_gettime_dynamic_old(id: c::clockid_t) -> io::Result<Timespec> {
+fn clock_gettime_dynamic_old(id: c::clockid_t) -> io::Result<Timespec> {
let mut old_timespec = MaybeUninit::<c::timespec>::uninit();
- ret(c::clock_gettime(
- id as c::clockid_t,
- old_timespec.as_mut_ptr(),
- ))?;
+ let old_timespec = unsafe {
+ ret(c::clock_gettime(
+ id as c::clockid_t,
+ old_timespec.as_mut_ptr(),
+ ))?;
+
+ old_timespec.assume_init()
+ };
- let old_timespec = old_timespec.assume_init();
Ok(Timespec {
tv_sec: old_timespec.tv_sec.into(),
tv_nsec: old_timespec.tv_nsec.into(),
@@ -251,25 +236,25 @@ unsafe fn clock_gettime_dynamic_old(id: c::clockid_t) -> io::Result<Timespec> {
)))]
#[inline]
pub(crate) fn clock_settime(id: ClockId, timespec: Timespec) -> io::Result<()> {
- #[cfg(all(
- any(target_arch = "arm", target_arch = "mips", target_arch = "x86"),
- target_env = "gnu",
- ))]
- unsafe {
+ // Old 32-bit version: libc has `clock_gettime` but it is not y2038 safe by
+ // default. But there may be a `__clock_settime64` we can use.
+ #[cfg(fix_y2038)]
+ {
+ #[cfg(target_env = "gnu")]
if let Some(libc_clock_settime) = __clock_settime64.get() {
- let mut new_timespec = core::mem::zeroed::<LibcTimespec>();
- new_timespec.tv_sec = timespec.tv_sec;
- new_timespec.tv_nsec = timespec.tv_nsec as _;
- ret(libc_clock_settime(id as c::clockid_t, &new_timespec))
- } else {
- clock_settime_old(id, timespec)
+ unsafe {
+ let mut new_timespec = core::mem::zeroed::<LibcTimespec>();
+ new_timespec.tv_sec = timespec.tv_sec;
+ new_timespec.tv_nsec = timespec.tv_nsec as _;
+ return ret(libc_clock_settime(id as c::clockid_t, &new_timespec));
+ }
}
+
+ clock_settime_old(id, timespec)
}
- #[cfg(not(all(
- any(target_arch = "arm", target_arch = "mips", target_arch = "x86"),
- target_env = "gnu",
- )))]
+ // Main version: libc is y2038 safe and has `clock_settime`.
+ #[cfg(not(fix_y2038))]
unsafe {
ret(c::clock_settime(id as c::clockid_t, &timespec))
}
@@ -280,11 +265,8 @@ pub(crate) fn clock_settime(id: ClockId, timespec: Timespec) -> io::Result<()> {
target_os = "wasi",
all(apple, not(target_os = "macos"))
)))]
-#[cfg(all(
- any(target_arch = "arm", target_arch = "mips", target_arch = "x86"),
- target_env = "gnu",
-))]
-unsafe fn clock_settime_old(id: ClockId, timespec: Timespec) -> io::Result<()> {
+#[cfg(fix_y2038)]
+fn clock_settime_old(id: ClockId, timespec: Timespec) -> io::Result<()> {
let old_timespec = c::timespec {
tv_sec: timespec
.tv_sec
@@ -292,7 +274,8 @@ unsafe fn clock_settime_old(id: ClockId, timespec: Timespec) -> io::Result<()> {
.map_err(|_| io::Errno::OVERFLOW)?,
tv_nsec: timespec.tv_nsec as _,
};
- ret(c::clock_settime(id as c::clockid_t, &old_timespec))
+
+ unsafe { ret(c::clock_settime(id as c::clockid_t, &old_timespec)) }
}
#[cfg(any(linux_kernel, target_os = "fuchsia"))]
@@ -308,31 +291,30 @@ pub(crate) fn timerfd_settime(
flags: TimerfdTimerFlags,
new_value: &Itimerspec,
) -> io::Result<Itimerspec> {
- let mut result = MaybeUninit::<LibcItimerspec>::uninit();
-
- #[cfg(all(
- any(target_arch = "arm", target_arch = "mips", target_arch = "x86"),
- target_env = "gnu",
- ))]
- unsafe {
+ // Old 32-bit version: libc has `timerfd_settime` but it is not y2038 safe
+ // by default. But there may be a `__timerfd_settime64` we can use.
+ #[cfg(fix_y2038)]
+ {
+ #[cfg(target_env = "gnu")]
if let Some(libc_timerfd_settime) = __timerfd_settime64.get() {
- ret(libc_timerfd_settime(
- borrowed_fd(fd),
- bitflags_bits!(flags),
- &new_value.clone().into(),
- result.as_mut_ptr(),
- ))?;
- Ok(result.assume_init().into())
- } else {
- timerfd_settime_old(fd, flags, new_value)
+ let mut result = MaybeUninit::<LibcItimerspec>::uninit();
+ unsafe {
+ ret(libc_timerfd_settime(
+ borrowed_fd(fd),
+ bitflags_bits!(flags),
+ &new_value.clone().into(),
+ result.as_mut_ptr(),
+ ))?;
+ return Ok(result.assume_init().into());
+ }
}
+
+ timerfd_settime_old(fd, flags, new_value)
}
- #[cfg(not(all(
- any(target_arch = "arm", target_arch = "mips", target_arch = "x86"),
- target_env = "gnu",
- )))]
+ #[cfg(not(fix_y2038))]
unsafe {
+ let mut result = MaybeUninit::<LibcItimerspec>::uninit();
ret(c::timerfd_settime(
borrowed_fd(fd),
bitflags_bits!(flags),
@@ -344,12 +326,9 @@ pub(crate) fn timerfd_settime(
}
#[cfg(any(linux_kernel, target_os = "fuchsia"))]
-#[cfg(all(
- any(target_arch = "arm", target_arch = "mips", target_arch = "x86"),
- target_env = "gnu",
-))]
+#[cfg(fix_y2038)]
#[cfg(feature = "time")]
-unsafe fn timerfd_settime_old(
+fn timerfd_settime_old(
fd: BorrowedFd<'_>,
flags: TimerfdTimerFlags,
new_value: &Itimerspec,
@@ -384,14 +363,16 @@ unsafe fn timerfd_settime_old(
},
};
- ret(c::timerfd_settime(
- borrowed_fd(fd),
- bitflags_bits!(flags),
- &old_new_value,
- old_result.as_mut_ptr(),
- ))?;
+ let old_result = unsafe {
+ ret(c::timerfd_settime(
+ borrowed_fd(fd),
+ bitflags_bits!(flags),
+ &old_new_value,
+ old_result.as_mut_ptr(),
+ ))?;
+ old_result.assume_init()
+ };
- let old_result = old_result.assume_init();
Ok(Itimerspec {
it_interval: Timespec {
tv_sec: old_result
@@ -415,43 +396,41 @@ unsafe fn timerfd_settime_old(
#[cfg(any(linux_kernel, target_os = "fuchsia"))]
#[cfg(feature = "time")]
pub(crate) fn timerfd_gettime(fd: BorrowedFd<'_>) -> io::Result<Itimerspec> {
- let mut result = MaybeUninit::<LibcItimerspec>::uninit();
-
- #[cfg(all(
- any(target_arch = "arm", target_arch = "mips", target_arch = "x86"),
- target_env = "gnu",
- ))]
- unsafe {
+ // Old 32-bit version: libc has `timerfd_gettime` but it is not y2038 safe
+ // by default. But there may be a `__timerfd_gettime64` we can use.
+ #[cfg(fix_y2038)]
+ {
+ #[cfg(target_env = "gnu")]
if let Some(libc_timerfd_gettime) = __timerfd_gettime64.get() {
- ret(libc_timerfd_gettime(borrowed_fd(fd), result.as_mut_ptr()))?;
- Ok(result.assume_init().into())
- } else {
- timerfd_gettime_old(fd)
+ let mut result = MaybeUninit::<LibcItimerspec>::uninit();
+ unsafe {
+ ret(libc_timerfd_gettime(borrowed_fd(fd), result.as_mut_ptr()))?;
+ return Ok(result.assume_init().into());
+ }
}
+
+ timerfd_gettime_old(fd)
}
- #[cfg(not(all(
- any(target_arch = "arm", target_arch = "mips", target_arch = "x86"),
- target_env = "gnu",
- )))]
+ #[cfg(not(fix_y2038))]
unsafe {
+ let mut result = MaybeUninit::<LibcItimerspec>::uninit();
ret(c::timerfd_gettime(borrowed_fd(fd), result.as_mut_ptr()))?;
Ok(result.assume_init())
}
}
#[cfg(any(linux_kernel, target_os = "fuchsia"))]
-#[cfg(all(
- any(target_arch = "arm", target_arch = "mips", target_arch = "x86"),
- target_env = "gnu",
-))]
+#[cfg(fix_y2038)]
#[cfg(feature = "time")]
-unsafe fn timerfd_gettime_old(fd: BorrowedFd<'_>) -> io::Result<Itimerspec> {
+fn timerfd_gettime_old(fd: BorrowedFd<'_>) -> io::Result<Itimerspec> {
let mut old_result = MaybeUninit::<c::itimerspec>::uninit();
- ret(c::timerfd_gettime(borrowed_fd(fd), old_result.as_mut_ptr()))?;
+ let old_result = unsafe {
+ ret(c::timerfd_gettime(borrowed_fd(fd), old_result.as_mut_ptr()))?;
+ old_result.assume_init()
+ };
- let old_result = old_result.assume_init();
Ok(Itimerspec {
it_interval: Timespec {
tv_sec: old_result
diff --git a/vendor/rustix/src/backend/libc/time/types.rs b/vendor/rustix/src/backend/libc/time/types.rs
index e1d4a8736..75cc61217 100644
--- a/vendor/rustix/src/backend/libc/time/types.rs
+++ b/vendor/rustix/src/backend/libc/time/types.rs
@@ -1,15 +1,10 @@
#[cfg(any(linux_kernel, target_os = "fuchsia"))]
use crate::backend::c;
-#[cfg(all(
- any(target_arch = "arm", target_arch = "mips", target_arch = "x86"),
- target_env = "gnu",
-))]
+#[cfg(any(linux_kernel, target_os = "fuchsia"))]
+#[cfg(fix_y2038)]
use crate::timespec::LibcTimespec;
#[cfg(any(linux_kernel, target_os = "fuchsia"))]
-#[cfg(all(
- any(target_arch = "arm", target_arch = "mips", target_arch = "x86"),
- target_env = "gnu",
-))]
+#[cfg(fix_y2038)]
use crate::timespec::Timespec;
#[cfg(any(linux_kernel, target_os = "fuchsia"))]
use bitflags::bitflags;
@@ -20,10 +15,7 @@ use bitflags::bitflags;
/// [`timerfd_gettime`]: crate::time::timerfd_gettime
/// [`timerfd_settime`]: crate::time::timerfd_settime
#[cfg(any(linux_kernel, target_os = "fuchsia"))]
-#[cfg(not(all(
- any(target_arch = "arm", target_arch = "mips", target_arch = "x86"),
- target_env = "gnu",
-)))]
+#[cfg(not(fix_y2038))]
pub type Itimerspec = c::itimerspec;
/// `struct itimerspec` for use with [`timerfd_gettime`] and
@@ -32,10 +24,7 @@ pub type Itimerspec = c::itimerspec;
/// [`timerfd_gettime`]: crate::time::timerfd_gettime
/// [`timerfd_settime`]: crate::time::timerfd_settime
#[cfg(any(linux_kernel, target_os = "fuchsia"))]
-#[cfg(all(
- any(target_arch = "arm", target_arch = "mips", target_arch = "x86"),
- target_env = "gnu",
-))]
+#[cfg(fix_y2038)]
#[allow(missing_docs)]
#[repr(C)]
#[derive(Debug, Clone)]
@@ -46,19 +35,13 @@ pub struct Itimerspec {
/// On most platforms, `LibcItimerspec` is just `Itimerspec`.
#[cfg(any(linux_kernel, target_os = "fuchsia"))]
-#[cfg(not(all(
- any(target_arch = "arm", target_arch = "mips", target_arch = "x86"),
- target_env = "gnu",
-)))]
+#[cfg(not(fix_y2038))]
pub(crate) type LibcItimerspec = Itimerspec;
/// On 32-bit glibc platforms, `LibcTimespec` differs from `Timespec`, so we
/// define our own struct, with bidirectional `From` impls.
#[cfg(any(linux_kernel, target_os = "fuchsia"))]
-#[cfg(all(
- any(target_arch = "arm", target_arch = "mips", target_arch = "x86"),
- target_env = "gnu",
-))]
+#[cfg(fix_y2038)]
#[repr(C)]
#[derive(Debug, Clone)]
pub(crate) struct LibcItimerspec {
@@ -67,10 +50,7 @@ pub(crate) struct LibcItimerspec {
}
#[cfg(any(linux_kernel, target_os = "fuchsia"))]
-#[cfg(all(
- any(target_arch = "arm", target_arch = "mips", target_arch = "x86"),
- target_env = "gnu",
-))]
+#[cfg(fix_y2038)]
impl From<LibcItimerspec> for Itimerspec {
#[inline]
fn from(t: LibcItimerspec) -> Self {
@@ -82,10 +62,7 @@ impl From<LibcItimerspec> for Itimerspec {
}
#[cfg(any(linux_kernel, target_os = "fuchsia"))]
-#[cfg(all(
- any(target_arch = "arm", target_arch = "mips", target_arch = "x86"),
- target_env = "gnu",
-))]
+#[cfg(fix_y2038)]
impl From<Itimerspec> for LibcItimerspec {
#[inline]
fn from(t: Itimerspec) -> Self {
@@ -179,7 +156,6 @@ pub enum TimerfdClockId {
#[cfg(any(linux_kernel, target_os = "fuchsia"))]
#[test]
fn test_types() {
- use core::mem::size_of;
- assert_eq!(size_of::<TimerfdFlags>(), size_of::<c::c_int>());
- assert_eq!(size_of::<TimerfdTimerFlags>(), size_of::<c::c_int>());
+ assert_eq_size!(TimerfdFlags, c::c_int);
+ assert_eq_size!(TimerfdTimerFlags, c::c_int);
}