Loading...
Searching...
No Matches
atomic_utils_arch.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2020 Otto-von-Guericke-Universität Magdeburg
3 * 2021 Gerson Fernando Budke
4 *
5 * This file is subject to the terms and conditions of the GNU Lesser General
6 * Public License v2.1. See the file LICENSE in the top level directory for more
7 * details.
8 */
9
21#ifndef ATOMIC_UTILS_ARCH_H
22#define ATOMIC_UTILS_ARCH_H
23#ifndef DOXYGEN
24
25#include "periph_cpu.h"
26
27#ifdef __cplusplus
28extern "C" {
29#endif
30
31/* clang provides no built-in atomic access to regular variables */
32#ifndef __clang__
33
34#define HAS_ATOMIC_LOAD_U8
35static inline uint8_t atomic_load_u8(const volatile uint8_t *var)
36{
37 return __atomic_load_1(var, __ATOMIC_SEQ_CST);
38}
39
40#define HAS_ATOMIC_STORE_U8
41static inline void atomic_store_u8(volatile uint8_t *dest, uint8_t val)
42{
43 __atomic_store_1(dest, val, __ATOMIC_SEQ_CST);
44}
45
46#endif /* __clang__ */
47
48#ifdef __cplusplus
49}
50#endif
51
52#endif /* DOXYGEN */
53#endif /* ATOMIC_UTILS_ARCH_H */
static void atomic_store_u8(volatile uint8_t *dest, uint8_t val)
Store an uint8_t atomically.
static uint8_t atomic_load_u8(const volatile uint8_t *var)
Load an uint8_t atomically.