]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/l4util/include/ARCH-sparc/atomic_arch.h
update
[l4.git] / l4 / pkg / l4util / include / ARCH-sparc / atomic_arch.h
1 /**
2  * \file
3  * \brief SPARC 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_SPARC__ATOMIC_ARCH_H__
14 #define __L4UTIL__INCLUDE__ARCH_SPARC__ATOMIC_ARCH_H__
15
16 #ifdef __GNUC__
17
18 #include <l4/sys/atomic.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   asm volatile ("ta 0");
44   return ~0;
45 }
46
47 #define __L4UTIL_ATOMIC_HAVE_ARCH_XCHG
48 L4_INLINE l4_umword_t
49 l4util_xchg(volatile l4_umword_t *dest, l4_umword_t new_val)
50 {
51 //  return l4_atomic_xchg((volatile long int *)dest, new_val);
52   asm volatile ("ta 0");
53   return ~0;
54 }
55
56 #define __L4UTIL_ATOMIC_HAVE_ARCH_ADD
57 L4_INLINE void
58 l4util_atomic_add(volatile long *dest, long val)
59 {
60   l4_atomic_add(dest, val);
61 }
62
63 #define __L4UTIL_ATOMIC_HAVE_ARCH_INC
64 L4_INLINE void
65 l4util_atomic_inc(volatile long *dest)
66 {
67   l4_atomic_add(dest, 1);
68 }
69
70 #define __L4UTIL_ATOMIC_HAVE_ARCH_INC32
71 L4_INLINE void
72 l4util_inc32(volatile l4_uint32_t *dest)
73 {
74   l4_atomic_add((volatile long int *)dest, 1);
75 }
76
77 #define __L4UTIL_ATOMIC_HAVE_ARCH_DEC32
78 L4_INLINE void
79 l4util_dec32(volatile l4_uint32_t *dest)
80 {
81   l4_atomic_add((volatile long int *)dest, -1);
82 }
83
84
85 #define __L4UTIL_ATOMIC_HAVE_ARCH_INC32_RES
86 L4_INLINE l4_uint32_t
87 l4util_inc32_res(volatile l4_uint32_t *dest)
88 {
89   return l4_atomic_add((volatile long int *)dest, 1);
90 }
91
92 #define __L4UTIL_ATOMIC_HAVE_ARCH_DEC32_RES
93 L4_INLINE l4_uint32_t
94 l4util_dec32_res(volatile l4_uint32_t *dest)
95 {
96   return l4_atomic_add((volatile long int *)dest, -1);
97 }
98
99 EXTERN_C_END
100
101 #endif //__GNUC__
102
103 #endif /* ! __L4UTIL__INCLUDE__ARCH_SPARC__ATOMIC_ARCH_H__ */