]> 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>
Sun, 10 Aug 2014 13:54:53 +0000 (09:54 -0400)
ports/sysdeps/hppa/nptl/pthread_spin_init.c
ports/sysdeps/hppa/nptl/pthread_spin_unlock.c

index c83669eb915f33a94725f452e1724bb66dac8c40..b0ff78917bb25933240fcb58dd222fe50bb98cf4 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 5a8aed8e3826df671ae27348879bf4212d182362..7a4a996b8ecda29cb5234a54570e660b73da7337 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;
 }