From b925cb121d68f103083e1aa18458a7d74d39c310 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 11 May 2020 15:55:35 +1000 Subject: [PATCH] HAL_Linux: resync for 4.0 update --- libraries/AP_HAL_Linux/Scheduler.cpp | 4 +--- libraries/AP_HAL_Linux/Semaphores.cpp | 6 ------ libraries/AP_HAL_Linux/Semaphores.h | 5 ----- libraries/AP_HAL_Linux/system.cpp | 8 ++++++-- 4 files changed, 7 insertions(+), 16 deletions(-) diff --git a/libraries/AP_HAL_Linux/Scheduler.cpp b/libraries/AP_HAL_Linux/Scheduler.cpp index 1cc012b27e..197a051ffb 100644 --- a/libraries/AP_HAL_Linux/Scheduler.cpp +++ b/libraries/AP_HAL_Linux/Scheduler.cpp @@ -237,9 +237,7 @@ void Scheduler::_timer_task() void Scheduler::_run_io(void) { - if (!_io_semaphore.take(HAL_SEMAPHORE_BLOCK_FOREVER)) { - return; - } + _io_semaphore.take_blocking(); // now call the IO based drivers for (int i = 0; i < _num_io_procs; i++) { diff --git a/libraries/AP_HAL_Linux/Semaphores.cpp b/libraries/AP_HAL_Linux/Semaphores.cpp index 0bcf98057c..d07a71baee 100644 --- a/libraries/AP_HAL_Linux/Semaphores.cpp +++ b/libraries/AP_HAL_Linux/Semaphores.cpp @@ -8,12 +8,6 @@ using namespace Linux; // construct a semaphore Semaphore::Semaphore() -{ - pthread_mutex_init(&_lock, nullptr); -} - -// construct a recursive semaphore (allows a thread to take it more than once) -Semaphore_Recursive::Semaphore_Recursive() { pthread_mutexattr_t attr; pthread_mutexattr_init(&attr); diff --git a/libraries/AP_HAL_Linux/Semaphores.h b/libraries/AP_HAL_Linux/Semaphores.h index f9436a928b..90655871ec 100644 --- a/libraries/AP_HAL_Linux/Semaphores.h +++ b/libraries/AP_HAL_Linux/Semaphores.h @@ -18,9 +18,4 @@ protected: pthread_mutex_t _lock; }; -class Semaphore_Recursive : public Semaphore { -public: - Semaphore_Recursive(); -}; - } diff --git a/libraries/AP_HAL_Linux/system.cpp b/libraries/AP_HAL_Linux/system.cpp index 52794183c9..fd40dc4380 100644 --- a/libraries/AP_HAL_Linux/system.cpp +++ b/libraries/AP_HAL_Linux/system.cpp @@ -30,8 +30,12 @@ void panic(const char *errormsg, ...) va_end(ap); UNUSED_RESULT(write(1, "\n", 1)); - hal.rcin->teardown(); - hal.scheduler->delay_microseconds(10000); + if (hal.rcin != nullptr) { + hal.rcin->teardown(); + } + if (hal.scheduler != nullptr) { + hal.scheduler->delay_microseconds(10000); + } exit(1); }