diff --git a/libraries/AP_HAL_Linux/Scheduler.cpp b/libraries/AP_HAL_Linux/Scheduler.cpp index f8847af108..c3bd58640b 100644 --- a/libraries/AP_HAL_Linux/Scheduler.cpp +++ b/libraries/AP_HAL_Linux/Scheduler.cpp @@ -313,13 +313,25 @@ void Scheduler::reboot(bool hold_in_bootloader) exit(1); } +#if APM_BUILD_TYPE(APM_BUILD_Replay) void Scheduler::stop_clock(uint64_t time_usec) { - if (time_usec >= _stopped_clock_usec) { - _stopped_clock_usec = time_usec; - _run_io(); + if (time_usec < _stopped_clock_usec) { + ::fprintf(stderr, "Warning: setting time backwards from (%" PRIu64 ") to (%" PRIu64 ")\n", _stopped_clock_usec, time_usec); + return; } + + _stopped_clock_usec = time_usec; + _run_io(); } +#else +void Scheduler::stop_clock(uint64_t time_usec) +{ + // stop_clock() is not called outside of Replay, but we can't + // guard it in the header because of the vehicle-dependent-library + // checks in waf. +} +#endif bool Scheduler::SchedulerThread::_run() { diff --git a/libraries/AP_HAL_Linux/Scheduler.h b/libraries/AP_HAL_Linux/Scheduler.h index 03abe785d1..4556b35d80 100644 --- a/libraries/AP_HAL_Linux/Scheduler.h +++ b/libraries/AP_HAL_Linux/Scheduler.h @@ -3,6 +3,7 @@ #include #include "AP_HAL_Linux.h" + #include "Semaphores.h" #include "Thread.h"