Module: xenomai-forge Branch: master Commit: b8ef6b521838fdfb93d88662532d07298ec3596e URL: http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=b8ef6b521838fdfb93d88662532d07298ec3596e
Author: Philippe Gerum <r...@xenomai.org> Date: Sun Nov 6 18:21:44 2011 +0100 alchemy: fix timeout to timespec conversion --- lib/alchemy/internal.c | 13 +++++++++++++ lib/alchemy/internal.h | 16 +++------------- lib/alchemy/sem.c | 13 +------------ lib/alchemy/task.c | 3 +-- 4 files changed, 18 insertions(+), 27 deletions(-) diff --git a/lib/alchemy/internal.c b/lib/alchemy/internal.c index dae5156..8bf1cf4 100644 --- a/lib/alchemy/internal.c +++ b/lib/alchemy/internal.c @@ -55,6 +55,19 @@ RTIME alchemy_rel2abs_timeout(RTIME timeout) return timeout; } +struct timespec *alchemy_get_timespec(RTIME timeout, struct timespec *tmp) +{ + if (timeout == TM_INFINITE) + return NULL; + + if (timeout == TM_NONBLOCK) + timeout = 0; + + clockobj_ticks_to_timespec(&alchemy_clock, timeout, tmp); + + return tmp; +} + int alchemy_bind_object(const char *name, struct syncluster *sc, RTIME timeout, int offset, diff --git a/lib/alchemy/internal.h b/lib/alchemy/internal.h index e4af9f2..86b0f21 100644 --- a/lib/alchemy/internal.h +++ b/lib/alchemy/internal.h @@ -27,19 +27,6 @@ struct alchemy_namegen { int serial; }; -static inline struct timespec * -alchemy_get_timespec(RTIME timeout, struct timespec *tmp) -{ - struct timespec *timespec = NULL; - - if (timeout != TM_INFINITE) { - clockobj_ticks_to_timespec(&alchemy_clock, timeout, tmp); - timespec = tmp; - } - - return timespec; -} - struct syncluster; char *alchemy_build_name(char *buf, const char *name, @@ -47,6 +34,9 @@ char *alchemy_build_name(char *buf, const char *name, RTIME alchemy_rel2abs_timeout(RTIME timeout); +struct timespec *alchemy_get_timespec(RTIME timeout, + struct timespec *tmp); + int alchemy_bind_object(const char *name, struct syncluster *sc, RTIME timeout, int offset, diff --git a/lib/alchemy/sem.c b/lib/alchemy/sem.c index 905b9d2..67abf69 100644 --- a/lib/alchemy/sem.c +++ b/lib/alchemy/sem.c @@ -154,18 +154,7 @@ int rt_sem_p_until(RT_SEM *sem, RTIME timeout) if (scb == NULL) goto out; - if (timeout == TM_INFINITE) - timespec = NULL; - else { - timespec = &ts; - if (timeout == TM_NONBLOCK) { - ts.tv_sec = 0; - ts.tv_nsec = 0; - } else - clockobj_ticks_to_timespec(&alchemy_clock, - timeout, timespec); - } - + timespec = alchemy_get_timespec(timeout, &ts); ret = semobj_wait(&scb->smobj, timespec); out: COPPERPLATE_UNPROTECT(svc); diff --git a/lib/alchemy/task.c b/lib/alchemy/task.c index 7fcfc2e..3ff9d95 100644 --- a/lib/alchemy/task.c +++ b/lib/alchemy/task.c @@ -813,8 +813,6 @@ int rt_task_receive_until(RT_TASK_MCB *mcb_r, RTIME timeout) if (current == NULL) return -EPERM; - timespec = alchemy_get_timespec(timeout, &ts); - COPPERPLATE_PROTECT(svc); syncobj_lock(¤t->sobj_msg, &syns); @@ -824,6 +822,7 @@ int rt_task_receive_until(RT_TASK_MCB *mcb_r, RTIME timeout) ret = -EWOULDBLOCK; goto done; } + timespec = alchemy_get_timespec(timeout, &ts); syncobj_wait_drain(¤t->sobj_msg, timespec, &syns); } _______________________________________________ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git