From 547dd8511b62f174679080e395eb411d8d0e0580 Mon Sep 17 00:00:00 2001 From: Julian Oes Date: Sun, 9 Dec 2018 12:22:49 +0100 Subject: [PATCH] platforms: use define for lockstep scheduler Instead of using the define __PX4_POSIX_SITL it makes more sense to have a define just to determine if the lockstep scheduler should be used. --- CMakeLists.txt | 7 +++++++ boards/px4/sitl/default.cmake | 3 +-- boards/px4/sitl/test.cmake | 2 ++ platforms/posix/src/CMakeLists.txt | 2 +- platforms/posix/src/px4_layer/CMakeLists.txt | 2 +- platforms/posix/src/px4_layer/drv_hrt.cpp | 6 +++--- src/include/visibility.h | 4 ++-- src/platforms/px4_time.h | 2 +- 8 files changed, 18 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index aa5dc10184..f1c3d96473 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -216,6 +216,13 @@ include(${PX4_CONFIG_FILE}) message(STATUS "PX4 config: ${PX4_CONFIG}") message(STATUS "PX4 platform: ${PX4_PLATFORM}") +if (ENABLE_LOCKSTEP_SCHEDULER) + add_definitions(-DENABLE_LOCKSTEP_SCHEDULER) + message(STATUS "PX4 lockstep: enabled") +else() + message(STATUS "PX4 lockstep: disabled") +endif() + # external modules set(EXTERNAL_MODULES_LOCATION "" CACHE STRING "External modules source location") diff --git a/boards/px4/sitl/default.cmake b/boards/px4/sitl/default.cmake index 8caa4b20e2..51cb4b4a9a 100644 --- a/boards/px4/sitl/default.cmake +++ b/boards/px4/sitl/default.cmake @@ -98,5 +98,4 @@ if(REPLAY_FILE) add_definitions(-DORB_USE_PUBLISHER_RULES) endif() -add_definitions(-D__PX4_POSIX_SITL) -set(LOCKSTEP_SCHEDULER_NEEDED yes) +set(ENABLE_LOCKSTEP_SCHEDULER yes) diff --git a/boards/px4/sitl/test.cmake b/boards/px4/sitl/test.cmake index 06e489326d..ced2a0f947 100644 --- a/boards/px4/sitl/test.cmake +++ b/boards/px4/sitl/test.cmake @@ -96,3 +96,5 @@ if(REPLAY_FILE) message("Building with uorb publisher rules support") add_definitions(-DORB_USE_PUBLISHER_RULES) endif() + +set(ENABLE_LOCKSTEP_SCHEDULER no) diff --git a/platforms/posix/src/CMakeLists.txt b/platforms/posix/src/CMakeLists.txt index 646d3a9a0c..a50e081bd4 100644 --- a/platforms/posix/src/CMakeLists.txt +++ b/platforms/posix/src/CMakeLists.txt @@ -31,7 +31,7 @@ # ############################################################################ -if (LOCKSTEP_SCHEDULER_NEEDED) +if (ENABLE_LOCKSTEP_SCHEDULER) add_subdirectory(lockstep_scheduler) endif() diff --git a/platforms/posix/src/px4_layer/CMakeLists.txt b/platforms/posix/src/px4_layer/CMakeLists.txt index 5ce8a3c4bd..000706bc57 100644 --- a/platforms/posix/src/px4_layer/CMakeLists.txt +++ b/platforms/posix/src/px4_layer/CMakeLists.txt @@ -56,7 +56,7 @@ target_compile_definitions(px4_layer PRIVATE MODULE_NAME="px4") target_link_libraries(px4_layer PRIVATE work_queue) target_link_libraries(px4_layer PRIVATE px4_daemon) -if(LOCKSTEP_SCHEDULER_NEEDED) +if(ENABLE_LOCKSTEP_SCHEDULER) target_link_libraries(px4_layer PRIVATE lockstep_scheduler) include_directories(${PX4_SOURCE_DIR}/platforms/posix/src/lockstep_scheduler/include) endif() diff --git a/platforms/posix/src/px4_layer/drv_hrt.cpp b/platforms/posix/src/px4_layer/drv_hrt.cpp index a0257327b8..e32e0521be 100644 --- a/platforms/posix/src/px4_layer/drv_hrt.cpp +++ b/platforms/posix/src/px4_layer/drv_hrt.cpp @@ -49,7 +49,7 @@ #include #include "hrt_work.h" -#if defined(__PX4_POSIX_SITL) +#if defined(ENABLE_LOCKSTEP_SCHEDULER) #include #endif @@ -72,7 +72,7 @@ static hrt_abstime _delay_interval = 0; static hrt_abstime max_time = 0; static pthread_mutex_t _hrt_mutex = PTHREAD_MUTEX_INITIALIZER; -#if defined(__PX4_POSIX_SITL) +#if defined(ENABLE_LOCKSTEP_SCHEDULER) static LockstepScheduler lockstep_scheduler; #endif @@ -594,7 +594,7 @@ void abstime_to_ts(struct timespec *ts, hrt_abstime abstime) ts->tv_nsec = abstime * 1000; } -#if defined(__PX4_POSIX_SITL) +#if defined(ENABLE_LOCKSTEP_SCHEDULER) int px4_clock_gettime(clockid_t clk_id, struct timespec *tp) { if (clk_id == CLOCK_MONOTONIC) { diff --git a/src/include/visibility.h b/src/include/visibility.h index 0f8494fb53..1a956f02e8 100644 --- a/src/include/visibility.h +++ b/src/include/visibility.h @@ -65,7 +65,7 @@ */ #define system_exit exit -#if defined(__PX4_POSIX_SITL) +#if defined(ENABLE_LOCKSTEP_SCHEDULER) #include #include @@ -99,7 +99,7 @@ #include #include -#else // defined(__PX4_POSIX_SITL) +#else // defined(ENABLE_LOCKSTEP_SCHEDULER) #define system_usleep usleep #define system_sleep sleep diff --git a/src/platforms/px4_time.h b/src/platforms/px4_time.h index c9668b6e2f..a2f9f8a656 100644 --- a/src/platforms/px4_time.h +++ b/src/platforms/px4_time.h @@ -9,7 +9,7 @@ #define clockid_t int #endif -#if defined(__PX4_POSIX_SITL) || defined(__PX4_QURT) +#if defined(ENABLE_LOCKSTEP_SCHEDULER) || defined(__PX4_QURT) __BEGIN_DECLS __EXPORT int px4_clock_gettime(clockid_t clk_id, struct timespec *tp);