From 258f61b4796f8e35ef417354309775b436901059 Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Wed, 4 Jun 2025 21:59:12 +0200 Subject: [PATCH] virthread: Add infrastructure for static virCond definitions MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Add the automatic cleanup handler as well as static initializer to allow simple stack allocated conditions. Signed-off-by: Peter Krempa Reviewed-by: Ján Tomko --- src/util/virthread.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/util/virthread.h b/src/util/virthread.h index a7ec6bf32c..9e4e8cdafe 100644 --- a/src/util/virthread.h +++ b/src/util/virthread.h @@ -73,6 +73,11 @@ struct virOnceControl { .once = PTHREAD_ONCE_INIT \ } +#define VIR_COND_INITIALIZER \ + { \ + .cond = PTHREAD_COND_INITIALIZER \ + } + typedef void (*virOnceFunc)(void); typedef void (*virThreadFunc)(void *opaque); @@ -142,6 +147,7 @@ void virRWLockUnlock(virRWLock *m); int virCondInit(virCond *c) G_GNUC_WARN_UNUSED_RESULT; int virCondDestroy(virCond *c); +G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(virCond, virCondDestroy); /* virCondWait, virCondWaitUntil: * These functions can return without the associated predicate -- 2.47.3