]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/l4util/include/ARCH-arm/atomic_arch.h
Inital import
[l4.git] / l4 / pkg / l4util / include / ARCH-arm / atomic_arch.h
1 /**
2  * \file
3  * \brief ARM specific implementation of atomic functions
4  */
5 /*
6  * (c) 2008-2009 Technische Universität Dresden
7  * This file is part of TUD:OS and distributed under the terms of the
8  * GNU Lesser General Public License 2.1.
9  * Please see the COPYING-LGPL-2.1 file for details.
10  */
11 #ifndef __L4UTIL__INCLUDE__ARCH_ARM__ATOMIC_ARCH_H__
12 #define __L4UTIL__INCLUDE__ARCH_ARM__ATOMIC_ARCH_H__
13
14 #ifdef __GNUC__
15
16 #include <l4/sys/kdebug.h>
17
18 EXTERN_C_BEGIN
19
20 #define __L4UTIL_ATOMIC_HAVE_ARCH_CMPXCHG32
21 L4_INLINE int
22 l4util_cmpxchg32(volatile l4_uint32_t * dest,
23                  l4_uint32_t cmp_val, l4_uint32_t new_val)
24 {
25   return l4_atomic_cmpxchg((volatile long int *)dest, cmp_val, new_val);
26 }
27
28 #define __L4UTIL_ATOMIC_HAVE_ARCH_CMPXCHG
29 L4_INLINE int
30 l4util_cmpxchg(volatile l4_umword_t * dest,
31                l4_umword_t cmp_val, l4_umword_t new_val)
32 {
33   return l4_atomic_cmpxchg((volatile long int *)dest, cmp_val, new_val);
34 }
35
36 #define __L4UTIL_ATOMIC_HAVE_ARCH_ADD
37 L4_INLINE void
38 l4util_atomic_add(volatile long *dest, long val)
39 {
40   l4_atomic_add(dest, val);
41 }
42
43 #define __L4UTIL_ATOMIC_HAVE_ARCH_INC
44 L4_INLINE void
45 l4util_atomic_inc(volatile long *dest)
46 {
47   l4_atomic_add(dest, 1);
48 }
49
50 L4_INLINE void
51 l4util_inc32(volatile l4_uint32_t *dest)
52 {
53   l4_atomic_add((volatile long int *)dest, 1);
54 }
55
56 L4_INLINE void
57 l4util_dec32(volatile l4_uint32_t *dest)
58 {
59   l4_atomic_add((volatile long int *)dest, -1);
60 }
61
62
63 L4_INLINE l4_uint32_t
64 l4util_inc32_res(volatile l4_uint32_t *dest)
65 {
66   return l4_atomic_add((volatile long int *)dest, 1);
67 }
68
69 L4_INLINE l4_uint32_t
70 l4util_dec32_res(volatile l4_uint32_t *dest)
71 {
72   return l4_atomic_add((volatile long int *)dest, -1);
73 }
74
75 EXTERN_C_END
76
77 #endif //__GNUC__
78
79 #endif /* ! __L4UTIL__INCLUDE__ARCH_ARM__ATOMIC_ARCH_H__ */