diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2019-02-05 14:15:47 +0100 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2019-02-11 09:36:55 +0100 |
commit | 4c8a1addeb03cd79468ee078a8f6052830b5fd4d (patch) | |
tree | 9b6de42c5784f9d9b18affd006c70e3103212b46 /rtemsbsd/include/machine | |
parent | Remove obsolete file (diff) | |
download | rtems-libbsd-4c8a1addeb03cd79468ee078a8f6052830b5fd4d.tar.bz2 |
atomic.h: Add atomic_load_32()
Diffstat (limited to 'rtemsbsd/include/machine')
-rw-r--r-- | rtemsbsd/include/machine/atomic.h | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/rtemsbsd/include/machine/atomic.h b/rtemsbsd/include/machine/atomic.h index 052df5a7..eb9e3ccb 100644 --- a/rtemsbsd/include/machine/atomic.h +++ b/rtemsbsd/include/machine/atomic.h @@ -997,6 +997,27 @@ atomic_readandclear_32(volatile uint32_t *p) } static inline uint32_t +atomic_load_32(volatile uint32_t *p) +{ + uint32_t tmp; + +#if defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_ATOMIC) + std::atomic_int *q = + reinterpret_cast<std::atomic_uint_least32_t *>(const_cast<uint32_t *>(p)); + + tmp = q->load(std::memory_order_relaxed); +#elif defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_STDATOMIC) + atomic_uint_least32_t *q = (atomic_uint_least32_t *)RTEMS_DEVOLATILE(uint32_t *, p); + + tmp = atomic_load_explicit(q, memory_order_relaxed); +#else + tmp = *p; +#endif + + return (tmp); +} + +static inline uint32_t atomic_load_acq_32(volatile uint32_t *p) { uint32_t tmp; |