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:
parent
68a4d3df7e
commit
e28fcbd777
@ -33,7 +33,8 @@
|
|||||||
#include <nuttx/irq.h>
|
#include <nuttx/irq.h>
|
||||||
|
|
||||||
#ifdef CONFIG_RW_SPINLOCK
|
#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_UNLOCKED 0
|
||||||
#define RW_SP_READ_LOCKED 1
|
#define RW_SP_READ_LOCKED 1
|
||||||
#define RW_SP_WRITE_LOCKED -1
|
#define RW_SP_WRITE_LOCKED -1
|
||||||
|
@ -476,7 +476,7 @@ void read_lock(FAR volatile rwlock_t *lock)
|
|||||||
{
|
{
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
rwlock_t old = atomic_load(lock);
|
int old = atomic_load(lock);
|
||||||
|
|
||||||
if (old <= RW_SP_WRITE_LOCKED)
|
if (old <= RW_SP_WRITE_LOCKED)
|
||||||
{
|
{
|
||||||
@ -521,7 +521,7 @@ bool read_trylock(FAR volatile rwlock_t *lock)
|
|||||||
{
|
{
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
rwlock_t old = atomic_load(lock);
|
int old = atomic_load(lock);
|
||||||
|
|
||||||
if (old <= RW_SP_WRITE_LOCKED)
|
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)
|
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))
|
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)
|
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))
|
if (atomic_compare_exchange_strong(lock, &zero, RW_SP_WRITE_LOCKED))
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user