summaryrefslogtreecommitdiff
path: root/gnuradio-runtime/include/gnuradio/high_res_timer.h
diff options
context:
space:
mode:
authorTim O'Shea <tim.oshea753@gmail.com>2013-06-04 13:35:53 -0400
committerTim O'Shea <tim.oshea753@gmail.com>2013-06-05 14:20:05 -0400
commit8c5d3f8b4d2b84bb214e7f7bd6b3c0d3c60df1db (patch)
tree7468b7ab1a7a0a538dcdcd466038c681cf9cd817 /gnuradio-runtime/include/gnuradio/high_res_timer.h
parent5e3fd0144cd3dde787985601416f798a37ebae86 (diff)
runtime: adding config file + ctrlport selectable gr::high_res_timer to select clock type for performance counters
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 fc7b007c6..7ec51602b 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;
}