diff --git a/src/lam/threads/Makefile.am b/src/lam/threads/Makefile.am index 177e1b9202..c88e90a7b5 100644 --- a/src/lam/threads/Makefile.am +++ b/src/lam/threads/Makefile.am @@ -17,6 +17,7 @@ headers = \ libthreads_la_SOURCES = \ $(headers) \ + mutex.c \ thread.c # Conditionally install the header files diff --git a/src/lam/threads/mutex.c b/src/lam/threads/mutex.c new file mode 100644 index 0000000000..86d97a4f6b --- /dev/null +++ b/src/lam/threads/mutex.c @@ -0,0 +1,8 @@ +/* + * $HEADER$ + */ + +#include "lam/threads/mutex.h" + +bool lam_uses_threads; + diff --git a/src/lam/threads/mutex.h b/src/lam/threads/mutex.h index 90c6978498..a9210fb5d3 100644 --- a/src/lam/threads/mutex.h +++ b/src/lam/threads/mutex.h @@ -5,10 +5,33 @@ #ifndef _MUTEX_H_ #define _MUTEX_H_ +#include "lam_config.h" + #if defined(USE_SPINWAIT) #include "lam/threads/mutex_spinwait.h" #else #include "lam/threads/mutex_spinlock.h" #endif + +extern bool lam_uses_threads; + +static inline bool lam_use_threads() { return lam_uses_threads; } + +/* + * 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)); + #endif