summaryrefslogtreecommitdiff
path: root/usr/src/lib/libast/common/man/tv.3
blob: 82b0dc40c6e3c054aac1a5424645e63f1e0a92b5 (plain)
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
.fp 5 CW
.de Af
.ds ;G \\*(;G\\f\\$1\\$3\\f\\$2
.if !\\$4 .Af \\$2 \\$1 "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
..
.de aF
.ie \\$3 .ft \\$1
.el \{\
.ds ;G \&
.nr ;G \\n(.f
.Af "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
\\*(;G
.ft \\n(;G \}
..
.de L
.aF 5 \\n(.f "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
..
.de LR
.aF 5 1 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
..
.de RL
.aF 1 5 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
..
.de EX		\" start example
.ta 1i 2i 3i 4i 5i 6i
.PP
.RS 
.PD 0
.ft 5
.nf
..
.de EE		\" end example
.fi
.ft
.PD
.RE
.PP
..
.TH TM 3
.SH NAME
tv \- high resolution time support
.SH SYNOPSIS
.L "#include <tv.h>"
.SH DESCRIPTION
The
.I tv
library supports high resolution
.B Tv_t
time specifications.
.SS Tv_t
contains these elements:
.TP
.L unsigned
.L _ast_int4_t
.L tv_sec
Seconds since the epoch.
.TP
.L unsigned
.L _ast_int4_t
.L tv_nsec
Nanosecond resolution.
.PP
In practice resolution is much coarser than 1 nanosecond.
Systems that only support 1 second resolution always set
.L tv_nsec
to 0.
.SS "int tvgettime(Tv_t* tv)"
Sets
.L tv
to the current time.
.L 0
is returned on success,
.L -1
on error.
.SS "int tvsettime(const Tv_t* tv)"
Sets the system time to
.LR tv .
The caller must have sufficient privilege.
.L 0
is returned on success,
.L -1
on error.
.SS "int tvcmp(const Tv_t* av, const Tv_t* bv)"
Compares the times
.L av
and
.L bv
and returns
.L -1
if
.L av
is less than
.LR bv ,
.L 0
if
.L av
is equal to
.LR bv ,
and
.L 1
if
.L av
is greater than
.LR bv .
.SS "time_t tvgetatime(const struct stat* st, Tv_t* tv)"
.SS "time_t tvgetmtime(const struct stat* st, Tv_t* tv)"
.SS "time_t tvgetctime(const struct stat* st, Tv_t* tv)"
These macros set
.L tv
to the
.L st
the access, modify, or change time, respectively.
The seconds portion of
.L tv
is returned.
.SS "time_t tvsetatime(struct stat* st, const Tv_t* tv)"
.SS "time_t tvsetmtime(struct stat* st, const Tv_t* tv)"
.SS "time_t tvsetctime(struct stat* st, const Tv_t* tv)"
These macros set the
.L st
access, modify, or change time, respectively, to
.LR tv .
The seconds portion of
.L tv
is returned.
.SS "int tvtouch(const char* path, const Tv_t* av, const Tv_t* mv, const Tv_t* cv, int copy)"
Sets the file
.L path
access time from
.LR av ,
modify time from
.LR mv ,
and change time from
.LR cv .
Any of
.LR av ,
.LR mv ,
and
.L cv
may be 0; the corresponding file time will retain the previous value if
.L path
exists and
.L copy
is
.L 1 ;
otherwise the corresponding file time will be set to the current time.
.L 0
is returned on success,
.L -1
on error.
.SS "int tvsleep(const Tv_t* tv, Tv_t* rv)"
Pauses execution for
.L tv
time.
.L 0
is returned if the full
.L tv
amount has expired.
Otherwise
.L -1
is returned and
.LR rv ,
if not 0, is set to the sleep time remaining.
.SH "RETURN VALUE"
Except for
.LR tvcmp() ,
an error return of
.L -1
also sets
.L errno
to the corresponding error code.
.SH "SEE ALSO"
tm(3)