]> git.itanic.dy.fi Git - rrdd/commitdiff
Introduce mutex_init()
authorTimo Kokkonen <timo.t.kokkonen@iki.fi>
Sun, 11 Oct 2020 09:07:56 +0000 (12:07 +0300)
committerTimo Kokkonen <timo.t.kokkonen@iki.fi>
Sun, 11 Oct 2020 09:07:56 +0000 (12:07 +0300)
This is to be used for run time mutex initialization.

Signed-off-by: Timo Kokkonen <timo.t.kokkonen@iki.fi>
utils.h

diff --git a/utils.h b/utils.h
index cdb082f3b5ea1fcfe7f495742d5f4a56c23c5f01..c230b5559b8394188b52a6c94639ef31c4d358c3 100644 (file)
--- a/utils.h
+++ b/utils.h
@@ -25,4 +25,14 @@ int _mutex_unlock(struct mutex *lock);
 #define mutex_unlock(lock) _mutex_unlock(lock)
 #define mutex_lock_acquired(lock) _mutex_lock_acquired(lock, __FILE__, __LINE__)
 
+static inline int mutex_init(struct mutex *mutex)
+{
+       mutex->line = 0;
+       mutex->owner_name[0] = '\0';
+       mutex->lock_time = 0;
+       mutex->name = NULL;
+
+       return pthread_mutex_init(&mutex->lock, NULL);
+}
+
 #endif