about summary refs log tree commit diff
path: root/linuxthreads/sysdeps/sparc/sparc64
diff options
context:
space:
mode:
authorAndreas Jaeger <aj@suse.de>2000-06-03 08:12:26 +0000
committerAndreas Jaeger <aj@suse.de>2000-06-03 08:12:26 +0000
commit554eca5cf0245d3c3c3cebe6eaf772a098f25aec (patch)
tree8c066082c327ddbddbb58d178ea445994b8b7d38 /linuxthreads/sysdeps/sparc/sparc64
parent80c7506e7b80151e73394e502e909a97e55c60fb (diff)
downloadglibc-554eca5cf0245d3c3c3cebe6eaf772a098f25aec.tar.gz
glibc-554eca5cf0245d3c3c3cebe6eaf772a098f25aec.tar.xz
glibc-554eca5cf0245d3c3c3cebe6eaf772a098f25aec.zip
* sysdeps/sparc/sparc32/pspinlock.c: Implement spinlocks.
* sysdeps/sparc/sparc32/sparcv9/pspinlock.c: New. 
* sysdeps/sparc/sparc64/pspinlock.c: Implement spinlocks.
2000-06-02  Jakub Jelinek  <jakub@redhat.com>

	* sysdeps/sparc/sparc32/pspinlock.c: Implement spinlocks.
	* sysdeps/sparc/sparc32/sparcv9/pspinlock.c: New.
	* sysdeps/sparc/sparc64/pspinlock.c: Implement spinlocks.
Diffstat (limited to 'linuxthreads/sysdeps/sparc/sparc64')
-rw-r--r--linuxthreads/sysdeps/sparc/sparc64/pspinlock.c35
1 files changed, 31 insertions, 4 deletions
diff --git a/linuxthreads/sysdeps/sparc/sparc64/pspinlock.c b/linuxthreads/sysdeps/sparc/sparc64/pspinlock.c
index 83edb08bba..e793b5c65c 100644
--- a/linuxthreads/sysdeps/sparc/sparc64/pspinlock.c
+++ b/linuxthreads/sysdeps/sparc/sparc64/pspinlock.c
@@ -21,10 +21,24 @@
 #include <pthread.h>
 
 
+/* This implementation is similar to the one used in the Linux kernel.  */
 int
 __pthread_spin_lock (pthread_spinlock_t *lock)
 {
-  XXX
+  asm volatile
+    ("1: ldstub  [%0], %%g5\n"
+     "   brnz,pn %%g5, 2f\n"
+     "    membar #StoreLoad | #StoreStore\n"
+     ".subsection 2\n"
+     "2: ldub    [%0], %%g5\n"
+     "   brnz,pt 2b\n"
+     "    membar #LoadLoad\n"
+     "   b,a,pt  %%xcc, 1b\n"
+     ".previous"
+     : /* no outputs */
+     : "r" (lock)
+     : "g5", "memory");
+  return 0;
 }
 weak_alias (__pthread_spin_lock, pthread_spin_lock)
 
@@ -32,7 +46,14 @@ weak_alias (__pthread_spin_lock, pthread_spin_lock)
 int
 __pthread_spin_trylock (pthread_spinlock_t *lock)
 {
-  XXX
+  int result;
+  asm volatile
+    ("ldstub [%1], %0\n"
+     "membar #StoreLoad | #StoreStore"
+     : "=r" (result)
+     : "r" (lock)
+     : "memory");
+  return result == 0 ? 0 : EBUSY;
 }
 weak_alias (__pthread_spin_trylock, pthread_spin_trylock)
 
@@ -40,7 +61,13 @@ weak_alias (__pthread_spin_trylock, pthread_spin_trylock)
 int
 __pthread_spin_unlock (pthread_spinlock_t *lock)
 {
-  XXX
+  asm volatile
+    ("membar #StoreStore | #LoadStore\n"
+     "stb    %%g0, [%0]"
+     :
+     : "r" (lock)
+     : "memory");
+  return 0;
 }
 weak_alias (__pthread_spin_unlock, pthread_spin_unlock)
 
@@ -51,7 +78,7 @@ __pthread_spin_init (pthread_spinlock_t *lock, int pshared)
   /* We can ignore the `pshared' parameter.  Since we are busy-waiting
      all processes which can access the memory location `lock' points
      to can use the spinlock.  */
-  XXX
+  *lock = 0;
   return 0;
 }
 weak_alias (__pthread_spin_init, pthread_spin_init)