[committed] tweak hppa atomicity.h

John David Anglin dave@hiauly1.hia.nrc.ca
Fri Aug 20 16:30:00 GMT 2004


Although there haven't been a problems reported with this particular
bit of code (probably because of the way this include is used), the
recent discussion on locks on the parisc-linux list got me looking at
the locking used here.  Basically, we don't want the "atomic" memory
operations migrating out of the locked region.

Tested on hppa2.0w-hp-ux11.11, hppa64-hp-hpux11.11 and hppa-unknown-linux-gnu.

Committed to main.

Dave
-- 
J. David Anglin                                  dave.anglin@nrc-cnrc.gc.ca
National Research Council of Canada              (613) 990-0752 (FAX: 952-6602)

2004-08-20  John David Anglin  <dave.anglin@nrc-cnrc.gc.ca>

	* cpu/hppa/atomicity.h (__exchange_and_add, __atomic_add): Add memory
	barrier to locking asm.

Index: config/cpu/hppa/atomicity.h
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/config/cpu/hppa/atomicity.h,v
retrieving revision 1.9
diff -u -3 -p -r1.9 atomicity.h
--- config/cpu/hppa/atomicity.h	7 Mar 2004 01:32:42 -0000	1.9
+++ config/cpu/hppa/atomicity.h	19 Aug 2004 16:29:50 -0000
@@ -61,7 +61,8 @@ namespace __gnu_cxx
 			  "nop\n\t"
 			  "b,n .-20"
 			  : "=&r" (tmp)
-			  : "r" (&lock));
+			  : "r" (&lock)
+			  : "memory");
     
     result = *__mem;
     *__mem = result + __val;
@@ -85,7 +86,8 @@ namespace __gnu_cxx
 			  "nop\n\t"
 			  "b,n .-20"
 			  : "=&r" (tmp)
-			  : "r" (&lock));
+			  : "r" (&lock)
+			  : "memory");
     
     *__mem += __val;
     /* Reset lock with PA 2.0 "ordered" store.  */



More information about the Gcc-patches mailing list