Licepnse -> License
[obnox/wireshark/wip.git] / epan / nstime.h
1 /* nstime.h
2  * Definition of data structure to hold time values with nanosecond resolution
3  *
4  * $Id$
5  *
6  * Wireshark - Network traffic analyzer
7  * By Gerald Combs <gerald@wireshark.org>
8  * Copyright 1998 Gerald Combs
9  *
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.
14  *
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.
19  *
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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
23  */
24
25 #ifndef __NSTIME_H__
26 #define __NSTIME_H__
27
28 #include <time.h>
29
30 typedef struct {
31         time_t  secs;
32         int     nsecs;
33 } nstime_t;
34
35 /* functions */
36
37 /* set the given nstime_t to zero */
38 extern void nstime_set_zero(nstime_t *nstime);
39
40 /* is the given nstime_t currently zero? */
41 extern gboolean nstime_is_zero(nstime_t *nstime);
42
43 /* calculate the delta between two times (can be negative!)
44  *
45  * delta = b-a
46  *
47  * Note that it is acceptable for two or more of the arguments to point at the
48  * same structure.
49  */
50 extern void nstime_delta(nstime_t *delta, const nstime_t *b, const nstime_t *a );
51
52 /* calculate the sum of two times
53  *
54  * sum = a+b
55  *
56  * Note that it is acceptable for two or more of the arguments to point at the
57  * same structure.
58  */
59 extern void nstime_sum(nstime_t *sum, const nstime_t *b, const nstime_t *a );
60
61 /* sum += a */
62 #define nstime_add(sum, a) nstime_sum(sum, sum, a)
63
64 /* converts nstime to double, time base is milli seconds */
65 extern double nstime_to_msec(const nstime_t *time);
66
67 /* converts nstime to double, time base is seconds */
68 extern double nstime_to_sec(const nstime_t *time);
69
70 #endif /* __NSTIME_H__  */