Module: xenomai-forge
Branch: next
Commit: 6909e05f6d1c59a4e8170965d4e7454dd14de0cf
URL:    
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=6909e05f6d1c59a4e8170965d4e7454dd14de0cf

Author: Philippe Gerum <r...@xenomai.org>
Date:   Wed Apr 24 18:16:46 2013 +0200

copperplate/threadobj: threadobj_set_mode() implicitly applies to current

---

 include/copperplate/threadobj.h |    3 +--
 lib/alchemy/task.c              |    2 +-
 lib/copperplate/threadobj.c     |   22 +++++++++++-----------
 3 files changed, 13 insertions(+), 14 deletions(-)

diff --git a/include/copperplate/threadobj.h b/include/copperplate/threadobj.h
index d5fc7d8..9f17035 100644
--- a/include/copperplate/threadobj.h
+++ b/include/copperplate/threadobj.h
@@ -270,8 +270,7 @@ int threadobj_unlock_sched(struct threadobj *thobj);
 
 int threadobj_set_priority(struct threadobj *thobj, int prio);
 
-int threadobj_set_mode(struct threadobj *thobj,
-                      int clrmask, int setmask, int *mode_r);
+int threadobj_set_mode(int clrmask, int setmask, int *mode_r);
 
 int threadobj_set_rr(struct threadobj *thobj, struct timespec *quantum);
 
diff --git a/lib/alchemy/task.c b/lib/alchemy/task.c
index 7e4d058..b378c31 100644
--- a/lib/alchemy/task.c
+++ b/lib/alchemy/task.c
@@ -957,7 +957,7 @@ int rt_task_set_mode(int clrmask, int setmask, int *mode_r)
        if (tcb == NULL)
                goto out;
 
-       ret = threadobj_set_mode(&tcb->thobj, clrmask, setmask, mode_r);
+       ret = threadobj_set_mode(clrmask, setmask, mode_r);
        put_alchemy_task(tcb);
 out:
        COPPERPLATE_UNPROTECT(svc);
diff --git a/lib/copperplate/threadobj.c b/lib/copperplate/threadobj.c
index c9c720f..8b622fe 100644
--- a/lib/copperplate/threadobj.c
+++ b/lib/copperplate/threadobj.c
@@ -298,12 +298,12 @@ int threadobj_set_priority(struct threadobj *thobj, int 
prio) /* thobj->lock hel
        return pthread_setschedparam_ex(tid, policy, &xparam);
 }
 
-int threadobj_set_mode(struct threadobj *thobj,
-                      int clrmask, int setmask, int *mode_r) /* thobj->lock 
held */
+int threadobj_set_mode(int clrmask, int setmask, int *mode_r) /* current->lock 
held */
 {
+       struct threadobj *current = threadobj_current();
        int ret, __clrmask = 0, __setmask = 0;
 
-       __threadobj_check_locked(thobj);
+       __threadobj_check_locked(current);
 
        if (setmask & __THREAD_M_LOCK)
                __setmask |= PTHREAD_LOCK_SCHED;
@@ -320,9 +320,9 @@ int threadobj_set_mode(struct threadobj *thobj,
        else if (clrmask & __THREAD_M_CONFORMING)
                __clrmask |= PTHREAD_CONFORMING;
 
-       threadobj_unlock(thobj);
+       threadobj_unlock(current);
        ret = pthread_set_mode_np(__clrmask, __setmask, mode_r);
-       threadobj_lock(thobj);
+       threadobj_lock(current);
 
        return ret;
 }
@@ -650,20 +650,20 @@ int threadobj_set_priority(struct threadobj *thobj, int 
prio) /* thobj->lock hel
        return pthread_setschedparam(tid, policy, &param);
 }
 
-int threadobj_set_mode(struct threadobj *thobj,
-                      int clrmask, int setmask, int *mode_r) /* thobj->lock 
held */
+int threadobj_set_mode(int clrmask, int setmask, int *mode_r) /* current->lock 
held */
 {
+       struct threadobj *current = threadobj_current();
        int ret = 0, old = 0;
 
-       __threadobj_check_locked(thobj);
+       __threadobj_check_locked(current);
 
-       if (thobj->status & THREADOBJ_SCHEDLOCK)
+       if (current->status & THREADOBJ_SCHEDLOCK)
                old |= __THREAD_M_LOCK;
 
        if (setmask & __THREAD_M_LOCK)
-               ret = __bt(threadobj_lock_sched_once(thobj));
+               ret = __bt(threadobj_lock_sched_once(current));
        else if (clrmask & __THREAD_M_LOCK)
-               threadobj_unlock_sched(thobj);
+               threadobj_unlock_sched(current);
 
        if (*mode_r)
                *mode_r = old;


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

Reply via email to