nc 0.9.8

Access system calls directly
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
/// Get time in seconds.
///
/// # Examples
///
/// ```
/// let mut t = 0;
/// let ret = unsafe { nc::time(&mut t) };
/// assert_eq!(ret.unwrap(), t);
/// assert!(t > 1610421040);
/// ```
pub unsafe fn time(t: &mut time_t) -> Result<time_t, Errno> {
    let t_ptr = core::ptr::from_mut::<time_t>(t) as usize;
    unsafe { syscall1(SYS_TIME, t_ptr).map(|ret| ret as time_t) }
}