timestamp: fix for bcm_timeval on older kernels
authorKevron Rees <kevron.m.rees@intel.com>
Tue, 19 Apr 2016 16:16:55 +0000 (09:16 -0700)
committerKevron Rees <tripzero.kev@gmail.com>
Tue, 19 Apr 2016 17:39:59 +0000 (10:39 -0700)
CMakeLists.txt
lib/timestamp.h

index 0fa62aa..4420659 100644 (file)
@@ -81,6 +81,15 @@ if(usebluez5)
 
 endif(usebluez5)
 
+include(CheckCSourceCompiles)
+check_c_source_compiles("
+        #include <linux/can/bcm.h>
+        int main() { struct bcm_timeval t; return 0;}" have_bcm_timeval)
+
+if(have_bcm_timeval)
+        add_definitions(-DHAVE_BCM_TIMEVAL)
+endif(have_bcm_timeval)
+
 set(ARCHIVE_NAME ${CMAKE_PROJECT_NAME}-${PROJECT_VERSION})
 add_custom_target(dist COMMAND git archive --prefix=${ARCHIVE_NAME}/ HEAD | bzip2 > ${CMAKE_BINARY_DIR}/${ARCHIVE_NAME}.tar.bz2 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
 
index d654d3f..c2effe0 100644 (file)
@@ -4,6 +4,12 @@
 #include <time.h>
 #include <linux/can/bcm.h>
 
+#ifndef HAVE_BCM_TIMEVAL
+
+#define bcm_timeval timeval
+
+#endif
+
 namespace amb {
 
 double currentTime();