1 /* SPDX-License-Identifier: BSD-3-Clause
2  *
3  * Copyright(c) 2018 Intel Corporation. All rights reserved.
4  *
5  * Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
6  */
7 
8 #ifdef __ZEPHYR__
9 #include <sys/atomic.h>
10 #else
11 #ifndef __SOF_ATOMIC_H__
12 #define __SOF_ATOMIC_H__
13 
14 #include <arch/atomic.h>
15 #include <stdint.h>
16 
atomic_init(atomic_t * a,int32_t value)17 static inline void atomic_init(atomic_t *a, int32_t value)
18 {
19 	arch_atomic_init(a, value);
20 }
21 
atomic_read(const atomic_t * a)22 static inline int32_t atomic_read(const atomic_t *a)
23 {
24 	return arch_atomic_read(a);
25 }
26 
atomic_set(atomic_t * a,int32_t value)27 static inline void atomic_set(atomic_t *a, int32_t value)
28 {
29 	arch_atomic_set(a, value);
30 }
31 
atomic_add(atomic_t * a,int32_t value)32 static inline int32_t atomic_add(atomic_t *a, int32_t value)
33 {
34 	return arch_atomic_add(a, value);
35 }
36 
atomic_sub(atomic_t * a,int32_t value)37 static inline int32_t atomic_sub(atomic_t *a, int32_t value)
38 {
39 	return arch_atomic_sub(a, value);
40 }
41 
42 #endif /* __SOF_ATOMIC_H__ */
43 
44 #endif /*__ZEPHYR__ */
45