1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
use crate::backend::c;
#[cfg(not(all(
libc,
any(target_arch = "arm", target_arch = "mips", target_arch = "x86"),
target_env = "gnu",
)))]
pub type Timespec = c::timespec;
#[cfg(all(
libc,
any(target_arch = "arm", target_arch = "mips", target_arch = "x86"),
target_env = "gnu",
))]
#[derive(Debug, Clone, Copy)]
#[repr(C)]
pub struct Timespec {
pub tv_sec: Secs,
pub tv_nsec: Nsecs,
}
#[cfg(not(all(
any(target_arch = "arm", target_arch = "mips", target_arch = "x86"),
target_env = "gnu",
)))]
#[allow(deprecated)]
pub type Secs = c::time_t;
#[cfg(all(
any(target_arch = "arm", target_arch = "mips", target_arch = "x86"),
target_env = "gnu",
))]
pub type Secs = i64;
#[cfg(all(libc, target_arch = "x86_64", target_pointer_width = "32"))]
pub type Nsecs = i64;
#[cfg(all(libc, not(all(target_arch = "x86_64", target_pointer_width = "32"))))]
pub type Nsecs = c::c_long;
#[cfg(linux_raw)]
pub type Nsecs = i64;
#[cfg(all(
libc,
any(target_arch = "arm", target_arch = "mips", target_arch = "x86"),
target_env = "gnu",
))]
#[repr(C)]
#[derive(Debug, Clone)]
pub(crate) struct LibcTimespec {
pub(crate) tv_sec: Secs,
#[cfg(target_endian = "big")]
padding: core::mem::MaybeUninit<u32>,
pub(crate) tv_nsec: Nsecs,
#[cfg(target_endian = "little")]
padding: core::mem::MaybeUninit<u32>,
}
#[cfg(all(
libc,
any(target_arch = "arm", target_arch = "mips", target_arch = "x86"),
target_env = "gnu",
))]
impl From<LibcTimespec> for Timespec {
#[inline]
fn from(t: LibcTimespec) -> Self {
Self {
tv_sec: t.tv_sec,
tv_nsec: t.tv_nsec,
}
}
}
#[cfg(all(
libc,
any(target_arch = "arm", target_arch = "mips", target_arch = "x86"),
target_env = "gnu",
))]
impl From<Timespec> for LibcTimespec {
#[inline]
fn from(t: Timespec) -> Self {
Self {
tv_sec: t.tv_sec,
tv_nsec: t.tv_nsec,
padding: core::mem::MaybeUninit::uninit(),
}
}
}