From dd33b3a14e9cbae66f51cbad3c6e42388b43f7c1 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Mon, 2 Sep 2019 15:54:31 +0200 Subject: [PATCH] shared: add nm_auto_unlock_g_mutex and NM_G_MUTEX_LOCKED() helper macros --- shared/nm-glib-aux/nm-macros-internal.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/shared/nm-glib-aux/nm-macros-internal.h b/shared/nm-glib-aux/nm-macros-internal.h index 619625942b..5c3b06717e 100644 --- a/shared/nm-glib-aux/nm-macros-internal.h +++ b/shared/nm-glib-aux/nm-macros-internal.h @@ -1975,4 +1975,18 @@ nm_close (int fd) #define NM_PID_T_INVAL ((pid_t) -1) +/*****************************************************************************/ + +NM_AUTO_DEFINE_FCN_VOID0 (GMutex *, _nm_auto_unlock_g_mutex, g_mutex_unlock) + +#define nm_auto_unlock_g_mutex nm_auto (_nm_auto_unlock_g_mutex) + +#define _NM_G_MUTEX_LOCKED(lock, uniq) \ + nm_auto_unlock_g_mutex GMutex *NM_UNIQ_T(nm_lock, uniq) = (lock) + +#define NM_G_MUTEX_LOCKED(lock) \ + _NM_G_MUTEX_LOCKED (lock, NM_UNIQ) + +/*****************************************************************************/ + #endif /* __NM_MACROS_INTERNAL_H__ */