2 .TH tv 3mLib "22 May 1999" mLib
4 tv \- arithmetic on \fBstruct timeval\fR objects
7 .B "#include <mLib/tv.h>"
9 .BI "void tv_add(struct timeval *" dst ,
10 .BI " const struct timeval *" a ,
11 .BI " const struct timeval *" b );
12 .BI "void tv_addl(struct timeval *" dst ,
13 .BI " const struct timeval *" a ,
14 .BI " time_t " sec ", unsigned long " usec );
15 .BI "void tv_sub(struct timeval *" dst ,
16 .BI " const struct timeval *" a ,
17 .BI " const struct timeval *" b );
18 .BI "void tv_subl(struct timeval *" dst ,
19 .BI " const struct timeval *" a ,
20 .BI " time_t " sec ", unsigned long " usec );
21 .BI "int tv_cmp(const struct timeval *" a ,
22 .BI " const struct timeval *" b );
25 .BI "void TV_ADD(struct timeval *" dst ,
26 .BI " const struct timeval *" a ,
27 .BI " const struct timeval *" b );
28 .BI "void TV_ADDL(struct timeval *" dst ,
29 .BI " const struct timeval *" a ,
30 .BI " time_t " sec ", unsigned long " usec );
31 .BI "void TV_SUB(struct timeval *" dst ,
32 .BI " const struct timeval *" a ,
33 .BI " const struct timeval *" b );
34 .BI "void TV_SUBL(struct timeval *" dst ,
35 .BI " const struct timeval *" a ,
36 .BI " time_t " sec ", unsigned long " usec );
37 .BI "int TV_CMP(const struct timeval *" a ", " op ,
38 .BI " const struct timeval *" b );
43 header file provides functions and macros which perform simple
44 arithmetic on objects of type
45 .BR "struct timeval" ,
46 which is capable of representing times to microsecond precision.
51 manpages for details of this structure.
53 The macros are the recommended interface to
55 facilities. The function interface is provided for compatibility
56 reasons, and for bizarre cases when macros won't do the job.
58 The main arithmetic functions are in three-address form: they accept two
59 source arguments and a separate destination argument (which may be the
60 same as one or even both of the source arguments). The destination is
61 written before the sources. All the arguments are pointers to the
64 .BI TV_ADD( d ", " x ", " y )
73 .BI TV_SUB( d ", " x ", " y )
89 respectively, except their second source operand is expressed
90 immediately as two integers arguments expressing a time in seconds and
91 microseconds respectively. Hence,
92 .BI TV_ADDL( d ", " s ", 3, 250000)"
95 and puts the result in
98 .BI TV_SUBL( d ", " s ", 3, 250000)"
99 subtracts 3.25 seconds from
101 and puts the answer in
104 The function equivalents for the above arithmetic macros work in exactly
105 the same way (and indeed have trivial implementations in terms of the
106 macros). The name of the function corresponding to a macro is simply
107 the macro name in lower-case.
111 objects can be compared using the
115 is a relational operator (e.g.,
121 .BI TV_CMP( x ", " op ", " y )
124 is true and zero otherwise.
128 works differently. Given two arguments
138 Hence, the result can be compared against zero in a relatively intuitive
141 except that because the results are defined more tightly, it's possible
146 The idea of passing a relational operator to
150 macro in the GNU C library. I don't know whether this macro is a GNU
151 original, but it certainly doesn't seem to be portable. The
153 macro had a warning attached to it that it wouldn't work for operators
156 although I can't see why there'd be a problem. (If there is one, then
157 my implementation has it too, because they're the same. I don't
158 document the restriction because I don't think it exists.)
160 Mark Wooding, <mdw@nsict.org>