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

Author: Philippe Gerum <r...@xenomai.org>
Date:   Tue Oct  1 12:04:33 2013 +0200

cobalt/posix/thread: drop obsolete, unused attributes

---

 kernel/cobalt/posix/internal.h |    1 -
 kernel/cobalt/posix/thread.c   |   33 ++++++---------------------------
 kernel/cobalt/posix/thread.h   |   14 ++++----------
 3 files changed, 10 insertions(+), 38 deletions(-)

diff --git a/kernel/cobalt/posix/internal.h b/kernel/cobalt/posix/internal.h
index fbf6505..bf73ea3 100644
--- a/kernel/cobalt/posix/internal.h
+++ b/kernel/cobalt/posix/internal.h
@@ -31,7 +31,6 @@
 #define COBALT_MAGIC(n) (0x8686##n##n)
 #define COBALT_ANY_MAGIC         COBALT_MAGIC(00)
 #define COBALT_THREAD_MAGIC      COBALT_MAGIC(01)
-#define COBALT_THREAD_ATTR_MAGIC COBALT_MAGIC(02)
 #define COBALT_MUTEX_ATTR_MAGIC  (COBALT_MAGIC(04) & ((1 << 24) - 1))
 #define COBALT_COND_ATTR_MAGIC   (COBALT_MAGIC(06) & ((1 << 24) - 1))
 #define COBALT_KEY_MAGIC         COBALT_MAGIC(08)
diff --git a/kernel/cobalt/posix/thread.c b/kernel/cobalt/posix/thread.c
index 6f124a2..a8b3db8 100644
--- a/kernel/cobalt/posix/thread.c
+++ b/kernel/cobalt/posix/thread.c
@@ -43,10 +43,7 @@
 
 xnticks_t cobalt_time_slice;
 
-static const pthread_attr_t default_thread_attr = {
-       .magic = COBALT_THREAD_ATTR_MAGIC,
-       .detachstate = PTHREAD_CREATE_JOINABLE,
-       .inheritsched = PTHREAD_EXPLICIT_SCHED,
+static const struct cobalt_threadattr default_thread_attr = {
        .policy = SCHED_NORMAL,
        .schedparam_ex = {
                .sched_priority = 0
@@ -414,7 +411,8 @@ unlock_and_exit:
  * using the SA_SIGINFO flag, and pass all the arguments you received
  * to cobalt_sigshadow_handler.
  */
-static inline int pthread_create(struct cobalt_thread **thread_p, const 
pthread_attr_t *attr)
+static inline int pthread_create(struct cobalt_thread **thread_p,
+                                const struct cobalt_threadattr *attr)
 {
        struct cobalt_thread *thread, *curr;
        struct xnsched_class *sched_class;
@@ -423,29 +421,12 @@ static inline int pthread_create(struct cobalt_thread 
**thread_p, const pthread_
        int prio, ret, pol, n;
        spl_t s;
 
-       if (attr && attr->magic != COBALT_THREAD_ATTR_MAGIC)
-               return -EINVAL;
-
        thread = xnmalloc(sizeof(*thread));
        if (thread == NULL)
                return -EAGAIN;
 
        curr = cobalt_current_thread();
-       thread->attr = attr ? *attr : default_thread_attr;
-       if (thread->attr.inheritsched == PTHREAD_INHERIT_SCHED) {
-               /*
-                * curr may be NULL if pthread_create is not called by
-                * a cobalt thread, in which case trying to inherit
-                * scheduling parameters is treated as an error.
-                */
-               if (curr == NULL) {
-                       xnfree(thread);
-                       return -EINVAL;
-               }
-
-               pthread_getschedparam_ex(curr, &thread->attr.policy,
-                                        &thread->attr.schedparam_ex);
-       }
+       thread->attr = *attr;
 
        /*
         * NOTE: The user-defined policy may be different than ours,
@@ -897,9 +878,9 @@ int cobalt_thread_create(unsigned long pth, int policy,
 {
        struct cobalt_thread *thread = NULL;
        struct task_struct *p = current;
+       struct cobalt_threadattr attr;
        struct cobalt_local_hkey hkey;
        struct sched_param_ex param;
-       pthread_attr_t attr;
        pid_t pid;
        int ret;
 
@@ -920,7 +901,6 @@ int cobalt_thread_create(unsigned long pth, int policy,
         */
        attr = default_thread_attr;
        attr.policy = policy;
-       attr.detachstate = PTHREAD_CREATE_DETACHED;
        attr.schedparam_ex = param;
        attr.name = p->comm;
 
@@ -954,12 +934,11 @@ cobalt_thread_shadow(struct task_struct *p,
                     unsigned long __user *u_window_offset)
 {
        struct cobalt_thread *thread = NULL;
-       pthread_attr_t attr;
+       struct cobalt_threadattr attr;
        pid_t pid;
        int ret;
 
        attr = default_thread_attr;
-       attr.detachstate = PTHREAD_CREATE_DETACHED;
        attr.name = p->comm;
 
        ret = pthread_create(&thread, &attr);
diff --git a/kernel/cobalt/posix/thread.h b/kernel/cobalt/posix/thread.h
index 7a30647..978c1c3 100644
--- a/kernel/cobalt/posix/thread.h
+++ b/kernel/cobalt/posix/thread.h
@@ -44,18 +44,12 @@
 struct cobalt_thread;
 struct cobalt_threadstat;
 
-typedef struct cobalt_threadattr {
-       unsigned magic;
-       int detachstate;
-       int inheritsched;
+struct cobalt_threadattr {
        int policy;
-
-       /* Non portable */
        struct sched_param_ex schedparam_ex;
-       char *name;
+       const char *name;
        cpumask_t affinity;
-
-} pthread_attr_t;
+};
 
 /*
  * pthread_mutexattr_t and pthread_condattr_t fit on 32 bits, for
@@ -108,7 +102,7 @@ struct cobalt_thread {
        struct list_head *container;
 
         /** Creation attributes. */
-       pthread_attr_t attr;
+       struct cobalt_threadattr attr;
 
        /** Signal management. */
        sigset_t sigpending;


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

Reply via email to