diff --git a/Makefile b/Makefile index eba3e9c..1548f0f 100644 --- a/Makefile +++ b/Makefile @@ -16,6 +16,7 @@ all: realall # Shared cache feature ifneq ($(USE_SHARED_CACHE),) CFLAGS += -DUSE_SHARED_CACHE -DUSE_SYSCALL_FUTEX +LDFLAGS += -Wl,--as-needed -lpthread OBJS += shctx.o ebtree/libebtree.a ALL += ebtree diff --git a/shctx.c b/shctx.c index 081c08d..611dcf7 100644 --- a/shctx.c +++ b/shctx.c @@ -7,7 +7,7 @@ * */ #include -#ifdef USE_SYSCALL_FUTEX +#if defined USE_SYSCALL_FUTEX && (defined __i386__ || defined __x86_64__) && defined __linux__ #include #include #include @@ -30,7 +30,7 @@ struct shared_session { struct shared_context { -#ifdef USE_SYSCALL_FUTEX +#if defined USE_SYSCALL_FUTEX && (defined __i386__ || defined __x86_64__) && defined __linux__ unsigned int waiters; #else /* USE_SYSCALL_FUTEX */ pthread_mutex_t mutex; @@ -47,7 +47,7 @@ static void (*shared_session_new_cbk)(unsigned char *session, unsigned int sessi /* Lock functions */ -#ifdef USE_SYSCALL_FUTEX +#if defined USE_SYSCALL_FUTEX && (defined __i386__ || defined __x86_64__) && defined __linux__ static inline unsigned int xchg(unsigned int *ptr, unsigned int x) { __asm volatile("lock xchgl %0,%1" @@ -344,7 +344,7 @@ int shared_context_init(SSL_CTX *ctx, int size) if (!shctx) { int i; -#ifndef USE_SYSCALL_FUTEX +#if !(defined USE_SYSCALL_FUTEX && (defined __i386__ || defined __x86_64__) && defined __linux__) pthread_mutexattr_t attr; #endif /* USE_SYSCALL_FUTEX */ struct shared_session *prev,*cur; @@ -354,7 +354,7 @@ int shared_context_init(SSL_CTX *ctx, int size) if (!shctx || shctx == MAP_FAILED) return -1; -#ifdef USE_SYSCALL_FUTEX +#if defined USE_SYSCALL_FUTEX && (defined __i386__ || defined __x86_64__) && defined __linux__ shctx->waiters = 0; #else pthread_mutexattr_init(&attr);