2 * Definition of data structure to hold time values with nanosecond resolution
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.org>
8 * Copyright 1998 Gerald Combs
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
30 #include <wiretap/wtap.h>
31 #include "ws_symbol_export.h"
35 #endif /* __cplusplus */
38 * Definition of data structure to hold time values with nanosecond resolution
41 /** data structure to hold time values with nanosecond resolution*/
49 /** set the given nstime_t to zero */
50 WS_DLL_PUBLIC void nstime_set_zero(nstime_t *nstime);
52 /** is the given nstime_t currently zero? */
53 WS_DLL_PUBLIC gboolean nstime_is_zero(nstime_t *nstime);
55 /** set the given nstime_t to (0,maxint) to mark it as "unset"
56 * That way we can find the first frame even when a timestamp
57 * is zero (fix for bug 1056)
59 WS_DLL_PUBLIC void nstime_set_unset(nstime_t *nstime);
61 /* is the given nstime_t currently (0,maxint)? */
62 WS_DLL_PUBLIC gboolean nstime_is_unset(nstime_t *nstime);
64 /** duplicate the current time
68 WS_DLL_PUBLIC void nstime_copy(nstime_t *a, const nstime_t *b);
70 /** calculate the delta between two times (can be negative!)
74 * Note that it is acceptable for two or more of the arguments to point at the
77 WS_DLL_PUBLIC void nstime_delta(nstime_t *delta, const nstime_t *b, const nstime_t *a );
79 /** calculate the sum of two times
83 * Note that it is acceptable for two or more of the arguments to point at the
86 WS_DLL_PUBLIC void nstime_sum(nstime_t *sum, const nstime_t *b, const nstime_t *a );
89 #define nstime_add(sum, a) nstime_sum(sum, sum, a)
92 #define nstime_subtract(sum, a) nstime_delta(sum, sum, a)
94 /** compare two times are return a value similar to memcmp() or strcmp().
100 WS_DLL_PUBLIC int nstime_cmp (const nstime_t *a, const nstime_t *b );
102 /** converts nstime to double, time base is milli seconds */
103 WS_DLL_PUBLIC double nstime_to_msec(const nstime_t *nstime);
105 /** converts nstime to double, time base is seconds */
106 WS_DLL_PUBLIC double nstime_to_sec(const nstime_t *nstime);
108 /** converts wtap_nstime to double, time base is seconds */
109 WS_DLL_PUBLIC double wtap_nstime_to_sec(const struct wtap_nstime *nstime);
113 #endif /* __cplusplus */
115 #endif /* __NSTIME_H__ */