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

Author: Philippe Gerum <r...@xenomai.org>
Date:   Thu Oct 16 14:38:03 2014 +0200

cobalt/posix/event: prepare for 32bit syscall emulation

---

 kernel/cobalt/posix/event.c |   37 ++++++++++++++++++++++++++-----------
 kernel/cobalt/posix/event.h |    7 ++++++-
 2 files changed, 32 insertions(+), 12 deletions(-)

diff --git a/kernel/cobalt/posix/event.c b/kernel/cobalt/posix/event.c
index d7d564d..0d0594e 100644
--- a/kernel/cobalt/posix/event.c
+++ b/kernel/cobalt/posix/event.c
@@ -105,11 +105,10 @@ COBALT_SYSCALL(event_init, current,
        return __xn_safe_copy_to_user(u_event, &shadow, sizeof(*u_event));
 }
 
-COBALT_SYSCALL(event_wait, primary,
-              int, (struct cobalt_event_shadow __user *u_event,
-                    unsigned int bits,
-                    unsigned int __user *u_bits_r,
-                    int mode, struct timespec __user *u_ts))
+int __cobalt_event_wait(struct cobalt_event_shadow __user *u_event,
+                       unsigned int bits,
+                       unsigned int __user *u_bits_r,
+                       int mode, const struct timespec *ts)
 {
        unsigned int rbits = 0, testval;
        xnticks_t timeout = XN_INFINITE;
@@ -117,23 +116,20 @@ COBALT_SYSCALL(event_wait, primary,
        xntmode_t tmode = XN_RELATIVE;
        struct event_wait_context ewc;
        struct cobalt_event *event;
-       struct timespec ts;
        xnhandle_t handle;
        int ret = 0, info;
        spl_t s;
 
        handle = cobalt_get_handle_from_user(&u_event->handle);
 
-       if (u_ts) {
-               if (__xn_safe_copy_from_user(&ts, u_ts, sizeof(ts)))
-                       return -EFAULT;
-               timeout = ts2ns(&ts);
+       if (ts) {
+               timeout = ts2ns(ts);
                if (timeout) {
                        timeout++;
                        tmode = XN_ABSOLUTE;
                } else
                        timeout = XN_NONBLOCK;
-               trace_cobalt_event_timedwait(u_event, bits, mode, &ts);
+               trace_cobalt_event_timedwait(u_event, bits, mode, ts);
        } else
                trace_cobalt_event_wait(u_event, bits, mode);
 
@@ -194,6 +190,25 @@ out:
        return ret;
 }
 
+COBALT_SYSCALL(event_wait, primary,
+              int, (struct cobalt_event_shadow __user *u_event,
+                    unsigned int bits,
+                    unsigned int __user *u_bits_r,
+                    int mode, const struct timespec __user *u_ts))
+{
+       struct timespec ts, *tsp = NULL;
+       int ret;
+
+       if (u_ts) {
+               tsp = &ts;
+               ret = __xn_safe_copy_from_user(&ts, u_ts, sizeof(ts));
+               if (ret)
+                       return ret;
+       }
+
+       return __cobalt_event_wait(u_event, bits, u_bits_r, mode, tsp);
+}
+
 COBALT_SYSCALL(event_sync, current,
               int, (struct cobalt_event_shadow __user *u_event))
 {
diff --git a/kernel/cobalt/posix/event.h b/kernel/cobalt/posix/event.h
index 9341800..6dd9f79 100644
--- a/kernel/cobalt/posix/event.h
+++ b/kernel/cobalt/posix/event.h
@@ -36,6 +36,11 @@ struct cobalt_event {
        xnhandle_t handle;
 };
 
+int __cobalt_event_wait(struct cobalt_event_shadow __user *u_event,
+                       unsigned int bits,
+                       unsigned int __user *u_bits_r,
+                       int mode, const struct timespec *ts);
+
 COBALT_SYSCALL_DECL(event_init,
                    int, (struct cobalt_event_shadow __user *u_evtsh,
                          unsigned int value,
@@ -46,7 +51,7 @@ COBALT_SYSCALL_DECL(event_wait,
                          unsigned int bits,
                          unsigned int __user *u_bits_r,
                          int mode,
-                         struct timespec __user *u_ts));
+                         const struct timespec __user *u_ts));
 
 COBALT_SYSCALL_DECL(event_sync,
                    int, (struct cobalt_event_shadow __user *u_evtsh));


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

Reply via email to