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       void timersub(struct timeval *a, struct timeval *b,
15                     struct timeval *res);
16
17       void timerclear(struct timeval *tvp);
18       int timerisset(struct timeval *tvp);
19
20       int timercmp(struct timeval *a, struct timeval *b, CMP);
21
22   Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
23
24       All functions shown above:
25           Since glibc 2.19:
26               _DEFAULT_SOURCE
27           Glibc 2.19 and earlier:
28               _BSD_SOURCE
29

DESCRIPTION

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

RETURN VALUE

64       timerisset() and timercmp() return true (nonzero) or false (0).
65

ERRORS

67       No errors are defined.
68

CONFORMING TO

70       Not in POSIX.1.  Present on most BSD derivatives.
71

SEE ALSO

73       gettimeofday(2), time(7)
74

COLOPHON

76       This  page  is  part of release 5.13 of the Linux man-pages project.  A
77       description of the project, information about reporting bugs,  and  the
78       latest     version     of     this    page,    can    be    found    at
79       https://www.kernel.org/doc/man-pages/.
80
81
82
83Linux                             2021-03-22                       TIMERADD(3)
Impressum