diff --git a/libs/libc/pthread/Kconfig b/libs/libc/pthread/Kconfig index 306d80600d..8e2c9f8804 100644 --- a/libs/libc/pthread/Kconfig +++ b/libs/libc/pthread/Kconfig @@ -9,8 +9,8 @@ menu "pthread support" config PTHREAD_SPINLOCKS bool "pthread spinlock support" default n - depends on SPINLOCK && BOARDCTL - select BOARDCTL_TESTSET + depends on SPINLOCK && (BUILD_FLAT || BOARDCTL) + select BOARDCTL_TESTSET if !BUILD_FLAT ---help--- Enable support for pthread spinlocks. diff --git a/libs/libc/pthread/pthread_spinlock.c b/libs/libc/pthread/pthread_spinlock.c index c72ac9d673..7f1391a109 100644 --- a/libs/libc/pthread/pthread_spinlock.c +++ b/libs/libc/pthread/pthread_spinlock.c @@ -26,6 +26,7 @@ #include #include +#include #include #include @@ -184,7 +185,11 @@ int pthread_spin_lock(pthread_spinlock_t *lock) do { +#ifdef CONFIG_BUILD_FLAT + ret = up_testset(&lock->sp_lock) == SP_LOCKED ? 1 : 0; +#else ret = boardctl(BOARDIOC_TESTSET, (uintptr_t)&lock->sp_lock); +#endif } while (ret == 1);