]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: thread: provide a set of lock initialisers
authorWilly Tarreau <w@1wt.eu>
Sun, 25 Nov 2018 18:28:23 +0000 (19:28 +0100)
committerWilly Tarreau <w@1wt.eu>
Mon, 26 Nov 2018 18:50:32 +0000 (19:50 +0100)
This patch adds ha_spin_init() and ha_rwlock_init() which are used as
a callback to initialise locks at boot time. They perform exactly the
same as HA_SPIN_INIT() or HA_RWLOCK_INIT() but from within a real
function.

include/common/hathreads.h
src/hathreads.c

index d2fd400e0138d1e8b128eed9c6183e1e69af2a54..c5be9b2643f4c24df89866ed51b4cb6ccdc51d97 100644 (file)
@@ -948,6 +948,9 @@ static __inline int __ha_cas_dw(void *target, void *compare, void *set)
 #define __ha_barrier_full __sync_synchronize
 #endif
 
+void ha_spin_init(HA_SPINLOCK_T *l);
+void ha_rwlock_init(HA_RWLOCK_T *l);
+
 #endif /* USE_THREAD */
 
 static inline void __ha_compiler_barrier(void)
index 075866a609620a8278898a4b0827515bb9f9e544..eb3eb59fb2664c3c1f52dd637ea2eb114e104811 100644 (file)
@@ -92,6 +92,18 @@ void thread_release()
        thread_harmless_end();
 }
 
+/* these calls are used as callbacks at init time */
+void ha_spin_init(HA_SPINLOCK_T *l)
+{
+       HA_SPIN_INIT(l);
+}
+
+/* these calls are used as callbacks at init time */
+void ha_rwlock_init(HA_RWLOCK_T *l)
+{
+       HA_RWLOCK_INIT(l);
+}
+
 __attribute__((constructor))
 static void __hathreads_init(void)
 {