summaryrefslogtreecommitdiffstats
path: root/src/Utils.h
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2015-06-05 10:09:18 +0200
committerMatthias P. Braendli <matthias.braendli@mpb.li>2015-06-05 10:09:18 +0200
commit01f55e125cdc2156bb6936f70aa52d13ff40420f (patch)
tree937c4e753c618409b87ce7f4498b0c73b340b4f1 /src/Utils.h
parent23ad47277e73348bca32226d87274541e56bbebb (diff)
parentc8b792fee07cfa591339cbf6f67454cb1cf4535b (diff)
downloaddabmod-01f55e125cdc2156bb6936f70aa52d13ff40420f.tar.gz
dabmod-01f55e125cdc2156bb6936f70aa52d13ff40420f.tar.bz2
dabmod-01f55e125cdc2156bb6936f70aa52d13ff40420f.zip
Merge branch 'next' into tii
Diffstat (limited to 'src/Utils.h')
-rw-r--r--src/Utils.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/Utils.h b/src/Utils.h
index 7c3129c..f023646 100644
--- a/src/Utils.h
+++ b/src/Utils.h
@@ -35,10 +35,28 @@
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
+#include <time.h>
void printUsage(char* progName);
void printVersion(void);
+inline long timespecdiff_us(struct timespec& oldTime, struct timespec& time)
+{
+ long tv_sec;
+ long tv_nsec;
+ if (time.tv_nsec < oldTime.tv_nsec) {
+ tv_sec = time.tv_sec - 1 - oldTime.tv_sec;
+ tv_nsec = 1000000000L + time.tv_nsec - oldTime.tv_nsec;
+ }
+ else {
+ tv_sec = time.tv_sec - oldTime.tv_sec;
+ tv_nsec = time.tv_nsec - oldTime.tv_nsec;
+ }
+
+ return tv_sec * 1000 + tv_nsec / 1000;
+}
+
+
#endif