summaryrefslogtreecommitdiffstats
path: root/vendor/rustix/src/time
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/rustix/src/time')
-rw-r--r--vendor/rustix/src/time/clock.rs24
-rw-r--r--vendor/rustix/src/time/mod.rs11
2 files changed, 25 insertions, 10 deletions
diff --git a/vendor/rustix/src/time/clock.rs b/vendor/rustix/src/time/clock.rs
index f76e3fa18..1bf74d60b 100644
--- a/vendor/rustix/src/time/clock.rs
+++ b/vendor/rustix/src/time/clock.rs
@@ -14,7 +14,7 @@ pub use backend::time::types::{ClockId, DynamicClockId};
///
/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/clock_getres.html
/// [Linux]: https://man7.org/linux/man-pages/man2/clock_getres.2.html
-#[cfg(any(not(any(target_os = "redox", target_os = "wasi"))))]
+#[cfg(not(any(target_os = "redox", target_os = "wasi")))]
#[inline]
#[must_use]
pub fn clock_getres(id: ClockId) -> Timespec {
@@ -54,3 +54,25 @@ pub fn clock_gettime(id: ClockId) -> Timespec {
pub fn clock_gettime_dynamic(id: DynamicClockId<'_>) -> io::Result<Timespec> {
backend::time::syscalls::clock_gettime_dynamic(id)
}
+
+/// `clock_settime(id, timespec)`—Sets the current value of a settable clock.
+///
+/// This fails with [`io::Errno::INVAL`] if the clock is not settable, and
+/// [`io::Errno::ACCESS`] if the current process does not have permission to
+/// set it.
+///
+/// # References
+/// - [POSIX]
+/// - [Linux]
+///
+/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/clock_settime.html
+/// [Linux]: https://man7.org/linux/man-pages/man2/clock_settime.2.html
+#[cfg(not(any(
+ target_os = "redox",
+ target_os = "wasi",
+ all(apple, not(target_os = "macos"))
+)))]
+#[inline]
+pub fn clock_settime(id: ClockId, timespec: Timespec) -> io::Result<()> {
+ backend::time::syscalls::clock_settime(id, timespec)
+}
diff --git a/vendor/rustix/src/time/mod.rs b/vendor/rustix/src/time/mod.rs
index ca5b2b2dd..9a0dcb4d7 100644
--- a/vendor/rustix/src/time/mod.rs
+++ b/vendor/rustix/src/time/mod.rs
@@ -7,14 +7,7 @@ mod timerfd;
// TODO: Convert WASI'S clock APIs to use handles rather than ambient clock
// identifiers, update `wasi-libc`, and then add support in `rustix`.
-#[cfg(not(any(target_os = "redox", target_os = "wasi")))]
-pub use clock::clock_getres;
-#[cfg(not(target_os = "wasi"))]
-pub use clock::{clock_gettime, clock_gettime_dynamic, ClockId, DynamicClockId};
-pub use clock::{Nsecs, Secs, Timespec};
+pub use clock::*;
#[cfg(any(target_os = "android", target_os = "fuchsia", target_os = "linux"))]
#[cfg(feature = "time")]
-pub use timerfd::{
- timerfd_create, timerfd_gettime, timerfd_settime, Itimerspec, TimerfdClockId, TimerfdFlags,
- TimerfdTimerFlags,
-};
+pub use timerfd::*;