You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ck/regressions/ck_spinlock/linux_spinlock.h

40 lines
856 B

#include <ck_cc.h>
14 years ago
CK_CC_INLINE static void
14 years ago
spin_lock(volatile unsigned int *lock)
{
#ifdef __x86_64__
__asm__ __volatile__(
14 years ago
"\n1:\t"
"lock ; decl %0\n\t"
"jns 2f\n"
"3:\n"
"rep;nop\n\t"
"cmpl $0,%0\n\t"
"jle 3b\n\t"
"jmp 1b\n"
"2:\t" : "=m" (*lock) : : "memory");
#else
*lock = 1;
#endif
return;
}
CK_CC_INLINE static void
14 years ago
spin_unlock(volatile unsigned int *lock)
{
#ifdef __x86_64__
__asm__ __volatile__("movl $1,%0" :"=m" (*lock) :: "memory");
14 years ago
#else
*lock = 0;
return;
#endif
}
#define LOCK_NAME "linux_spinlock"
#define LOCK_DEFINE volatile unsigned int lock = 1
#define LOCK spin_lock(&lock)
#define UNLOCK spin_unlock(&lock)