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

Author: Philippe Gerum <r...@xenomai.org>
Date:   Sun Jun  9 18:44:22 2013 +0200

nucleus: drop xnthread_operations

The only handler returned the interface binding magic, but we can now
do simpler and faster, directly checking the ->personality property
each thread exhibits.

---

 include/cobalt/nucleus/thread.h     |   14 +-------------
 kernel/cobalt/nucleus/pod.c         |    1 +
 kernel/cobalt/nucleus/sched.c       |    1 -
 kernel/cobalt/nucleus/thread.c      |    1 -
 kernel/cobalt/rtdm/drvlib.c         |    1 -
 kernel/cobalt/thread.c              |   10 ----------
 kernel/cobalt/thread.h              |    8 ++++----
 kernel/drivers/testing/switchtest.c |    1 -
 8 files changed, 6 insertions(+), 31 deletions(-)

diff --git a/include/cobalt/nucleus/thread.h b/include/cobalt/nucleus/thread.h
index 293377e..c7365fc 100644
--- a/include/cobalt/nucleus/thread.h
+++ b/include/cobalt/nucleus/thread.h
@@ -165,12 +165,7 @@ union xnsched_policy_param;
 struct xnbufd;
 struct xnpersonality;
 
-struct xnthread_operations {
-       unsigned (*get_magic)(void);
-};
-
 struct xnthread_init_attr {
-       struct xnthread_operations *ops;
        struct xnpersonality *personality;
        xnflags_t flags;
        const char *name;
@@ -279,8 +274,6 @@ typedef struct xnthread {
                const char *waitkey;    /* Pended key */
        } registry;
 
-       struct xnthread_operations *ops; /* Thread class operations. */
-
        char name[XNOBJECT_NAME_LEN]; /* Symbolic name of thread */
 
        void (*entry)(void *cookie); /* Thread entry routine */
@@ -292,7 +285,7 @@ typedef struct xnthread {
 
        void *privdata;                         /* Private data for extension */
 
-       struct xnpersonality *personality;
+       struct xnpersonality *personality; /* Originating interface/personality 
*/
 
 #ifdef CONFIG_XENO_OPT_DEBUG
        const char *exe_path;   /* Executable path */
@@ -341,11 +334,6 @@ typedef struct xnthread {
 #define xnthread_private(thread)           ((thread)->privdata)
 #define xnthread_personality(thread)       ((thread)->personality)
 
-static inline unsigned xnthread_get_magic(struct xnthread *t)
-{
-       return t->ops ? t->ops->get_magic() : 0;
-}
-
 static inline
 struct xnthread_wait_context *xnthread_get_wait_context(struct xnthread 
*thread)
 {
diff --git a/kernel/cobalt/nucleus/pod.c b/kernel/cobalt/nucleus/pod.c
index 39fade8..1a252bd 100644
--- a/kernel/cobalt/nucleus/pod.c
+++ b/kernel/cobalt/nucleus/pod.c
@@ -2720,6 +2720,7 @@ void xnpod_cleanup_proc(void)
 
 struct xnpersonality generic_personality = {
        .name = "xenomai",
+       /* .magic = 0 */
 };
 EXPORT_SYMBOL_GPL(generic_personality);
 
diff --git a/kernel/cobalt/nucleus/sched.c b/kernel/cobalt/nucleus/sched.c
index 9319080..d04ac5a 100644
--- a/kernel/cobalt/nucleus/sched.c
+++ b/kernel/cobalt/nucleus/sched.c
@@ -155,7 +155,6 @@ void xnsched_init(struct xnsched *sched, int cpu)
 
        attr.flags = XNROOT | XNSTARTED | XNFPU;
        attr.name = root_name;
-       attr.ops = NULL;
        attr.personality = &generic_personality;
        param.idle.prio = XNSCHED_IDLE_PRIO;
 
diff --git a/kernel/cobalt/nucleus/thread.c b/kernel/cobalt/nucleus/thread.c
index 95323dc..ba9a784 100644
--- a/kernel/cobalt/nucleus/thread.c
+++ b/kernel/cobalt/nucleus/thread.c
@@ -166,7 +166,6 @@ int xnthread_init(struct xnthread *thread,
        thread->asr = XNTHREAD_INVALID_ASR;
        thread->asrlevel = 0;
 
-       thread->ops = attr->ops;
        thread->rrperiod = XN_INFINITE;
        thread->wchan = NULL;
        thread->wwake = NULL;
diff --git a/kernel/cobalt/rtdm/drvlib.c b/kernel/cobalt/rtdm/drvlib.c
index 2c09283..2b7f5d3 100644
--- a/kernel/cobalt/rtdm/drvlib.c
+++ b/kernel/cobalt/rtdm/drvlib.c
@@ -143,7 +143,6 @@ int rtdm_task_init(rtdm_task_t *task, const char *name,
 
        iattr.name = name;
        iattr.flags = 0;
-       iattr.ops = NULL;
        iattr.personality = &rtdm_personality;
        param.rt.prio = priority;
 
diff --git a/kernel/cobalt/thread.c b/kernel/cobalt/thread.c
index 5a4ef74..5b42dc1 100644
--- a/kernel/cobalt/thread.c
+++ b/kernel/cobalt/thread.c
@@ -49,15 +49,6 @@ static const pthread_attr_t default_thread_attr = {
        .affinity = XNPOD_ALL_CPUS,
 };
 
-static unsigned cobalt_get_magic(void)
-{
-       return COBALT_BINDING_MAGIC;
-}
-
-static struct xnthread_operations cobalt_thread_ops = {
-       .get_magic = &cobalt_get_magic,
-};
-
 #define PTHREAD_HSLOTS (1 << 8)        /* Must be a power of 2 */
 
 struct cobalt_hash {
@@ -401,7 +392,6 @@ static inline int pthread_create(pthread_t *tid, const 
pthread_attr_t *attr)
 
        iattr.name = name;
        iattr.flags = flags;
-       iattr.ops = &cobalt_thread_ops;
        iattr.personality = &cobalt_personality;
 
        /*
diff --git a/kernel/cobalt/thread.h b/kernel/cobalt/thread.h
index 2bae1c7..295dc5f 100644
--- a/kernel/cobalt/thread.h
+++ b/kernel/cobalt/thread.h
@@ -42,10 +42,10 @@ struct cobalt_thread {
 
 #define thread2pthread(taddr) \
        ({                                                              \
-               xnthread_t *_taddr = (taddr);                           \
-               (_taddr                                                 \
-                ? ((xnthread_get_magic(_taddr) == COBALT_BINDING_MAGIC)        
\
-                   ? (container_of(_taddr, struct cobalt_thread, threadbase)) \
+               xnthread_t *__t = (taddr);                              \
+               (__t                                                    \
+                ? ((__t->personality == &cobalt_personality)           \
+                   ? (container_of(__t, struct cobalt_thread, threadbase)) \
                    : NULL)                                             \
                 : NULL);                                               \
        })
diff --git a/kernel/drivers/testing/switchtest.c 
b/kernel/drivers/testing/switchtest.c
index 616d47f..8195b9a 100644
--- a/kernel/drivers/testing/switchtest.c
+++ b/kernel/drivers/testing/switchtest.c
@@ -470,7 +470,6 @@ static int rtswitch_create_ktask(rtswitch_context_t *ctx,
 
        iattr.name = name;
        iattr.flags = init_flags;
-       iattr.ops = NULL;
        iattr.personality = &generic_personality;
        param.rt.prio = 1;
 


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

Reply via email to