1TIMERADD(3)                Linux Programmer's Manual               TIMERADD(3)
2
3
4

NAME

6       timeradd,  timersub,  timercmp, timerclear, timerisset - timeval opera‐
7       tions
8

SYNOPSIS

10       #include <sys/time.h>
11
12       void timeradd(struct timeval *a, struct timeval *b,
13                     struct timeval *res);
14
15       void timersub(struct timeval *a, struct timeval *b,
16                     struct timeval *res);
17
18       void timerclear(struct timeval *tvp);
19
20       int timerisset(struct timeval *tvp);
21
22       int timercmp(struct timeval *a, struct timeval *b, CMP);
23
24   Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
25
26       All functions shown above:
27           Since glibc 2.19:
28               _DEFAULT_SOURCE
29           Glibc 2.19 and earlier:
30               _BSD_SOURCE
31

DESCRIPTION

33       The macros are provided to operate on timeval  structures,  defined  in
34       <sys/time.h> as:
35
36           struct timeval {
37               time_t      tv_sec;     /* seconds */
38               suseconds_t tv_usec;    /* microseconds */
39           };
40
41       timeradd()  adds  the time values in a and b, and places the sum in the
42       timeval pointed  to  by  res.   The  result  is  normalized  such  that
43       res->tv_usec has a value in the range 0 to 999,999.
44
45       timersub()  subtracts the time value in b from the time value in a, and
46       places the result in the timeval pointed to by res.  The result is nor‐
47       malized such that res->tv_usec has a value in the range 0 to 999,999.
48
49       timerclear() zeros out the timeval structure pointed to by tvp, so that
50       it represents the Epoch: 1970-01-01 00:00:00 +0000 (UTC).
51
52       timerisset() returns true (nonzero) if  either  field  of  the  timeval
53       structure pointed to by tvp contains a nonzero value.
54
55       timercmp()  compares  the  timer values in a and b using the comparison
56       operator CMP, and returns true (nonzero) or false (0) depending on  the
57       result  of  the comparison.  Some systems (but not Linux/glibc), have a
58       broken timercmp() implementation, in which CMP of >=, <=, and == do not
59       work; portable applications can instead use
60
61           !timercmp(..., <)
62           !timercmp(..., >)
63           !timercmp(..., !=)
64

RETURN VALUE

66       timerisset() and timercmp() return true (nonzero) or false (0).
67

ERRORS

69       No errors are defined.
70

CONFORMING TO

72       Not in POSIX.1.  Present on most BSD derivatives.
73

SEE ALSO

75       gettimeofday(2), time(7)
76

COLOPHON

78       This  page  is  part of release 5.10 of the Linux man-pages project.  A
79       description of the project, information about reporting bugs,  and  the
80       latest     version     of     this    page,    can    be    found    at
81       https://www.kernel.org/doc/man-pages/.
82
83
84
85Linux                             2017-09-15                       TIMERADD(3)
Impressum