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 <tjwu1217@gmail.com>
This commit is contained in:
TaiJu Wu 2023-10-13 21:53:47 +00:00 committed by Xiang Xiao
parent 68a4d3df7e
commit e28fcbd777
2 changed files with 6 additions and 5 deletions

View File

@ -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

View File

@ -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))
{