diff options
author | Dmitry Kozlov <xeb@mail.ru> | 2010-11-21 17:31:00 +0300 |
---|---|---|
committer | Dmitry Kozlov <xeb@mail.ru> | 2010-11-21 17:31:00 +0300 |
commit | a09fdabf7939819581c6b7797b180a18c4f477fa (patch) | |
tree | 4cfaa02377ff7a660c53099c300de0890dff5d3f /accel-pptpd/triton/spinlock.h | |
parent | ddad202eca1c0a1d95321bd396df0dda01620a2b (diff) | |
download | accel-ppp-a09fdabf7939819581c6b7797b180a18c4f477fa.tar.gz accel-ppp-a09fdabf7939819581c6b7797b180a18c4f477fa.zip |
bug fixes
Diffstat (limited to 'accel-pptpd/triton/spinlock.h')
-rw-r--r-- | accel-pptpd/triton/spinlock.h | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/accel-pptpd/triton/spinlock.h b/accel-pptpd/triton/spinlock.h index 61f9b01..bb8dcf4 100644 --- a/accel-pptpd/triton/spinlock.h +++ b/accel-pptpd/triton/spinlock.h @@ -1,13 +1,35 @@ #ifndef __TRITON_SPINLOCK_H #define __TRITON_SPINLOCK_H -#ifdef GCC_SPINLOCK -typedef volatile unsigned int spinlock_t; +#if defined(FUTEX_SPINLOCK) + +/*#include <unistd.h> +#include <sys/syscall.h> +#include <linux/futex.h> +typedef volatile int __attribute__((aligned)) spinlock_t; +static inline void _spin_lock(spinlock_t *l) +{ + syscall(SYS_futex, l, FUTEX_WAIT, r, NULL, NULL, 0); +} +static inline void _spin_unlock(spinlock_t *l) +{ + syscall(SYS_futex, l, FUTEX_WAKE, 2, NULL, NULL, 0); +} +#define spin_lock(l) _spin_lock(l) +#define spin_unlock(l) _spin_unlock(l) +#define SPINLOCK_INITIALIZER 1 +#define spinlock_init(l) {*(l)=1;}*/ + +#elif defined(GCC_SPINLOCK) + +typedef volatile int __attribute__((aligned)) spinlock_t; #define spin_lock(l) {while(__sync_lock_test_and_set(l,1));} #define spin_unlock(l) __sync_lock_release(l) #define SPINLOCK_INITIALIZER 0 #define spinlock_init(l) {*(l)=0;} + #else + #include <pthread.h> typedef pthread_mutex_t spinlock_t; #define spin_lock(l) pthread_mutex_lock(l) |