about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJohn David Anglin <dave.anglin@bell.net>2014-08-10 09:54:53 -0400
committerMike Frysinger <vapier@gentoo.org>2014-08-10 09:54:53 -0400
commitbb18aaeae7ba7f46ac2897889ee92b3f551fc0b4 (patch)
treea4ca22170e74c5759f47c038267687968b26604d
parentc2934dc5e03bc0369b76d0b1209aea9323345ff8 (diff)
downloadglibc-bb18aaeae7ba7f46ac2897889ee92b3f551fc0b4.tar.gz
glibc-bb18aaeae7ba7f46ac2897889ee92b3f551fc0b4.tar.xz
glibc-bb18aaeae7ba7f46ac2897889ee92b3f551fc0b4.zip
hppa: fix pthread spinlock
-rw-r--r--ports/sysdeps/hppa/nptl/pthread_spin_init.c8
-rw-r--r--ports/sysdeps/hppa/nptl/pthread_spin_unlock.c8
2 files changed, 8 insertions, 8 deletions
diff --git a/ports/sysdeps/hppa/nptl/pthread_spin_init.c b/ports/sysdeps/hppa/nptl/pthread_spin_init.c
index c83669eb91..b0ff78917b 100644
--- a/ports/sysdeps/hppa/nptl/pthread_spin_init.c
+++ b/ports/sysdeps/hppa/nptl/pthread_spin_init.c
@@ -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;
 }
diff --git a/ports/sysdeps/hppa/nptl/pthread_spin_unlock.c b/ports/sysdeps/hppa/nptl/pthread_spin_unlock.c
index 5a8aed8e38..7a4a996b8e 100644
--- a/ports/sysdeps/hppa/nptl/pthread_spin_unlock.c
+++ b/ports/sysdeps/hppa/nptl/pthread_spin_unlock.c
@@ -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;
 }