Back to index

glibc  2.9
Functions
pthread_spin_trylock.c File Reference
#include <errno.h>
#include "pthreadP.h"

Go to the source code of this file.

Functions

int pthread_spin_trylock (pthread_spinlock_t *lock)

Function Documentation

int pthread_spin_trylock ( pthread_spinlock_t *  lock)

Definition at line 24 of file pthread_spin_trylock.c.

{
  unsigned int old;
  int err = EBUSY;

  asm ("1:    lwarx  %0,0,%2\n"
       "      cmpwi  0,%0,0\n"
       "      bne    2f\n"
       "      stwcx. %3,0,%2\n"
       "      bne-   1b\n"
       "      li     %1,0\n"
       "      isync\n"
       "2:    "
       : "=&r" (old), "=&r" (err)
       : "r" (lock), "r" (1), "1" (err)
       : "cr0", "memory");

  return err;
}

Here is the call graph for this function: