1timeradd(3) Library Functions Manual timeradd(3)
2
3
4
6 timeradd, timersub, timercmp, timerclear, timerisset - timeval opera‐
7 tions
8
10 Standard C library (libc, -lc)
11
13 #include <sys/time.h>
14
15 void timeradd(struct timeval *a, struct timeval *b,
16 struct timeval *res);
17 void timersub(struct timeval *a, struct timeval *b,
18 struct timeval *res);
19
20 void timerclear(struct timeval *tvp);
21 int timerisset(struct timeval *tvp);
22
23 int timercmp(struct timeval *a, struct timeval *b, CMP);
24
25 Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
26
27 All functions shown above:
28 Since glibc 2.19:
29 _DEFAULT_SOURCE
30 glibc 2.19 and earlier:
31 _BSD_SOURCE
32
34 The macros are provided to operate on timeval structures, defined in
35 <sys/time.h> as:
36
37 struct timeval {
38 time_t tv_sec; /* seconds */
39 suseconds_t tv_usec; /* microseconds */
40 };
41
42 timeradd() adds the time values in a and b, and places the sum in the
43 timeval pointed to by res. The result is normalized such that
44 res->tv_usec has a value in the range 0 to 999,999.
45
46 timersub() subtracts the time value in b from the time value in a, and
47 places the result in the timeval pointed to by res. The result is nor‐
48 malized such that res->tv_usec has a value in the range 0 to 999,999.
49
50 timerclear() zeros out the timeval structure pointed to by tvp, so that
51 it represents the Epoch: 1970-01-01 00:00:00 +0000 (UTC).
52
53 timerisset() returns true (nonzero) if either field of the timeval
54 structure pointed to by tvp contains a nonzero value.
55
56 timercmp() compares the timer values in a and b using the comparison
57 operator CMP, and returns true (nonzero) or false (0) depending on the
58 result of the comparison. Some systems (but not Linux/glibc), have a
59 broken timercmp() implementation, in which CMP of >=, <=, and == do not
60 work; portable applications can instead use
61
62 !timercmp(..., <)
63 !timercmp(..., >)
64 !timercmp(..., !=)
65
67 timerisset() and timercmp() return true (nonzero) or false (0).
68
70 No errors are defined.
71
73 None.
74
76 BSD.
77
79 gettimeofday(2), time(7)
80
81
82
83Linux man-pages 6.05 2023-03-30 timeradd(3)