[kaffe] CVS kaffe (guilhem): Partial fix for bug #5.

Kaffe CVS cvs-commits at kaffe.org
Thu Feb 2 12:28:45 PST 2006


PatchSet 7111 
Date: 2006/02/02 20:14:10
Author: guilhem
Branch: HEAD
Tag: (none) 
Log:

        Partial fix for bug #5.

        * config/arm/atomicity.h
        (compare_and_swap): Fixed assembly.
        (atomic_compare_and_exchange_val_acq): Defined macro.

        * config/arm/common.h: Use atomicity.h now.

Members: 
	ChangeLog:1.4629->1.4630 
	config/arm/atomicity.h:1.3->1.4 
	config/arm/common.h:1.14->1.15 

Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.4629 kaffe/ChangeLog:1.4630
--- kaffe/ChangeLog:1.4629	Tue Jan 31 02:27:12 2006
+++ kaffe/ChangeLog	Thu Feb  2 20:14:10 2006
@@ -1,3 +1,13 @@
+2006-02-02  Guilhem Lavaux  <guilhem at kaffe.org>
+
+	Partial fix for bug #5.
+
+	* config/arm/atomicity.h
+	(compare_and_swap): Fixed assembly.
+	(atomic_compare_and_exchange_val_acq): Defined macro.
+
+	* config/arm/common.h: Use atomicity.h now.
+	
 2006-01-30  Dalibor Topic  <robilad at kaffe.org>
 
 	Fixed bug #2.
Index: kaffe/config/arm/atomicity.h
diff -u kaffe/config/arm/atomicity.h:1.3 kaffe/config/arm/atomicity.h:1.4
--- kaffe/config/arm/atomicity.h:1.3	Mon Jul  4 00:03:48 2005
+++ kaffe/config/arm/atomicity.h	Thu Feb  2 20:14:13 2006
@@ -29,24 +29,36 @@
 {
   long int result, tmp;
   __asm__ ("\n"
-           "0:\tldr\t%1,[%2]\n\t"
-           "mov\t%0,#0\n\t"
-           "cmp\t%1,%4\n\t"
-           "bne\t1f\n\t"
-           "swp\t%0,%3,[%2]\n\t"
-           "cmp\t%1,%0\n\t"
-           "swpne\t%1,%0,[%2]\n\t"
-           "bne\t0b\n\t"
-           "mov\t%0,%4\n"
-	   "jmp\t2f\n\t"
-           "1:"
-	   "mov\t%0,%1\n\t"
+ 	   "0:\tldr\t%1,[%2]\n\t"
+   	   "mov\t%0,#0\n\t"
+   	   "cmp\t%1,%4\n\t"
+   	   "bne\t1f\n\t"
+   	   "swp\t%0,%3,[%2]\n\t"
+   	   "cmp\t%1,%0\n\t"
+   	   "swpne\t%1,%0,[%2]\n\t"
+  	   "bne\t0b\n\t"
+	   "mov\t%0,%4\n\t"
+	   "b\t2f\n\t"
+   	   "1:"
+ 	   "mov\t%0,%1\n"
 	   "2:"
-           : "=&r" (result), "=&r" (tmp)
-           : "r" (p), "r" (newval), "r" (oldval)
-           : "cc", "memory");
+	: "=&r" (result), "=&r" (tmp)
+	: "r" (p), "r" (newval), "r" (oldval)
+	: "cc", "memory");
   return result;
 }
+
+#define atomic_compare_and_exchange_val_acq(mem, newval, oldval)  \
+    ({ __typeof (*mem) result;                                    \
+           if (sizeof(*mem) == 4)                                 \
+	     result = compare_and_swap((long int*)(mem), (long int)(oldval), (long int)(newval));      \
+	   else                                                   \
+	     {                                                    \
+	       result = (__typeof(*mem))0;                        \
+	       abort();                                           \
+	     }                                                    \
+	   result;                                                \
+    })
 
 #endif /* atomicity.h */
 
Index: kaffe/config/arm/common.h
diff -u kaffe/config/arm/common.h:1.14 kaffe/config/arm/common.h:1.15
--- kaffe/config/arm/common.h:1.14	Sun Apr 17 20:36:39 2005
+++ kaffe/config/arm/common.h	Thu Feb  2 20:14:13 2006
@@ -24,7 +24,8 @@
 
 #include "gccbuiltin.h"
 #include "katomic.h"
-#include "generic/genatomic.h"
+#include "atomicity.h"
+#include "katomic.h"
 #include "generic/comparexch.h"
 
 #endif




More information about the kaffe mailing list