From 3104f915e5d2045692e4e612956701d89bbf87e8 Mon Sep 17 00:00:00 2001 From: "roberto@freebsd64" Date: Fri, 17 Dec 2010 13:44:33 +0100 Subject: [PATCH] use umtx_* locking functions on FreeBSD --- lock.c | 19 +++++++++++++++++++ uwsgiconfig.py | 4 ++++ 2 files changed, 23 insertions(+) diff --git a/lock.c b/lock.c index 4e8e4cb0..26f744ee 100644 --- a/lock.c +++ b/lock.c @@ -34,6 +34,25 @@ void uwsgi_unlock(void *lock) { } +#endif + +#ifdef UWSGI_LOCK_USE_UMTX + +#include +#include + +void uwsgi_lock_init(void *lock) { + umtx_init((struct umtx*) lock); +} + +void uwsgi_lock(void *lock) { + umtx_lock(lock, 1); +} + +void uwsgi_unlock(void *lock) { + umtx_unlock(lock, 1); +} + #endif diff --git a/uwsgiconfig.py b/uwsgiconfig.py index 9ff44046..8b7bf8a7 100644 --- a/uwsgiconfig.py +++ b/uwsgiconfig.py @@ -195,11 +195,15 @@ class uConf(): if locking_mode == 'auto': if uwsgi_os == 'Linux': locking_mode = 'pthread_mutex' + elif uwsgi_os == 'FreeBSD': + locking_mode = 'umtx' elif uwsgi_os == 'Darwin': locking_mode = 'osx_spinlock' if locking_mode == 'pthread_mutex': self.cflags.append('-DUWSGI_LOCK_USE_MUTEX') + elif locking_mode == 'umtx': + self.cflags.append('-DUWSGI_LOCK_USE_UMTX') elif locking_mode == 'osx_spinlock': self.cflags.append('-DUWSGI_LOCK_USE_OSX_SPINLOCK') else: