From 57d386769472f99ea4f63e2573ef9de0cad27f72 Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Sat, 9 May 2026 10:29:18 +0200 Subject: [PATCH] Fix the case of using STL without pthreads but with mutexes (#1433) * Print test names at test time (#1343) * Fix operator| conflict with std::ranges (#1395) * Fix the case of using STL without pthreads but with mutexes On non-POSIX targets in STL mode, std::mutex is included from mutex.h but will probably miss pthreads. Instead, other implementations might be detected and used in mutex.h. Therefore, adding ETL_NO_STD_MUTEX as a profile option for ETL. Further, removing unnecessary includes from queue headers. --------- Co-authored-by: John Wellbelove Co-authored-by: John Wellbelove --- include/etl/mutex.h | 2 +- include/etl/platform.h | 10 ++++++++++ include/etl/queue_lockable.h | 1 - include/etl/queue_spsc_isr.h | 1 - include/etl/queue_spsc_locked.h | 1 - 5 files changed, 11 insertions(+), 4 deletions(-) diff --git a/include/etl/mutex.h b/include/etl/mutex.h index ec40c7c6..fc7d2f4d 100644 --- a/include/etl/mutex.h +++ b/include/etl/mutex.h @@ -40,7 +40,7 @@ SOFTWARE. #elif defined(ETL_TARGET_OS_THREADX) #include "mutex/mutex_threadx.h" #define ETL_HAS_MUTEX 1 -#elif ETL_USING_STL && ETL_USING_CPP11 +#elif ETL_USING_STL && ETL_USING_CPP11 && ETL_USING_STD_MUTEX #include "mutex/mutex_std.h" #define ETL_HAS_MUTEX 1 #elif defined(ETL_COMPILER_ARM5) || defined(ETL_COMPILER_ARM6) || defined(ETL_COMPILER_ARM7) || defined(ETL_COMPILER_ARM8) diff --git a/include/etl/platform.h b/include/etl/platform.h index bbf3022c..a7ca8305 100644 --- a/include/etl/platform.h +++ b/include/etl/platform.h @@ -102,6 +102,16 @@ SOFTWARE. #define ETL_NOT_USING_STL 0 #endif +//************************************* +// Helper macros for ETL_NO_STD_MUTEX. +#if defined(ETL_NO_STD_MUTEX) + #define ETL_USING_STD_MUTEX 0 + #define ETL_NOT_USING_STD_MUTEX 1 +#else + #define ETL_USING_STD_MUTEX 1 + #define ETL_NOT_USING_STD_MUTEX 0 +#endif + //************************************* // Helper macros for ETL_STLPORT. #if defined(ETL_STLPORT) diff --git a/include/etl/queue_lockable.h b/include/etl/queue_lockable.h index 8821a9b7..92daba21 100644 --- a/include/etl/queue_lockable.h +++ b/include/etl/queue_lockable.h @@ -35,7 +35,6 @@ SOFTWARE. #include "integral_limits.h" #include "memory.h" #include "memory_model.h" -#include "mutex.h" #include "parameter_type.h" #include "placement_new.h" #include "utility.h" diff --git a/include/etl/queue_spsc_isr.h b/include/etl/queue_spsc_isr.h index d25e6d14..b5bb79f6 100644 --- a/include/etl/queue_spsc_isr.h +++ b/include/etl/queue_spsc_isr.h @@ -35,7 +35,6 @@ SOFTWARE. #include "alignment.h" #include "integral_limits.h" #include "memory_model.h" -#include "mutex.h" #include "parameter_type.h" #include "placement_new.h" #include "utility.h" diff --git a/include/etl/queue_spsc_locked.h b/include/etl/queue_spsc_locked.h index 18424100..2aab884a 100644 --- a/include/etl/queue_spsc_locked.h +++ b/include/etl/queue_spsc_locked.h @@ -36,7 +36,6 @@ SOFTWARE. #include "integral_limits.h" #include "memory.h" #include "memory_model.h" -#include "mutex.h" #include "parameter_type.h" #include "placement_new.h" #include "utility.h"