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

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

copperplate: enable error checking for mutexes in debug mode

---

 lib/copperplate/clockobj.c        |    1 +
 lib/copperplate/heapobj-malloc.c  |    1 +
 lib/copperplate/heapobj-pshared.c |    2 ++
 lib/copperplate/notifier.c        |    2 ++
 lib/copperplate/registry.c        |    2 ++
 lib/copperplate/syncobj.c         |    1 +
 lib/copperplate/threadobj.c       |    1 +
 lib/copperplate/timerobj.c        |    3 ++-
 lib/copperplate/traceobj.c        |    1 +
 9 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/lib/copperplate/clockobj.c b/lib/copperplate/clockobj.c
index 1a22ab2..4f5541d 100644
--- a/lib/copperplate/clockobj.c
+++ b/lib/copperplate/clockobj.c
@@ -398,6 +398,7 @@ int clockobj_init(struct clockobj *clkobj,
         * confirmed reading loop.
         */
        __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(&clkobj->lock, &mattr));
diff --git a/lib/copperplate/heapobj-malloc.c b/lib/copperplate/heapobj-malloc.c
index f428da6..57dca08 100644
--- a/lib/copperplate/heapobj-malloc.c
+++ b/lib/copperplate/heapobj-malloc.c
@@ -58,6 +58,7 @@ int __heapobj_init_private(struct heapobj *hobj, const char 
*name,
                return __bt(-ENOMEM);
 
        __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(&ph->lock, &mattr));
diff --git a/lib/copperplate/heapobj-pshared.c 
b/lib/copperplate/heapobj-pshared.c
index d4c6cf4..6cde6ad 100644
--- a/lib/copperplate/heapobj-pshared.c
+++ b/lib/copperplate/heapobj-pshared.c
@@ -175,6 +175,7 @@ static void init_heap(struct shared_heap *heap, const char 
*name,
        __list_init_nocheck(heap, &heap->extents);
 
        __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_SHARED));
        __RT(pthread_mutex_init(&heap->lock, &mattr));
@@ -194,6 +195,7 @@ static void init_main_heap(struct session_heap *m_heap, 
void *mem, size_t size)
        m_heap->cpid = copperplate_get_tid();
 
        __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_SHARED));
        __RT(pthread_mutex_init(&m_heap->sysgroup.lock, &mattr));
diff --git a/lib/copperplate/notifier.c b/lib/copperplate/notifier.c
index c94998b..ab69a75 100644
--- a/lib/copperplate/notifier.c
+++ b/lib/copperplate/notifier.c
@@ -167,6 +167,7 @@ int notifier_init(struct notifier *nf,
        nf->notified = 0;
        nf->owner = owned ? copperplate_get_tid() : 0;
        __STD(pthread_mutexattr_init(&mattr));
+       __RT(pthread_mutexattr_settype(&mattr, mutex_type_attribute));
        __STD(pthread_mutexattr_setprotocol(&mattr, PTHREAD_PRIO_INHERIT));
        __STD(pthread_mutexattr_setpshared(&mattr, PTHREAD_PROCESS_PRIVATE));
        __STD(pthread_mutex_init(&nf->lock, &mattr));
@@ -306,6 +307,7 @@ void notifier_pkg_init(void)
        struct sigaction sa;
 
        __STD(pthread_mutexattr_init(&mattr));
+       __RT(pthread_mutexattr_settype(&mattr, mutex_type_attribute));
        __STD(pthread_mutexattr_setprotocol(&mattr, PTHREAD_PRIO_INHERIT));
        __STD(pthread_mutexattr_setpshared(&mattr, PTHREAD_PROCESS_PRIVATE));
        __STD(pthread_mutex_init(&notifier_lock, &mattr));
diff --git a/lib/copperplate/registry.c b/lib/copperplate/registry.c
index fe8153a..b3ef2ed 100644
--- a/lib/copperplate/registry.c
+++ b/lib/copperplate/registry.c
@@ -165,6 +165,7 @@ void registry_init_file(struct fsobj *fsobj,
        pvholder_init(&fsobj->link);
 
        __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(&fsobj->lock, &mattr));
@@ -704,6 +705,7 @@ int __registry_pkg_init(const char *arg0, char *mountpt)
        int ret;
 
        __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(&p->lock, &mattr));
diff --git a/lib/copperplate/syncobj.c b/lib/copperplate/syncobj.c
index 00b2a61..7834f86 100644
--- a/lib/copperplate/syncobj.c
+++ b/lib/copperplate/syncobj.c
@@ -189,6 +189,7 @@ static inline void syncobj_init_corespec(struct syncobj 
*sobj,
        int ret;
 
        pthread_mutexattr_init(&mattr);
+       __RT(pthread_mutexattr_settype(&mattr, mutex_type_attribute));
        pthread_mutexattr_setprotocol(&mattr, PTHREAD_PRIO_INHERIT);
        ret = pthread_mutexattr_setpshared(&mattr, mutex_scope_attribute);
        assert(ret == 0); (void)ret;
diff --git a/lib/copperplate/threadobj.c b/lib/copperplate/threadobj.c
index 8261841..a2a9dcd 100644
--- a/lib/copperplate/threadobj.c
+++ b/lib/copperplate/threadobj.c
@@ -865,6 +865,7 @@ void threadobj_init(struct threadobj *thobj,
         */
 
        __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(&thobj->lock, &mattr));
diff --git a/lib/copperplate/timerobj.c b/lib/copperplate/timerobj.c
index 0e40577..b420986 100644
--- a/lib/copperplate/timerobj.c
+++ b/lib/copperplate/timerobj.c
@@ -205,6 +205,7 @@ int timerobj_init(struct timerobj *tmobj)
                return __bt(-errno);
 
        __RT(pthread_mutexattr_init(&mattr));
+       __RT(pthread_mutexattr_settype(&mattr, mutex_type_attribute));
        __RT(pthread_mutexattr_setprotocol(&mattr, PTHREAD_PRIO_INHERIT));
        ret = __RT(pthread_mutexattr_setpshared(&mattr, mutex_scope_attribute));
        assert(ret == 0);
@@ -280,8 +281,8 @@ int timerobj_pkg_init(void)
        int ret;
 
        __RT(pthread_mutexattr_init(&mattr));
-       __RT(pthread_mutexattr_setprotocol(&mattr, PTHREAD_PRIO_INHERIT));
        __RT(pthread_mutexattr_settype(&mattr, PTHREAD_MUTEX_RECURSIVE));
+       __RT(pthread_mutexattr_setprotocol(&mattr, PTHREAD_PRIO_INHERIT));
        __RT(pthread_mutexattr_setpshared(&mattr, PTHREAD_PROCESS_PRIVATE));
        ret = __RT(pthread_mutex_init(&svlock, &mattr));
        __RT(pthread_mutexattr_destroy(&mattr));
diff --git a/lib/copperplate/traceobj.c b/lib/copperplate/traceobj.c
index 5195b87..6bec5dc 100644
--- a/lib/copperplate/traceobj.c
+++ b/lib/copperplate/traceobj.c
@@ -36,6 +36,7 @@ void traceobj_init(struct traceobj *trobj, const char *label, 
int nr_marks)
        pthread_condattr_t cattr;
 
        __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(&trobj->lock, &mattr));


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

Reply via email to