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