mirror of
https://github.com/apache/nuttx.git
synced 2026-08-20 13:08:26 +00:00
include/nuttx/atomic.h: fix C++ definition conflicts
when C++ lib has an atomic implementation, we shouldn't include NuttX defined macros to avoid conflicts
Fix errors like:
build/include/libcxx/__atomic/atomic.h:445:1: error: expected identifier before numeric constant
445 | atomic_fetch_add(volatile atomic<_Tp>* __o, typename atomic<_Tp>::difference_type __op) _NOEXCEPT
| ^~~~~~~~~~~~~~~~
Signed-off-by: raiden00pl <raiden00@railab.me>
This commit is contained in:
parent
667171fbd8
commit
cd8ba3377c
1 changed files with 11 additions and 0 deletions
|
|
@ -29,6 +29,13 @@
|
||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
#define NEED_ATOMIC_MACROS
|
||||||
|
#if defined(__has_include)
|
||||||
|
# if __has_include(<atomic>) && defined(__cplusplus)
|
||||||
|
# undef NEED_ATOMIC_MACROS
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(__has_include) && !defined(CONFIG_LIBC_ARCH_ATOMIC)
|
#if defined(__has_include) && !defined(CONFIG_LIBC_ARCH_ATOMIC)
|
||||||
# if __has_include(<atomic>) && defined(__cplusplus)
|
# if __has_include(<atomic>) && defined(__cplusplus)
|
||||||
extern "C++"
|
extern "C++"
|
||||||
|
|
@ -98,6 +105,8 @@ typedef volatile int64_t atomic64_t;
|
||||||
* Pre-processor Definitions
|
* Pre-processor Definitions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef NEED_ATOMIC_MACROS
|
||||||
|
|
||||||
#define atomic_set(obj, val) ATOMIC_FUNC(store, 4)(obj, val, __ATOMIC_RELAXED)
|
#define atomic_set(obj, val) ATOMIC_FUNC(store, 4)(obj, val, __ATOMIC_RELAXED)
|
||||||
#define atomic_set_release(obj, val) ATOMIC_FUNC(store, 4)(obj, val, __ATOMIC_RELEASE)
|
#define atomic_set_release(obj, val) ATOMIC_FUNC(store, 4)(obj, val, __ATOMIC_RELEASE)
|
||||||
#define atomic64_set(obj, val) ATOMIC_FUNC(store, 8)(obj, val, __ATOMIC_RELAXED)
|
#define atomic64_set(obj, val) ATOMIC_FUNC(store, 8)(obj, val, __ATOMIC_RELAXED)
|
||||||
|
|
@ -198,6 +207,8 @@ typedef volatile int64_t atomic64_t;
|
||||||
#define atomic64_try_cmpxchg_relaxed(obj, expected, desired) \
|
#define atomic64_try_cmpxchg_relaxed(obj, expected, desired) \
|
||||||
ATOMIC_FUNC(compare_exchange_weak, 8)(obj, (FAR int64_t *)expected, desired, __ATOMIC_RELAXED, __ATOMIC_RELAXED)
|
ATOMIC_FUNC(compare_exchange_weak, 8)(obj, (FAR int64_t *)expected, desired, __ATOMIC_RELAXED, __ATOMIC_RELAXED)
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Function Prototypes
|
* Public Function Prototypes
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue