diff options
author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2015-06-05 10:09:18 +0200 |
---|---|---|
committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2015-06-05 10:09:18 +0200 |
commit | 01f55e125cdc2156bb6936f70aa52d13ff40420f (patch) | |
tree | 937c4e753c618409b87ce7f4498b0c73b340b4f1 /src/Utils.h | |
parent | 23ad47277e73348bca32226d87274541e56bbebb (diff) | |
parent | c8b792fee07cfa591339cbf6f67454cb1cf4535b (diff) | |
download | dabmod-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.h | 18 |
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 |