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 33782f3..e827361 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 eeb0e04..370c0b1 100644
--- a/src/thread.c
+++ b/src/thread.c
@@ -154,13 +154,13 @@
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);