aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/types
diff options
context:
space:
mode:
Diffstat (limited to 'host/lib/types')
-rw-r--r--host/lib/types/CMakeLists.txt15
-rw-r--r--host/lib/types/time_spec.cpp16
2 files changed, 18 insertions, 13 deletions
diff --git a/host/lib/types/CMakeLists.txt b/host/lib/types/CMakeLists.txt
index ad625111e..957dfd345 100644
--- a/host/lib/types/CMakeLists.txt
+++ b/host/lib/types/CMakeLists.txt
@@ -58,19 +58,24 @@ CHECK_CXX_SOURCE_COMPILES("
IF(HAVE_CLOCK_GETTIME)
MESSAGE(STATUS " High resolution timing supported through clock_gettime.")
- ADD_DEFINITIONS(-DTIME_SPEC_USE_CLOCK_GETTIME)
- SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -lrt")
+ SET(TIME_SPEC_DEFS HAVE_CLOCK_GETTIME)
+ LIBUHD_APPEND_LIBS("-lrt")
ELSEIF(HAVE_MACH_ABSOLUTE_TIME)
MESSAGE(STATUS " High resolution timing supported through mach_absolute_time.")
- ADD_DEFINITIONS(-DTIME_SPEC_USE_MACH_ABSOLUTE_TIME)
+ SET(TIME_SPEC_DEFS HAVE_MACH_ABSOLUTE_TIME)
ELSEIF(HAVE_QUERY_PERFORMANCE_COUNTER)
MESSAGE(STATUS " High resolution timing supported through QueryPerformanceCounter.")
- ADD_DEFINITIONS(-DTIME_SPEC_USE_QUERY_PERFORMANCE_COUNTER)
+ SET(TIME_SPEC_DEFS HAVE_QUERY_PERFORMANCE_COUNTER)
ELSE()
MESSAGE(STATUS " High resolution timing supported though microsec_clock.")
- ADD_DEFINITIONS(-DTIME_SPEC_USE_MICROSEC_CLOCK)
+ SET(TIME_SPEC_DEFS HAVE_MICROSEC_CLOCK)
ENDIF()
+SET_SOURCE_FILES_PROPERTIES(
+ ${CMAKE_CURRENT_SOURCE_DIR}/time_spec.cpp
+ PROPERTIES COMPILE_DEFINITIONS "${TIME_SPEC_DEFS}"
+)
+
########################################################################
# This file included, use CMake directory variables
########################################################################
diff --git a/host/lib/types/time_spec.cpp b/host/lib/types/time_spec.cpp
index 4a41f0fb9..a785332c2 100644
--- a/host/lib/types/time_spec.cpp
+++ b/host/lib/types/time_spec.cpp
@@ -36,26 +36,26 @@ static UHD_INLINE time_spec_t time_spec_t_from_counts(intmax_t counts, intmax_t
return time_spec_t(time_t(divres.quot), double(divres.rem)/freq);
}
-#ifdef TIME_SPEC_USE_CLOCK_GETTIME
+#ifdef HAVE_CLOCK_GETTIME
#include <time.h>
time_spec_t time_spec_t::get_system_time(void){
timespec ts; clock_gettime(CLOCK_MONOTONIC, &ts);
return time_spec_t(ts.tv_sec, ts.tv_nsec, 1e9);
}
-#endif /* TIME_SPEC_USE_CLOCK_GETTIME */
+#endif /* HAVE_CLOCK_GETTIME */
-#ifdef TIME_SPEC_USE_MACH_ABSOLUTE_TIME
+#ifdef HAVE_MACH_ABSOLUTE_TIME
#include <mach/mach_time.h>
time_spec_t time_spec_t::get_system_time(void){
mach_timebase_info_data_t info; mach_timebase_info(&info);
intmax_t nanosecs = mach_absolute_time()*info.numer/info.denom;
return time_spec_t_from_counts(nanosecs, intmax_t(1e9));
}
-#endif /* TIME_SPEC_USE_MACH_ABSOLUTE_TIME */
+#endif /* HAVE_MACH_ABSOLUTE_TIME */
-#ifdef TIME_SPEC_USE_QUERY_PERFORMANCE_COUNTER
+#ifdef HAVE_QUERY_PERFORMANCE_COUNTER
#include <Windows.h>
time_spec_t time_spec_t::get_system_time(void){
LARGE_INTEGER counts, freq;
@@ -63,10 +63,10 @@ time_spec_t time_spec_t::get_system_time(void){
QueryPerformanceFrequency(&freq);
return time_spec_t_from_counts(counts.QuadPart, freq.QuadPart);
}
-#endif /* TIME_SPEC_USE_QUERY_PERFORMANCE_COUNTER */
+#endif /* HAVE_QUERY_PERFORMANCE_COUNTER */
-#ifdef TIME_SPEC_USE_MICROSEC_CLOCK
+#ifdef HAVE_MICROSEC_CLOCK
#include <boost/date_time/posix_time/posix_time.hpp>
namespace pt = boost::posix_time;
time_spec_t time_spec_t::get_system_time(void){
@@ -78,7 +78,7 @@ time_spec_t time_spec_t::get_system_time(void){
double(pt::time_duration::ticks_per_second())
);
}
-#endif /* TIME_SPEC_USE_MICROSEC_CLOCK */
+#endif /* HAVE_MICROSEC_CLOCK */
/***********************************************************************
* Time spec constructors