treewide: rework mutex

Wrap mutex calls with traceable messages to help debugging resource locks.

[cleanup commit message]
Signed-off-by: Nick Hainke <vincent@systemli.org>
This commit is contained in:
Ian Clowes 2022-01-31 10:54:38 +00:00 committed by Nick Hainke
parent 0a962bea1f
commit be49c35686
6 changed files with 76 additions and 46 deletions

View file

@ -3,6 +3,7 @@
#include <stdint.h>
#include <syslog.h>
#include <pthread.h>
/**
* Check if a string is greater than another one.
@ -99,4 +100,20 @@ void dawnlog(int level, const char* fmt, ...);
* @return
*/
const char* dawnlog_basename(const char* file);
#endif
/**
** Wrap mutex operations to help track down mis-matches
*/
#define DAWN_MUTEX_WRAP
#ifndef DAWN_MUTEX_WRAP
#define dawn_mutex_lock(m) pthread_mutex_lock(m)
#define dawn_mutex_unlock(m) pthread_mutex_unlock(m)
#else
#define dawn_mutex_lock(m) _dawn_mutex_lock(m, __FILE__, __LINE__)
int _dawn_mutex_lock(pthread_mutex_t* m, char* f, int l);
#define dawn_mutex_unlock(m) _dawn_mutex_unlock(m, __FILE__, __LINE__)
int _dawn_mutex_unlock(pthread_mutex_t* m, char* f, int l);
#endif
#endif