From: Willy Tarreau Date: Sun, 18 Oct 2020 08:20:59 +0000 (+0200) Subject: CLEANUP: threads: don't register an initcall when not debugging X-Git-Tag: v2.3-dev8~44 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3d18498645308a068797b157f509fbabcb934c3f;p=thirdparty%2Fhaproxy.git CLEANUP: threads: don't register an initcall when not debugging It's a bit overkill to register an initcall to call a function to set a lock to zero when not debugging, let's just declare the lock as pre-initialized to zero. --- diff --git a/include/haproxy/thread-t.h b/include/haproxy/thread-t.h index 33782f3c12..e827361646 100644 --- a/include/haproxy/thread-t.h +++ b/include/haproxy/thread-t.h @@ -45,9 +45,29 @@ #define __decl_rwlock(lock) #define __decl_aligned_rwlock(lock) +#elif !defined(DEBUG_THREAD) && !defined(DEBUG_FULL) + +/************** THREADS ENABLED WITHOUT DEBUGGING **************/ + +/* declare a self-initializing spinlock */ +#define __decl_spinlock(lock) \ + HA_SPINLOCK_T (lock) = 0; + +/* declare a self-initializing spinlock, aligned on a cache line */ +#define __decl_aligned_spinlock(lock) \ + HA_SPINLOCK_T (lock) __attribute__((aligned(64))) = 0; + +/* declare a self-initializing rwlock */ +#define __decl_rwlock(lock) \ + HA_RWLOCK_T (lock) = 0; + +/* declare a self-initializing rwlock, aligned on a cache line */ +#define __decl_aligned_rwlock(lock) \ + HA_RWLOCK_T (lock) __attribute__((aligned(64))) = 0; + #else /* !USE_THREAD */ -/********************** THREADS ENABLED ************************/ +/**************** THREADS ENABLED WITH DEBUGGING ***************/ /* declare a self-initializing spinlock */ #define __decl_spinlock(lock) \ diff --git a/src/thread.c b/src/thread.c index eeb0e04f42..370c0b15da 100644 --- a/src/thread.c +++ b/src/thread.c @@ -154,13 +154,13 @@ void ha_tkillall(int sig) raise(sig); } -/* these calls are used as callbacks at init time */ +/* these calls are used as callbacks at init time when debugging is on */ void ha_spin_init(HA_SPINLOCK_T *l) { HA_SPIN_INIT(l); } -/* these calls are used as callbacks at init time */ +/* these calls are used as callbacks at init time when debugging is on */ void ha_rwlock_init(HA_RWLOCK_T *l) { HA_RWLOCK_INIT(l);