summaryrefslogtreecommitdiff
path: root/accel-pppd/triton
diff options
context:
space:
mode:
authorDmitry Kozlov <xeb@mail.ru>2014-06-03 21:43:27 +0400
committerDmitry Kozlov <xeb@mail.ru>2014-06-03 21:43:27 +0400
commitbd30f9451a3f775e7db30a9c405e4db9d4c259b8 (patch)
tree9700f1cc1c1a12c658e51176dd928a2a675d6a21 /accel-pppd/triton
parent093c53e3e08abb609cae6e58b1b438616c57c17f (diff)
downloadaccel-ppp-bd30f9451a3f775e7db30a9c405e4db9d4c259b8.tar.gz
accel-ppp-bd30f9451a3f775e7db30a9c405e4db9d4c259b8.zip
get out of SPINLOCK_INITIALIZER as it is not cross-platform compatible
Diffstat (limited to 'accel-pppd/triton')
-rw-r--r--accel-pppd/triton/mempool.c9
-rw-r--r--accel-pppd/triton/spinlock.h22
-rw-r--r--accel-pppd/triton/triton.c7
3 files changed, 12 insertions, 26 deletions
diff --git a/accel-pppd/triton/mempool.c b/accel-pppd/triton/mempool.c
index 1ee00f3..4a3ec8b 100644
--- a/accel-pppd/triton/mempool.c
+++ b/accel-pppd/triton/mempool.c
@@ -53,8 +53,8 @@ struct _item_t
};
static LIST_HEAD(pools);
-static spinlock_t pools_lock = SPINLOCK_INITIALIZER;
-static spinlock_t mmap_lock = SPINLOCK_INITIALIZER;
+static spinlock_t pools_lock;
+static spinlock_t mmap_lock;
static void *mmap_ptr;
static void *mmap_endptr;
@@ -343,7 +343,10 @@ static void __init init(void)
{
sigset_t set;
sigfillset(&set);
-
+
+ spinlock_init(&pools_lock);
+ spinlock_init(&mmap_lock);
+
struct sigaction sa = {
.sa_handler = sigclean,
.sa_mask = set,
diff --git a/accel-pppd/triton/spinlock.h b/accel-pppd/triton/spinlock.h
index b09d827..529719e 100644
--- a/accel-pppd/triton/spinlock.h
+++ b/accel-pppd/triton/spinlock.h
@@ -1,26 +1,7 @@
#ifndef __TRITON_SPINLOCK_H
#define __TRITON_SPINLOCK_H
-#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)
+#if defined(GCC_SPINLOCK)
typedef volatile int __attribute__((aligned)) spinlock_t;
#define spin_lock(l) {while(__sync_lock_test_and_set(l,1));}
@@ -34,7 +15,6 @@ typedef volatile int __attribute__((aligned)) spinlock_t;
typedef pthread_spinlock_t spinlock_t;
#define spin_lock(l) pthread_spin_lock(l)
#define spin_unlock(l) pthread_spin_unlock(l)
-#define SPINLOCK_INITIALIZER 1
#define spinlock_init(l) pthread_spin_init(l, 0)
#endif
diff --git a/accel-pppd/triton/triton.c b/accel-pppd/triton/triton.c
index b0adf57..05cbf21 100644
--- a/accel-pppd/triton/triton.c
+++ b/accel-pppd/triton/triton.c
@@ -16,13 +16,13 @@ int thread_count = 2;
int thread_count_max = 200;
int max_events = 64;
-static spinlock_t threads_lock = SPINLOCK_INITIALIZER;
+static spinlock_t threads_lock;
static LIST_HEAD(threads);
static LIST_HEAD(sleep_threads);
static LIST_HEAD(ctx_queue);
-static spinlock_t ctx_list_lock = SPINLOCK_INITIALIZER;
+static spinlock_t ctx_list_lock;
static LIST_HEAD(ctx_list);
static LIST_HEAD(init_list);
@@ -581,6 +581,9 @@ void __export triton_register_init(int order, void (*func)(void))
int __export triton_init(const char *conf_file)
{
+ spinlock_init(&threads_lock);
+ spinlock_init(&ctx_list_lock);
+
ctx_pool = mempool_create(sizeof(struct _triton_context_t));
call_pool = mempool_create(sizeof(struct _triton_ctx_call_t));