12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- #include "pthreadP.h"
- #ifndef LOCK_PREFIX
- # ifdef UP
- # define LOCK_PREFIX
- # else
- # define LOCK_PREFIX "lock;"
- # endif
- #endif
- int
- pthread_spin_lock (
- pthread_spinlock_t *lock)
- {
- __asm__ ("\n"
- "1:\t" LOCK_PREFIX "decl %0\n\t"
- "jne 2f\n\t"
- ".subsection 1\n\t"
- ".align 16\n"
- "2:\trep; nop\n\t"
- "cmpl $0, %0\n\t"
- "jg 1b\n\t"
- "jmp 2b\n\t"
- ".previous"
- : "=m" (*lock)
- : "m" (*lock));
- return 0;
- }
|