[Xenomai-git] Gilles Chanteperdrix : lib/cobalt: wrap time and gettimeofday calls

2014-10-28 Thread git repository hosting
Module: xenomai-gch
Branch: for-forge
Commit: f1af3ef972088fcedc931b73c49d3a9ae00a4d2f
URL:
http://git.xenomai.org/?p=xenomai-gch.git;a=commit;h=f1af3ef972088fcedc931b73c49d3a9ae00a4d2f

Author: Gilles Chanteperdrix gilles.chanteperd...@xenomai.org
Date:   Sat Sep 20 23:06:02 2014 +0200

lib/cobalt: wrap time and gettimeofday calls

---

 include/cobalt/time.h   |2 ++
 lib/cobalt/assert_context.c |7 ---
 lib/cobalt/clock.c  |   23 +++
 lib/cobalt/cobalt.wrappers  |1 +
 4 files changed, 26 insertions(+), 7 deletions(-)

diff --git a/include/cobalt/time.h b/include/cobalt/time.h
index c5d7412..fed8957 100644
--- a/include/cobalt/time.h
+++ b/include/cobalt/time.h
@@ -44,6 +44,8 @@ COBALT_DECL(int, clock_nanosleep(clockid_t clock_id,
 const struct timespec *rqtp,
 struct timespec *rmtp));
 
+COBALT_DECL(time_t, time(time_t *t));
+
 COBALT_DECL(int, nanosleep(const struct timespec *rqtp,
   struct timespec *rmtp));
 
diff --git a/lib/cobalt/assert_context.c b/lib/cobalt/assert_context.c
index 6b49f3d..48690dc 100644
--- a/lib/cobalt/assert_context.c
+++ b/lib/cobalt/assert_context.c
@@ -75,10 +75,3 @@ COBALT_IMPL(void, free, (void *ptr))
assert_nrt();
__STD(free(ptr));
 }
-
-/* vsyscall-based services */
-COBALT_IMPL(int, gettimeofday, (struct timeval *tv, struct timezone *tz))
-{
-   assert_nrt();
-   return __STD(gettimeofday(tv, tz));
-}
diff --git a/lib/cobalt/clock.c b/lib/cobalt/clock.c
index b31517f..d17ea56 100644
--- a/lib/cobalt/clock.c
+++ b/lib/cobalt/clock.c
@@ -25,6 +25,7 @@
 #include pthread.h
 #include unistd.h
 #include time.h
+#include sys/time.h
 #include cobalt/uapi/time.h
 #include cobalt/ticks.h
 #include asm/xenomai/syscall.h
@@ -356,4 +357,26 @@ COBALT_IMPL(unsigned int, sleep, (unsigned int seconds))
return 0;
 }
 
+COBALT_IMPL(int, gettimeofday, (struct timeval *tv, struct timezone *tz))
+{
+   struct timespec ts;
+   int ret = __WRAP(clock_gettime(CLOCK_REALTIME, ts));
+   if (ret == 0) {
+   tv-tv_sec = ts.tv_sec;
+   tv-tv_usec = ts.tv_nsec / 1000;
+   }
+   return ret;
+}
+
+COBALT_IMPL(time_t, time, (time_t *t))
+{
+   struct timespec ts;
+   int ret = __WRAP(clock_gettime(CLOCK_REALTIME, ts));
+   if (ret)
+   return (time_t)-1;
+
+   if (t)
+   *t = ts.tv_sec;
+   return ts.tv_sec;
+}
 /** @} */
diff --git a/lib/cobalt/cobalt.wrappers b/lib/cobalt/cobalt.wrappers
index 10cb36a..329ff3b 100644
--- a/lib/cobalt/cobalt.wrappers
+++ b/lib/cobalt/cobalt.wrappers
@@ -104,3 +104,4 @@
 --wrap kill
 --wrap sleep
 --wrap mmap
+--wrap time


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


[Xenomai-git] Gilles Chanteperdrix : cobalt/rtdm: add fcntl syscall

2014-10-28 Thread git repository hosting
Module: xenomai-gch
Branch: for-forge
Commit: 4fb6e99253b29aa86f08a44f4a6af361248da6ae
URL:
http://git.xenomai.org/?p=xenomai-gch.git;a=commit;h=4fb6e99253b29aa86f08a44f4a6af361248da6ae

Author: Gilles Chanteperdrix gilles.chanteperd...@xenomai.org
Date:   Sat Oct 25 21:11:16 2014 +0200

cobalt/rtdm: add fcntl syscall

---

 include/cobalt/fcntl.h|2 +
 include/cobalt/kernel/rtdm/fd.h   |2 +
 include/cobalt/kernel/rtdm/rtdm.h |3 +
 include/cobalt/uapi/syscall.h |  133 +++--
 kernel/cobalt/posix/io.c  |6 ++
 kernel/cobalt/posix/io.h  |2 +
 kernel/cobalt/posix/syscall.c |   10 +--
 kernel/cobalt/rtdm/fd.c   |   42 +++-
 lib/cobalt/cobalt.wrappers|1 +
 lib/cobalt/rtdm.c |   18 +
 lib/cobalt/wrappers.c |   13 
 11 files changed, 159 insertions(+), 73 deletions(-)

diff --git a/include/cobalt/fcntl.h b/include/cobalt/fcntl.h
index ed96dd7..2a83a7a 100644
--- a/include/cobalt/fcntl.h
+++ b/include/cobalt/fcntl.h
@@ -29,6 +29,8 @@ extern C {
 
 COBALT_DECL(int, open(const char *path, int oflag, ...));
 
+COBALT_DECL(int, fcntl(int fd, int cmd, ...));
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/include/cobalt/kernel/rtdm/fd.h b/include/cobalt/kernel/rtdm/fd.h
index ccf0332..5685b3a 100644
--- a/include/cobalt/kernel/rtdm/fd.h
+++ b/include/cobalt/kernel/rtdm/fd.h
@@ -353,6 +353,8 @@ void rtdm_fd_put(struct rtdm_fd *fd);
 
 void rtdm_fd_unlock(struct rtdm_fd *fd);
 
+int rtdm_fd_fcntl(int ufd, int cmd, ...);
+
 int rtdm_fd_ioctl(int ufd, unsigned int request, ...);
 
 ssize_t rtdm_fd_read(int ufd, void __user *buf, size_t size);
diff --git a/include/cobalt/kernel/rtdm/rtdm.h 
b/include/cobalt/kernel/rtdm/rtdm.h
index db1e270..2b1c8fd 100644
--- a/include/cobalt/kernel/rtdm/rtdm.h
+++ b/include/cobalt/kernel/rtdm/rtdm.h
@@ -50,6 +50,9 @@ int __rtdm_dev_socket(int protocol_family,
 #define rt_dev_close(fd)   \
rtdm_fd_close(fd, RTDM_FD_MAGIC)
 
+#define rt_dev_fcntl(fd, cmd, ...) \
+   rtdm_fd_fcntl(fd,cmd, __VA_ARGS__)
+
 #define rt_dev_ioctl(fd, request, ...) \
rtdm_fd_ioctl(fd, request, __VA_ARGS__)
 
diff --git a/include/cobalt/uapi/syscall.h b/include/cobalt/uapi/syscall.h
index aa364a1..025d2ff 100644
--- a/include/cobalt/uapi/syscall.h
+++ b/include/cobalt/uapi/syscall.h
@@ -21,63 +21,63 @@
 #include cobalt/uapi/asm-generic/syscall.h
 
 #define sc_cobalt_bind 0
-#define sc_cobalt_thread_create1
-#define sc_cobalt_thread_getpid2
-#define sc_cobalt_thread_setmode   3
-#define sc_cobalt_thread_setname   4
-#define sc_cobalt_thread_join  5
-#define sc_cobalt_thread_kill  6
+#define sc_cobalt_thread_create1
+#define sc_cobalt_thread_getpid2
+#define sc_cobalt_thread_setmode   3
+#define sc_cobalt_thread_setname   4
+#define sc_cobalt_thread_join  5
+#define sc_cobalt_thread_kill  6
 #define sc_cobalt_thread_setschedparam_ex  7
 #define sc_cobalt_thread_getschedparam_ex  8
-#define sc_cobalt_thread_getstat   9
+#define sc_cobalt_thread_getstat   9
 /* 10 unimp */
-#define sc_cobalt_sem_init 11
-#define sc_cobalt_sem_destroy  12
-#define sc_cobalt_sem_post 13
-#define sc_cobalt_sem_wait 14
-#define sc_cobalt_sem_trywait  15
-#define sc_cobalt_sem_getvalue 16
-#define sc_cobalt_sem_open 17
-#define sc_cobalt_sem_close18
-#define sc_cobalt_sem_unlink   19
-#define sc_cobalt_sem_timedwait20
-#define sc_cobalt_sem_inquire  21
+#define sc_cobalt_sem_init 11
+#define sc_cobalt_sem_destroy  12
+#define sc_cobalt_sem_post 13
+#define sc_cobalt_sem_wait 14
+#define sc_cobalt_sem_trywait  15
+#define sc_cobalt_sem_getvalue 16
+#define sc_cobalt_sem_open 17
+#define sc_cobalt_sem_close18
+#define sc_cobalt_sem_unlink   19
+#define sc_cobalt_sem_timedwait20
+#define sc_cobalt_sem_inquire  21
 /* 22 unimp */
-#define sc_cobalt_sem_broadcast_np 23
-#define sc_cobalt_clock_getres 24
-#define sc_cobalt_clock_gettime25
-#define sc_cobalt_clock_settime26
-#define sc_cobalt_clock_nanosleep  27
-#define sc_cobalt_mutex_init   28
-#define sc_cobalt_mutex_check_init 29
-#define sc_cobalt_mutex_destroy30
-#define 

[Xenomai-git] Gilles Chanteperdrix : cobalt/spinlocks: rebase on linux spinlocks

2014-10-28 Thread git repository hosting
Module: xenomai-gch
Branch: for-forge
Commit: e58faf9f814fff05633b6178597655ef05d2e22e
URL:
http://git.xenomai.org/?p=xenomai-gch.git;a=commit;h=e58faf9f814fff05633b6178597655ef05d2e22e

Author: Gilles Chanteperdrix gilles.chanteperd...@xenomai.org
Date:   Sun Oct 19 21:43:37 2014 +0200

cobalt/spinlocks: rebase on linux spinlocks

---

 include/cobalt/kernel/lock.h |   35 ++-
 kernel/cobalt/debug.c|2 +-
 kernel/cobalt/lock.c |   15 ---
 3 files changed, 19 insertions(+), 33 deletions(-)

diff --git a/include/cobalt/kernel/lock.h b/include/cobalt/kernel/lock.h
index b0c34bf..e590b85 100644
--- a/include/cobalt/kernel/lock.h
+++ b/include/cobalt/kernel/lock.h
@@ -66,7 +66,8 @@ typedef unsigned long spl_t;
 #if XENO_DEBUG(LOCKING)
 
 struct xnlock {
-   atomic_t owner;
+   unsigned owner;
+   arch_spinlock_t alock;
const char *file;
const char *function;
unsigned int line;
@@ -84,7 +85,8 @@ struct xnlockinfo {
 };
 
 #define XNARCH_LOCK_UNLOCKED (struct xnlock) { \
-   { ~0 }, \
+   ~0, \
+   __ARCH_SPIN_LOCK_UNLOCKED,  \
NULL,   \
NULL,   \
0,  \
@@ -117,10 +119,15 @@ DECLARE_PER_CPU(struct xnlockinfo, xnlock_stats);
 #else /* !XENO_DEBUG(LOCKING) */
 
 struct xnlock {
-   atomic_t owner;
+   unsigned owner;
+   arch_spinlock_t alock;
 };
 
-#define XNARCH_LOCK_UNLOCKED   (struct xnlock) { { ~0 } }
+#define XNARCH_LOCK_UNLOCKED   \
+   (struct xnlock) {   \
+   ~0, \
+   __ARCH_SPIN_LOCK_UNLOCKED,  \
+   }
 
 #define XNLOCK_DBG_CONTEXT
 #define XNLOCK_DBG_CONTEXT_ARGS
@@ -175,20 +182,18 @@ static inline void xnlock_init (struct xnlock *lock)
 #define DEFINE_XNLOCK(lock)struct xnlock lock = 
XNARCH_LOCK_UNLOCKED
 #define DEFINE_PRIVATE_XNLOCK(lock)static DEFINE_XNLOCK(lock)
 
-void __xnlock_spin(int cpu, struct xnlock *lock /*, */ 
XNLOCK_DBG_CONTEXT_ARGS);
-
 static inline int xnlock_get(struct xnlock *lock /*, */ 
XNLOCK_DBG_CONTEXT_ARGS)
 {
int cpu = ipipe_processor_id();
unsigned long long start;
 
-   if (atomic_read(lock-owner) == cpu)
+   if (lock-owner == cpu)
return 2;
 
xnlock_dbg_prepare_acquire(start);
 
-   if (unlikely(atomic_cmpxchg(lock-owner, ~0, cpu) != ~0))
-   __xnlock_spin(cpu, lock /*, */ XNLOCK_DBG_PASS_CONTEXT);
+   arch_spin_lock(lock-alock);
+   lock-owner = cpu;
 
xnlock_dbg_acquired(lock, cpu, start /*, */ XNLOCK_DBG_PASS_CONTEXT);
 
@@ -200,12 +205,8 @@ static inline void xnlock_put(struct xnlock *lock /*, 
*/ XNLOCK_DBG_CONTEXT_
if (xnlock_dbg_release(lock /*, */ XNLOCK_DBG_PASS_CONTEXT))
return;
 
-   /*
-* Make sure all data written inside the lock is visible to
-* other CPUs before we release the lock.
-*/
-   mb();
-   atomic_set(lock-owner, ~0);
+   lock-owner = ~0U;
+   arch_spin_unlock(lock-alock);
 }
 
 #ifndef CONFIG_XENO_ARCH_OUTOFLINE_XNLOCK
@@ -250,7 +251,7 @@ static inline void __xnlock_put_irqrestore(struct xnlock 
*lock, spl_t flags
 static inline int xnlock_is_owner(struct xnlock *lock)
 {
if (__locking_active__)
-   return atomic_read(lock-owner) == ipipe_processor_id();
+   return lock-owner == ipipe_processor_id();
 
return 1;
 }
@@ -266,7 +267,7 @@ static inline int __xnlock_get(struct xnlock *lock /*, */ 
XNLOCK_DBG_CONTEXT_ARG
 static inline void __xnlock_put(struct xnlock *lock /*, */ 
XNLOCK_DBG_CONTEXT_ARGS)
 {
if (__locking_active__)
-   ___xnlock_put(lock /*, */ XNLOCK_DBG_PASS_CONTEXT); 
+   ___xnlock_put(lock /*, */ XNLOCK_DBG_PASS_CONTEXT);
 }
 
 #undef __locking_active__
diff --git a/kernel/cobalt/debug.c b/kernel/cobalt/debug.c
index ad72a3e..ef46e0b 100644
--- a/kernel/cobalt/debug.c
+++ b/kernel/cobalt/debug.c
@@ -598,7 +598,7 @@ int xnlock_dbg_release(struct xnlock *lock,
lock-function = invalid;
}
 
-   if (unlikely(atomic_read(lock-owner) != cpu)) {
+   if (unlikely(lock-owner != cpu)) {
ipipe_prepare_panic();
printk(XENO_ERR lock %p already unlocked on CPU #%d\n
  last owner = %s:%u (%s(), CPU 
#%d)\n,
diff --git a/kernel/cobalt/lock.c b/kernel/cobalt/lock.c
index 5c339b5..a1b2e37 100644
--- a/kernel/cobalt/lock.c
+++ b/kernel/cobalt/lock.c
@@ -42,21 +42,6 @@ DEFINE_XNLOCK(nklock);
 #if defined(CONFIG_SMP) || XENO_DEBUG(LOCKING)
 EXPORT_SYMBOL_GPL(nklock);
 
-void __xnlock_spin(int cpu, struct xnlock *lock /*, */ XNLOCK_DBG_CONTEXT_ARGS)
-{
-   unsigned int 

[Xenomai-git] Gilles Chanteperdrix : cobalt/mqueue: use rtdm fd flags

2014-10-28 Thread git repository hosting
Module: xenomai-gch
Branch: for-forge
Commit: 091b20ab67377f65b589e9a7648554b102d4f154
URL:
http://git.xenomai.org/?p=xenomai-gch.git;a=commit;h=091b20ab67377f65b589e9a7648554b102d4f154

Author: Gilles Chanteperdrix gilles.chanteperd...@xenomai.org
Date:   Sat Oct 25 21:52:07 2014 +0200

cobalt/mqueue: use rtdm fd flags

---

 include/cobalt/uapi/syscall.h |2 +-
 kernel/cobalt/posix/mqueue.c  |   79 +
 kernel/cobalt/posix/syscall.c |2 --
 lib/cobalt/mq.c   |   19 --
 4 files changed, 27 insertions(+), 75 deletions(-)

diff --git a/include/cobalt/uapi/syscall.h b/include/cobalt/uapi/syscall.h
index 025d2ff..0f74f37 100644
--- a/include/cobalt/uapi/syscall.h
+++ b/include/cobalt/uapi/syscall.h
@@ -63,7 +63,7 @@
 #define sc_cobalt_mq_close 40
 #define sc_cobalt_mq_unlink41
 #define sc_cobalt_mq_getattr   42
-#define sc_cobalt_mq_setattr   43
+/* 43 unimp */
 #define sc_cobalt_mq_timedsend 44
 #define sc_cobalt_mq_timedreceive  45
 #define sc_cobalt_mq_notify46
diff --git a/kernel/cobalt/posix/mqueue.c b/kernel/cobalt/posix/mqueue.c
index f5a69f9..5d17ec7 100644
--- a/kernel/cobalt/posix/mqueue.c
+++ b/kernel/cobalt/posix/mqueue.c
@@ -31,7 +31,7 @@
 
 #define COBALT_MSGMAX  65536
 #define COBALT_MSGSIZEMAX  (16*1024*1024)
-#define COBALT_MSGPRIOMAX  32768
+#define COBALT_MSGPRIOMAX  32768
 
 struct cobalt_mq {
unsigned magic;
@@ -62,7 +62,6 @@ struct cobalt_mq {
 };
 
 struct cobalt_mqd {
-   long flags;
struct cobalt_mq *mq;
struct rtdm_fd fd;
 };
@@ -228,7 +227,7 @@ mqd_select(struct rtdm_fd *fd, struct xnselector *selector,
switch(type) {
case XNSELECT_READ:
err = -EBADF;
-   if ((mqd-flags  COBALT_PERMS_MASK) == O_WRONLY)
+   if ((rtdm_fd_flags(fd)  COBALT_PERMS_MASK) == O_WRONLY)
goto unlock_and_error;
 
err = xnselect_bind(mq-read_select, binding,
@@ -240,7 +239,7 @@ mqd_select(struct rtdm_fd *fd, struct xnselector *selector,
 
case XNSELECT_WRITE:
err = -EBADF;
-   if ((mqd-flags  COBALT_PERMS_MASK) == O_RDONLY)
+   if ((rtdm_fd_flags(fd)  COBALT_PERMS_MASK) == O_RDONLY)
goto unlock_and_error;
 
err = xnselect_bind(mq-write_select, binding,
@@ -275,7 +274,7 @@ static inline int mqd_create(struct cobalt_mq *mq, unsigned 
long flags, int ufd)
if (mqd == NULL)
return -ENOSPC;
 
-   mqd-flags = flags;
+   mqd-fd.oflags = flags;
mqd-mq = mq;
 
return rtdm_fd_enter(mqd-fd, ufd, COBALT_MQD_MAGIC, mqd_ops);
@@ -416,7 +415,7 @@ mq_trysend(struct cobalt_mqd *mqd, size_t len)
unsigned flags;
 
mq = mqd-mq;
-   flags = mqd-flags  COBALT_PERMS_MASK;
+   flags = rtdm_fd_flags(mqd-fd)  COBALT_PERMS_MASK;
 
if (flags != O_WRONLY  flags != O_RDWR)
return ERR_PTR(-EBADF);
@@ -442,7 +441,7 @@ mq_tryrcv(struct cobalt_mqd *mqd, size_t len)
struct cobalt_mq *mq;
 
mq = mqd-mq;
-   flags = mqd-flags  COBALT_PERMS_MASK;
+   flags = rtdm_fd_flags(mqd-fd)  COBALT_PERMS_MASK;
 
if (flags != O_RDONLY  flags != O_RDWR)
return ERR_PTR(-EBADF);
@@ -485,7 +484,7 @@ redo:
if (msg != ERR_PTR(-EAGAIN))
goto out;
 
-   if (mqd-flags  O_NONBLOCK)
+   if (rtdm_fd_flags(mqd-fd)  O_NONBLOCK)
goto out;
 
if (fetch_timeout) {
@@ -614,7 +613,7 @@ redo:
if (msg != ERR_PTR(-EAGAIN))
goto out;
 
-   if (mqd-flags  O_NONBLOCK)
+   if (rtdm_fd_flags(mqd-fd)  O_NONBLOCK)
goto out;
 
if (fetch_timeout) {
@@ -668,36 +667,13 @@ static inline int mq_getattr(struct cobalt_mqd *mqd, 
struct mq_attr *attr)
mq = mqd-mq;
*attr = mq-attr;
xnlock_get_irqsave(nklock, s);
-   attr-mq_flags = mqd-flags;
+   attr-mq_flags = rtdm_fd_flags(mqd-fd);
attr-mq_curmsgs = mq-nrqueued;
xnlock_put_irqrestore(nklock, s);
 
return 0;
 }
 
-static inline int mq_setattr(struct cobalt_mqd *mqd,
-const struct mq_attr *__restrict__ attr,
-struct mq_attr *__restrict__ oattr)
-{
-   struct cobalt_mq *mq;
-   long flags;
-   spl_t s;
-
-   xnlock_get_irqsave(nklock, s);
-   mq = mqd-mq;
-   if (oattr) {
-   *oattr = mq-attr;
-   oattr-mq_flags = mqd-flags;
-   oattr-mq_curmsgs = mq-nrqueued;
-   }
-   flags = (mqd-flags  COBALT_PERMS_MASK)
-   | (attr-mq_flags  ~COBALT_PERMS_MASK);
-   mqd-flags = flags;
-   xnlock_put_irqrestore(nklock, s);
-
-   return 0;
-}
-
 static inline int
 mq_notify(struct cobalt_mqd *mqd, 

[Xenomai-git] Philippe Gerum : alchemy/pipe: add missing wrapping to Cobalt

2014-10-28 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: c683a8bb9d469c67eafdf76f8403abfc918d3531
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=c683a8bb9d469c67eafdf76f8403abfc918d3531

Author: Philippe Gerum r...@xenomai.org
Date:   Tue Oct 28 11:06:26 2014 +0100

alchemy/pipe: add missing wrapping to Cobalt

---

 lib/alchemy/pipe.c |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/alchemy/pipe.c b/lib/alchemy/pipe.c
index 93da9be..439a00f 100644
--- a/lib/alchemy/pipe.c
+++ b/lib/alchemy/pipe.c
@@ -166,8 +166,8 @@ int rt_pipe_create(RT_PIPE *pipe,
}
 
if (poolsize  0) {
-   ret = setsockopt(pcb-sock, SOL_XDDP, XDDP_POOLSZ,
-poolsize, sizeof(poolsize));
+   ret = __RT(setsockopt(pcb-sock, SOL_XDDP, XDDP_POOLSZ,
+ poolsize, sizeof(poolsize)));
if (ret)
goto fail_sockopt;
}
@@ -181,7 +181,7 @@ int rt_pipe_create(RT_PIPE *pipe,
memset(saddr, 0, sizeof(saddr));
saddr.sipc_family = AF_RTIPC;
saddr.sipc_port = minor;
-   ret = bind(sock, (struct sockaddr *)saddr, sizeof(saddr));
+   ret = __RT(bind(sock, (struct sockaddr *)saddr, sizeof(saddr)));
if (ret)
goto fail_sockopt;
 


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


[Xenomai-git] Philippe Gerum : cobalt/posix/compat: fix sys32_put_sigset() helper

2014-10-28 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 37374676e81988e6dffb52cfb96ebcbe24560006
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=37374676e81988e6dffb52cfb96ebcbe24560006

Author: Philippe Gerum r...@xenomai.org
Date:   Tue Oct 28 11:50:03 2014 +0100

cobalt/posix/compat: fix sys32_put_sigset() helper

---

 kernel/cobalt/posix/compat.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/cobalt/posix/compat.c b/kernel/cobalt/posix/compat.c
index de2143a..e0f9609 100644
--- a/kernel/cobalt/posix/compat.c
+++ b/kernel/cobalt/posix/compat.c
@@ -273,7 +273,7 @@ int sys32_put_sigset(compat_sigset_t *u_cset, const 
sigset_t *set)
 
sigset_to_compat(cset, set);
 
-   return __xn_safe_copy_from_user(u_cset, cset, sizeof(cset));
+   return __xn_safe_copy_to_user(u_cset, cset, sizeof(cset));
 }
 EXPORT_SYMBOL_GPL(sys32_put_sigset);
 


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


[Xenomai-git] Philippe Gerum : cobalt/posix/compat: fix sys32_get_sigevent() helper

2014-10-28 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 0313853e0802acc09121d291f7694818e8af3ade
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=0313853e0802acc09121d291f7694818e8af3ade

Author: Philippe Gerum r...@xenomai.org
Date:   Tue Oct 28 16:09:01 2014 +0100

cobalt/posix/compat: fix sys32_get_sigevent() helper

---

 kernel/cobalt/posix/compat.c |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/kernel/cobalt/posix/compat.c b/kernel/cobalt/posix/compat.c
index e0f9609..948616c 100644
--- a/kernel/cobalt/posix/compat.c
+++ b/kernel/cobalt/posix/compat.c
@@ -229,7 +229,7 @@ int sys32_get_sigevent(struct sigevent *ev,
return ret;
 
memset(ev, 0, sizeof(*ev));
-   ev-sigev_value.sival_int = cev.sigev_value.sival_int;
+   ev-sigev_value.sival_ptr = compat_ptr(cev.sigev_value.sival_ptr);
ev-sigev_signo = cev.sigev_signo;
ev-sigev_notify = cev.sigev_notify;
/*
@@ -238,8 +238,8 @@ int sys32_get_sigevent(struct sigevent *ev,
 */
p = ev-_sigev_un._pad;
cp = cev._sigev_un._pad;
-   while ((void *)cp  (void *)cev._sigev_un._pad
-  + sizeof(cev._sigev_un._pad))
+   while (p  ev-_sigev_un._pad[ARRAY_SIZE(ev-_sigev_un._pad)] 
+  cp  cev._sigev_un._pad[ARRAY_SIZE(cev._sigev_un._pad)])
*p++ = *cp++;
 
return 0;


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


[Xenomai-git] Philippe Gerum : cobalt/posix/compat: fix mq_timedreceive() for 32/ 64bit neutrality

2014-10-28 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: d8c9e4ec89151d625acaef8abd926a22d48f6a2a
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=d8c9e4ec89151d625acaef8abd926a22d48f6a2a

Author: Philippe Gerum r...@xenomai.org
Date:   Tue Oct 28 17:02:25 2014 +0100

cobalt/posix/compat: fix mq_timedreceive() for 32/64bit neutrality

---

 kernel/cobalt/posix/mqueue.c|   30 +++---
 kernel/cobalt/posix/mqueue.h|2 +-
 kernel/cobalt/posix/syscall32.c |8 +---
 3 files changed, 21 insertions(+), 19 deletions(-)

diff --git a/kernel/cobalt/posix/mqueue.c b/kernel/cobalt/posix/mqueue.c
index f5a69f9..33d8310 100644
--- a/kernel/cobalt/posix/mqueue.c
+++ b/kernel/cobalt/posix/mqueue.c
@@ -998,7 +998,7 @@ COBALT_SYSCALL(mq_timedsend, primary,
 }
 
 int __cobalt_mq_timedreceive(mqd_t uqd, void __user *u_buf,
-ssize_t __user *u_len,
+ssize_t *lenp,
 unsigned int __user *u_prio,
 const void __user *u_ts,
 int (*fetch_timeout)(struct timespec *ts,
@@ -1007,24 +1007,18 @@ int __cobalt_mq_timedreceive(mqd_t uqd, void __user 
*u_buf,
struct cobalt_mqd *mqd;
struct cobalt_msg *msg;
unsigned int prio;
-   ssize_t len;
int ret;
 
mqd = cobalt_mqd_get(uqd);
if (IS_ERR(mqd))
return PTR_ERR(mqd);
 
-   if (__xn_get_user(len, u_len)) {
+   if (*lenp  0  !access_wok(u_buf, *lenp)) {
ret = -EFAULT;
goto fail;
}
 
-   if (len  0  !access_wok(u_buf, len)) {
-   ret = -EFAULT;
-   goto fail;
-   }
-
-   msg = mq_timedrcv_inner(mqd, len, u_ts, fetch_timeout);
+   msg = mq_timedrcv_inner(mqd, *lenp, u_ts, fetch_timeout);
if (IS_ERR(msg)) {
ret = PTR_ERR(msg);
goto fail;
@@ -1036,7 +1030,7 @@ int __cobalt_mq_timedreceive(mqd_t uqd, void __user 
*u_buf,
goto fail;
}
 
-   len = msg-len;
+   *lenp = msg-len;
prio = msg-prio;
ret = mq_finish_rcv(mqd, msg);
if (ret)
@@ -1044,9 +1038,6 @@ int __cobalt_mq_timedreceive(mqd_t uqd, void __user 
*u_buf,
 
cobalt_mqd_put(mqd);
 
-   if (__xn_put_user(len, u_len))
-   return -EFAULT;
-
if (u_prio  __xn_put_user(prio, u_prio))
return -EFAULT;
 
@@ -1063,8 +1054,17 @@ COBALT_SYSCALL(mq_timedreceive, primary,
 unsigned int __user *u_prio,
 const struct timespec __user *u_ts))
 {
-   return __cobalt_mq_timedreceive(uqd, u_buf, u_len, u_prio,
-   u_ts, u_ts ? mq_fetch_timeout : NULL);
+   ssize_t len;
+   int ret;
+
+   ret = __xn_safe_copy_from_user(len, u_len, sizeof(len));
+   if (ret)
+   return ret;
+
+   ret = __cobalt_mq_timedreceive(uqd, u_buf, len, u_prio,
+  u_ts, u_ts ? mq_fetch_timeout : NULL);
+
+   return ret ?: __xn_safe_copy_to_user(u_len, len, sizeof(*u_len));
 }
 
 int cobalt_mq_pkg_init(void)
diff --git a/kernel/cobalt/posix/mqueue.h b/kernel/cobalt/posix/mqueue.h
index 8bdccd4..8fc42d0 100644
--- a/kernel/cobalt/posix/mqueue.h
+++ b/kernel/cobalt/posix/mqueue.h
@@ -44,7 +44,7 @@ int __cobalt_mq_timedsend(mqd_t uqd, const void __user 
*u_buf, size_t len,
   const void __user *u_ts));
 
 int __cobalt_mq_timedreceive(mqd_t uqd, void __user *u_buf,
-ssize_t __user *u_len,
+ssize_t *lenp,
 unsigned int __user *u_prio,
 const void __user *u_ts,
 int (*fetch_timeout)(struct timespec *ts,
diff --git a/kernel/cobalt/posix/syscall32.c b/kernel/cobalt/posix/syscall32.c
index 3074a3a..e813d21 100644
--- a/kernel/cobalt/posix/syscall32.c
+++ b/kernel/cobalt/posix/syscall32.c
@@ -264,14 +264,16 @@ COBALT_SYSCALL32emu(mq_timedreceive, primary,
ssize_t len;
int ret;
 
-   ret = __cobalt_mq_timedreceive(uqd, u_buf, len, u_prio,
-  u_ts, u_ts ? sys32_fetch_timeout : NULL);
+   ret = __xn_safe_copy_from_user(clen, u_len, sizeof(*u_len));
if (ret)
return ret;
 
+   len = clen;
+   ret = __cobalt_mq_timedreceive(uqd, u_buf, len, u_prio,
+  u_ts, u_ts ? sys32_fetch_timeout : NULL);
clen = len;
 
-   return __xn_safe_copy_to_user(u_len, clen, sizeof(*u_len));
+   return ret ?: __xn_safe_copy_to_user(u_len, clen, sizeof(*u_len));
 }
 
 COBALT_SYSCALL32emu(mq_notify, primary,


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