Zephyr API Documentation 4.4.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
13
14#ifndef ZEPHYR_INCLUDE_SYS_BARRIER_BUILTIN_H_
15#define ZEPHYR_INCLUDE_SYS_BARRIER_BUILTIN_H_
16
17#ifndef ZEPHYR_INCLUDE_SYS_BARRIER_H_
18#error Please include <zephyr/sys/barrier.h>
19#endif
20
21#include <zephyr/toolchain.h>
22
23#ifdef __cplusplus
24extern "C" {
25#endif
26
27static ALWAYS_INLINE void z_barrier_sync_synchronize(void)
28{
29 __sync_synchronize();
30}
31
32static ALWAYS_INLINE void z_barrier_dmem_fence_full(void)
33{
34#if defined(__GNUC__)
35 /* GCC-ism */
36 __atomic_thread_fence(__ATOMIC_SEQ_CST);
37#else
38 atomic_thread_fence(memory_order_seq_cst);
39#endif
40}
41
42static ALWAYS_INLINE void z_barrier_dsync_fence_full(void)
43{
44#if defined(__GNUC__)
45 /* GCC-ism */
46 __atomic_thread_fence(__ATOMIC_SEQ_CST);
47#else
48 atomic_thread_fence(memory_order_seq_cst);
49#endif
50}
51
52static ALWAYS_INLINE void z_barrier_isync_fence_full(void)
53{
54 __asm__ volatile("" : : : "memory");
55}
56
57#ifdef __cplusplus
58}
59#endif
60
61#endif /* ZEPHYR_INCLUDE_SYS_BARRIER_BUILTIN_H_ */
Macros to abstract toolchain specific capabilities.