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

Author: Philippe Gerum <r...@xenomai.org>
Date:   Fri May 10 17:37:44 2013 +0200

cobalt/thread: turn PTHREAD_CONFORMING into no-bit value

---

 include/cobalt/pthread.h    |    2 +-
 kernel/cobalt/nucleus/pod.c |    3 +++
 kernel/cobalt/thread.c      |   15 +++++++++------
 3 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/include/cobalt/pthread.h b/include/cobalt/pthread.h
index 802f778..a80d60d 100644
--- a/include/cobalt/pthread.h
+++ b/include/cobalt/pthread.h
@@ -140,7 +140,7 @@ struct timespec;
 
 #define PTHREAD_WARNSW     XNTRAPSW
 #define PTHREAD_LOCK_SCHED XNLOCK
-#define PTHREAD_CONFORMING XNTHREAD_STATE_SPARE1
+#define PTHREAD_CONFORMING 0
 
 struct cobalt_mutexattr {
        unsigned magic: 24;
diff --git a/kernel/cobalt/nucleus/pod.c b/kernel/cobalt/nucleus/pod.c
index 43481cf..dc1de97 100644
--- a/kernel/cobalt/nucleus/pod.c
+++ b/kernel/cobalt/nucleus/pod.c
@@ -760,6 +760,9 @@ EXPORT_SYMBOL_GPL(xnpod_stop_thread);
  *
  * Rescheduling: never, therefore, the caller should reschedule if
  * XNLOCK has been passed into @a clrmask.
+ *
+ * @note Setting @a clrmask and @a setmask to zero leads to a nop,
+ * only returning the previous mode if @a mode_r is a valid address.
  */
 
 xnflags_t xnpod_set_thread_mode(xnthread_t *thread,
diff --git a/kernel/cobalt/thread.c b/kernel/cobalt/thread.c
index f5360d5..a7a62b2 100644
--- a/kernel/cobalt/thread.c
+++ b/kernel/cobalt/thread.c
@@ -556,7 +556,7 @@ static inline int pthread_make_periodic_np(pthread_t thread,
  * - PTHREAD_CONFORMING can be passed in @a setmask to switch the
  * current user-space task to its preferred runtime mode. The only
  * meaningful use of this switch is to force a real-time shadow back
- * to primary mode. Any other use either cause to a nop, or an error.
+ * to primary mode. Any other use leads to a nop.
  *
  * PTHREAD_LOCK_SCHED is valid for any Xenomai thread, the other bits are only
  * valid for Xenomai user-space threads.
@@ -576,20 +576,23 @@ static inline int pthread_make_periodic_np(pthread_t 
thread,
  * @return an error number if:
  * - EINVAL, some bit in @a clrmask or @a setmask is invalid.
  *
+ * @note Setting @a clrmask and @a setmask to zero leads to a nop,
+ * only returning the previous mode if @a mode_r is a valid address.
  */
 static inline int pthread_set_mode_np(int clrmask, int setmask, int *mode_r)
 {
-       /* XNTHREAD_STATE_SPARE1 is used as the CONFORMING mode bit. */
-       const xnflags_t valid_flags = XNLOCK|XNTHREAD_STATE_SPARE1|XNTRAPSW;
+       const xnflags_t valid_flags = XNLOCK|XNTRAPSW;
        xnthread_t *cur = xnpod_current_thread();
        xnflags_t old;
 
+       /*
+        * The conforming mode bit is actually zero, since jumping to
+        * this code entailed switching to the proper mode already.
+        */
        if ((clrmask & ~valid_flags) != 0 || (setmask & ~valid_flags) != 0)
                return -EINVAL;
 
-       old = xnpod_set_thread_mode(cur,
-                                   clrmask & ~XNTHREAD_STATE_SPARE1,
-                                   setmask & ~XNTHREAD_STATE_SPARE1);
+       old = xnpod_set_thread_mode(cur, clrmask, setmask);
        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