Module: xenomai-forge
Branch: rtdm-api-waitqueues
Commit: ecc2483637d83eceb992ec192a2795855e85daee
URL:    
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=ecc2483637d83eceb992ec192a2795855e85daee

Author: Philippe Gerum <r...@xenomai.org>
Date:   Wed Apr 16 16:55:50 2014 +0200

boilerplate: enable error checking for mutexes in debug mode

---

 include/boilerplate/lock.h |    6 ++++++
 lib/boilerplate/hash.c     |    2 ++
 2 files changed, 8 insertions(+)

diff --git a/include/boilerplate/lock.h b/include/boilerplate/lock.h
index 4819b34..879f736 100644
--- a/include/boilerplate/lock.h
+++ b/include/boilerplate/lock.h
@@ -206,4 +206,10 @@ int __check_cancel_type(const char *locktype);
 #define read_unlock_safe(__lock, __state)      \
        __do_unlock_safe(__lock, __state)
 
+#ifdef CONFIG_XENO_DEBUG
+#define mutex_type_attribute PTHREAD_MUTEX_ERRORCHECK
+#else
+#define mutex_type_attribute PTHREAD_MUTEX_NORMAL
+#endif
+
 #endif /* _BOILERPLATE_LOCK_H */
diff --git a/lib/boilerplate/hash.c b/lib/boilerplate/hash.c
index 32a3d65..04fdeee 100644
--- a/lib/boilerplate/hash.c
+++ b/lib/boilerplate/hash.c
@@ -101,6 +101,7 @@ void __hash_init(void *heap, struct hash_table *t,
 
        t->compare = compare;
        __RT(pthread_mutexattr_init(&mattr));
+       __RT(pthread_mutexattr_settype(&mattr, mutex_type_attribute));
        __RT(pthread_mutexattr_setprotocol(&mattr, PTHREAD_PRIO_INHERIT));
        __RT(pthread_mutexattr_setpshared(&mattr, mutex_scope_attribute));
        __RT(pthread_mutex_init(&t->lock, &mattr));
@@ -322,6 +323,7 @@ void pvhash_init(struct pvhash_table *t,
 
        t->compare = compare;
        __RT(pthread_mutexattr_init(&mattr));
+       __RT(pthread_mutexattr_settype(&mattr, mutex_type_attribute));
        __RT(pthread_mutexattr_setprotocol(&mattr, PTHREAD_PRIO_INHERIT));
        __RT(pthread_mutexattr_setpshared(&mattr, PTHREAD_PROCESS_PRIVATE));
        __RT(pthread_mutex_init(&t->lock, &mattr));


_______________________________________________
Xenomai-git mailing list
Xenomai-git@xenomai.org
http://www.xenomai.org/mailman/listinfo/xenomai-git

Reply via email to