Zephyr API Documentation 4.0.0-rc3
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
barrier_builtin.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2023 Carlo Caione <ccaione@baylibre.com>
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7#ifndef ZEPHYR_INCLUDE_SYS_BARRIER_BUILTIN_H_
8#define ZEPHYR_INCLUDE_SYS_BARRIER_BUILTIN_H_
9
10#ifndef ZEPHYR_INCLUDE_SYS_BARRIER_H_
11#error Please include <zephyr/sys/barrier.h>
12#endif
13
14#include <zephyr/toolchain.h>
15
16#ifdef __cplusplus
17extern "C" {
18#endif
19
20static ALWAYS_INLINE void z_barrier_dmem_fence_full(void)
21{
22#if defined(__GNUC__)
23 /* GCC-ism */
24 __atomic_thread_fence(__ATOMIC_SEQ_CST);
25#else
26 atomic_thread_fence(memory_order_seq_cst);
27#endif
28}
29
30static ALWAYS_INLINE void z_barrier_dsync_fence_full(void)
31{
32#if defined(__GNUC__)
33 /* GCC-ism */
34 __atomic_thread_fence(__ATOMIC_SEQ_CST);
35#else
36 atomic_thread_fence(memory_order_seq_cst);
37#endif
38}
39
40static ALWAYS_INLINE void z_barrier_isync_fence_full(void)
41{
42 __asm__ volatile("" : : : "memory");
43}
44
45#ifdef __cplusplus
46}
47#endif
48
49#endif /* ZEPHYR_INCLUDE_SYS_BARRIER_BUILTIN_H_ */
#define ALWAYS_INLINE
Definition common.h:129
Macros to abstract toolchain specific capabilities.