]>
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 | |
15 | .\" the use of the information contained herein. | |
16 | .\" | |
17 | .\" Formatted or processed versions of this manual, if unaccompanied by | |
18 | .\" the source, must acknowledge the copyright and authors of this work. | |
19 | .\" | |
20 | .\" 2007-07-31, mtk, Created | |
21 | .\" | |
22 | .TH TIMERADD 3 2007-07-31 "Linux" "Linux Programmer's Manual" | |
23 | .SH NAME | |
93d67152 | 24 | timeradd, timersub, timercmp, timerclear, timerisset \- timeval operations |
d6d74fd8 MK |
25 | .SH SYNOPSIS |
26 | .nf | |
27 | .B #include <sys/time.h> | |
28 | ||
29 | .BI "void timeradd(struct timeval *" a ", struct timeval *" b , | |
30 | .BI " struct timeval *" res ); | |
31 | ||
32 | .BI "void timersub(struct timeval *" a ", struct timeval *" b , | |
33 | .BI " struct timeval *" res ); | |
34 | ||
35 | .BI "void timerclear(struct timeval *" tvp ); | |
36 | ||
37 | .BI "void timerisset(struct timeval *" tvp ); | |
38 | ||
39 | .BI "void timercmp(struct timeval *" a ", struct timeval *" b ", " CMP ); | |
40 | .fi | |
41 | .sp | |
42 | .in -4n | |
43 | Feature Test Macro Requirements for glibc (see | |
44 | .BR feature_test_macros (7)): | |
45 | .in | |
46 | .sp | |
93d67152 | 47 | All functions shown above require: |
d6d74fd8 MK |
48 | _BSD_SOURCE |
49 | .SH DESCRIPTION | |
50 | The macros are provided to operate on | |
51 | .I timeval | |
52 | structures, defined in | |
53 | .IR <sys/time.h> | |
54 | as: | |
55 | .sp | |
56 | .in +0.5i | |
57 | .nf | |
58 | struct timeval { | |
59 | time_t tv_sec; /* seconds */ | |
60 | suseconds_t tv_usec; /* microseconds */ | |
61 | }; | |
62 | .fi | |
63 | .PP | |
64 | .BR timeradd () | |
65 | adds the time values in | |
66 | .I a | |
67 | and | |
68 | .IR b , | |
69 | and places the sum in the | |
70 | .I timeval | |
71 | pointed to by | |
72 | .IR res . | |
73 | The result is normalized such that | |
74 | .I res->tv_usec | |
75 | has a value in the range 0 to 999,999. | |
76 | ||
77 | .BR timersub () | |
93d67152 | 78 | subtracts the time value in |
d6d74fd8 | 79 | .I b |
93d67152 | 80 | from the time value in |
d6d74fd8 MK |
81 | .IR a , |
82 | and places the result in the | |
83 | .I timeval | |
84 | pointed to by | |
85 | .IR res . | |
86 | The result is normalized such that | |
87 | .I res->tv_usec | |
88 | has a value in the range 0 to 999,999. | |
89 | ||
90 | .BR timerclear () | |
91 | zeroes out the | |
92 | .I timeval | |
93 | structure pointed to by | |
94 | .IR tvp , | |
95 | so that it represents the time at midnight | |
96 | on the morning of 1 January 1970 (the Epoch). | |
97 | ||
98 | .BR timerisset () | |
99 | returns true (non-zero) if either field of the | |
100 | .I timeval | |
101 | structure pointed to by | |
102 | .IR tvp | |
103 | contains a non-zero value. | |
104 | ||
105 | .BR timercmp () | |
106 | compares the timer values in | |
107 | .I a | |
108 | and | |
109 | .IR b | |
110 | using the comparison operator | |
111 | .IR CMP , | |
112 | and returns true (non-zero) or false (0) depending on | |
113 | the result of the comparison. | |
114 | .SH RETURN VALUE | |
115 | .BR timerisset () | |
116 | and | |
117 | .BR timercmp () | |
118 | return true (non-zero) or false (0). | |
119 | .BR | |
120 | .SH ERRORS | |
121 | No errors are defined. | |
122 | .SH CONFORMING TO | |
123 | Not in POSIX.1-2001. | |
124 | Present on most BSD derivatives. | |
125 | .SH "SEE ALSO" | |
126 | .BR gettimeofday (2), | |
127 | .BR time (7). |