]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/timeradd.3
getauxval.3: wfix
[thirdparty/man-pages.git] / man3 / timeradd.3
CommitLineData
c11b1abf 1.\" Copyright (c) 2007 by Michael Kerrisk <mtk.manpages@gmail.com>
d6d74fd8 2.\"
93015253 3.\" %%%LICENSE_START(VERBATIM)
d6d74fd8
MK
4.\" Permission is granted to make and distribute verbatim copies of this
5.\" manual provided the copyright notice and this permission notice are
6.\" preserved on all copies.
7.\"
8.\" Permission is granted to copy and distribute modified versions of this
9.\" manual under the conditions for verbatim copying, provided that the
10.\" entire resulting derived work is distributed under the terms of a
11.\" permission notice identical to this one.
12.\"
13.\" Since the Linux kernel and libraries are constantly changing, this
14.\" manual page may be incorrect or out-of-date. The author(s) assume no
15.\" responsibility for errors or omissions, or for damages resulting from
10d76543
MK
16.\" the use of the information contained herein. The author(s) may not
17.\" have taken the same level of care in the production of this manual,
18.\" which is licensed free of charge, as they might when working
19.\" professionally.
d6d74fd8
MK
20.\"
21.\" Formatted or processed versions of this manual, if unaccompanied by
22.\" the source, must acknowledge the copyright and authors of this work.
4b72fb64 23.\" %%%LICENSE_END
d6d74fd8
MK
24.\"
25.\" 2007-07-31, mtk, Created
26.\"
513051f7 27.TH TIMERADD 3 2010-02-25 "Linux" "Linux Programmer's Manual"
d6d74fd8 28.SH NAME
93d67152 29timeradd, timersub, timercmp, timerclear, timerisset \- timeval operations
d6d74fd8
MK
30.SH SYNOPSIS
31.nf
32.B #include <sys/time.h>
33
34.BI "void timeradd(struct timeval *" a ", struct timeval *" b ,
35.BI " struct timeval *" res );
36
37.BI "void timersub(struct timeval *" a ", struct timeval *" b ,
38.BI " struct timeval *" res );
39
40.BI "void timerclear(struct timeval *" tvp );
41
f6c92d2a 42.BI "int timerisset(struct timeval *" tvp );
d6d74fd8 43
f6c92d2a 44.BI "int timercmp(struct timeval *" a ", struct timeval *" b ", " CMP );
d6d74fd8
MK
45.fi
46.sp
47.in -4n
48Feature Test Macro Requirements for glibc (see
49.BR feature_test_macros (7)):
50.in
51.sp
cfc2d88d 52All functions shown above:
d6d74fd8
MK
53_BSD_SOURCE
54.SH DESCRIPTION
55The macros are provided to operate on
56.I timeval
57structures, defined in
0daa9e92 58.I <sys/time.h>
d6d74fd8
MK
59as:
60.sp
088a639b 61.in +4n
d6d74fd8
MK
62.nf
63struct timeval {
64 time_t tv_sec; /* seconds */
65 suseconds_t tv_usec; /* microseconds */
66};
67.fi
088a639b 68.in
d6d74fd8
MK
69.PP
70.BR timeradd ()
71adds the time values in
72.I a
73and
74.IR b ,
75and places the sum in the
76.I timeval
77pointed to by
78.IR res .
79The result is normalized such that
94e9d9fe 80.I res\->tv_usec
d6d74fd8
MK
81has a value in the range 0 to 999,999.
82
83.BR timersub ()
93d67152 84subtracts the time value in
d6d74fd8 85.I b
93d67152 86from the time value in
d6d74fd8
MK
87.IR a ,
88and places the result in the
89.I timeval
90pointed to by
91.IR res .
92The result is normalized such that
94e9d9fe 93.I res\->tv_usec
d6d74fd8
MK
94has a value in the range 0 to 999,999.
95
96.BR timerclear ()
7b01461a 97zeros out the
d6d74fd8
MK
98.I timeval
99structure pointed to by
100.IR tvp ,
f49c451a 101so that it represents the Epoch: 1970-01-01 00:00:00 +0000 (UTC).
d6d74fd8
MK
102
103.BR timerisset ()
c7094399 104returns true (nonzero) if either field of the
d6d74fd8
MK
105.I timeval
106structure pointed to by
0daa9e92 107.I tvp
c7094399 108contains a nonzero value.
d6d74fd8
MK
109
110.BR timercmp ()
111compares the timer values in
112.I a
113and
0daa9e92 114.I b
d6d74fd8
MK
115using the comparison operator
116.IR CMP ,
c7094399 117and returns true (nonzero) or false (0) depending on
d6d74fd8 118the result of the comparison.
6652fffa
MK
119Some systems (but not Linux/glibc),
120have a broken
121.BR timercmp ()
122implementation,
123.\" HP-UX, Tru64, Irix have a definition like:
124.\"#define timercmp(tvp, uvp, cmp) \
125.\" ((tvp)->tv_sec cmp (uvp)->tv_sec || \
126.\" (tvp)->tv_sec == (uvp)->tv_sec && (tvp)->tv_usec cmp (uvp)->tv_usec)
127in which
128.I CMP
129of
130.IR >= ,
131.IR <= ,
132and
133.I ==
134do not work;
135portable applications can instead use
136
137 !timercmp(..., <)
138 !timercmp(..., >)
139 !timercmp(..., !=)
d6d74fd8
MK
140.SH RETURN VALUE
141.BR timerisset ()
142and
143.BR timercmp ()
c7094399 144return true (nonzero) or false (0).
d6d74fd8
MK
145.SH ERRORS
146No errors are defined.
147.SH CONFORMING TO
7aecd4d8 148Not in POSIX.1.
d6d74fd8 149Present on most BSD derivatives.
47297adb 150.SH SEE ALSO
d6d74fd8 151.BR gettimeofday (2),
f0c34053 152.BR time (7)