summaryrefslogtreecommitdiff
path: root/accel-pptpd/triton/spinlock.h
diff options
context:
space:
mode:
authorDmitry Kozlov <xeb@mail.ru>2010-11-21 17:31:00 +0300
committerDmitry Kozlov <xeb@mail.ru>2010-11-21 17:31:00 +0300
commita09fdabf7939819581c6b7797b180a18c4f477fa (patch)
tree4cfaa02377ff7a660c53099c300de0890dff5d3f /accel-pptpd/triton/spinlock.h
parentddad202eca1c0a1d95321bd396df0dda01620a2b (diff)
downloadaccel-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.h26
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)