Module: xenomai-jki
Branch: for-forge
Commit: bffcc58ed0114985a4d8d8a4cff2adff1b13292d
URL:    
http://git.xenomai.org/?p=xenomai-jki.git;a=commit;h=bffcc58ed0114985a4d8d8a4cff2adff1b13292d

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 also ugly as we do not
use them in every module that includes task.h. 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 fbb8cb7..fb86034 100644
--- a/lib/alchemy/task.c
+++ b/lib/alchemy/task.c
@@ -1975,6 +1975,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