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

Author: Jan Kiszka <jan.kis...@siemens.com>
Date:   Tue Feb  4 16:12:07 2014 +0100

alchemy: Replace static variable no_alchemy_task with macro

The current definition of a static const variable representing an
invalid alchemy task is both C++-incompatible and may leave variables in
the .bss of modules behind that are including task.h, even if they don't
use the symbol. So replace it with a macro that builds the required
struct on-the-fly.

Signed-off-by: Jan Kiszka <jan.kis...@siemens.com>

---

 include/alchemy/task.h |    5 +----
 lib/alchemy/mutex.c    |    4 ++--
 lib/alchemy/task.c     |    2 +-
 3 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/include/alchemy/task.h b/include/alchemy/task.h
index 2d9e13e..b8f2ec0 100644
--- a/include/alchemy/task.h
+++ b/include/alchemy/task.h
@@ -80,10 +80,7 @@ struct RT_TASK_INFO {
 
 typedef struct RT_TASK_INFO RT_TASK_INFO;
 
-static const RT_TASK no_alchemy_task = {
-       .handle = 0,
-       .thread = 0
-};
+#define NO_ALCHEMY_TASK        ((RT_TASK){ 0, 0 })
 
 #ifdef __cplusplus
 extern "C" {
diff --git a/lib/alchemy/mutex.c b/lib/alchemy/mutex.c
index e10d360..4c4d980 100644
--- a/lib/alchemy/mutex.c
+++ b/lib/alchemy/mutex.c
@@ -111,7 +111,7 @@ int rt_mutex_create(RT_MUTEX *mutex, const char *name)
        }
 
        generate_name(mcb->name, name, &mutex_namegen);
-       mcb->owner = no_alchemy_task;
+       mcb->owner = NO_ALCHEMY_TASK;
        __RT(pthread_mutexattr_init(&mattr));
        __RT(pthread_mutexattr_setprotocol(&mattr, PTHREAD_PRIO_INHERIT));
        __RT(pthread_mutexattr_setpshared(&mattr, mutex_scope_attribute));
@@ -409,7 +409,7 @@ int rt_mutex_inquire(RT_MUTEX *mutex, RT_MUTEX_INFO *info)
                ret = 0;
        } else {
                __RT(pthread_mutex_unlock(&mcb->lock));
-               info->owner = no_alchemy_task;
+               info->owner = NO_ALCHEMY_TASK;
        }
 
        strcpy(info->name, mcb->name);
diff --git a/lib/alchemy/task.c b/lib/alchemy/task.c
index 38aaf18..59a076a 100644
--- a/lib/alchemy/task.c
+++ b/lib/alchemy/task.c
@@ -1981,6 +1981,6 @@ int rt_task_bind(RT_TASK *task,
  */
 int rt_task_unbind(RT_TASK *task)
 {
-       *task = no_alchemy_task;
+       *task = NO_ALCHEMY_TASK;
        return 0;
 }


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

Reply via email to