From ba6ee2a40749f1cc575e02eea5c406d7edd84fb7 Mon Sep 17 00:00:00 2001 From: Xiang Xiao Date: Tue, 17 May 2022 04:42:37 +0800 Subject: [PATCH] pthread/spinlock: Call up_testsest directly in the flat build Signed-off-by: Xiang Xiao --- libs/libc/pthread/Kconfig | 4 ++-- libs/libc/pthread/pthread_spinlock.c | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/libs/libc/pthread/Kconfig b/libs/libc/pthread/Kconfig index 306d80600da3a..8e2c9f8804bbd 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 c72ac9d67379f..7f1391a109c94 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);