spinlock: Move the inclusion of stdatomic.h to source file

to make rwlock work with c++ source code

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
Xiang Xiao
2023-11-18 20:13:27 +08:00
committed by Petro Karashchenko
parent f35ec7727d
commit b2f75c2f3d
2 changed files with 38 additions and 30 deletions
+7 -8
View File
@@ -41,9 +41,8 @@ extern "C"
#define EXTERN extern
#endif
#if defined(CONFIG_RW_SPINLOCK) && !defined(__cplusplus)
# include <stdatomic.h>
typedef atomic_int rwlock_t;
#if defined(CONFIG_RW_SPINLOCK)
typedef int rwlock_t;
# define RW_SP_UNLOCKED 0
# define RW_SP_READ_LOCKED 1
# define RW_SP_WRITE_LOCKED -1
@@ -60,10 +59,10 @@ union spinlock_u
{
struct
{
uint16_t owner;
uint16_t next;
unsigned short owner;
unsigned short next;
} tickets;
uint32_t value;
unsigned int value;
};
typedef union spinlock_u spinlock_t;
@@ -505,7 +504,7 @@ void spin_unlock_irqrestore_wo_note(FAR spinlock_t *lock, irqstate_t flags);
# define spin_unlock_irqrestore_wo_note(l, f) up_irq_restore(f)
#endif
#if defined(CONFIG_RW_SPINLOCK) && !defined(__cplusplus)
#if defined(CONFIG_RW_SPINLOCK)
/****************************************************************************
* Name: rwlock_init
@@ -813,7 +812,7 @@ void write_unlock_irqrestore(FAR rwlock_t *lock, irqstate_t flags);
# define write_unlock_irqrestore(l, f) up_irq_restore(f)
#endif
#endif /* CONFIG_RW_SPINLOCK && !__cplusplus */
#endif /* CONFIG_RW_SPINLOCK */
#undef EXTERN
#if defined(__cplusplus)