]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
hppa: fix pthread spinlock
authorJohn David Anglin <dave.anglin@bell.net>
Sun, 10 Aug 2014 13:54:53 +0000 (09:54 -0400)
committerMike Frysinger <vapier@gentoo.org>
Mon, 9 Feb 2015 15:02:06 +0000 (10:02 -0500)
sysdeps/hppa/nptl/pthread_spin_init.c
sysdeps/hppa/nptl/pthread_spin_unlock.c

index 865ef2bfac52fb7d646e4138713624ab14a3fac6..a49a8468ca0374458f8220c891ac1cd841cacc9d 100644 (file)
@@ -20,9 +20,9 @@
 int
 pthread_spin_init (pthread_spinlock_t *lock, int pshared)
 {
-  int tmp = 0;
-  /* This should be a memory barrier to newer compilers */
-  __asm__ __volatile__ ("stw,ma %1,0(%0)"
-                        : : "r" (lock), "r" (tmp) : "memory");
+  /* The LWS-CAS operation on hppa is a synthetic atomic operation
+     that doesn't provide the type of coherency that we need. Therefore
+     we force that coherency by using LWS-CAS again.  */
+  atomic_exchange_rel (lock, 0);
   return 0;
 }
index a183fed35efa02f0eb99693910feefb96eae7309..b576649d2a76dc1ea54dafb98bc3fb976bece360 100644 (file)
@@ -20,9 +20,9 @@
 int
 pthread_spin_unlock (pthread_spinlock_t *lock)
 {
-  int tmp = 0;
-  /* This should be a memory barrier to newer compilers */
-  __asm__ __volatile__ ("stw,ma %1,0(%0)"
-                        : : "r" (lock), "r" (tmp) : "memory");
+  /* The LWS-CAS operation on hppa is a synthetic atomic operation
+     that doesn't provide the type of coherency that we need. Therefore
+     we force that coherency by using LWS-CAS again.  */
+  atomic_exchange_rel (lock, 0);
   return 0;
 }