summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevron Rees <kevron.m.rees@intel.com>2016-04-19 09:16:55 -0700
committerKevron Rees <tripzero.kev@gmail.com>2016-04-19 10:39:59 -0700
commit43ba250b5d13afc493e9a73a1b344c5de7b3b839 (patch)
tree16eacbe2682e5026721c89d96109836afa820582
parentcfa575b59daa4caa09310fc6f378878605af972c (diff)
downloadautomotive-message-broker-43ba250b5d13afc493e9a73a1b344c5de7b3b839.tar.gz
timestamp: fix for bcm_timeval on older kernels
-rw-r--r--CMakeLists.txt9
-rw-r--r--lib/timestamp.h6
2 files changed, 15 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0fa62aad..4420659a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -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})
diff --git a/lib/timestamp.h b/lib/timestamp.h
index d654d3f7..c2effe0e 100644
--- a/lib/timestamp.h
+++ b/lib/timestamp.h
@@ -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();