Browse code

- armv6 arch fixes: - fixed return values for *atomic_inc_and_test* and *atomic_dec_and_test* - fixed *atomic_cmpxchg*: init %1 to 0 (or else if cmp fails and strexeq is not executed a "garbage" non zero value in %1 would cause an infinite loop) - removed "not tested" warning

Andrei Pelinescu-Onciul authored on 06/05/2008 16:35:35
Showing 1 changed files
... ...
@@ -39,7 +39,6 @@
39 39
 
40 40
 
41 41
 
42
-#warning "arm atomic operations support not tested"
43 42
 
44 43
 #ifdef NOSMP
45 44
 #define HAVE_ASM_INLINE_MEMBAR
... ...
@@ -167,8 +166,10 @@
167 167
 			"     strexeq %1, %4, [%3] \n\t" \
168 168
 			"     cmp %1, #0 \n\t" \
169 169
 			"     bne 1b \n\t" \
170
+			/* strexeq is exec. only if cmp was successful \
171
+			 * => if not successful %1 is not changed and remains 0 */ \
170 172
 			: "=&r"(ret), "=&r"(tmp), "=m"(*var) :\
171
-				"r"(var), "r"(new_v), "r"(old) : "cc" \
173
+				"r"(var), "r"(new_v), "r"(old), "1"(0) : "cc" \
172 174
 			); \
173 175
 		return ret; \
174 176
 	}
... ...
@@ -179,8 +180,8 @@ ATOMIC_FUNC_DECL(inc,      "add  %1, %0, #1", int, void, /* no return */ )
179 179
 ATOMIC_FUNC_DECL(dec,      "sub  %1, %0, #1", int, void, /* no return */ )
180 180
 ATOMIC_FUNC_DECL1(and,     "and  %1, %0, %4", int, void, /* no return */ )
181 181
 ATOMIC_FUNC_DECL1(or,      "orr  %1, %0, %4", int, void, /* no return */ )
182
-ATOMIC_FUNC_DECL(inc_and_test, "add  %1, %0, #1", int, int, ret )
183
-ATOMIC_FUNC_DECL(dec_and_test, "sub  %1, %0, #1", int, int, ret )
182
+ATOMIC_FUNC_DECL(inc_and_test, "add  %1, %0, #1", int, int, ret==0 )
183
+ATOMIC_FUNC_DECL(dec_and_test, "sub  %1, %0, #1", int, int, ret==0 )
184 184
 //ATOMIC_FUNC_DECL2(get_and_set, /* no extra op needed */ , int, int,  ret)
185 185
 ATOMIC_XCHG_DECL(get_and_set, int)
186 186
 ATOMIC_CMPXCHG_DECL(cmpxchg, int)
... ...
@@ -190,8 +191,8 @@ ATOMIC_FUNC_DECL(inc,      "add  %1, %0, #1", long, void, /* no return */ )
190 190
 ATOMIC_FUNC_DECL(dec,      "sub  %1, %0, #1", long, void, /* no return */ )
191 191
 ATOMIC_FUNC_DECL1(and,     "and  %1, %0, %4", long, void, /* no return */ )
192 192
 ATOMIC_FUNC_DECL1(or,      "orr  %1, %0, %4", long, void, /* no return */ )
193
-ATOMIC_FUNC_DECL(inc_and_test, "add  %1, %0, #1", long, long, ret )
194
-ATOMIC_FUNC_DECL(dec_and_test, "sub  %1, %0, #1", long, long, ret )
193
+ATOMIC_FUNC_DECL(inc_and_test, "add  %1, %0, #1", long, long, ret==0 )
194
+ATOMIC_FUNC_DECL(dec_and_test, "sub  %1, %0, #1", long, long, ret==0 )
195 195
 //ATOMIC_FUNC_DECL2(get_and_set, /* no extra op needed */ , long, long,  ret)
196 196
 ATOMIC_XCHG_DECL(get_and_set, long)
197 197
 ATOMIC_CMPXCHG_DECL(cmpxchg, long)