diff -Naur glibc-2.9-orig/sysdeps/sparc/sparc32/bits/atomic.h glibc-2.9/sysdeps/sparc/sparc32/bits/atomic.h
--- glibc-2.9-orig/sysdeps/sparc/sparc32/bits/atomic.h	2008-11-17 20:24:03.000000000 +0100
+++ glibc-2.9/sysdeps/sparc/sparc32/bits/atomic.h	2010-09-01 11:10:16.000000000 +0200
@@ -57,6 +57,12 @@
 __make_section_unallocated
   (".gnu.linkonce.b.__sparc32_atomic_locks, \"aw\", %nobits");
 
+/* save SHARED and unset it to use casa instruction */ 
+#ifdef SHARED
+#define SHARED_SAVE SHARED
+#undef SHARED
+#endif
+
 volatile unsigned char __sparc32_atomic_locks[64]
   __attribute__ ((nocommon, section (".gnu.linkonce.b.__sparc32_atomic_locks"
 				     __sec_comment),
@@ -110,6 +116,13 @@
 
 
 #ifndef SHARED
+   /* Use the additional CASA instruction for our sparc V8 implementation here 
+    *
+    * .word 0xcde04145 is casa [%g1]0xA, %g5, %g6 
+    * (format=3, rd=6, op3=111100 - casa, rs1=1, imm_asi=10, rs2=5)    
+    * 
+    * Do not simply write the symbolic 'casa' instruction as the assembler is not aware that our sparcv8 knows about this opcode ... 
+    */
 # define __v9_compare_and_exchange_val_32_acq(mem, newval, oldval) \
 ({									      \
   register __typeof (*(mem)) __acev_tmp __asm ("%g6");			      \
@@ -117,9 +130,7 @@
   register __typeof (*(mem)) __acev_oldval __asm ("%g5");		      \
   __acev_tmp = (newval);						      \
   __acev_oldval = (oldval);						      \
-  /* .word 0xcde05005 is cas [%g1], %g5, %g6.  Can't use cas here though,     \
-     because as will then mark the object file as V8+ arch.  */		      \
-  __asm __volatile (".word 0xcde05005"					      \
+  __asm __volatile (".word 0xcde04145"					      \
 		    : "+r" (__acev_tmp), "=m" (*__acev_mem)		      \
 		    : "r" (__acev_oldval), "m" (*__acev_mem),		      \
 		      "r" (__acev_mem) : "memory");			      \
@@ -246,6 +257,11 @@
    && __builtin_expect (_dl_hwcap & __ATOMIC_HWCAP_SPARC_V9, \
 			__ATOMIC_HWCAP_SPARC_V9))
 
+/* Force atomic v9 to use casa instruction */
+#ifndef __atomic_is_v9
+#define __atomic_is_v9
+#endif
+
 # define atomic_compare_and_exchange_val_acq(mem, newval, oldval) \
   ({								      \
      __typeof (*mem) __acev_wret;				      \
@@ -324,4 +340,11 @@
 
 #endif
 
+/* Restore SHARED */ 
+#ifdef SHARED_SAVE
+#define SHARED SHARED_SAVE
+#undef SHARED_SAVE
+#endif
+
+
 #endif	/* bits/atomic.h */
