1.fp 5 CW
2.de Af
3.ds ;G \\*(;G\\f\\$1\\$3\\f\\$2
4.if !\\$4 .Af \\$2 \\$1 "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
5..
6.de aF
7.ie \\$3 .ft \\$1
8.el \{\
9.ds ;G \&
10.nr ;G \\n(.f
11.Af "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
12\\*(;G
13.ft \\n(;G \}
14..
15.de L
16.aF 5 \\n(.f "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
17..
18.de LR
19.aF 5 1 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
20..
21.de RL
22.aF 1 5 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
23..
24.de EX		\" start example
25.ta 1i 2i 3i 4i 5i 6i
26.PP
27.RS 
28.PD 0
29.ft 5
30.nf
31..
32.de EE		\" end example
33.fi
34.ft
35.PD
36.RE
37.PP
38..
39.TH TM 3
40.SH NAME
41tv \- high resolution time support
42.SH SYNOPSIS
43.L "#include <tv.h>"
44.SH DESCRIPTION
45The
46.I tv
47library supports high resolution
48.B Tv_t
49time specifications.
50.SS Tv_t
51contains these elements:
52.TP
53.L unsigned
54.L _ast_int4_t
55.L tv_sec
56Seconds since the epoch.
57.TP
58.L unsigned
59.L _ast_int4_t
60.L tv_nsec
61Nanosecond resolution.
62.PP
63In practice resolution is much coarser than 1 nanosecond.
64Systems that only support 1 second resolution always set
65.L tv_nsec
66to 0.
67.SS "int tvgettime(Tv_t* tv)"
68Sets
69.L tv
70to the current time.
71.L 0
72is returned on success,
73.L -1
74on error.
75.SS "int tvsettime(const Tv_t* tv)"
76Sets the system time to
77.LR tv .
78The caller must have sufficient privilege.
79.L 0
80is returned on success,
81.L -1
82on error.
83.SS "int tvcmp(const Tv_t* av, const Tv_t* bv)"
84Compares the times
85.L av
86and
87.L bv
88and returns
89.L -1
90if
91.L av
92is less than
93.LR bv ,
94.L 0
95if
96.L av
97is equal to
98.LR bv ,
99and
100.L 1
101if
102.L av
103is greater than
104.LR bv .
105.SS "time_t tvgetatime(const struct stat* st, Tv_t* tv)"
106.SS "time_t tvgetmtime(const struct stat* st, Tv_t* tv)"
107.SS "time_t tvgetctime(const struct stat* st, Tv_t* tv)"
108These macros set
109.L tv
110to the
111.L st
112the access, modify, or change time, respectively.
113The seconds portion of
114.L tv
115is returned.
116.SS "time_t tvsetatime(struct stat* st, const Tv_t* tv)"
117.SS "time_t tvsetmtime(struct stat* st, const Tv_t* tv)"
118.SS "time_t tvsetctime(struct stat* st, const Tv_t* tv)"
119These macros set the
120.L st
121access, modify, or change time, respectively, to
122.LR tv .
123The seconds portion of
124.L tv
125is returned.
126.SS "int tvtouch(const char* path, const Tv_t* av, const Tv_t* mv, const Tv_t* cv, int copy)"
127Sets the file
128.L path
129access time from
130.LR av ,
131modify time from
132.LR mv ,
133and change time from
134.LR cv .
135Any of
136.LR av ,
137.LR mv ,
138and
139.L cv
140may be 0; the corresponding file time will retain the previous value if
141.L path
142exists and
143.L copy
144is
145.L 1 ;
146otherwise the corresponding file time will be set to the current time.
147.L 0
148is returned on success,
149.L -1
150on error.
151.SS "int tvsleep(const Tv_t* tv, Tv_t* rv)"
152Pauses execution for
153.L tv
154time.
155.L 0
156is returned if the full
157.L tv
158amount has expired.
159Otherwise
160.L -1
161is returned and
162.LR rv ,
163if not 0, is set to the sleep time remaining.
164.SH "RETURN VALUE"
165Except for
166.LR tvcmp() ,
167an error return of
168.L -1
169also sets
170.L errno
171to the corresponding error code.
172.SH "SEE ALSO"
173tm(3)
174