Back to index

glibc  2.9
Functions
pspinlock.c File Reference
#include <errno.h>
#include <pthread.h>
#include "internals.h"
#include <ia64intrin.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 30 of file pspinlock.c.

{
  int *p = (int *) lock;
  
  while (__builtin_expect (__sync_val_compare_and_swap (p, 0, 1), 0))
    {
      /* Spin without using the atomic instruction.  */
      do
        __asm __volatile ("" : : : "memory");
      while (*p);
    }
  return 0;
}

Definition at line 43 of file pspinlock.c.

{
  return __sync_val_compare_and_swap ((int *) lock, 0, 1) == 0 ? 0 : EBUSY;
}

Definition at line 51 of file pspinlock.c.

{
  return *lock = 0;
}

Definition at line 59 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.  */
  return *lock = 0;
}

Definition at line 70 of file pspinlock.c.

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