]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/l4util/include/ARCH-arm/atomic_arch.h
update
[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 Adam Lackorzynski <adam@os.inf.tu-dresden.de>,
7  *               Alexander Warg <warg@os.inf.tu-dresden.de>
8  *     economic rights: Technische Universität Dresden (Germany)
9  * This file is part of TUD:OS and distributed under the terms of the
10  * GNU Lesser General Public License 2.1.
11  * Please see the COPYING-LGPL-2.1 file for details.
12  */
13 #ifndef __L4UTIL__INCLUDE__ARCH_ARM__ATOMIC_ARCH_H__
14 #define __L4UTIL__INCLUDE__ARCH_ARM__ATOMIC_ARCH_H__
15
16 #ifdef __GNUC__
17
18 #include <l4/sys/kdebug.h>
19
20 EXTERN_C_BEGIN
21
22 #define __L4UTIL_ATOMIC_HAVE_ARCH_CMPXCHG32
23 L4_INLINE int
24 l4util_cmpxchg32(volatile l4_uint32_t * dest,
25                  l4_uint32_t cmp_val, l4_uint32_t new_val)
26 {
27   return l4_atomic_cmpxchg((volatile long int *)dest, cmp_val, new_val);
28 }
29
30 #define __L4UTIL_ATOMIC_HAVE_ARCH_CMPXCHG
31 L4_INLINE int
32 l4util_cmpxchg(volatile l4_umword_t * dest,
33                l4_umword_t cmp_val, l4_umword_t new_val)
34 {
35   return l4_atomic_cmpxchg((volatile long int *)dest, cmp_val, new_val);
36 }
37
38 #define __L4UTIL_ATOMIC_HAVE_ARCH_XCHG32
39 L4_INLINE l4_uint32_t
40 l4util_xchg32(volatile l4_uint32_t *dest, l4_uint32_t new_val)
41 {
42   return l4_atomic_xchg((volatile long int *)dest, new_val);
43 }
44
45 #define __L4UTIL_ATOMIC_HAVE_ARCH_XCHG
46 L4_INLINE l4_umword_t
47 l4util_xchg(volatile l4_umword_t *dest, l4_umword_t new_val)
48 {
49   return l4_atomic_xchg((volatile long int *)dest, new_val);
50 }
51
52 #define __L4UTIL_ATOMIC_HAVE_ARCH_ADD
53 L4_INLINE void
54 l4util_atomic_add(volatile long *dest, long val)
55 {
56   l4_atomic_add(dest, val);
57 }
58
59 #define __L4UTIL_ATOMIC_HAVE_ARCH_INC
60 L4_INLINE void
61 l4util_atomic_inc(volatile long *dest)
62 {
63   l4_atomic_add(dest, 1);
64 }
65
66 L4_INLINE void
67 l4util_inc32(volatile l4_uint32_t *dest)
68 {
69   l4_atomic_add((volatile long int *)dest, 1);
70 }
71
72 L4_INLINE void
73 l4util_dec32(volatile l4_uint32_t *dest)
74 {
75   l4_atomic_add((volatile long int *)dest, -1);
76 }
77
78
79 L4_INLINE l4_uint32_t
80 l4util_inc32_res(volatile l4_uint32_t *dest)
81 {
82   return l4_atomic_add((volatile long int *)dest, 1);
83 }
84
85 L4_INLINE l4_uint32_t
86 l4util_dec32_res(volatile l4_uint32_t *dest)
87 {
88   return l4_atomic_add((volatile long int *)dest, -1);
89 }
90
91 EXTERN_C_END
92
93 #endif //__GNUC__
94
95 #endif /* ! __L4UTIL__INCLUDE__ARCH_ARM__ATOMIC_ARCH_H__ */