aboutsummaryrefslogtreecommitdiffstats
path: root/epan/nstime.c
diff options
context:
space:
mode:
authorUlf Lamping <ulf.lamping@web.de>2005-08-24 21:31:56 +0000
committerUlf Lamping <ulf.lamping@web.de>2005-08-24 21:31:56 +0000
commit6f43fbb2f088438dae20d4007df830863391b1c6 (patch)
tree7be99a00405385c14e1606c31906463d60107655 /epan/nstime.c
parentef81f7d060f39b43cc8eadf86c8e965a3e820225 (diff)
EVERYTHING IN THE BUILDBOT IS GOING TO BE RED!!! Sorry!
I've done more than a day to change the timestamp resolution from microseconds to nanoseconds. As I really don't want to loose those changes, I'm going to check in the changes I've done so far. Hopefully someone else will give me a helping hand with the things left ... What's done: I've changed the timestamp resolution from usec to nsec in almost any place in the sources. I've changed parts of the implementation in nstime.s/.h and a lot of places elsewhere. As I don't understand the editcap source (well, I'm maybe just too tired right now), hopefully someone else might be able to fix this soon. Doing all those changes, we get native nanosecond timestamp resolution in Ethereal. After fixing all the remaining issues, I'll take a look how to display this in a convenient way... As I've also changed the wiretap timestamp resolution from usec to nsec we might want to change the wiretap version number... svn path=/trunk/; revision=15520
Diffstat (limited to 'epan/nstime.c')
-rw-r--r--epan/nstime.c37
1 files changed, 33 insertions, 4 deletions
diff --git a/epan/nstime.c b/epan/nstime.c
index b5089bb97c..e20159afcf 100644
--- a/epan/nstime.c
+++ b/epan/nstime.c
@@ -25,6 +25,7 @@
*
*/
+#include <glib.h>
#include "nstime.h"
/* this is #defined so that we can clearly see that we have the right number of
@@ -32,12 +33,30 @@
changing ;) */
#define NS_PER_S 1000000000
+/* set the given nstime_t to zero */
+void nstime_set_zero(nstime_t *nstime)
+{
+ nstime->secs = 0;
+ nstime->nsecs = 0;
+}
+
+/* is the given nstime_t currently zero? */
+gboolean nstime_is_zero(nstime_t *nstime)
+{
+ if(nstime->secs == 0 && nstime->nsecs == 0) {
+ return TRUE;
+ } else {
+ return FALSE;
+ }
+}
+
+
/*
- * function: get_timedelta
+ * function: nstime_delta
* delta = b - a
*/
-void get_timedelta(nstime_t *delta, const nstime_t *b, const nstime_t *a )
+void nstime_delta(nstime_t *delta, const nstime_t *b, const nstime_t *a )
{
if (b->secs == a->secs) {
/* The seconds part of b is the same as the seconds part of a, so if
@@ -74,11 +93,11 @@ void get_timedelta(nstime_t *delta, const nstime_t *b, const nstime_t *a )
}
/*
- * function: get_timesum
+ * function: nstime_sum
* sum = a + b
*/
-void get_timesum(nstime_t *sum, const nstime_t *a, const nstime_t *b)
+void nstime_sum(nstime_t *sum, const nstime_t *a, const nstime_t *b)
{
sum->secs = a->secs + b->secs;
sum->nsecs = a->nsecs + b->nsecs;
@@ -101,3 +120,13 @@ double nstime_to_msec(const nstime_t *time)
return ((double)time->secs*1000 + (double)time->nsecs/1000000);
}
+/*
+ * function: nstime_to_sec
+ * converts nstime to double, time base is seconds
+ */
+
+double nstime_to_sec(const nstime_t *time)
+{
+ return ((double)time->secs + (double)time->nsecs/1000000000);
+}
+