diff options
author | Tom Rondeau <trondeau@vt.edu> | 2010-06-27 12:01:17 -0400 |
---|---|---|
committer | Tom Rondeau <trondeau@vt.edu> | 2010-06-27 12:01:17 -0400 |
commit | ec0fcd99133c7f6a4e63830a9cf6674c4abc95bf (patch) | |
tree | a91b84daf443eacb06faf9d52b01dfad8e392cf9 /gr-qtgui/src | |
parent | 9a739da173287cfdbf9e8dbc2f7ef9bef2cdae6e (diff) |
Checking for clock_gettime and timespec defined; use gettimeofday if not, but put it into a timespec structure.
Diffstat (limited to 'gr-qtgui/src')
-rw-r--r-- | gr-qtgui/src/lib/highResTimeFunctions.h | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/gr-qtgui/src/lib/highResTimeFunctions.h b/gr-qtgui/src/lib/highResTimeFunctions.h index 4a82498b49..dc5e1bb801 100644 --- a/gr-qtgui/src/lib/highResTimeFunctions.h +++ b/gr-qtgui/src/lib/highResTimeFunctions.h @@ -246,6 +246,9 @@ diff_timespec(const struct timespec* t1, } +#ifdef CLOCK_REALTIME +// If we can use clock_gettime, use it; +// otherwise, use gettimeofday static inline void get_highres_clock(struct timespec* ret) { @@ -259,6 +262,29 @@ get_highres_clock(struct timespec* ret) } } +#else + +// Test to see if timespec is defined; if not, define it here +#if !defined __timespec_defined +typedef struct _timespec +{ + long int tv_sec; + long int tv_nsec; +} timespec; +#endif + +// Trick the system into thinking it has an nsec timer +// but only use the low resolution (usec) timer. +static inline void +get_highres_clock(struct timespec* ret) +{ + timeval lowResTime; + gettimeofday(&lowResTime, NULL); + ret->tv_sec = lowResTime.tv_sec; + ret->tv_nsec = lowResTime.tv_usec*1000; +} +#endif + static inline struct timespec get_highres_clock() { |