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

Author: Philippe Gerum <r...@xenomai.org>
Date:   Sat Nov 26 17:25:58 2011 +0100

alchemy: inline scalar->timespec conversion in caller context

Unconditional ticks/nanoseconds to timespec conversions via a common
helper routine can be costly on low end hardware, putting some useless
pressure on the I-cache when the operation just substitutes an input
constant by another.

Typically, most often the caller passes an infinite wait specification
to blocking Alchemy services, which is translated to NULL for the
copperplate API to start an unbounded wait, so going through a
conversion call to map TM_INFINITE to NULL is pure overhead. In that
case, we would be better off doing the substitution directly from the
calling context.

To thos end, this patch introduces a *_timed() call form for each
blocking Alchemy service, which receives a timespec directly. All
existing relative and absolute call forms of blocking services now
convert the timeout value inline when possible, before branching to
the *_timed() call.

---

 include/alchemy/buffer.h |   48 +++++++++++++++++++++++++++++------
 include/alchemy/cond.h   |   23 ++++++++++++----
 include/alchemy/event.h  |   29 +++++++++++++++------
 include/alchemy/heap.h   |   26 +++++++++++++++++--
 include/alchemy/mutex.h  |   21 ++++++++++++---
 include/alchemy/pipe.h   |   39 +++++++++++++++++------------
 include/alchemy/queue.h  |   62 ++++++++++++++++++++++++++++++---------------
 include/alchemy/sem.h    |   17 +++++++++---
 include/alchemy/task.h   |   47 +++++++++++++++++++++++++++-------
 include/alchemy/timer.h  |   29 +++++++++++++++++++++
 lib/alchemy/buffer.c     |   48 ++++++++++++-----------------------
 lib/alchemy/cond.c       |   58 ++++++++++--------------------------------
 lib/alchemy/event.c      |   21 +++------------
 lib/alchemy/heap.c       |   14 ++++------
 lib/alchemy/internal.c   |   47 +++-------------------------------
 lib/alchemy/internal.h   |    8 ------
 lib/alchemy/mutex.c      |   39 +++++++++-------------------
 lib/alchemy/pipe.c       |   54 ++++++++++++++--------------------------
 lib/alchemy/queue.c      |   33 ++++++-----------------
 lib/alchemy/sem.c        |   12 +-------
 lib/alchemy/task.c       |   36 ++++++--------------------
 lib/alchemy/timer.h      |    2 -
 22 files changed, 358 insertions(+), 355 deletions(-)

diff --git a/include/alchemy/buffer.h b/include/alchemy/buffer.h
index c258fb4..9b53a22 100644
--- a/include/alchemy/buffer.h
+++ b/include/alchemy/buffer.h
@@ -53,21 +53,53 @@ int rt_buffer_create(RT_BUFFER *bf,
 
 int rt_buffer_delete(RT_BUFFER *bf);
 
-ssize_t rt_buffer_write(RT_BUFFER *bf,
-                       const void *ptr, size_t size,
-                       RTIME timeout);
+ssize_t rt_buffer_write_timed(RT_BUFFER *bf,
+                             const void *ptr, size_t size,
+                             const struct timespec *abs_timeout);
 
+static inline
 ssize_t rt_buffer_write_until(RT_BUFFER *bf,
                              const void *ptr, size_t size,
-                             RTIME timeout);
+                             RTIME timeout)
+{
+       struct timespec ts;
+       return rt_buffer_write_timed(bf, ptr, size,
+                                    alchemy_abs_timeout(timeout, &ts));
+}
 
-ssize_t rt_buffer_read(RT_BUFFER *bf,
-                      void *ptr, size_t size,
-                      RTIME timeout);
+static inline
+ssize_t rt_buffer_write(RT_BUFFER *bf,
+                       const void *ptr, size_t size,
+                       RTIME timeout)
+{
+       struct timespec ts;
+       return rt_buffer_write_timed(bf, ptr, size,
+                                    alchemy_rel_timeout(timeout, &ts));
+}
+
+ssize_t rt_buffer_read_timed(RT_BUFFER *bf,
+                            void *ptr, size_t size,
+                            const struct timespec *abs_timeout);
 
+static inline
 ssize_t rt_buffer_read_until(RT_BUFFER *bf,
                             void *ptr, size_t size,
-                            RTIME timeout);
+                            RTIME timeout)
+{
+       struct timespec ts;
+       return rt_buffer_read_timed(bf, ptr, size,
+                                   alchemy_abs_timeout(timeout, &ts));
+}
+
+static inline
+ssize_t rt_buffer_read(RT_BUFFER *bf,
+                      void *ptr, size_t size,
+                      RTIME timeout)
+{
+       struct timespec ts;
+       return rt_buffer_read_timed(bf, ptr, size,
+                                   alchemy_rel_timeout(timeout, &ts));
+}
 
 int rt_buffer_clear(RT_BUFFER *bf);
 
diff --git a/include/alchemy/cond.h b/include/alchemy/cond.h
index cff5f9f..747a311 100644
--- a/include/alchemy/cond.h
+++ b/include/alchemy/cond.h
@@ -48,13 +48,24 @@ int rt_cond_signal(RT_COND *cond);
 
 int rt_cond_broadcast(RT_COND *cond);
 
-int rt_cond_wait(RT_COND *cond,
-                RT_MUTEX *mutex,
-                RTIME timeout);
-
-int rt_cond_wait_until(RT_COND *cond,
+int rt_cond_wait_timed(RT_COND *cond,
                       RT_MUTEX *mutex,
-                      RTIME timeout);
+                      const struct timespec *abs_timeout);
+static inline
+int rt_cond_wait_until(RT_COND *cond, RT_MUTEX *mutex, RTIME timeout)
+{
+       struct timespec ts;
+       return rt_cond_wait_timed(cond, mutex,
+                                 alchemy_abs_timeout(timeout, &ts));
+}
+
+static inline
+int rt_cond_wait(RT_COND *cond, RT_MUTEX *mutex, RTIME timeout)
+{
+       struct timespec ts;
+       return rt_cond_wait_timed(cond, mutex,
+                                 alchemy_rel_timeout(timeout, &ts));
+}
 
 int rt_cond_inquire(RT_COND *cond,
                    RT_COND_INFO *info);
diff --git a/include/alchemy/event.h b/include/alchemy/event.h
index c1d74c2..3d824d0 100644
--- a/include/alchemy/event.h
+++ b/include/alchemy/event.h
@@ -58,17 +58,30 @@ int rt_event_delete(RT_EVENT *event);
 int rt_event_signal(RT_EVENT *event,
                    unsigned long mask);
 
-int rt_event_wait(RT_EVENT *event,
-                 unsigned long mask,
-                 unsigned long *mask_r,
-                 int mode,
-                 RTIME timeout);
-
-int rt_event_wait_until(RT_EVENT *event,
+int rt_event_wait_timed(RT_EVENT *event,
                        unsigned long mask,
                        unsigned long *mask_r,
                        int mode,
-                       RTIME timeout);
+                       const struct timespec *abs_timeout);
+static inline
+int rt_event_wait_until(RT_EVENT *event,
+                       unsigned long mask, unsigned long *mask_r,
+                       int mode, RTIME timeout)
+{
+       struct timespec ts;
+       return rt_event_wait_timed(event, mask, mask_r, mode,
+                                  alchemy_abs_timeout(timeout, &ts));
+}
+
+static inline
+int rt_event_wait(RT_EVENT *event,
+                 unsigned long mask, unsigned long *mask_r,
+                 int mode, RTIME timeout)
+{
+       struct timespec ts;
+       return rt_event_wait_timed(event, mask, mask_r, mode,
+                                  alchemy_rel_timeout(timeout, &ts));
+}
 
 int rt_event_clear(RT_EVENT *event,
                   unsigned long mask,
diff --git a/include/alchemy/heap.h b/include/alchemy/heap.h
index 4d1b5f4..26c4802 100644
--- a/include/alchemy/heap.h
+++ b/include/alchemy/heap.h
@@ -59,10 +59,30 @@ int rt_heap_create(RT_HEAP *heap,
 
 int rt_heap_delete(RT_HEAP *heap);
 
+int rt_heap_alloc_timed(RT_HEAP *heap,
+                       size_t size,
+                       const struct timespec *abs_timeout,
+                       void **blockp);
+
+static inline
+int rt_heap_alloc_until(RT_HEAP *heap,
+                 size_t size, RTIME timeout, void **blockp)
+{
+       struct timespec ts;
+       return rt_heap_alloc_timed(heap, size,
+                                  alchemy_abs_timeout(timeout, &ts),
+                                  blockp);
+}
+
+static inline
 int rt_heap_alloc(RT_HEAP *heap,
-                 size_t size,
-                 RTIME timeout,
-                 void **blockp);
+                 size_t size, RTIME timeout, void **blockp)
+{
+       struct timespec ts;
+       return rt_heap_alloc_timed(heap, size,
+                                  alchemy_rel_timeout(timeout, &ts),
+                                  blockp);
+}
 
 int rt_heap_free(RT_HEAP *heap,
                 void *block);
diff --git a/include/alchemy/mutex.h b/include/alchemy/mutex.h
index 7440aea..2949077 100644
--- a/include/alchemy/mutex.h
+++ b/include/alchemy/mutex.h
@@ -45,11 +45,24 @@ int rt_mutex_create(RT_MUTEX *mutex,
 
 int rt_mutex_delete(RT_MUTEX *mutex);
 
-int rt_mutex_acquire(RT_MUTEX *mutex,
-                    RTIME timeout);
+int rt_mutex_acquire_timed(RT_MUTEX *mutex,
+                          const struct timespec *abs_timeout);
+
+static inline
+int rt_mutex_acquire_until(RT_MUTEX *mutex, RTIME timeout)
+{
+       struct timespec ts;
+       return rt_mutex_acquire_timed(mutex,
+                                     alchemy_abs_timeout(timeout, &ts));
+}
 
-int rt_mutex_acquire_until(RT_MUTEX *mutex,
-                          RTIME timeout);
+static inline
+int rt_mutex_acquire(RT_MUTEX *mutex, RTIME timeout)
+{
+       struct timespec ts;
+       return rt_mutex_acquire_timed(mutex,
+                                     alchemy_rel_timeout(timeout, &ts));
+}
 
 int rt_mutex_release(RT_MUTEX *mutex);
 
diff --git a/include/alchemy/pipe.h b/include/alchemy/pipe.h
index 2e5ced7..d6dce06 100644
--- a/include/alchemy/pipe.h
+++ b/include/alchemy/pipe.h
@@ -41,33 +41,40 @@ extern "C" {
 
 int rt_pipe_create(RT_PIPE *pipe,
                   const char *name,
-                  int minor,
-                  size_t poolsize);
+                  int minor, size_t poolsize);
 
 int rt_pipe_delete(RT_PIPE *pipe);
 
-ssize_t rt_pipe_read(RT_PIPE *pipe,
-                    void *buf,
-                    size_t size,
-                    RTIME timeout);
+ssize_t rt_pipe_read_timed(RT_PIPE *pipe,
+                          void *buf, size_t size,
+                          const struct timespec *abs_timeout);
 
+static inline
 ssize_t rt_pipe_read_until(RT_PIPE *pipe,
-                          void *buf,
-                          size_t size,
-                          RTIME timeout);
+                          void *buf, size_t size, RTIME timeout)
+{
+       struct timespec ts;
+       return rt_pipe_read_timed(pipe, buf, size,
+                                 alchemy_abs_timeout(timeout, &ts));
+}
+
+static inline
+ssize_t rt_pipe_read(RT_PIPE *pipe,
+                    void *buf, size_t size, RTIME timeout)
+{
+       struct timespec ts;
+       return rt_pipe_read_timed(pipe, buf, size,
+                                 alchemy_rel_timeout(timeout, &ts));
+}
 
 ssize_t rt_pipe_write(RT_PIPE *pipe,
-                     const void *buf,
-                     size_t size,
-                     int mode);
+                     const void *buf, size_t size, int mode);
 
 ssize_t rt_pipe_stream(RT_PIPE *pipe,
-                      const void *buf,
-                      size_t size);
+                      const void *buf, size_t size);
 
 int rt_pipe_bind(RT_PIPE *pipe,
-                const char *name,
-                RTIME timeout);
+                const char *name, RTIME timeout);
 
 int rt_pipe_unbind(RT_PIPE *pipe);
 
diff --git a/include/alchemy/queue.h b/include/alchemy/queue.h
index b9d68f5..4bab191 100644
--- a/include/alchemy/queue.h
+++ b/include/alchemy/queue.h
@@ -63,9 +63,7 @@ extern "C" {
 
 int rt_queue_create(RT_QUEUE *queue,
                    const char *name,
-                   size_t poolsize,
-                   size_t qlimit,
-                   int mode);
+                   size_t poolsize, size_t qlimit, int mode);
 
 int rt_queue_delete(RT_QUEUE *queue);
 
@@ -76,32 +74,54 @@ int rt_queue_free(RT_QUEUE *queue,
                  void *buf);
 
 int rt_queue_send(RT_QUEUE *queue,
-                 const void *buf,
-                 size_t size,
-                 int mode);
+                 const void *buf, size_t size, int mode);
 
 int rt_queue_write(RT_QUEUE *queue,
-                  const void *buf,
-                  size_t size,
-                  int mode);
+                  const void *buf, size_t size, int mode);
 
-ssize_t rt_queue_receive(RT_QUEUE *queue,
-                        void **bufp,
-                        RTIME timeout);
+ssize_t rt_queue_receive_timed(RT_QUEUE *queue,
+                              void **bufp,
+                              const struct timespec *abs_timeout);
 
+static inline
 ssize_t rt_queue_receive_until(RT_QUEUE *queue,
-                              void **bufp,
-                              RTIME timeout);
+                              void **bufp, RTIME timeout)
+{
+       struct timespec ts;
+       return rt_queue_receive_timed(queue, bufp,
+                                     alchemy_abs_timeout(timeout, &ts));
+}
 
-ssize_t rt_queue_read(RT_QUEUE *queue,
-                     void *buf,
-                     size_t size,
-                     RTIME timeout);
+static inline
+ssize_t rt_queue_receive(RT_QUEUE *queue,
+                        void **bufp, RTIME timeout)
+{
+       struct timespec ts;
+       return rt_queue_receive_timed(queue, bufp,
+                                     alchemy_rel_timeout(timeout, &ts));
+}
+
+ssize_t rt_queue_read_timed(RT_QUEUE *queue,
+                           void *buf, size_t size,
+                           const struct timespec *abs_timeout);
 
+static inline
 ssize_t rt_queue_read_until(RT_QUEUE *queue,
-                           void *buf,
-                           size_t size,
-                           RTIME timeout);
+                           void *buf, size_t size, RTIME timeout)
+{
+       struct timespec ts;
+       return rt_queue_read_timed(queue, buf, size,
+                                  alchemy_abs_timeout(timeout, &ts));
+}
+
+static inline
+ssize_t rt_queue_read(RT_QUEUE *queue,
+                     void *buf, size_t size, RTIME timeout)
+{
+       struct timespec ts;
+       return rt_queue_read_timed(queue, buf, size,
+                                  alchemy_rel_timeout(timeout, &ts));
+}
 
 int rt_queue_flush(RT_QUEUE *queue);
 
diff --git a/include/alchemy/sem.h b/include/alchemy/sem.h
index 981530b..abeeffa 100644
--- a/include/alchemy/sem.h
+++ b/include/alchemy/sem.h
@@ -52,11 +52,20 @@ int rt_sem_create(RT_SEM *sem,
 
 int rt_sem_delete(RT_SEM *sem);
 
-int rt_sem_p(RT_SEM *sem,
-            RTIME timeout);
+int rt_sem_p_timed(RT_SEM *sem,
+                  const struct timespec *abs_timeout);
 
-int rt_sem_p_until(RT_SEM *sem,
-                  RTIME timeout);
+static inline int rt_sem_p_until(RT_SEM *sem, RTIME timeout)
+{
+       struct timespec ts;
+       return rt_sem_p_timed(sem, alchemy_abs_timeout(timeout, &ts));
+}
+
+static inline int rt_sem_p(RT_SEM *sem, RTIME timeout)
+{
+       struct timespec ts;
+       return rt_sem_p_timed(sem, alchemy_rel_timeout(timeout, &ts));
+}
 
 int rt_sem_v(RT_SEM *sem);
 
diff --git a/include/alchemy/task.h b/include/alchemy/task.h
index cd0e164..3b2cd6b 100644
--- a/include/alchemy/task.h
+++ b/include/alchemy/task.h
@@ -124,21 +124,48 @@ int rt_task_slice(RT_TASK *task, RTIME quantum);
 int rt_task_inquire(RT_TASK *task,
                    RT_TASK_INFO *info);
 
+ssize_t rt_task_send_timed(RT_TASK *task,
+                          RT_TASK_MCB *mcb_s, RT_TASK_MCB *mcb_r,
+                          const struct timespec *abs_timeout);
+
+static inline
 ssize_t rt_task_send_until(RT_TASK *task,
-                          RT_TASK_MCB *mcb_s,
-                          RT_TASK_MCB *mcb_r,
-                          RTIME timeout);
+                          RT_TASK_MCB *mcb_s, RT_TASK_MCB *mcb_r,
+                          RTIME timeout)
+{
+       struct timespec ts;
+       return rt_task_send_timed(task, mcb_s, mcb_r,
+                                 alchemy_abs_timeout(timeout, &ts));
+}
 
+static inline
 ssize_t rt_task_send(RT_TASK *task,
-                    RT_TASK_MCB *mcb_s,
-                    RT_TASK_MCB *mcb_r,
-                    RTIME timeout);
+                    RT_TASK_MCB *mcb_s, RT_TASK_MCB *mcb_r,
+                    RTIME timeout)
+{
+       struct timespec ts;
+       return rt_task_send_timed(task, mcb_s, mcb_r,
+                                 alchemy_rel_timeout(timeout, &ts));
+}
 
-int rt_task_receive_until(RT_TASK_MCB *mcb_r,
-                         RTIME timeout);
+int rt_task_receive_timed(RT_TASK_MCB *mcb_r,
+                         const struct timespec *abs_timeout);
 
-int rt_task_receive(RT_TASK_MCB *mcb_r,
-                   RTIME timeout);
+static inline
+int rt_task_receive_until(RT_TASK_MCB *mcb_r, RTIME timeout)
+{
+       struct timespec ts;
+       return rt_task_receive_timed(mcb_r,
+                                    alchemy_abs_timeout(timeout, &ts));
+}
+
+static inline
+int rt_task_receive(RT_TASK_MCB *mcb_r, RTIME timeout)
+{
+       struct timespec ts;
+       return rt_task_receive_timed(mcb_r,
+                                    alchemy_rel_timeout(timeout, &ts));
+}
 
 int rt_task_reply(int flowid,
                  RT_TASK_MCB *mcb_s);
diff --git a/include/alchemy/timer.h b/include/alchemy/timer.h
index 16c26ef..2467849 100644
--- a/include/alchemy/timer.h
+++ b/include/alchemy/timer.h
@@ -19,6 +19,7 @@
 #ifndef _XENOMAI_ALCHEMY_TIMER_H
 #define _XENOMAI_ALCHEMY_TIMER_H
 
+#include <stddef.h>
 #include <copperplate/clockobj.h>
 
 typedef ticks_t RTIME;
@@ -36,6 +37,34 @@ typedef struct rt_timer_info {
        RTIME tsc;
 } RT_TIMER_INFO;
 
+extern struct clockobj alchemy_clock;
+
+#define alchemy_abs_timeout(__t, __ts)                                 \
+       ({                                                              \
+               (__t) == TM_INFINITE ? NULL :                           \
+               (__t) == TM_NONBLOCK ?                                  \
+               ({ (__ts)->tv_sec = (__ts)->tv_nsec = 0; (__ts); }) :   \
+               ({ clockobj_ticks_to_timespec(&alchemy_clock, (__t), (__ts)); \
+                       (__ts); });                                     \
+       })
+
+#define alchemy_rel_timeout(__t, __ts)                                 \
+       ({                                                              \
+               (__t) == TM_INFINITE ? NULL :                           \
+               (__t) == TM_NONBLOCK ?                                  \
+               ({ (__ts)->tv_sec = (__ts)->tv_nsec = 0; (__ts); }) :   \
+               ({ clockobj_ticks_to_timeout(&alchemy_clock, (__t), (__ts)); \
+                       (__ts); });                                     \
+       })
+
+static inline
+int alchemy_poll_mode(const struct timespec *abs_timeout)
+{
+       return abs_timeout &&
+               abs_timeout->tv_sec == 0 &&
+               abs_timeout->tv_nsec == 0;
+}
+
 #ifdef __cplusplus
 extern "C" {
 #endif
diff --git a/lib/alchemy/buffer.c b/lib/alchemy/buffer.c
index a246925..32a922d 100644
--- a/lib/alchemy/buffer.c
+++ b/lib/alchemy/buffer.c
@@ -162,11 +162,11 @@ out:
        return ret;
 }
 
-ssize_t rt_buffer_read_until(RT_BUFFER *bf,
-                            void *ptr, size_t size, RTIME timeout)
+ssize_t rt_buffer_read_timed(RT_BUFFER *bf,
+                            void *ptr, size_t size,
+                            const struct timespec *abs_timeout)
 {
        struct alchemy_buffer_wait *wait = NULL;
-       struct timespec ts, *timespec = NULL;
        struct alchemy_buffer *bcb;
        struct threadobj *thobj;
        size_t len, rbytes, n;
@@ -180,7 +180,7 @@ ssize_t rt_buffer_read_until(RT_BUFFER *bf,
        if (len == 0)
                return 0;
 
-       if (timeout != TM_NONBLOCK && !threadobj_current_p())
+       if (!threadobj_current_p() && !alchemy_poll_mode(abs_timeout))
                return -EPERM;
 
        COPPERPLATE_PROTECT(svc);
@@ -242,7 +242,7 @@ redo:
 
                goto done;
        wait:
-               if (timeout == TM_NONBLOCK) {
+               if (alchemy_poll_mode(abs_timeout)) {
                        ret = -EWOULDBLOCK;
                        goto done;
                }
@@ -259,13 +259,12 @@ redo:
                        goto redo;
                }
 
-               if (wait == NULL) {
-                       timespec = alchemy_get_timespec(timeout, &ts);
+               if (wait == NULL)
                        wait = threadobj_prepare_wait(struct 
alchemy_buffer_wait);
-               }
+
                wait->size = len;
 
-               ret = syncobj_pend(&bcb->sobj, timespec, &syns);
+               ret = syncobj_pend(&bcb->sobj, abs_timeout, &syns);
                if (ret) {
                        if (ret == -EIDRM)
                                goto out;
@@ -283,18 +282,11 @@ out:
        return ret;
 }
 
-ssize_t rt_buffer_read(RT_BUFFER *bf,
-                      void *ptr, size_t size, RTIME timeout)
-{
-       timeout = alchemy_rel2abs_timeout(timeout);
-       return rt_buffer_read_until(bf, ptr, size, timeout);
-}
-
-ssize_t rt_buffer_write_until(RT_BUFFER *bf,
-                             const void *ptr, size_t size, RTIME timeout)
+ssize_t rt_buffer_write_timed(RT_BUFFER *bf,
+                             const void *ptr, size_t size,
+                             const struct timespec *abs_timeout)
 {
        struct alchemy_buffer_wait *wait = NULL;
-       struct timespec ts, *timespec = NULL;
        struct alchemy_buffer *bcb;
        struct threadobj *thobj;
        size_t len, rbytes, n;
@@ -308,7 +300,7 @@ ssize_t rt_buffer_write_until(RT_BUFFER *bf,
        if (len == 0)
                return 0;
 
-       if (timeout != TM_NONBLOCK && !threadobj_current_p())
+       if (!threadobj_current_p() && !alchemy_poll_mode(abs_timeout))
                return -EPERM;
 
        COPPERPLATE_PROTECT(svc);
@@ -370,15 +362,14 @@ ssize_t rt_buffer_write_until(RT_BUFFER *bf,
 
                goto done;
        wait:
-               if (timeout == TM_NONBLOCK) {
+               if (alchemy_poll_mode(abs_timeout)) {
                        ret = -EWOULDBLOCK;
                        goto done;
                }
 
-               if (wait == NULL) {
-                       timespec = alchemy_get_timespec(timeout, &ts);
+               if (wait == NULL)
                        wait = threadobj_prepare_wait(struct 
alchemy_buffer_wait);
-               }
+
                wait->size = len;
 
                /*
@@ -399,7 +390,7 @@ ssize_t rt_buffer_write_until(RT_BUFFER *bf,
                if (bcb->fillsz > 0 && syncobj_pend_count(&bcb->sobj))
                        syncobj_flush(&bcb->sobj, SYNCOBJ_BROADCAST);
 
-               ret = syncobj_wait_drain(&bcb->sobj, timespec, &syns);
+               ret = syncobj_wait_drain(&bcb->sobj, abs_timeout, &syns);
                if (ret) {
                        if (ret == -EIDRM)
                                goto out;
@@ -417,13 +408,6 @@ out:
        return ret;
 }
 
-ssize_t rt_buffer_write(RT_BUFFER *bf,
-                       const void *ptr, size_t size, RTIME timeout)
-{
-       timeout = alchemy_rel2abs_timeout(timeout);
-       return rt_buffer_write_until(bf, ptr, size, timeout);
-}
-
 int rt_buffer_clear(RT_BUFFER *bf)
 {
        struct alchemy_buffer *bcb;
diff --git a/lib/alchemy/cond.c b/lib/alchemy/cond.c
index 3dedfbb..ce8fd38 100644
--- a/lib/alchemy/cond.c
+++ b/lib/alchemy/cond.c
@@ -125,18 +125,13 @@ out:
 int rt_cond_signal(RT_COND *cond)
 {
        struct alchemy_cond *ccb;
-       struct service svc;
        int ret = 0;
 
-       COPPERPLATE_PROTECT(svc);
-
        ccb = find_alchemy_cond(cond, &ret);
        if (ccb == NULL)
-               goto out;
+               return ret;
 
-       ret = -__RT(pthread_cond_signal(&ccb->cond));
-out:
-       COPPERPLATE_UNPROTECT(svc);
+       return -__RT(pthread_cond_signal(&ccb->cond));
 
        return ret;
 }
@@ -144,77 +139,52 @@ out:
 int rt_cond_broadcast(RT_COND *cond)
 {
        struct alchemy_cond *ccb;
-       struct service svc;
        int ret = 0;
 
-       COPPERPLATE_PROTECT(svc);
-
        ccb = find_alchemy_cond(cond, &ret);
        if (ccb == NULL)
-               goto out;
-
-       ret = -__RT(pthread_cond_broadcast(&ccb->cond));
-out:
-       COPPERPLATE_UNPROTECT(svc);
+               return ret;
 
-       return ret;
+       return -__RT(pthread_cond_broadcast(&ccb->cond));
 }
 
-int rt_cond_wait_until(RT_COND *cond, RT_MUTEX *mutex,
-                      RTIME timeout)
+int rt_cond_wait_timed(RT_COND *cond, RT_MUTEX *mutex,
+                      const struct timespec *abs_timeout)
 {
        struct alchemy_mutex *mcb;
        struct alchemy_cond *ccb;
-       struct service svc;
-       struct timespec ts;
        int ret = 0;
 
-       if (timeout == TM_NONBLOCK)
+       if (alchemy_poll_mode(abs_timeout))
                return -EWOULDBLOCK;
 
-       COPPERPLATE_PROTECT(svc);
-
        ccb = find_alchemy_cond(cond, &ret);
        if (ccb == NULL)
-               goto out;
+               return ret;
 
        mcb = find_alchemy_mutex(mutex, &ret);
        if (mcb == NULL)
-               goto out;
+               return ret;
 
-       if (timeout != TM_INFINITE) {
-               clockobj_ticks_to_timespec(&alchemy_clock, timeout, &ts);
-               ret = -__RT(pthread_cond_timedwait(&ccb->cond, &mcb->lock, 
&ts));
-       } else
+       if (abs_timeout)
+               ret = -__RT(pthread_cond_timedwait(&ccb->cond,
+                                                  &mcb->lock, abs_timeout));
+       else
                ret = -__RT(pthread_cond_wait(&ccb->cond, &mcb->lock));
-out:
-       COPPERPLATE_UNPROTECT(svc);
 
        return ret;
 }
 
-int rt_cond_wait(RT_COND *cond, RT_MUTEX *mutex,
-                RTIME timeout)
-{
-       timeout = alchemy_rel2abs_timeout(timeout);
-       return rt_cond_wait_until(cond, mutex, timeout);
-}
-
 int rt_cond_inquire(RT_COND *cond, RT_COND_INFO *info)
 {
        struct alchemy_cond *ccb;
-       struct service svc;
        int ret = 0;
 
-       COPPERPLATE_PROTECT(svc);
-
        ccb = find_alchemy_cond(cond, &ret);
        if (ccb == NULL)
-               goto out;
+               return ret;
 
        strcpy(info->name, ccb->name);
-out:
-       COPPERPLATE_UNPROTECT(svc);
 
        return ret;
 }
diff --git a/lib/alchemy/event.c b/lib/alchemy/event.c
index a793772..bfac429 100644
--- a/lib/alchemy/event.c
+++ b/lib/alchemy/event.c
@@ -138,19 +138,18 @@ out:
        return ret;
 }
 
-int rt_event_wait_until(RT_EVENT *event,
+int rt_event_wait_timed(RT_EVENT *event,
                        unsigned long mask, unsigned long *mask_r,
-                       int mode, RTIME timeout)
+                       int mode, const struct timespec *abs_timeout)
 {
        struct alchemy_event_wait *wait;
-       struct timespec ts, *timespec;
        unsigned long bits, testval;
        struct alchemy_event *evcb;
        struct syncstate syns;
        struct service svc;
        int ret = 0;
 
-       if (timeout != TM_NONBLOCK && !threadobj_current_p())
+       if (!threadobj_current_p() && !alchemy_poll_mode(abs_timeout))
                return -EPERM;
 
        COPPERPLATE_PROTECT(svc);
@@ -171,7 +170,7 @@ int rt_event_wait_until(RT_EVENT *event,
        if (bits && bits == testval)
                goto done;
 
-       if (timeout == TM_NONBLOCK) {
+       if (alchemy_poll_mode(abs_timeout)) {
                ret = -EWOULDBLOCK;
                goto done;
        }
@@ -180,9 +179,7 @@ int rt_event_wait_until(RT_EVENT *event,
        wait->mask = mask;
        wait->mode = mode;
 
-       timespec = alchemy_get_timespec(timeout, &ts);
-
-       ret = syncobj_pend(&evcb->sobj, timespec, &syns);
+       ret = syncobj_pend(&evcb->sobj, abs_timeout, &syns);
        if (ret) {
                if (ret == -EIDRM) {
                        threadobj_finish_wait();
@@ -200,14 +197,6 @@ out:
        return ret;
 }
 
-int rt_event_wait(RT_EVENT *event,
-                 unsigned long mask, unsigned long *mask_r,
-                 int mode, RTIME timeout)
-{
-       timeout = alchemy_rel2abs_timeout(timeout);
-       return rt_event_wait_until(event, mask, mask_r, mode, timeout);
-}
-
 int rt_event_signal(RT_EVENT *event, unsigned long mask)
 {
        struct alchemy_event_wait *wait;
diff --git a/lib/alchemy/heap.c b/lib/alchemy/heap.c
index 85e9c2f..72b3793 100644
--- a/lib/alchemy/heap.c
+++ b/lib/alchemy/heap.c
@@ -154,18 +154,18 @@ out:
        return ret;
 }
 
-int rt_heap_alloc(RT_HEAP *heap,
-                 size_t size, RTIME timeout, void **blockp)
+int rt_heap_alloc_timed(RT_HEAP *heap,
+                       size_t size, const struct timespec *abs_timeout,
+                       void **blockp)
 {
        struct alchemy_heap_wait *wait;
-       struct timespec ts, *timespec;
        struct alchemy_heap *hcb;
        struct syncstate syns;
        struct service svc;
        void *p = NULL;
        int ret = 0;
 
-       if (timeout != TM_NONBLOCK && !threadobj_current_p())
+       if (!threadobj_current_p() && !alchemy_poll_mode(abs_timeout))
                return -EPERM;
 
        COPPERPLATE_PROTECT(svc);
@@ -195,17 +195,15 @@ int rt_heap_alloc(RT_HEAP *heap,
        if (p)
                goto done;
 
-       if (timeout == TM_NONBLOCK) {
+       if (alchemy_poll_mode(abs_timeout)) {
                ret = -EWOULDBLOCK;
                goto done;
        }
 
-       timespec = alchemy_get_timespec(timeout, &ts);
-
        wait = threadobj_prepare_wait(struct alchemy_heap_wait);
        wait->size = size;
 
-       ret = syncobj_pend(&hcb->sobj, timespec, &syns);
+       ret = syncobj_pend(&hcb->sobj, abs_timeout, &syns);
        if (ret) {
                if (ret == -EIDRM) {
                        threadobj_finish_wait();
diff --git a/lib/alchemy/internal.c b/lib/alchemy/internal.c
index 445d50e..e812562 100644
--- a/lib/alchemy/internal.c
+++ b/lib/alchemy/internal.c
@@ -40,60 +40,21 @@ char *alchemy_build_name(char *buf, const char *name,
        return buf;
 }
 
-RTIME alchemy_rel2abs_timeout(RTIME timeout)
-{
-       ticks_t now;
-
-       if (timeout != TM_INFINITE && timeout != TM_NONBLOCK) {
-               clockobj_get_time(&alchemy_clock, &now, NULL);
-               timeout += now;
-       }
-
-       return timeout;
-}
-
-struct timespec *alchemy_get_timespec(RTIME timeout, struct timespec *tmp)
-{
-       if (timeout == TM_INFINITE)
-               return NULL;
-
-       if (timeout == TM_NONBLOCK) {
-               tmp->tv_sec = 0;
-               tmp->tv_nsec = 0;
-       } else
-               clockobj_ticks_to_timespec(&alchemy_clock, timeout, tmp);
-
-       return tmp;
-}
-
-struct timespec *alchemy_get_timeout(RTIME timeout, struct timespec *tmp)
-{
-       if (timeout == TM_INFINITE)
-               return NULL;
-
-       if (timeout == TM_NONBLOCK) {
-               tmp->tv_sec = 0;
-               tmp->tv_nsec = 0;
-       } else
-               clockobj_ticks_to_timeout(&alchemy_clock, timeout, tmp);
-
-       return tmp;
-}
-
 int alchemy_bind_object(const char *name, struct syncluster *sc,
                        RTIME timeout,
                        int offset,
                        uintptr_t *handle)
 {
-       struct timespec ts, *timespec;
        struct clusterobj *cobj;
        struct service svc;
+       struct timespec ts;
        void *p;
        int ret;
 
        COPPERPLATE_PROTECT(svc);
-       timespec = alchemy_get_timeout(timeout, &ts);
-       ret = syncluster_findobj(sc, name, timespec, &cobj);
+       ret = syncluster_findobj(sc, name,
+                                alchemy_rel_timeout(timeout, &ts),
+                                &cobj);
        COPPERPLATE_UNPROTECT(svc);
        if (ret)
                return ret;
diff --git a/lib/alchemy/internal.h b/lib/alchemy/internal.h
index 6389985..60d8e34 100644
--- a/lib/alchemy/internal.h
+++ b/lib/alchemy/internal.h
@@ -32,14 +32,6 @@ struct syncluster;
 char *alchemy_build_name(char *buf, const char *name,
                         struct alchemy_namegen *ngen);
 
-RTIME alchemy_rel2abs_timeout(RTIME timeout);
-
-struct timespec *alchemy_get_timespec(RTIME timeout,
-                                     struct timespec *tmp);
-
-struct timespec *alchemy_get_timeout(RTIME timeout,
-                                    struct timespec *tmp);
-
 int alchemy_bind_object(const char *name, struct syncluster *sc,
                        RTIME timeout,
                        int offset,
diff --git a/lib/alchemy/mutex.c b/lib/alchemy/mutex.c
index ee3fc96..4e111c2 100644
--- a/lib/alchemy/mutex.c
+++ b/lib/alchemy/mutex.c
@@ -126,12 +126,12 @@ out:
        return ret;
 }
 
-int rt_mutex_acquire_until(RT_MUTEX *mutex, RTIME timeout)
+int rt_mutex_acquire_timed(RT_MUTEX *mutex,
+                          const struct timespec *abs_timeout)
 {
        struct alchemy_task *current;
        struct alchemy_mutex *mcb;
        struct timespec ts;
-       struct service svc;
        int ret = 0;
 
        /* This must be an alchemy task. */
@@ -139,23 +139,25 @@ int rt_mutex_acquire_until(RT_MUTEX *mutex, RTIME timeout)
        if (current == NULL)
                return -EPERM;
 
-       COPPERPLATE_PROTECT(svc);
-
-       /* Try the fast path first. */
+       /*
+        * Try the fast path first. Note that we don't need any
+        * protected section here: the caller should have provided for
+        * it.
+        */
        mcb = find_alchemy_mutex(mutex, &ret);
        if (mcb == NULL)
-               goto out;
+               return ret;
 
        /*
         * We found the mutex, but locklessly: let the POSIX layer
         * check for object existence.
         */
        ret = -__RT(pthread_mutex_trylock(&mcb->lock));
-       if (ret == 0 || ret != -EBUSY || timeout == TM_NONBLOCK)
+       if (ret == 0 || ret != -EBUSY || alchemy_poll_mode(abs_timeout))
                goto done;
 
        /* Slow path. */
-       if (timeout == TM_INFINITE) {
+       if (abs_timeout == NULL) {
                ret = -__RT(pthread_mutex_lock(&mcb->lock));
                goto done;
        }
@@ -166,7 +168,7 @@ int rt_mutex_acquire_until(RT_MUTEX *mutex, RTIME timeout)
         * implicitly based on CLOCK_REALTIME, so we need to translate
         * the user timeout into something POSIX understands.
         */
-       clockobj_ticks_to_clock(&alchemy_clock, timeout, CLOCK_REALTIME, &ts);
+       clockobj_convert_clocks(&alchemy_clock, abs_timeout, CLOCK_REALTIME, 
&ts);
        ret = -__RT(pthread_mutex_timedlock(&mcb->lock, &ts));
 done:
        switch (ret) {
@@ -185,36 +187,21 @@ done:
        case 0:
                mcb->owner.handle = mainheap_ref(current, uintptr_t);
        }
-out:
-       COPPERPLATE_UNPROTECT(svc);
 
        return ret;
 }
 
-int rt_mutex_acquire(RT_MUTEX *mutex, RTIME timeout)
-{
-       timeout = alchemy_rel2abs_timeout(timeout);
-       return rt_mutex_acquire_until(mutex, timeout);
-}
-
 int rt_mutex_release(RT_MUTEX *mutex)
 {
        struct alchemy_mutex *mcb;
-       struct service svc;
        int ret = 0;
 
-       COPPERPLATE_PROTECT(svc);
-
        mcb = find_alchemy_mutex(mutex, &ret);
        if (mcb == NULL)
-               goto out;
+               return ret;
 
        /* Let the POSIX layer check for object existence. */
-       ret = -__RT(pthread_mutex_unlock(&mcb->lock));
-out:
-       COPPERPLATE_UNPROTECT(svc);
-
-       return ret;
+       return -__RT(pthread_mutex_unlock(&mcb->lock));
 }
 
 int rt_mutex_inquire(RT_MUTEX *mutex, RT_MUTEX_INFO *info)
diff --git a/lib/alchemy/pipe.c b/lib/alchemy/pipe.c
index 1315f21..e3bfbab 100644
--- a/lib/alchemy/pipe.c
+++ b/lib/alchemy/pipe.c
@@ -169,59 +169,43 @@ out:
        return ret;
 }
 
-ssize_t rt_pipe_read_until(RT_PIPE *pipe,
-                          void *buf, size_t size, RTIME timeout)
+ssize_t rt_pipe_read_timed(RT_PIPE *pipe,
+                          void *buf, size_t size,
+                          const struct timespec *abs_timeout)
 {
-       struct timeval tv = { .tv_sec = 0, .tv_usec = 0 };
-       struct timespec ts, *timespec;
        struct alchemy_pipe *pcb;
-       struct service svc;
-       int err, flags;
+       int err = 0, flags;
+       struct timeval tv;
        ssize_t ret;
 
-       if (timeout != TM_NONBLOCK && !threadobj_current_p())
-               return -EPERM;
-
-       COPPERPLATE_PROTECT(svc);
-
        pcb = find_alchemy_pipe(pipe, &err);
-       if (pcb == NULL) {
-               ret = err;
-               goto out;
-       }
+       if (pcb == NULL)
+               return err;
 
-       switch (timeout) {
-       default:
-               timespec = alchemy_get_timespec(timeout, &ts);
-               tv.tv_sec = ts.tv_sec;
-               tv.tv_usec = ts.tv_nsec / 1000;
-               /* Falldown wanted. */
-       case TM_INFINITE:
+       if (alchemy_poll_mode(abs_timeout))
+               flags = MSG_DONTWAIT;
+       else {
+               if (!threadobj_current_p())
+                       return -EPERM;
+               if (abs_timeout) {
+                       tv.tv_sec = abs_timeout->tv_sec;
+                       tv.tv_usec = abs_timeout->tv_nsec / 1000;
+               } else {
+                       tv.tv_sec = 0;
+                       tv.tv_usec = 0;
+               }
                __RT(setsockopt(pcb->sock, SOL_SOCKET,
                                SO_RCVTIMEO, &tv, sizeof(tv)));
                flags = 0;
-               break;
-       case TM_NONBLOCK:
-               flags = MSG_DONTWAIT;
-               break;
        }
 
        ret = __RT(recvfrom(pcb->sock, buf, size, flags, NULL, 0));
        if (ret < 0)
                ret = -errno;
-out:
-       COPPERPLATE_UNPROTECT(svc);
 
        return ret;
 }
 
-ssize_t rt_pipe_read(RT_PIPE *pipe,
-                    void *buf, size_t size, RTIME timeout)
-{
-       timeout = alchemy_rel2abs_timeout(timeout);
-       return rt_pipe_read_until(pipe, buf, size, timeout);
-}
-
 static ssize_t do_write_pipe(RT_PIPE *pipe,
                             const void *buf, size_t size, int flags)
 {
diff --git a/lib/alchemy/queue.c b/lib/alchemy/queue.c
index 4b80983..d78da8b 100644
--- a/lib/alchemy/queue.c
+++ b/lib/alchemy/queue.c
@@ -320,19 +320,18 @@ int rt_queue_write(RT_QUEUE *queue,
        return ret;
 }
 
-ssize_t rt_queue_receive_until(RT_QUEUE *queue,
-                              void **bufp, RTIME timeout)
+ssize_t rt_queue_receive_timed(RT_QUEUE *queue, void **bufp,
+                              const struct timespec *abs_timeout)
 {
        struct alchemy_queue_wait *wait;
        struct alchemy_queue_msg *msg;
-       struct timespec ts, *timespec;
        struct alchemy_queue *qcb;
        struct syncstate syns;
        struct service svc;
        ssize_t ret;
        int err = 0;
 
-       if (timeout != TM_NONBLOCK && !threadobj_current_p())
+       if (!threadobj_current_p() && !alchemy_poll_mode(abs_timeout))
                return -EPERM;
 
        COPPERPLATE_PROTECT(svc);
@@ -352,15 +351,14 @@ ssize_t rt_queue_receive_until(RT_QUEUE *queue,
                goto done;
        }
 
-       if (timeout == TM_NONBLOCK) {
+       if (alchemy_poll_mode(abs_timeout)) {
                ret = -EWOULDBLOCK;
                goto done;
        }
 
        wait = threadobj_prepare_wait(struct alchemy_queue_wait);
-       timespec = alchemy_get_timespec(timeout, &ts);
 
-       ret = syncobj_pend(&qcb->sobj, timespec, &syns);
+       ret = syncobj_pend(&qcb->sobj, abs_timeout, &syns);
        if (ret) {
                if (ret == -EIDRM) {
                        threadobj_finish_wait();
@@ -381,21 +379,15 @@ out:
        return ret;
 }
 
-ssize_t rt_queue_receive(RT_QUEUE *queue,
-                        void **bufp, RTIME timeout)
-{
-       timeout = alchemy_rel2abs_timeout(timeout);
-       return rt_queue_receive_until(queue, bufp, timeout);
-}
-
-ssize_t rt_queue_read_until(RT_QUEUE *queue,
-                           void *buf, size_t size, RTIME timeout)
+ssize_t rt_queue_read_timed(RT_QUEUE *queue,
+                           void *buf, size_t size,
+                           const struct timespec *abs_timeout)
 {
        ssize_t rsize;
        void *_buf;
        int ret;
 
-       rsize = rt_queue_receive_until(queue, &_buf, timeout);
+       rsize = rt_queue_receive_timed(queue, &_buf, abs_timeout);
        if (rsize < 0)
                return rsize;
 
@@ -412,13 +404,6 @@ ssize_t rt_queue_read_until(RT_QUEUE *queue,
        return rsize;
 }
 
-ssize_t rt_queue_read(RT_QUEUE *queue,
-                     void *buf, size_t size, RTIME timeout)
-{
-       timeout = alchemy_rel2abs_timeout(timeout);
-       return rt_queue_read_until(queue, buf, size, timeout);
-}
-
 int rt_queue_flush(RT_QUEUE *queue)
 {
        struct alchemy_queue_msg *msg, *tmp;
diff --git a/lib/alchemy/sem.c b/lib/alchemy/sem.c
index b3fa93c..375e2b9 100644
--- a/lib/alchemy/sem.c
+++ b/lib/alchemy/sem.c
@@ -142,9 +142,8 @@ out:
        return ret;
 }
 
-int rt_sem_p_until(RT_SEM *sem, RTIME timeout)
+int rt_sem_p_timed(RT_SEM *sem, const struct timespec *abs_timeout)
 {
-       struct timespec ts, *timespec;
        struct alchemy_sem *scb;
        struct service svc;
        int ret = 0;
@@ -155,20 +154,13 @@ int rt_sem_p_until(RT_SEM *sem, RTIME timeout)
        if (scb == NULL)
                goto out;
 
-       timespec  = alchemy_get_timespec(timeout, &ts);
-       ret = semobj_wait(&scb->smobj, timespec);
+       ret = semobj_wait(&scb->smobj, abs_timeout);
 out:
        COPPERPLATE_UNPROTECT(svc);
 
        return ret;
 }
 
-int rt_sem_p(RT_SEM *sem, RTIME timeout)
-{
-       timeout = alchemy_rel2abs_timeout(timeout);
-       return rt_sem_p_until(sem, timeout);
-}
-
 int rt_sem_v(RT_SEM *sem)
 {
        struct alchemy_sem *scb;
diff --git a/lib/alchemy/task.c b/lib/alchemy/task.c
index 5cfd1d0..81b16f4 100644
--- a/lib/alchemy/task.c
+++ b/lib/alchemy/task.c
@@ -695,12 +695,11 @@ out:
        return ret;
 }
 
-ssize_t rt_task_send_until(RT_TASK *task,
+ssize_t rt_task_send_timed(RT_TASK *task,
                           RT_TASK_MCB *mcb_s, RT_TASK_MCB *mcb_r,
-                          RTIME timeout)
+                          const struct timespec *abs_timeout)
 {
        struct alchemy_task_wait *wait;
-       struct timespec ts, *timespec;
        struct threadobj *current;
        struct alchemy_task *tcb;
        struct syncstate syns;
@@ -733,12 +732,12 @@ ssize_t rt_task_send_until(RT_TASK *task,
 
        put_alchemy_task(tcb);
 
-       if (timeout == TM_NONBLOCK) {
+       if (alchemy_poll_mode(abs_timeout)) {
                if (!syncobj_drain_count(&tcb->sobj_msg)) {
                        ret = -EWOULDBLOCK;
                        goto done;
                }
-               timeout = TM_INFINITE;
+               abs_timeout = NULL;
        }
 
        /* Get space for the reply. */
@@ -764,9 +763,7 @@ ssize_t rt_task_send_until(RT_TASK *task,
        if (syncobj_drain_count(&tcb->sobj_msg))
                syncobj_signal_drain(&tcb->sobj_msg);
 
-       timespec = alchemy_get_timespec(timeout, &ts);
-
-       ret = syncobj_pend(&tcb->sobj_msg, timespec, &syns);
+       ret = syncobj_pend(&tcb->sobj_msg, abs_timeout, &syns);
        if (ret) {
                threadobj_finish_wait();
                if (ret == -EIDRM)
@@ -784,18 +781,10 @@ out:
        return ret;
 }
 
-ssize_t rt_task_send(RT_TASK *task,
-                    RT_TASK_MCB *mcb_s, RT_TASK_MCB *mcb_r,
-                    RTIME timeout)
-{
-       timeout = alchemy_rel2abs_timeout(timeout);
-       return rt_task_send_until(task, mcb_s, mcb_r, timeout);
-}
-
-int rt_task_receive_until(RT_TASK_MCB *mcb_r, RTIME timeout)
+int rt_task_receive_timed(RT_TASK_MCB *mcb_r,
+                         const struct timespec *abs_timeout)
 {
        struct alchemy_task_wait *wait;
-       struct timespec ts, *timespec;
        struct alchemy_task *current;
        struct threadobj *thobj;
        struct syncstate syns;
@@ -812,12 +801,11 @@ int rt_task_receive_until(RT_TASK_MCB *mcb_r, RTIME 
timeout)
        syncobj_lock(&current->sobj_msg, &syns);
 
        while (!syncobj_pended_p(&current->sobj_msg)) {
-               if (timeout == TM_NONBLOCK) {
+               if (alchemy_poll_mode(abs_timeout)) {
                        ret = -EWOULDBLOCK;
                        goto done;
                }
-               timespec = alchemy_get_timespec(timeout, &ts);
-               syncobj_wait_drain(&current->sobj_msg, timespec, &syns);
+               syncobj_wait_drain(&current->sobj_msg, abs_timeout, &syns);
        }
 
        thobj = syncobj_peek_at_pend(&current->sobj_msg);
@@ -845,12 +833,6 @@ done:
        return ret;
 }
 
-int rt_task_receive(RT_TASK_MCB *mcb_r, RTIME timeout)
-{
-       timeout = alchemy_rel2abs_timeout(timeout);
-       return rt_task_receive_until(mcb_r, timeout);
-}
-
 int rt_task_reply(int flowid, RT_TASK_MCB *mcb_s)
 {
        struct alchemy_task_wait *wait = NULL;
diff --git a/lib/alchemy/timer.h b/lib/alchemy/timer.h
index 2e61d7d..cb0285f 100644
--- a/lib/alchemy/timer.h
+++ b/lib/alchemy/timer.h
@@ -22,6 +22,4 @@
 #include <copperplate/clockobj.h>
 #include <alchemy/timer.h>
 
-extern struct clockobj alchemy_clock;
-
 #endif /* _ALCHEMY_TIMER_H */


_______________________________________________
Xenomai-git mailing list
Xenomai-git@gna.org
https://mail.gna.org/listinfo/xenomai-git

Reply via email to