2003-12-22 19:29:21 +03:00
|
|
|
/*
|
2004-01-07 21:39:35 +03:00
|
|
|
* $HEADER$
|
2003-12-22 19:29:21 +03:00
|
|
|
*/
|
2004-01-07 21:39:35 +03:00
|
|
|
|
2003-12-22 19:29:21 +03:00
|
|
|
#ifndef _MUTEX_H_
|
|
|
|
#define _MUTEX_H_
|
|
|
|
|
2004-01-11 01:22:50 +03:00
|
|
|
#include "lam_config.h"
|
|
|
|
|
2003-12-22 19:29:21 +03:00
|
|
|
#if defined(USE_SPINWAIT)
|
|
|
|
#include "lam/threads/mutex_spinwait.h"
|
|
|
|
#else
|
|
|
|
#include "lam/threads/mutex_spinlock.h"
|
|
|
|
#endif
|
2004-01-11 01:22:50 +03:00
|
|
|
|
|
|
|
extern bool lam_uses_threads;
|
|
|
|
|
2004-01-11 03:50:59 +03:00
|
|
|
static inline bool lam_use_threads(void) { return lam_uses_threads; }
|
2004-01-11 01:22:50 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Lock macros
|
|
|
|
*/
|
|
|
|
#define THREAD_LOCK(a) if(lam_use_threads()) \
|
|
|
|
lam_mtx_lock((a));
|
|
|
|
|
|
|
|
#define LOCK(a) lam_mtx_lock((a))
|
|
|
|
|
|
|
|
/*
|
|
|
|
* unlock macros
|
|
|
|
*/
|
|
|
|
#define THREAD_UNLOCK(a) if(lam_use_threads()) \
|
|
|
|
lam_mtx_unlock((a));
|
|
|
|
|
|
|
|
#define UNLOCK(a) lam_mtx_unlock((a));
|
|
|
|
|
2003-12-22 19:29:21 +03:00
|
|
|
#endif
|
|
|
|
|