Skip to content
This repository has been archived by the owner on May 24, 2022. It is now read-only.

cache: use optimized futexes on i386 and amd64 arch only #105

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
10 changes: 5 additions & 5 deletions shctx.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*
*/
#include <sys/mman.h>
#ifdef USE_SYSCALL_FUTEX
#if defined USE_SYSCALL_FUTEX && (defined __i386__ || defined __x86_64__) && defined __linux__
#include <unistd.h>
#include <linux/futex.h>
#include <sys/syscall.h>
Expand All @@ -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;
Expand All @@ -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"
Expand Down Expand Up @@ -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;
Expand All @@ -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);
Expand Down