Annotation of fam/fam/timeval.h, Revision 1.1.1.1
1.1 trev 1: // Copyright (C) 1999 Silicon Graphics, Inc. All Rights Reserved.
2: //
3: // This program is free software; you can redistribute it and/or modify it
4: // under the terms of version 2 of the GNU General Public License as
5: // published by the Free Software Foundation.
6: //
7: // This program is distributed in the hope that it would be useful, but
8: // WITHOUT ANY WARRANTY; without even the implied warranty of
9: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Further, any
10: // license provided herein, whether implied or otherwise, is limited to
11: // this program in accordance with the express provisions of the GNU
12: // General Public License. Patent licenses, if any, provided herein do not
13: // apply to combinations of this program with other product or programs, or
14: // any other product whatsoever. This program is distributed without any
15: // warranty that the program is delivered free of the rightful claim of any
16: // third person by way of infringement or the like. See the GNU General
17: // Public License for more details.
18: //
19: // You should have received a copy of the GNU General Public License along
20: // with this program; if not, write the Free Software Foundation, Inc., 59
21: // Temple Place - Suite 330, Boston MA 02111-1307, USA.
22:
23: #ifndef timeval_included
24: #define timeval_included
25:
26: #include <sys/time.h>
27:
28: //////////////////////////////////////////////////////////////////////////////
29: // Define a few arithmetic ops on timevals. Makes code much more
30: // readable.
31: //
32: // operators += and -= are defined in timeval.C. The rest are
33: // defined as inline functions.
34:
35: timeval& operator += (timeval& left, const timeval& right);
36: timeval& operator -= (timeval& left, const timeval& right);
37:
38: inline timeval
39: operator + (const timeval& left, const timeval& right)
40: {
41: timeval result = left;
42: result += right;
43: return result;
44: }
45:
46: inline timeval
47: operator - (const timeval& left, const timeval& right)
48: {
49: timeval result = left;
50: result -= right;
51: return result;
52: }
53:
54: inline int
55: operator < (const timeval& left, const timeval& right)
56: {
57: return timercmp(&left, &right, < );
58: }
59:
60: inline int
61: operator > (const timeval& left, const timeval& right)
62: {
63: return timercmp(&left, &right, > );
64: }
65:
66: inline int
67: operator >= (const timeval& left, const timeval& right)
68: {
69: return !(left < right);
70: }
71:
72: inline int
73: operator <= (const timeval& left, const timeval& right)
74: {
75: return !(left > right);
76: }
77:
78: inline int
79: operator == (const timeval& left, const timeval& right)
80: {
81: return timercmp(&left, &right, == );
82: }
83:
84: inline int
85: operator != (const timeval& left, const timeval& right)
86: {
87: return timercmp(&left, &right, != );
88: }
89:
90: #endif /* !timeval_included */
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>