]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/timeradd.3
rename.2: SEE ALSO: add rename(1)
[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.\"
4b8c67d9 27.TH TIMERADD 3 2017-09-15 "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>
dbfe9c70 33.PP
d6d74fd8
MK
34.BI "void timeradd(struct timeval *" a ", struct timeval *" b ,
35.BI " struct timeval *" res );
dbfe9c70 36.PP
d6d74fd8
MK
37.BI "void timersub(struct timeval *" a ", struct timeval *" b ,
38.BI " struct timeval *" res );
dbfe9c70 39.PP
d6d74fd8 40.BI "void timerclear(struct timeval *" tvp );
dbfe9c70 41.PP
f6c92d2a 42.BI "int timerisset(struct timeval *" tvp );
dbfe9c70 43.PP
f6c92d2a 44.BI "int timercmp(struct timeval *" a ", struct timeval *" b ", " CMP );
d6d74fd8 45.fi
68e4db0a 46.PP
d6d74fd8
MK
47.in -4n
48Feature Test Macro Requirements for glibc (see
49.BR feature_test_macros (7)):
50.in
68e4db0a 51.PP
cfc2d88d 52All functions shown above:
51c612fb
MK
53 Since glibc 2.19:
54 _DEFAULT_SOURCE
55 Glibc 2.19 and earlier:
56 _BSD_SOURCE
d6d74fd8
MK
57.SH DESCRIPTION
58The macros are provided to operate on
59.I timeval
60structures, defined in
0daa9e92 61.I <sys/time.h>
d6d74fd8 62as:
51f5698d 63.PP
088a639b 64.in +4n
bdd915e2 65.EX
d6d74fd8
MK
66struct timeval {
67 time_t tv_sec; /* seconds */
68 suseconds_t tv_usec; /* microseconds */
69};
bdd915e2 70.EE
088a639b 71.in
d6d74fd8
MK
72.PP
73.BR timeradd ()
74adds the time values in
75.I a
76and
77.IR b ,
78and places the sum in the
79.I timeval
80pointed to by
81.IR res .
82The result is normalized such that
94e9d9fe 83.I res\->tv_usec
d6d74fd8 84has a value in the range 0 to 999,999.
847e0d88 85.PP
d6d74fd8 86.BR timersub ()
93d67152 87subtracts the time value in
d6d74fd8 88.I b
93d67152 89from the time value in
d6d74fd8
MK
90.IR a ,
91and places the result in the
92.I timeval
93pointed to by
94.IR res .
95The result is normalized such that
94e9d9fe 96.I res\->tv_usec
d6d74fd8 97has a value in the range 0 to 999,999.
847e0d88 98.PP
d6d74fd8 99.BR timerclear ()
7b01461a 100zeros out the
d6d74fd8
MK
101.I timeval
102structure pointed to by
103.IR tvp ,
f49c451a 104so that it represents the Epoch: 1970-01-01 00:00:00 +0000 (UTC).
847e0d88 105.PP
d6d74fd8 106.BR timerisset ()
c7094399 107returns true (nonzero) if either field of the
d6d74fd8
MK
108.I timeval
109structure pointed to by
0daa9e92 110.I tvp
c7094399 111contains a nonzero value.
847e0d88 112.PP
d6d74fd8
MK
113.BR timercmp ()
114compares the timer values in
115.I a
116and
0daa9e92 117.I b
d6d74fd8
MK
118using the comparison operator
119.IR CMP ,
c7094399 120and returns true (nonzero) or false (0) depending on
d6d74fd8 121the result of the comparison.
6652fffa
MK
122Some systems (but not Linux/glibc),
123have a broken
124.BR timercmp ()
125implementation,
126.\" HP-UX, Tru64, Irix have a definition like:
127.\"#define timercmp(tvp, uvp, cmp) \
128.\" ((tvp)->tv_sec cmp (uvp)->tv_sec || \
129.\" (tvp)->tv_sec == (uvp)->tv_sec && (tvp)->tv_usec cmp (uvp)->tv_usec)
130in which
131.I CMP
132of
133.IR >= ,
134.IR <= ,
135and
136.I ==
137do not work;
138portable applications can instead use
847e0d88 139.PP
6652fffa
MK
140 !timercmp(..., <)
141 !timercmp(..., >)
142 !timercmp(..., !=)
d6d74fd8
MK
143.SH RETURN VALUE
144.BR timerisset ()
145and
146.BR timercmp ()
c7094399 147return true (nonzero) or false (0).
d6d74fd8
MK
148.SH ERRORS
149No errors are defined.
150.SH CONFORMING TO
7aecd4d8 151Not in POSIX.1.
d6d74fd8 152Present on most BSD derivatives.
47297adb 153.SH SEE ALSO
d6d74fd8 154.BR gettimeofday (2),
f0c34053 155.BR time (7)