]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/timeradd.3
Many pages: Fix style issues reported by `make lint-groff`
[thirdparty/man-pages.git] / man3 / timeradd.3
CommitLineData
c11b1abf 1.\" Copyright (c) 2007 by Michael Kerrisk <mtk.manpages@gmail.com>
d6d74fd8 2.\"
5fbde956 3.\" SPDX-License-Identifier: Linux-man-pages-copyleft
d6d74fd8
MK
4.\"
5.\" 2007-07-31, mtk, Created
6.\"
1d767b55 7.TH TIMERADD 3 2021-03-22 "Linux" "Linux Programmer's Manual"
d6d74fd8 8.SH NAME
93d67152 9timeradd, timersub, timercmp, timerclear, timerisset \- timeval operations
e90d015d
AC
10.SH LIBRARY
11Standard C library
8fc3b2cf 12.RI ( libc ", " \-lc )
d6d74fd8
MK
13.SH SYNOPSIS
14.nf
15.B #include <sys/time.h>
dbfe9c70 16.PP
d6d74fd8
MK
17.BI "void timeradd(struct timeval *" a ", struct timeval *" b ,
18.BI " struct timeval *" res );
d6d74fd8
MK
19.BI "void timersub(struct timeval *" a ", struct timeval *" b ,
20.BI " struct timeval *" res );
dbfe9c70 21.PP
d6d74fd8 22.BI "void timerclear(struct timeval *" tvp );
f6c92d2a 23.BI "int timerisset(struct timeval *" tvp );
dbfe9c70 24.PP
f6c92d2a 25.BI "int timercmp(struct timeval *" a ", struct timeval *" b ", " CMP );
d6d74fd8 26.fi
68e4db0a 27.PP
d39ad78f 28.RS -4
d6d74fd8
MK
29Feature Test Macro Requirements for glibc (see
30.BR feature_test_macros (7)):
d39ad78f 31.RE
68e4db0a 32.PP
cfc2d88d 33All functions shown above:
9d281e06 34.nf
51c612fb
MK
35 Since glibc 2.19:
36 _DEFAULT_SOURCE
37 Glibc 2.19 and earlier:
38 _BSD_SOURCE
9d281e06 39.fi
d6d74fd8
MK
40.SH DESCRIPTION
41The macros are provided to operate on
42.I timeval
43structures, defined in
0daa9e92 44.I <sys/time.h>
d6d74fd8 45as:
51f5698d 46.PP
088a639b 47.in +4n
bdd915e2 48.EX
d6d74fd8
MK
49struct timeval {
50 time_t tv_sec; /* seconds */
51 suseconds_t tv_usec; /* microseconds */
52};
bdd915e2 53.EE
088a639b 54.in
d6d74fd8
MK
55.PP
56.BR timeradd ()
57adds the time values in
58.I a
59and
60.IR b ,
61and places the sum in the
62.I timeval
63pointed to by
64.IR res .
65The result is normalized such that
94e9d9fe 66.I res\->tv_usec
d6d74fd8 67has a value in the range 0 to 999,999.
847e0d88 68.PP
d6d74fd8 69.BR timersub ()
93d67152 70subtracts the time value in
d6d74fd8 71.I b
93d67152 72from the time value in
d6d74fd8
MK
73.IR a ,
74and places the result in the
75.I timeval
76pointed to by
77.IR res .
78The result is normalized such that
94e9d9fe 79.I res\->tv_usec
d6d74fd8 80has a value in the range 0 to 999,999.
847e0d88 81.PP
d6d74fd8 82.BR timerclear ()
7b01461a 83zeros out the
d6d74fd8
MK
84.I timeval
85structure pointed to by
86.IR tvp ,
f49c451a 87so that it represents the Epoch: 1970-01-01 00:00:00 +0000 (UTC).
847e0d88 88.PP
d6d74fd8 89.BR timerisset ()
c7094399 90returns true (nonzero) if either field of the
d6d74fd8
MK
91.I timeval
92structure pointed to by
0daa9e92 93.I tvp
c7094399 94contains a nonzero value.
847e0d88 95.PP
d6d74fd8
MK
96.BR timercmp ()
97compares the timer values in
98.I a
99and
0daa9e92 100.I b
d6d74fd8
MK
101using the comparison operator
102.IR CMP ,
c7094399 103and returns true (nonzero) or false (0) depending on
d6d74fd8 104the result of the comparison.
6652fffa
MK
105Some systems (but not Linux/glibc),
106have a broken
107.BR timercmp ()
108implementation,
109.\" HP-UX, Tru64, Irix have a definition like:
110.\"#define timercmp(tvp, uvp, cmp) \
111.\" ((tvp)->tv_sec cmp (uvp)->tv_sec || \
112.\" (tvp)->tv_sec == (uvp)->tv_sec && (tvp)->tv_usec cmp (uvp)->tv_usec)
113in which
114.I CMP
115of
116.IR >= ,
117.IR <= ,
118and
119.I ==
120do not work;
121portable applications can instead use
847e0d88 122.PP
1ae6b2c7
AC
123.in +4n
124.EX
125!timercmp(..., <)
126!timercmp(..., >)
127!timercmp(..., !=)
128.EE
129.in
d6d74fd8
MK
130.SH RETURN VALUE
131.BR timerisset ()
132and
133.BR timercmp ()
c7094399 134return true (nonzero) or false (0).
d6d74fd8
MK
135.SH ERRORS
136No errors are defined.
137.SH CONFORMING TO
7aecd4d8 138Not in POSIX.1.
d6d74fd8 139Present on most BSD derivatives.
47297adb 140.SH SEE ALSO
d6d74fd8 141.BR gettimeofday (2),
f0c34053 142.BR time (7)