Skip to content

Commit

Permalink
barriers: builtin: Check for GCC-ism
Browse files Browse the repository at this point in the history
__atomic_thread_fence() is GCC-ism. When supported by the compiler
(C11), use atomic_thread_fence() instead.

Signed-off-by: Carlo Caione <[email protected]>
  • Loading branch information
carlocaione authored and nashif committed May 24, 2023
1 parent 6f3a13d commit b87534a
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions include/zephyr/sys/barrier_builtin.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,22 @@ extern "C" {

static ALWAYS_INLINE void z_barrier_dmem_fence_full(void)
{
#if defined(__GNUC__)
/* GCC-ism */
__atomic_thread_fence(__ATOMIC_SEQ_CST);
#else
atomic_thread_fence(memory_order_seq_cst);
#endif
}

static ALWAYS_INLINE void z_barrier_dsync_fence_full(void)
{
#if defined(__GNUC__)
/* GCC-ism */
__atomic_thread_fence(__ATOMIC_SEQ_CST);
#else
atomic_thread_fence(memory_order_seq_cst);
#endif
}

static ALWAYS_INLINE void z_barrier_isync_fence_full(void)
Expand Down

0 comments on commit b87534a

Please sign in to comment.