Back to index

glibc  2.9
Functions
pspinlock.c File Reference
#include <errno.h>
#include <pthread.h>
#include "internals.h"

Go to the source code of this file.

Functions

int __pthread_spin_lock (pthread_spinlock_t *lock)
 weak_alias (__pthread_spin_lock, pthread_spin_lock)
 weak_alias (__pthread_spin_trylock, pthread_spin_trylock)
 weak_alias (__pthread_spin_unlock, pthread_spin_unlock)
 weak_alias (__pthread_spin_init, pthread_spin_init)

Function Documentation

int __pthread_spin_lock ( pthread_spinlock_t *  lock)

Definition at line 26 of file pspinlock.c.

{
  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 %%g5, 2b\n"
     "    membar #LoadLoad\n"
     "   b,a,pt  %%xcc, 1b\n"
     ".previous"
     : /* no outputs */
     : "r" (lock)
     : "g5", "memory");
  return 0;
}

Definition at line 43 of file pspinlock.c.

{
  int result;
  asm volatile
    ("ldstub [%1], %0\n"
     "membar #StoreLoad | #StoreStore"
     : "=r" (result)
     : "r" (lock)
     : "memory");
  return result == 0 ? 0 : EBUSY;
}

Definition at line 58 of file pspinlock.c.

{
  asm volatile
    ("membar #StoreStore | #LoadStore\n"
     "stb    %%g0, [%0]"
     :
     : "r" (lock)
     : "memory");
  return 0;
}

Definition at line 72 of file pspinlock.c.

{
  /* 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.  */
  *lock = 0;
  return 0;
}

Definition at line 84 of file pspinlock.c.

{
  /* Nothing to do.  */
  return 0;
}