Module: xenomai-3
Branch: stable-3.0.x
Commit: 6bbe209033f8dde34df107329622a6bc77808d3c
URL:    
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=6bbe209033f8dde34df107329622a6bc77808d3c

Author: Philippe Gerum <r...@xenomai.org>
Date:   Fri Nov  4 16:25:21 2016 +0100

cobalt/posix/timerfd: allow usage with external clocks

Same as e6cd961.

---

 include/cobalt/kernel/timer.h |    2 +-
 kernel/cobalt/posix/timerfd.c |    8 +++++---
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/include/cobalt/kernel/timer.h b/include/cobalt/kernel/timer.h
index f45a753..d92c8c8 100644
--- a/include/cobalt/kernel/timer.h
+++ b/include/cobalt/kernel/timer.h
@@ -163,7 +163,7 @@ typedef struct {
        })
 
 #define xntimerq_destroy(q) do { } while (0)
-#define xntimerq_empty(q) ((q)->head != NULL)
+#define xntimerq_empty(q) ((q)->head == NULL)
 
 #define xntimerq_head(q) ((q)->head)
 
diff --git a/kernel/cobalt/posix/timerfd.c b/kernel/cobalt/posix/timerfd.c
index 90c4b3f..132aba8 100644
--- a/kernel/cobalt/posix/timerfd.c
+++ b/kernel/cobalt/posix/timerfd.c
@@ -166,12 +166,14 @@ COBALT_SYSCALL(timerfd_create, lostage, (int clockid, int 
flags))
 {
        struct cobalt_tfd *tfd;
        struct xnthread *curr;
+       struct xnclock *clock;
        int ret, ufd;
 
-       if (clockid != CLOCK_REALTIME && clockid != CLOCK_MONOTONIC)
+       if (flags & ~TFD_CREATE_FLAGS)
                return -EINVAL;
 
-       if (flags & ~TFD_CREATE_FLAGS)
+       clock = cobalt_clock_find(clockid);
+       if (clock == NULL)
                return -EINVAL;
 
        tfd = xnmalloc(sizeof(*tfd));
@@ -189,7 +191,7 @@ COBALT_SYSCALL(timerfd_create, lostage, (int clockid, int 
flags))
        tfd->fd.oflags = (flags & TFD_NONBLOCK) ? O_NONBLOCK : 0;
        tfd->clockid = clockid;
        curr = xnthread_current();
-       xntimer_init(&tfd->timer, &nkclock, timerfd_handler,
+       xntimer_init(&tfd->timer, clock, timerfd_handler,
                     curr ? curr->sched : NULL, XNTIMER_UGRAVITY);
        xnsynch_init(&tfd->readers, XNSYNCH_PRIO | XNSYNCH_NOPIP, NULL);
        xnselect_init(&tfd->read_select);


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

Reply via email to