]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
CLEANUP: threads: don't register an initcall when not debugging
authorWilly Tarreau <w@1wt.eu>
Sun, 18 Oct 2020 08:20:59 +0000 (10:20 +0200)
committerWilly Tarreau <w@1wt.eu>
Mon, 19 Oct 2020 12:08:13 +0000 (14:08 +0200)
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.

include/haproxy/thread-t.h
src/thread.c

index 33782f3c1270f96b655ffec700fc9bed1284bba8..e827361646e30d64a9cbe7aaeeaa4ba40ca9bdd0 100644 (file)
 #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)                               \
index eeb0e04f42b5824a1feb96e9a0cb375cb938524c..370c0b15da5c4454626d0ca58bdc051fbca583fc 100644 (file)
@@ -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);