Lines Matching +full:use +full:- +full:libc
1 use crate::sys::time::TimeSpec;
10 use crate::unistd::Pid;
11 use crate::{Errno, Result};
12 use libc::{self, clockid_t};
13 use std::mem::MaybeUninit;
24 pub const fn from_raw(clk_id: clockid_t) -> Self { in from_raw()
30 /// Returns `ClockId` of a `pid` CPU-time clock
39 pub fn pid_cpu_clock_id(pid: Pid) -> Result<Self> {
47 pub fn res(self) -> Result<TimeSpec> { in res()
52 pub fn now(self) -> Result<TimeSpec> { in now()
64 pub fn set_time(self, timespec: TimeSpec) -> Result<()> { in set_time()
69 pub const fn as_raw(self) -> clockid_t { in as_raw()
80 pub const CLOCK_BOOTTIME: ClockId = ClockId(libc::CLOCK_BOOTTIME);
89 ClockId(libc::CLOCK_BOOTTIME_ALARM);
90 pub const CLOCK_MONOTONIC: ClockId = ClockId(libc::CLOCK_MONOTONIC);
99 ClockId(libc::CLOCK_MONOTONIC_COARSE);
103 ClockId(libc::CLOCK_MONOTONIC_FAST);
107 ClockId(libc::CLOCK_MONOTONIC_PRECISE);
115 pub const CLOCK_MONOTONIC_RAW: ClockId = ClockId(libc::CLOCK_MONOTONIC_RAW);
129 ClockId(libc::CLOCK_PROCESS_CPUTIME_ID);
132 pub const CLOCK_PROF: ClockId = ClockId(libc::CLOCK_PROF);
133 pub const CLOCK_REALTIME: ClockId = ClockId(libc::CLOCK_REALTIME);
142 ClockId(libc::CLOCK_REALTIME_ALARM);
151 ClockId(libc::CLOCK_REALTIME_COARSE);
154 pub const CLOCK_REALTIME_FAST: ClockId = ClockId(libc::CLOCK_REALTIME_FAST);
158 ClockId(libc::CLOCK_REALTIME_PRECISE);
161 pub const CLOCK_SECOND: ClockId = ClockId(libc::CLOCK_SECOND);
168 pub const CLOCK_SGI_CYCLE: ClockId = ClockId(libc::CLOCK_SGI_CYCLE);
176 pub const CLOCK_TAI: ClockId = ClockId(libc::CLOCK_TAI);
189 ClockId(libc::CLOCK_THREAD_CPUTIME_ID);
192 pub const CLOCK_UPTIME: ClockId = ClockId(libc::CLOCK_UPTIME);
195 pub const CLOCK_UPTIME_FAST: ClockId = ClockId(libc::CLOCK_UPTIME_FAST);
199 ClockId(libc::CLOCK_UPTIME_PRECISE);
202 pub const CLOCK_VIRTUAL: ClockId = ClockId(libc::CLOCK_VIRTUAL);
206 fn from(clock_id: ClockId) -> Self { in from()
212 fn from(clk_id: clockid_t) -> Self { in from()
218 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { in fmt()
227 pub fn clock_getres(clock_id: ClockId) -> Result<TimeSpec> { in clock_getres()
228 let mut c_time: MaybeUninit<libc::timespec> = MaybeUninit::uninit(); in clock_getres()
230 unsafe { libc::clock_getres(clock_id.as_raw(), c_time.as_mut_ptr()) }; in clock_getres()
238 pub fn clock_gettime(clock_id: ClockId) -> Result<TimeSpec> { in clock_gettime()
239 let mut c_time: MaybeUninit<libc::timespec> = MaybeUninit::uninit(); in clock_gettime()
241 unsafe { libc::clock_gettime(clock_id.as_raw(), c_time.as_mut_ptr()) }; in clock_gettime()
256 pub fn clock_settime(clock_id: ClockId, timespec: TimeSpec) -> Result<()> { in clock_settime()
258 unsafe { libc::clock_settime(clock_id.as_raw(), timespec.as_ref()) }; in clock_settime()
273 pub fn clock_getcpuclockid(pid: Pid) -> Result<ClockId> { in clock_getcpuclockid()
274 let mut clk_id: MaybeUninit<libc::clockid_t> = MaybeUninit::uninit(); in clock_getcpuclockid()
276 unsafe { libc::clock_getcpuclockid(pid.into(), clk_id.as_mut_ptr()) }; in clock_getcpuclockid()