libnative: Avoid double-evaluation of rt_task_self()
PATCH 1/1 libnative: Avoid double-evaluation of rt_task_self()
[ can be pulled from git.xenomai.org/xenomai-jki.git queues/assorted ]
Keep the result of rt_task_self() in a local variable to avoid the second invocation.
---
src/skins/native/task.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
src/skins/native/task.c +2 -1
@@ -247,10 +247,11 @@ int rt_task_resume(RT_TASK *task)int rt_task_delete (RT_TASK *task) { +RT_TASK *self;int err;if (task ==NULL || - (rt_task_self () && task->opaque ==rt_task_self ()->opaque)) { + ((self =rt_task_self ()) && self->opaque == task->opaque)) {/* Silently migrate to avoid raising SIGXCPU. */ XENOMAI_SYSCALL1 (__xn_sys_migrate,XENOMAI_LINUX_DOMAIN );pthread_exit (NULL );
Quoted 4 lines · Jan Kiszka
[ can be pulled from git.xenomai.org/xenomai-jki.git queues/assorted ]
Keep the result of
rt_task_self()in a local variable to avoid the second invocation.
Maybe we could create a pure/const variant of rt_task_self() for use in task.c only which would avoid the double evaluatino ?
Signature · 1 line
Gilles.
Quoted 9 lines · Gilles Chanteperdrix
Quoted 4 lines · Jan Kiszka
[ can be pulled from git.xenomai.org/xenomai-jki.git queues/assorted ]
Keep the result of
rt_task_self()in a local variable to avoid the second invocation.Maybe we could create a pure/const variant of
rt_task_self()for use intask.conly which would avoid the double evaluatino ?
Can't do const because of pthread_getspecific(), but pure attribute is t hand, yes.
Signature · 1 line
Philippe.
Quoted 4 lines · Philippe Gerum
Quoted 3 lines · Gilles Chanteperdrix
Quoted 2 lines · Jan Kiszka
[ can be pulled from git.xenomai.org/xenomai-jki.git queues/assorted ]
Quoted 9 lines
Quoted 5 lines
Quoted 2 lines
Keep the result of
rt_task_self()in a local variable to avoid the second invocation.Maybe we could create a pure/const variant of
rt_task_self()for use intask.conly which would avoid the double evaluatino ?Can't do const because of
pthread_getspecific(), but pure attribute is t hand, yes.
At least my gcc 4.3 ignores
RT_TASK *rt_task_self(void) __attribute__ ((pure));
and keeps on inserting two calls in rt_task_delete.
Jan
Quoted 11 lines · Jan Kiszka
Quoted 10 lines · Philippe Gerum
Quoted 8 lines · Gilles Chanteperdrix
Quoted 4 lines · Jan Kiszka
[ can be pulled from git.xenomai.org/xenomai-jki.git queues/assorted ]
Keep the result of
rt_task_self()in a local variable to avoid the second invocation.Maybe we could create a pure/const variant of
rt_task_self()for use intask.conly which would avoid the double evaluatino ?
Quoted 8 lines
Quoted 3 lines
Can't do const because of
pthread_getspecific(), but pure attribute is t hand, yes.At least my gcc 4.3 ignores
RT_TASK*rt_task_self(void)__attribute__((pure));
We can't do that on rt_task_self() directly, because of rt_task_shadow().
Quoted 2 lines
and keeps on inserting two calls in
rt_task_delete.
What if a pure static inline helper is used internally from task.c?
Quoted 2 lines
Jan
Signature · 1 line
Philippe.
Quoted 19 lines · Philippe Gerum
Quoted 10 lines · Jan Kiszka
Quoted 9 lines · Philippe Gerum
Quoted 8 lines · Gilles Chanteperdrix
Quoted 4 lines · Jan Kiszka
[ can be pulled from git.xenomai.org/xenomai-jki.git queues/assorted ]
Keep the result of
rt_task_self()in a local variable to avoid the second invocation.Maybe we could create a pure/const variant of
rt_task_self()for use intask.conly which would avoid the double evaluatino ?Quoted 7 lines
Quoted 3 lines
Can't do const because of
pthread_getspecific(), but pure attribute is t hand, yes.At least my gcc 4.3 ignores
RT_TASK*rt_task_self(void)__attribute__((pure));
Quoted 8 lines
We can't do that on
rt_task_self()directly, because ofrt_task_shadow().Quoted 2 lines
and keeps on inserting two calls in
rt_task_delete.What if a pure static inline helper is used internally from
task.c?
Makes no difference (and defining a new helper for this purpose would be overkill anyway).
So please pull my original version fromgit://git.xenomai.org/xenomai-jki.git for-upstream
BTW, you'll find another trivial fix in that queue:
src/testsuite/switchtest/switchtest.c +1 -1
@@ -1094,7 +1094,7 @@ int check_fpu(void)exit (EXIT_FAILURE ); } -return (int ) status; +return (long ) status; }int main (int argc,const char *argv[])
Jan