[Xenomai-core] [PATCH 01/12] Generic thread registration

2008-10-16 Thread Jan Kiszka
Lay groundwork for registering every thread at least anonymously with
the Xenomai registry when required (e.g. handle-based fast xnsynch
support). Wrap the operations appropriately, also saving a few #ifdefs.

Signed-off-by: Jan Kiszka [EMAIL PROTECTED]
---
 include/nucleus/registry.h   |1 
 include/nucleus/thread.h |   25 +
 ksrc/nucleus/thread.c|2 +
 ksrc/skins/native/syscall.c  |   61 ++-
 ksrc/skins/native/task.c |   13 -
 ksrc/skins/psos+/syscall.c   |   19 -
 ksrc/skins/psos+/task.c  |   20 +++---
 ksrc/skins/vxworks/syscall.c |   31 -
 ksrc/skins/vxworks/taskLib.c |   10 ---
 9 files changed, 102 insertions(+), 80 deletions(-)

Index: b/ksrc/skins/native/syscall.c
===
--- a/ksrc/skins/native/syscall.c
+++ b/ksrc/skins/native/syscall.c
@@ -52,7 +52,8 @@ int __native_muxid;
 static int __rt_bind_helper(struct task_struct *p,
struct pt_regs *regs,
xnhandle_t *handlep,
-   unsigned magic, void **objaddrp)
+   unsigned magic, void **objaddrp,
+   unsigned long objoffs)
 {
char name[XNOBJECT_NAME_LEN];
RTIME timeout;
@@ -82,7 +83,7 @@ static int __rt_bind_helper(struct task_
 
/* Also validate the type of the bound object. */
 
-   if (xeno_test_magic(objaddr, magic)) {
+   if (xeno_test_magic(objaddr + objoffs, magic)) {
if (objaddrp)
*objaddrp = objaddr;
} else
@@ -93,6 +94,11 @@ static int __rt_bind_helper(struct task_
return err;
 }
 
+static RT_TASK *__rt_task_lookup(xnhandle_t threadh)
+{
+   return thread2rtask(xnthread_lookup(threadh));
+}
+
 static RT_TASK *__rt_task_current(struct task_struct *p)
 {
xnthread_t *thread = xnshadow_thread(p);
@@ -223,7 +229,9 @@ static int __rt_task_bind(struct pt_regs
RT_TASK_PLACEHOLDER ph;
int err;
 
-   err = __rt_bind_helper(p, regs, ph.opaque, XENO_TASK_MAGIC, NULL);
+   err =
+   __rt_bind_helper(p, regs, ph.opaque, XENO_TASK_MAGIC, NULL,
+-offsetof(RT_TASK, thread_base));
 
if (err)
return err;
@@ -253,7 +261,7 @@ static int __rt_task_start(struct pt_reg
 sizeof(ph)))
return -EFAULT;
 
-   task = (RT_TASK *)xnregistry_fetch(ph.opaque);
+   task = __rt_task_lookup(ph.opaque);
 
if (!task)
return -ESRCH;
@@ -279,7 +287,7 @@ static int __rt_task_suspend(struct pt_r
 sizeof(ph)))
return -EFAULT;
 
-   task = (RT_TASK *)xnregistry_fetch(ph.opaque);
+   task = __rt_task_lookup(ph.opaque);
} else
task = __rt_task_current(p);
 
@@ -302,7 +310,7 @@ static int __rt_task_resume(struct pt_re
 sizeof(ph)))
return -EFAULT;
 
-   task = (RT_TASK *)xnregistry_fetch(ph.opaque);
+   task = __rt_task_lookup(ph.opaque);
 
if (!task)
return -ESRCH;
@@ -326,7 +334,7 @@ static int __rt_task_delete(struct pt_re
 sizeof(ph)))
return -EFAULT;
 
-   task = (RT_TASK *)xnregistry_fetch(ph.opaque);
+   task = __rt_task_lookup(ph.opaque);
} else
task = __rt_task_current(p);
 
@@ -364,7 +372,7 @@ static int __rt_task_set_periodic(struct
 sizeof(ph)))
return -EFAULT;
 
-   task = (RT_TASK *)xnregistry_fetch(ph.opaque);
+   task = __rt_task_lookup(ph.opaque);
} else
task = __rt_task_current(p);
 
@@ -418,7 +426,7 @@ static int __rt_task_set_priority(struct
 sizeof(ph)))
return -EFAULT;
 
-   task = (RT_TASK *)xnregistry_fetch(ph.opaque);
+   task = __rt_task_lookup(ph.opaque);
} else
task = __rt_task_current(p);
 
@@ -473,7 +481,7 @@ static int __rt_task_unblock(struct pt_r
 sizeof(ph)))
return -EFAULT;
 
-   task = (RT_TASK *)xnregistry_fetch(ph.opaque);
+   task = __rt_task_lookup(ph.opaque);
 
if (!task)
return -ESRCH;
@@ -500,7 +508,7 @@ static int __rt_task_inquire(struct pt_r
 sizeof(ph)))
return -EFAULT;
 
-   task = (RT_TASK *)xnregistry_fetch(ph.opaque);
+   task = __rt_task_lookup(ph.opaque);
} else
task = __rt_task_current(p);
 
@@ -541,7 +549,7 @@ static int 

Re: [Xenomai-core] [PATCH 01/12] Generic thread registration

2008-10-16 Thread Jan Kiszka
Gilles Chanteperdrix wrote:
 Jan Kiszka wrote:
 
 Why the funky last parameter added to __rt_bind_helper ?

As __rt_bind_helper can now be called with an xnthread object address,
thus we take its offset inside RT_TASK into account. It is not a nice
interface, I know, but I didn't find a better one.

Jan



signature.asc
Description: OpenPGP digital signature
___
Xenomai-core mailing list
Xenomai-core@gna.org
https://mail.gna.org/listinfo/xenomai-core