return ret;
}
+/* Test if this mutex is locked by the current thread
+ * returns:
+ * 0 - unlocked
+ * 1 - locked by the current thread
+ * 2 - locked by an other thread
+ */
+int lmgr_mutex_is_locked(void *m)
+{
+ lmgr_thread_t *self = lmgr_get_thread_info();
+
+ for(int i=0; i <= self->current; i++) {
+ if (self->lock_list[i].lock == m) {
+ return 1; /* locked by us */
+ }
+ }
+
+ return 0; /* not locked by us */
+}
+
/*
* Use this function when the caller handle the mutex directly
*
P(mutex4);
P(mutex5);
P(mutex6);
+ ok(lmgr_mutex_is_locked(&mutex6) == 1, "Check if mutex is locked");
V(mutex6);
+ ok(lmgr_mutex_is_locked(&mutex6) == 0, "Check if mutex is locked");
V(mutex5);
V(mutex4);
int bthread_mutex_unlock_p(bthread_mutex_t *m,
const char *file="*unknown*", int line=0);
+/* Test if this mutex is locked by the current thread
+ * 0 - not locked by the current thread
+ * 1 - locked by the current thread
+ */
+int lmgr_mutex_is_locked(void *m);
+
/*
* Use them when you want use your lock yourself (ie rwlock)
*/
# define BTHREAD_MUTEX_PRIORITY(p) PTHREAD_MUTEX_INITIALIZER
# define BTHREAD_MUTEX_NO_PRIORITY PTHREAD_MUTEX_INITIALIZER
# define BTHREAD_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
+# define lmgr_mutex_is_locked(m) (1)
+
#endif /* _USE_LOCKMGR */
#endif /* _LOCKMGR_H */