diff options
author | Gary E. Miller <gem@rellim.com> | 2015-06-04 16:21:34 -0700 |
---|---|---|
committer | Gary E. Miller <gem@rellim.com> | 2015-06-04 16:21:34 -0700 |
commit | 271801553f4cd8da3b12c43a73f5a965cb1153f6 (patch) | |
tree | 3cee7cb211aeb1dc50fe29bd062aed5ffdef7716 /timespec.h | |
parent | 09200839cc0c8c8418adae9a5347b0a1fd5eacdc (diff) | |
download | gpsd-271801553f4cd8da3b12c43a73f5a965cb1153f6.tar.gz |
Remove duplicate definition of timespec_diff_ns()
Plus a logical reordering of things so more timespec stuff is in
timespec.h
Diffstat (limited to 'timespec.h')
-rw-r--r-- | timespec.h | 7 |
1 files changed, 7 insertions, 0 deletions
@@ -21,6 +21,13 @@ #define NS_IN_SEC 1000000000 #define MS_IN_SEC 1000000 +/* return the difference between timespecs in nanoseconds + * int may be too small, 32 bit long is too small, floats are too imprecise, + * doubles are not quite precise enough + * MUST be long long to maintain precision on 32 bit code */ +#define timespec_diff_ns(x, y) \ + (long long)((((x).tv_sec-(y).tv_sec)*NS_IN_SEC)+(x).tv_nsec-(y).tv_nsec) + static inline void TS_NORM( struct timespec *ts) { if ( ( 1 <= ts->tv_sec ) || |