From e28fcbd7779383810faa9a6a5b7a2741abcd991a Mon Sep 17 00:00:00 2001 From: TaiJu Wu Date: Fri, 13 Oct 2023 21:53:47 +0000 Subject: [PATCH] fix: Mac sim-02 compiler issue This path just for modify Mac sim-02 issue. The compiler require the firt paramter of atomic_compare_exchange_strong is atomic type and second parameter is int type. Signed-off-by: TaiJu Wu --- include/nuttx/spinlock.h | 3 ++- sched/semaphore/spinlock.c | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/include/nuttx/spinlock.h b/include/nuttx/spinlock.h index 43eec96e85..63c82c2e8d 100644 --- a/include/nuttx/spinlock.h +++ b/include/nuttx/spinlock.h @@ -33,7 +33,8 @@ #include #ifdef CONFIG_RW_SPINLOCK -typedef int32_t rwlock_t; +#include +typedef atomic_int rwlock_t; #define RW_SP_UNLOCKED 0 #define RW_SP_READ_LOCKED 1 #define RW_SP_WRITE_LOCKED -1 diff --git a/sched/semaphore/spinlock.c b/sched/semaphore/spinlock.c index 8059cfa4c1..ca75c14b02 100644 --- a/sched/semaphore/spinlock.c +++ b/sched/semaphore/spinlock.c @@ -476,7 +476,7 @@ void read_lock(FAR volatile rwlock_t *lock) { while (true) { - rwlock_t old = atomic_load(lock); + int old = atomic_load(lock); if (old <= RW_SP_WRITE_LOCKED) { @@ -521,7 +521,7 @@ bool read_trylock(FAR volatile rwlock_t *lock) { while (true) { - rwlock_t old = atomic_load(lock); + int old = atomic_load(lock); if (old <= RW_SP_WRITE_LOCKED) { @@ -592,7 +592,7 @@ void read_unlock(FAR volatile rwlock_t *lock) void write_lock(FAR volatile rwlock_t *lock) { - rwlock_t zero = RW_SP_UNLOCKED; + int zero = RW_SP_UNLOCKED; while (!atomic_compare_exchange_strong(lock, &zero, RW_SP_WRITE_LOCKED)) { @@ -630,7 +630,7 @@ void write_lock(FAR volatile rwlock_t *lock) bool write_trylock(FAR volatile rwlock_t *lock) { - rwlock_t zero = RW_SP_UNLOCKED; + int zero = RW_SP_UNLOCKED; if (atomic_compare_exchange_strong(lock, &zero, RW_SP_WRITE_LOCKED)) {