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

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

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

---

 kernel/cobalt/posix/monitor.c |   35 ++++++++++++++++++++++++-----------
 kernel/cobalt/posix/monitor.h |    4 ++++
 2 files changed, 28 insertions(+), 11 deletions(-)

diff --git a/kernel/cobalt/posix/monitor.c b/kernel/cobalt/posix/monitor.c
index 9572c3b..fa05477 100644
--- a/kernel/cobalt/posix/monitor.c
+++ b/kernel/cobalt/posix/monitor.c
@@ -224,10 +224,9 @@ drain:
                datp->flags &= ~COBALT_MONITOR_PENDED;
 }
 
-COBALT_SYSCALL(monitor_wait, nonrestartable,
-              int, (struct cobalt_monitor_shadow __user *u_mon,
-                    int event, const struct timespec __user *u_ts,
-                    int __user *u_ret))
+int __cobalt_monitor_wait(struct cobalt_monitor_shadow __user *u_mon,
+                         int event, const struct timespec *ts,
+                         int __user *u_ret)
 {
        struct cobalt_thread *curr = cobalt_current_thread();
        struct cobalt_monitor_data *datp;
@@ -235,18 +234,14 @@ COBALT_SYSCALL(monitor_wait, nonrestartable,
        int ret = 0, opret = 0, info;
        struct cobalt_monitor *mon;
        struct xnsynch *synch;
-       struct timespec ts;
        xnhandle_t handle;
        xntmode_t tmode;
        spl_t s;
 
        handle = cobalt_get_handle_from_user(&u_mon->handle);
 
-       if (u_ts) {
-               if (__xn_safe_copy_from_user(&ts, u_ts, sizeof(ts)))
-                       return -EFAULT;
-               timeout = ts2ns(&ts) + 1;
-       }
+       if (ts)
+               timeout = ts2ns(ts) + 1;
 
        xnlock_get_irqsave(&nklock, s);
 
@@ -277,7 +272,7 @@ COBALT_SYSCALL(monitor_wait, nonrestartable,
        }
        datp->flags |= COBALT_MONITOR_PENDED;
 
-       tmode = u_ts ? mon->tmode : XN_RELATIVE;
+       tmode = ts ? mon->tmode : XN_RELATIVE;
        info = xnsynch_sleep_on(synch, timeout, tmode);
        if (info) {
                if ((event & COBALT_MONITOR_WAITDRAIN) == 0 &&
@@ -304,6 +299,24 @@ out:
        return ret;
 }
 
+COBALT_SYSCALL(monitor_wait, nonrestartable,
+              int, (struct cobalt_monitor_shadow __user *u_mon,
+                    int event, const struct timespec __user *u_ts,
+                    int __user *u_ret))
+{
+       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_monitor_wait(u_mon, event, tsp, u_ret);
+}
+
 COBALT_SYSCALL(monitor_sync, nonrestartable,
               int, (struct cobalt_monitor_shadow __user *u_mon))
 {
diff --git a/kernel/cobalt/posix/monitor.h b/kernel/cobalt/posix/monitor.h
index 1519abf..ff84acf 100644
--- a/kernel/cobalt/posix/monitor.h
+++ b/kernel/cobalt/posix/monitor.h
@@ -38,6 +38,10 @@ struct cobalt_monitor {
        xnhandle_t handle;
 };
 
+int __cobalt_monitor_wait(struct cobalt_monitor_shadow __user *u_mon,
+                         int event, const struct timespec *ts,
+                         int __user *u_ret);
+
 COBALT_SYSCALL_DECL(monitor_init,
                    int, (struct cobalt_monitor_shadow __user *u_monsh,
                          clockid_t clk_id,


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

Reply via email to