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 35 of file pspinlock.c.

{
  unsigned int tmp;
  asm volatile
    ("1:      ldl_l  %0,%1\n"
     "        blbs   %0,2f\n"
     "        or     %0,1,%0\n"
     "        stl_c  %0,%1\n"
     "        beq    %0,2f\n"
     "        mb\n"
     ".subsection 2\n"
     "2:      ldl    %0,%1\n"
     "        blbs   %0,2b\n"
     "        br     1b\n"
     ".previous"
     : "=r" (tmp), "=m" (lock)
     : "m" (lock));
  return 0;
}

Definition at line 54 of file pspinlock.c.

{
  unsigned long int oldval;
  unsigned long int temp;

  asm volatile
    ("1:      ldl_l  %0,%1\n"
     "        and    %0,%3,%2\n"
     "        bne    %2,2f\n"
     "        xor    %0,%3,%0\n"
     "        stl_c  %0,%1\n"
     "        beq    %0,3f\n"
     "        mb\n"
     "2:\n"
     ".subsection 2\n"
     "3:      br     1b\n"
     ".previous"
     : "=&r" (temp), "=m" (*lock), "=&r" (oldval)
     : "Ir" (1UL), "m" (*lock));

  return oldval == 0 ? 0 : EBUSY;
}

Definition at line 80 of file pspinlock.c.

{
  asm volatile ("mb");
  return *lock = 0;
}

Definition at line 89 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 101 of file pspinlock.c.

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