Switzerland, email:ftf@fsfeurope.org.
 */
 
+/*
+  How to use mutex with bad order usage detection
+ ------------------------------------------------
+
+ Instead of using:
+    pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
+    P(mutex);
+    ..
+    V(mutex);
+
+ use:
+    bthread_mutex_t mutex = BTHREAD_MUTEX_PRIORITY_1;
+    P(mutex);
+    ...
+    V(mutex);
+
+ Mutex that doesn't need this extra check can be declared as pthread_mutex_t.
+ You can use this object on pthread_mutex_lock/unlock/cond_wait/cond_timewait.
+ 
+ With dynamic creation, you can use:
+    bthread_mutex_t mutex;
+    pthread_mutex_init(&mutex);     // you can also use bthread_mutex_init()
+    bthread_mutex_set_priority(&mutex, 10);
+    pthread_mutex_destroy(&mutex);
+ 
+ */
+
 #define _LOCKMGR_COMPLIANT
 #include "bacula.h"
 
    return pthread_mutex_destroy(&m->mutex);
 }
 
+/*
+ * Replacement for pthread_mutex_init() for pthread_mutex_t
+ */
+int bthread_mutex_init(pthread_mutex_t *m, const pthread_mutexattr_t *attr)
+{
+   return pthread_mutex_init(m, attr);
+}
+
+/*
+ * Replacement for pthread_mutex_destroy() for pthread_mutex_t
+ */
+int bthread_mutex_destroy(pthread_mutex_t *m)
+{
+   return pthread_mutex_destroy(m);
+}
+
+
 /*
  * Replacement for pthread_mutex_lock()
  * Returns always ok 
 
 int bthread_mutex_destroy(bthread_mutex_t *m);
 void bthread_mutex_set_priority(bthread_mutex_t *m, int prio);
 
+/* init/destroy for real pthread_mutex_t object */
+int bthread_mutex_init(pthread_mutex_t *m, const pthread_mutexattr_t *attr);
+int bthread_mutex_destroy(pthread_mutex_t *m);
+
 /*
  * Each thread have to call this function to put a lmgr_thread_t object
  * in the stack and be able to call mutex_lock/unlock
 # define pthread_mutex_unlock(x)         bthread_mutex_unlock(x)
 # define pthread_cond_wait(x,y)          bthread_cond_wait(x,y)
 # define pthread_cond_timedwait(x,y,z)   bthread_cond_timedwait(x,y,z)
+# define pthread_mutex_init(x,y)         bthread_mutex_init(x,y)
+# define pthread_mutex_destroy(x)        bthread_mutex_destroy(x)
 #endif
 
 #else   /* _USE_LOCKMGR */