libc_core/
time.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
//! This module provides the `libc` types for Time (time management).
//!
//! MUSL: <https://github.com/bminor/musl/blob/c47ad25ea3b484e10326f933e927c0bc8cded3da/include/sys/time.h>

use crate::types::TimeVal;

/// 定时器结构体,表示间隔和当前值(对应 C 语言中的 `struct itimerval`)
#[repr(C)]
#[cfg_attr(
    feature = "zerocopy",
    derive(
        zerocopy::FromBytes,
        zerocopy::Immutable,
        zerocopy::IntoBytes,
        zerocopy::KnownLayout
    )
)]
#[derive(Clone, Debug, Default)]
pub struct ITimerVal {
    /// 重复触发的间隔时间(interval > 0 表示周期性定时器)
    pub interval: TimeVal,
    /// 当前倒计时的剩余时间(初始超时时长)
    pub value: TimeVal,
}