From 17cd09c3a9c59bc914c28417fc244c5cc274a437 Mon Sep 17 00:00:00 2001 From: Marian Buschsieweke Date: Thu, 5 Nov 2020 17:33:59 +0100 Subject: [PATCH] fixup! cpu/cortexm_common: Add atomic_utils_arch.h --- .../include/atomic_utils_arch.h | 42 ++++++++++++------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/cpu/cortexm_common/include/atomic_utils_arch.h b/cpu/cortexm_common/include/atomic_utils_arch.h index 7e02b966138b7..0045445b53e1f 100644 --- a/cpu/cortexm_common/include/atomic_utils_arch.h +++ b/cpu/cortexm_common/include/atomic_utils_arch.h @@ -76,6 +76,16 @@ typedef volatile uint32_t *atomic_bit_u16_t; typedef volatile uint32_t *atomic_bit_u32_t; typedef volatile uint32_t *atomic_bit_u64_t; +static inline void __attribute__((always_inline)) _bit_barrier_pre(void) +{ + __asm__ volatile ("" : : : "memory"); +} + +static inline void __attribute__((always_inline)) _bit_barrier_post(void) +{ + __asm__ volatile ("" : : : "memory"); +} + static inline bool _is_addr_valid_for_bitbanding(void *_addr) { /* SRAM bit-band region goes from 0x20000000 to 0x200fffff, @@ -118,57 +128,57 @@ static inline atomic_bit_u64_t atomic_bit_u64(uint64_t *dest, uint8_t bit) static inline void atomic_set_bit_u8(atomic_bit_u8_t bit) { - __asm__ volatile ("" ::: "memory"); + _bit_barrier_pre(); *bit = 1; - __asm__ volatile ("" ::: "memory"); + _bit_barrier_post(); } static inline void atomic_set_bit_u16(atomic_bit_u16_t bit) { - __asm__ volatile ("" ::: "memory"); + _bit_barrier_pre(); *bit = 1; - __asm__ volatile ("" ::: "memory"); + _bit_barrier_post(); } static inline void atomic_set_bit_u32(atomic_bit_u32_t bit) { - __asm__ volatile ("" ::: "memory"); + _bit_barrier_pre(); *bit = 1; - __asm__ volatile ("" ::: "memory"); + _bit_barrier_post(); } static inline void atomic_set_bit_u64(atomic_bit_u64_t bit) { - __asm__ volatile ("" ::: "memory"); + _bit_barrier_pre(); *bit = 1; - __asm__ volatile ("" ::: "memory"); + _bit_barrier_post(); } static inline void atomic_clear_bit_u8(atomic_bit_u8_t bit) { - __asm__ volatile ("" ::: "memory"); + _bit_barrier_pre(); *bit = 0; - __asm__ volatile ("" ::: "memory"); + _bit_barrier_post(); } static inline void atomic_clear_bit_u16(atomic_bit_u16_t bit) { - __asm__ volatile ("" ::: "memory"); + _bit_barrier_pre(); *bit = 0; - __asm__ volatile ("" ::: "memory"); + _bit_barrier_post(); } static inline void atomic_clear_bit_u32(atomic_bit_u32_t bit) { - __asm__ volatile ("" ::: "memory"); + _bit_barrier_pre(); *bit = 0; - __asm__ volatile ("" ::: "memory"); + _bit_barrier_post(); } static inline void atomic_clear_bit_u64(atomic_bit_u64_t bit) { - __asm__ volatile ("" ::: "memory"); + _bit_barrier_pre(); *bit = 0; - __asm__ volatile ("" ::: "memory"); + _bit_barrier_post(); }