From e5f40aa3ece3ee1100b4c72455d73106091d4407 Mon Sep 17 00:00:00 2001 From: Timo Kokkonen Date: Sun, 11 Oct 2020 12:07:56 +0300 Subject: [PATCH] Introduce mutex_init() This is to be used for run time mutex initialization. Signed-off-by: Timo Kokkonen --- utils.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/utils.h b/utils.h index cdb082f..c230b55 100644 --- 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 -- 2.45.0