]>
Commit | Line | Data |
---|---|---|
c11b1abf | 1 | .\" Copyright (c) 2007 by Michael Kerrisk <mtk.manpages@gmail.com> |
d6d74fd8 MK |
2 | .\" |
3 | .\" Permission is granted to make and distribute verbatim copies of this | |
4 | .\" manual provided the copyright notice and this permission notice are | |
5 | .\" preserved on all copies. | |
6 | .\" | |
7 | .\" Permission is granted to copy and distribute modified versions of this | |
8 | .\" manual under the conditions for verbatim copying, provided that the | |
9 | .\" entire resulting derived work is distributed under the terms of a | |
10 | .\" permission notice identical to this one. | |
11 | .\" | |
12 | .\" Since the Linux kernel and libraries are constantly changing, this | |
13 | .\" manual page may be incorrect or out-of-date. The author(s) assume no | |
14 | .\" responsibility for errors or omissions, or for damages resulting from | |
10d76543 MK |
15 | .\" the use of the information contained herein. The author(s) may not |
16 | .\" have taken the same level of care in the production of this manual, | |
17 | .\" which is licensed free of charge, as they might when working | |
18 | .\" professionally. | |
d6d74fd8 MK |
19 | .\" |
20 | .\" Formatted or processed versions of this manual, if unaccompanied by | |
21 | .\" the source, must acknowledge the copyright and authors of this work. | |
22 | .\" | |
23 | .\" 2007-07-31, mtk, Created | |
24 | .\" | |
25 | .TH TIMERADD 3 2007-07-31 "Linux" "Linux Programmer's Manual" | |
26 | .SH NAME | |
93d67152 | 27 | timeradd, timersub, timercmp, timerclear, timerisset \- timeval operations |
d6d74fd8 MK |
28 | .SH SYNOPSIS |
29 | .nf | |
30 | .B #include <sys/time.h> | |
31 | ||
32 | .BI "void timeradd(struct timeval *" a ", struct timeval *" b , | |
33 | .BI " struct timeval *" res ); | |
34 | ||
35 | .BI "void timersub(struct timeval *" a ", struct timeval *" b , | |
36 | .BI " struct timeval *" res ); | |
37 | ||
38 | .BI "void timerclear(struct timeval *" tvp ); | |
39 | ||
40 | .BI "void timerisset(struct timeval *" tvp ); | |
41 | ||
42 | .BI "void timercmp(struct timeval *" a ", struct timeval *" b ", " CMP ); | |
43 | .fi | |
44 | .sp | |
45 | .in -4n | |
46 | Feature Test Macro Requirements for glibc (see | |
47 | .BR feature_test_macros (7)): | |
48 | .in | |
49 | .sp | |
cfc2d88d | 50 | All functions shown above: |
d6d74fd8 MK |
51 | _BSD_SOURCE |
52 | .SH DESCRIPTION | |
53 | The macros are provided to operate on | |
54 | .I timeval | |
55 | structures, defined in | |
0daa9e92 | 56 | .I <sys/time.h> |
d6d74fd8 MK |
57 | as: |
58 | .sp | |
088a639b | 59 | .in +4n |
d6d74fd8 MK |
60 | .nf |
61 | struct timeval { | |
62 | time_t tv_sec; /* seconds */ | |
63 | suseconds_t tv_usec; /* microseconds */ | |
64 | }; | |
65 | .fi | |
088a639b | 66 | .in |
d6d74fd8 MK |
67 | .PP |
68 | .BR timeradd () | |
69 | adds the time values in | |
70 | .I a | |
71 | and | |
72 | .IR b , | |
73 | and places the sum in the | |
74 | .I timeval | |
75 | pointed to by | |
76 | .IR res . | |
77 | The result is normalized such that | |
94e9d9fe | 78 | .I res\->tv_usec |
d6d74fd8 MK |
79 | has a value in the range 0 to 999,999. |
80 | ||
81 | .BR timersub () | |
93d67152 | 82 | subtracts the time value in |
d6d74fd8 | 83 | .I b |
93d67152 | 84 | from the time value in |
d6d74fd8 MK |
85 | .IR a , |
86 | and places the result in the | |
87 | .I timeval | |
88 | pointed to by | |
89 | .IR res . | |
90 | The result is normalized such that | |
94e9d9fe | 91 | .I res\->tv_usec |
d6d74fd8 MK |
92 | has a value in the range 0 to 999,999. |
93 | ||
94 | .BR timerclear () | |
7b01461a | 95 | zeros out the |
d6d74fd8 MK |
96 | .I timeval |
97 | structure pointed to by | |
98 | .IR tvp , | |
99 | so that it represents the time at midnight | |
100 | on the morning of 1 January 1970 (the Epoch). | |
101 | ||
102 | .BR timerisset () | |
eba72288 | 103 | returns true (non-zero) if either field of the |
d6d74fd8 MK |
104 | .I timeval |
105 | structure pointed to by | |
0daa9e92 | 106 | .I tvp |
eba72288 | 107 | contains a non-zero value. |
d6d74fd8 MK |
108 | |
109 | .BR timercmp () | |
110 | compares the timer values in | |
111 | .I a | |
112 | and | |
0daa9e92 | 113 | .I b |
d6d74fd8 MK |
114 | using the comparison operator |
115 | .IR CMP , | |
eba72288 | 116 | and returns true (non-zero) or false (0) depending on |
d6d74fd8 MK |
117 | the result of the comparison. |
118 | .SH RETURN VALUE | |
119 | .BR timerisset () | |
120 | and | |
121 | .BR timercmp () | |
eba72288 | 122 | return true (non-zero) or false (0). |
d6d74fd8 MK |
123 | .SH ERRORS |
124 | No errors are defined. | |
125 | .SH CONFORMING TO | |
126 | Not in POSIX.1-2001. | |
127 | Present on most BSD derivatives. | |
128 | .SH "SEE ALSO" | |
129 | .BR gettimeofday (2), | |
130 | .BR time (7). |