Zephyr API Documentation 4.3.99
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_sync_synchronize(void)
21{
22 __sync_synchronize();
23}
24
25static ALWAYS_INLINE void z_barrier_dmem_fence_full(void)
26{
27#if defined(__GNUC__)
28 /* GCC-ism */
29 __atomic_thread_fence(__ATOMIC_SEQ_CST);
30#else
31 atomic_thread_fence(memory_order_seq_cst);
32#endif
33}
34
35static ALWAYS_INLINE void z_barrier_dsync_fence_full(void)
36{
37#if defined(__GNUC__)
38 /* GCC-ism */
39 __atomic_thread_fence(__ATOMIC_SEQ_CST);
40#else
41 atomic_thread_fence(memory_order_seq_cst);
42#endif
43}
44
45static ALWAYS_INLINE void z_barrier_isync_fence_full(void)
46{
47 __asm__ volatile("" : : : "memory");
48}
49
50#ifdef __cplusplus
51}
52#endif
53
54#endif /* ZEPHYR_INCLUDE_SYS_BARRIER_BUILTIN_H_ */
#define ALWAYS_INLINE
Definition common.h:160
Macros to abstract toolchain specific capabilities.