Skip to content

Commit

Permalink
fix: Mac sim-02 compiler issue
Browse files Browse the repository at this point in the history
Signed-off-by: TaiJu Wu <[email protected]>
  • Loading branch information
TaiJuWu committed Oct 13, 2023
1 parent f4d5624 commit 40a355e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion include/nuttx/spinlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
#include <nuttx/irq.h>

#ifdef CONFIG_RW_SPINLOCK
typedef int32_t rwlock_t;
#include <stdatomic.h>
typedef atomic_int rwlock_t;
#define RW_SP_UNLOCKED 0
#define RW_SP_READ_LOCKED 1
#define RW_SP_WRITE_LOCKED -1
Expand Down
8 changes: 4 additions & 4 deletions sched/semaphore/spinlock.c
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ void spin_clrbit(FAR volatile cpu_set_t *set, unsigned int cpu,

void read_lock(FAR volatile rwlock_t *lock)
{
rwlock_t old;
int32_t old;

while (true)
{
Expand Down Expand Up @@ -521,7 +521,7 @@ void read_lock(FAR volatile rwlock_t *lock)

bool read_trylock(FAR volatile rwlock_t *lock)
{
rwlock_t old = atomic_load(lock);
int32_t old = atomic_load(lock);

if (old >= RW_SP_UNLOCKED &&
atomic_compare_exchange_strong(lock, &old, old + 1))
Expand Down Expand Up @@ -587,7 +587,7 @@ void read_unlock(FAR volatile rwlock_t *lock)

void write_lock(FAR volatile rwlock_t *lock)
{
rwlock_t zero = RW_SP_UNLOCKED;
int32_t zero = RW_SP_UNLOCKED;

while (!atomic_compare_exchange_strong(lock, &zero, RW_SP_WRITE_LOCKED))
{
Expand Down Expand Up @@ -625,7 +625,7 @@ void write_lock(FAR volatile rwlock_t *lock)

bool write_trylock(FAR volatile rwlock_t *lock)
{
rwlock_t zero = RW_SP_UNLOCKED;
int32_t zero = RW_SP_UNLOCKED;

if (!atomic_compare_exchange_strong(lock, &zero, RW_SP_WRITE_LOCKED))
{
Expand Down

0 comments on commit 40a355e

Please sign in to comment.