1 #ifndef __ASM_METAG_ATOMIC_LNKGET_H
2 #define __ASM_METAG_ATOMIC_LNKGET_H
4 #define ATOMIC_INIT(i) { (i) }
6 #define atomic_set(v, i) ((v)->counter = (i))
8 #include <linux/compiler.h>
10 #include <asm/barrier.h>
13 * None of these asm statements clobber memory as LNKSET writes around
14 * the cache so the memory it modifies cannot safely be read by any means
15 * other than these accessors.
18 static inline int atomic_read(const atomic_t *v)
25 : "da" (&v->counter));
30 static inline void atomic_add(int i, atomic_t *v)
35 "1: LNKGETD %0, [%1]\n"
39 " ANDT %0, %0, #HI(0x3f000000)\n"
40 " CMPT %0, #HI(0x02000000)\n"
43 : "da" (&v->counter), "bd" (i)
47 static inline void atomic_sub(int i, atomic_t *v)
52 "1: LNKGETD %0, [%1]\n"
56 " ANDT %0, %0, #HI(0x3f000000)\n"
57 " CMPT %0, #HI(0x02000000)\n"
60 : "da" (&v->counter), "bd" (i)
64 static inline int atomic_add_return(int i, atomic_t *v)
71 "1: LNKGETD %1, [%2]\n"
75 " ANDT %0, %0, #HI(0x3f000000)\n"
76 " CMPT %0, #HI(0x02000000)\n"
78 : "=&d" (temp), "=&da" (result)
79 : "da" (&v->counter), "bd" (i)
87 static inline int atomic_sub_return(int i, atomic_t *v)
94 "1: LNKGETD %1, [%2]\n"
98 " ANDT %0, %0, #HI(0x3f000000)\n"
99 " CMPT %0, #HI(0x02000000)\n"
101 : "=&d" (temp), "=&da" (result)
102 : "da" (&v->counter), "bd" (i)
110 static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
115 "1: LNKGETD %0, [%1]\n"
119 " ANDT %0, %0, #HI(0x3f000000)\n"
120 " CMPT %0, #HI(0x02000000)\n"
123 : "da" (&v->counter), "bd" (~mask)
127 static inline void atomic_set_mask(unsigned int mask, atomic_t *v)
132 "1: LNKGETD %0, [%1]\n"
134 " LNKSETD [%1], %0\n"
136 " ANDT %0, %0, #HI(0x3f000000)\n"
137 " CMPT %0, #HI(0x02000000)\n"
140 : "da" (&v->counter), "bd" (mask)
144 static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
151 "1: LNKGETD %1, [%2]\n"
153 " LNKSETDEQ [%2], %4\n"
156 " ANDT %0, %0, #HI(0x3f000000)\n"
157 " CMPT %0, #HI(0x02000000)\n"
160 : "=&d" (temp), "=&d" (result)
161 : "da" (&v->counter), "bd" (old), "da" (new)
169 static inline int atomic_xchg(atomic_t *v, int new)
174 "1: LNKGETD %1, [%2]\n"
175 " LNKSETD [%2], %3\n"
177 " ANDT %0, %0, #HI(0x3f000000)\n"
178 " CMPT %0, #HI(0x02000000)\n"
180 : "=&d" (temp), "=&d" (old)
181 : "da" (&v->counter), "da" (new)
187 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
194 "1: LNKGETD %1, [%2]\n"
197 " LNKSETDNE [%2], %0\n"
200 " ANDT %0, %0, #HI(0x3f000000)\n"
201 " CMPT %0, #HI(0x02000000)\n"
204 : "=&d" (temp), "=&d" (result)
205 : "da" (&v->counter), "bd" (u), "bd" (a)
213 static inline int atomic_sub_if_positive(int i, atomic_t *v)
218 "1: LNKGETD %1, [%2]\n"
220 " LNKSETDGE [%2], %1\n"
223 " ANDT %0, %0, #HI(0x3f000000)\n"
224 " CMPT %0, #HI(0x02000000)\n"
227 : "=&d" (temp), "=&da" (result)
228 : "da" (&v->counter), "bd" (i)
234 #endif /* __ASM_METAG_ATOMIC_LNKGET_H */