From 98ae0186e93e6e4576026113706f43b01698d810 Mon Sep 17 00:00:00 2001 From: Julian Oes Date: Mon, 15 Oct 2018 15:02:03 +0200 Subject: [PATCH] px4_sem: use px4_sem on all POSIX system This uses the "fake" px4_sem based on mutex and condition_variable on all POSIX system, not just macOS and Cygwin. This means that we can change px4_sem_timedwait under the hood and inject the simulated time. --- platforms/posix/src/px4_layer/px4_sem.cpp | 5 +++-- src/platforms/px4_sem.h | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/platforms/posix/src/px4_layer/px4_sem.cpp b/platforms/posix/src/px4_layer/px4_sem.cpp index 938188a6fe..f3598a349b 100644 --- a/platforms/posix/src/px4_layer/px4_sem.cpp +++ b/platforms/posix/src/px4_layer/px4_sem.cpp @@ -40,12 +40,13 @@ #include #include #include +#include #include #include #include #include -#if defined(__PX4_DARWIN) || defined(__PX4_CYGWIN) +#if defined(__PX4_DARWIN) || defined(__PX4_CYGWIN) || defined(__PX4_POSIX) #include @@ -132,7 +133,7 @@ int px4_sem_timedwait(px4_sem_t *s, const struct timespec *abstime) int err = ret; - if (err != 0 && err != ETIMEDOUT) { + if (err != 0 && errno != ETIMEDOUT) { setbuf(stdout, NULL); setbuf(stderr, NULL); const unsigned NAMELEN = 32; diff --git a/src/platforms/px4_sem.h b/src/platforms/px4_sem.h index aa8c9009ec..661fb97953 100644 --- a/src/platforms/px4_sem.h +++ b/src/platforms/px4_sem.h @@ -50,7 +50,7 @@ #define sem_setprotocol(s,p) #endif -#if defined(__PX4_DARWIN) || defined(__PX4_CYGWIN) +#if defined(__PX4_DARWIN) || defined(__PX4_CYGWIN) || defined(__PX4_POSIX) __BEGIN_DECLS