summaryrefslogtreecommitdiff
path: root/gnuradio-runtime/include/gnuradio/high_res_timer.h
diff options
context:
space:
mode:
Diffstat (limited to 'gnuradio-runtime/include/gnuradio/high_res_timer.h')
-rw-r--r--gnuradio-runtime/include/gnuradio/high_res_timer.h43
1 files changed, 26 insertions, 17 deletions
diff --git a/gnuradio-runtime/include/gnuradio/high_res_timer.h b/gnuradio-runtime/include/gnuradio/high_res_timer.h
index fc7b007c61..7ec51602b0 100644
--- a/gnuradio-runtime/include/gnuradio/high_res_timer.h
+++ b/gnuradio-runtime/include/gnuradio/high_res_timer.h
@@ -22,44 +22,53 @@
#ifndef INCLUDED_GNURADIO_HIGH_RES_TIMER_H
#define INCLUDED_GNURADIO_HIGH_RES_TIMER_H
-namespace gr {
-
- //! Typedef for the timer tick count
- typedef signed long long high_res_timer_type;
-
- //! Get the current time in ticks
- high_res_timer_type high_res_timer_now(void);
-
- //! Get the number of ticks per second
- high_res_timer_type high_res_timer_tps(void);
-
- //! Get the tick count at the epoch
- high_res_timer_type high_res_timer_epoch(void);
-
-} /* namespace gr */
+#include <gnuradio/api.h>
////////////////////////////////////////////////////////////////////////
// Use architecture defines to determine the implementation
////////////////////////////////////////////////////////////////////////
#if defined(linux) || defined(__linux) || defined(__linux__)
#define GNURADIO_HRT_USE_CLOCK_GETTIME
+ #include <ctime>
#elif defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
#define GNURADIO_HRT_USE_QUERY_PERFORMANCE_COUNTER
#elif defined(macintosh) || defined(__APPLE__) || defined(__APPLE_CC__)
#define GNURADIO_HRT_USE_MACH_ABSOLUTE_TIME
#elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
#define GNURADIO_HRT_USE_CLOCK_GETTIME
+ #include <ctime>
#else
#define GNURADIO_HRT_USE_MICROSEC_CLOCK
#endif
+
////////////////////////////////////////////////////////////////////////
+namespace gr {
+
+ //! Typedef for the timer tick count
+ typedef signed long long high_res_timer_type;
+
+ //! Get the current time in ticks
+ high_res_timer_type high_res_timer_now(void);
+
+ //! Get the number of ticks per second
+ high_res_timer_type high_res_timer_tps(void);
+
+ //! Get the tick count at the epoch
+ high_res_timer_type high_res_timer_epoch(void);
+
#ifdef GNURADIO_HRT_USE_CLOCK_GETTIME
- #include <ctime>
+ //! storage for high res timer type
+ GR_RUNTIME_API extern clockid_t high_res_timer_source;
+#endif
+} /* namespace gr */
+
+////////////////////////////////////////////////////////////////////////
+#ifdef GNURADIO_HRT_USE_CLOCK_GETTIME
inline gr::high_res_timer_type gr::high_res_timer_now(void){
timespec ts;
- clock_gettime(CLOCK_MONOTONIC, &ts);
+ clock_gettime(high_res_timer_source, &ts);
return ts.tv_sec*high_res_timer_tps() + ts.tv_nsec;
}