Module: xenomai-gch
Branch: for-forge
Commit: 9cf6dd92acb501313dc2425f84123981cac0eec9
URL:    
http://git.xenomai.org/?p=xenomai-gch.git;a=commit;h=9cf6dd92acb501313dc2425f84123981cac0eec9

Author: Gilles Chanteperdrix <gilles.chanteperd...@xenomai.org>
Date:   Sun Dec 11 17:46:32 2011 +0100

cobalt: move cond_attr system calls to cond_attr.c

---

 include/cobalt/pthread.h  |   93 ---------------------------------
 kernel/cobalt/cond.c      |    5 +--
 kernel/cobalt/cond.h      |   16 ++++++
 kernel/cobalt/cond_attr.c |  124 ++++++++++++++++++++++++++++++++++++++-------
 kernel/cobalt/syscall.c   |  104 ++-----------------------------------
 5 files changed, 129 insertions(+), 213 deletions(-)

diff --git a/include/cobalt/pthread.h b/include/cobalt/pthread.h
index 62a7134..139802f 100644
--- a/include/cobalt/pthread.h
+++ b/include/cobalt/pthread.h
@@ -198,99 +198,6 @@ struct cobalt_monitor_shadow {
 typedef struct cobalt_mutexattr pthread_mutexattr_t;
 
 typedef struct cobalt_condattr pthread_condattr_t;
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-int pthread_attr_init(pthread_attr_t *attr);
-
-int pthread_attr_destroy(pthread_attr_t *attr);
-
-int pthread_attr_getdetachstate(const pthread_attr_t *attr,
-                               int *detachstate);
-
-int pthread_attr_setdetachstate(pthread_attr_t *attr,
-                               int detachstate);
-
-int pthread_attr_getstackaddr(const pthread_attr_t *attr,
-                             void **stackaddr);
-
-int pthread_attr_setstackaddr(pthread_attr_t *attr,
-                             void *stackaddr);
-
-int pthread_attr_getstacksize(const pthread_attr_t *attr,
-                             size_t *stacksize);
-
-int pthread_attr_setstacksize(pthread_attr_t *attr,
-                             size_t stacksize);
-
-int pthread_attr_getinheritsched(const pthread_attr_t *attr,
-                                int *inheritsched);
-
-int pthread_attr_setinheritsched(pthread_attr_t *attr,
-                                int inheritsched);
-
-int pthread_attr_getschedpolicy(const pthread_attr_t *attr,
-                               int *policy);
-
-int pthread_attr_setschedpolicy(pthread_attr_t *attr,
-                               int policy);
-
-int pthread_attr_getschedparam(const pthread_attr_t *attr,
-                              struct sched_param *par);
-
-int pthread_attr_getschedparam_ex(const pthread_attr_t *attr,
-                                 struct sched_param_ex *par);
-
-int pthread_attr_setschedparam(pthread_attr_t *attr,
-                              const struct sched_param *par);
-
-int pthread_attr_setschedparam_ex(pthread_attr_t *attr,
-                                 const struct sched_param_ex *par);
-
-int pthread_attr_getscope(const pthread_attr_t *attr,
-                         int *scope);
-
-int pthread_attr_setscope(pthread_attr_t *attr,
-                         int scope);
-
-int pthread_attr_getname_np(const pthread_attr_t *attr,
-                           const char **name);
-
-int pthread_attr_setname_np(pthread_attr_t *attr,
-                           const char *name);
-
-int pthread_attr_getfp_np(const pthread_attr_t *attr,
-                         int *use_fp);
-
-int pthread_attr_setfp_np(pthread_attr_t *attr,
-                         int use_fp);
-
-int pthread_attr_getaffinity_np(const pthread_attr_t *attr,
-                               xnarch_cpumask_t *mask);
-
-int pthread_attr_setaffinity_np(pthread_attr_t *attr,
-                               xnarch_cpumask_t mask);
-
-int pthread_condattr_init(pthread_condattr_t *attr);
-
-int pthread_condattr_destroy(pthread_condattr_t *attr);
-
-int pthread_condattr_getclock(const pthread_condattr_t *attr,
-                             clockid_t *clk_id);
-
-int pthread_condattr_setclock(pthread_condattr_t *attr,
-                             clockid_t clk_id);
-
-int pthread_condattr_getpshared(const pthread_condattr_t *attr, int *pshared);
-
-int pthread_condattr_setpshared(pthread_condattr_t *attr, int pshared);
-
-#ifdef __cplusplus
-}
-#endif
-
 #else /* !(__KERNEL__ || __XENO_SIM__) */
 
 typedef struct {
diff --git a/kernel/cobalt/cond.c b/kernel/cobalt/cond.c
index c19643c..cfe5201 100644
--- a/kernel/cobalt/cond.c
+++ b/kernel/cobalt/cond.c
@@ -51,8 +51,6 @@
 #include "mutex.h"
 #include "cond.h"
 
-static pthread_condattr_t default_cond_attr;
-
 static inline void
 cond_destroy_internal(cobalt_cond_t *cond, cobalt_kqueues_t *q)
 {
@@ -106,7 +104,7 @@ pthread_cond_init(struct __shadow_cond *cnd, const 
pthread_condattr_t *attr)
        int err;
 
        if (!attr)
-               attr = &default_cond_attr;
+               attr = &cobalt_default_cond_attr;
 
        cond = (cobalt_cond_t *)xnmalloc(sizeof(*cond));
        if (!cond)
@@ -491,7 +489,6 @@ void cobalt_condq_cleanup(cobalt_kqueues_t *q)
 void cobalt_cond_pkg_init(void)
 {
        initq(&cobalt_global_kqueues.condq);
-       pthread_condattr_init(&default_cond_attr);
 }
 
 void cobalt_cond_pkg_cleanup(void)
diff --git a/kernel/cobalt/cond.h b/kernel/cobalt/cond.h
index dc75f0d..243e016 100644
--- a/kernel/cobalt/cond.h
+++ b/kernel/cobalt/cond.h
@@ -68,6 +68,8 @@ typedef struct cobalt_cond {
        cobalt_kqueues_t *owningq;
 } cobalt_cond_t;
 
+extern const pthread_condattr_t cobalt_default_cond_attr;
+
 static inline int cobalt_cond_deferred_signals(struct cobalt_cond *cond)
 {
        unsigned long pending_signals;
@@ -96,6 +98,20 @@ static inline int cobalt_cond_deferred_signals(struct 
cobalt_cond *cond)
        return need_resched;
 }
 
+int cobalt_condattr_init(pthread_condattr_t __user *u_attr);
+
+int cobalt_condattr_destroy(pthread_condattr_t __user *u_attr);
+
+int cobalt_condattr_getclock(const pthread_condattr_t __user *u_attr,
+                            clockid_t __user *u_clock);
+
+int cobalt_condattr_setclock(pthread_condattr_t __user *u_attr, clockid_t 
clock);
+
+int cobalt_condattr_getpshared(const pthread_condattr_t __user *u_attr,
+                              int __user *u_pshared);
+
+int cobalt_condattr_setpshared(pthread_condattr_t __user *u_attr, int pshared);
+
 int cobalt_cond_init(struct __shadow_cond __user *u_cnd,
                     const pthread_condattr_t __user *u_attr);
 
diff --git a/kernel/cobalt/cond_attr.c b/kernel/cobalt/cond_attr.c
index 5223caa..f14d5d6 100644
--- a/kernel/cobalt/cond_attr.c
+++ b/kernel/cobalt/cond_attr.c
@@ -23,10 +23,11 @@
 
 #include "internal.h"
 
-static pthread_condattr_t default_cond_attr = {
+const pthread_condattr_t cobalt_default_cond_attr = {
 
-      magic:COBALT_COND_ATTR_MAGIC,
-      clock:CLOCK_REALTIME
+      magic: COBALT_COND_ATTR_MAGIC,
+      pshared: 0,
+      clock: CLOCK_REALTIME
 };
 
 /**
@@ -52,12 +53,12 @@ static pthread_condattr_t default_cond_attr = {
  * Specification.</a>
  *
  */
-int pthread_condattr_init(pthread_condattr_t * attr)
+static inline int pthread_condattr_init(pthread_condattr_t * attr)
 {
        if (!attr)
                return ENOMEM;
 
-       *attr = default_cond_attr;
+       *attr = cobalt_default_cond_attr;
 
        return 0;
 }
@@ -80,7 +81,7 @@ int pthread_condattr_init(pthread_condattr_t * attr)
  * Specification.</a>
  *
  */
-int pthread_condattr_destroy(pthread_condattr_t * attr)
+static inline int pthread_condattr_destroy(pthread_condattr_t * attr)
 {
        spl_t s;
 
@@ -122,8 +123,8 @@ int pthread_condattr_destroy(pthread_condattr_t * attr)
  * Specification.</a>
  *
  */
-int pthread_condattr_getclock(const pthread_condattr_t * attr,
-                             clockid_t * clk_id)
+static inline int
+pthread_condattr_getclock(const pthread_condattr_t * attr, clockid_t * clk_id)
 {
        spl_t s;
 
@@ -164,7 +165,8 @@ int pthread_condattr_getclock(const pthread_condattr_t * 
attr,
  * Specification.</a>
  *
  */
-int pthread_condattr_setclock(pthread_condattr_t * attr, clockid_t clk_id)
+static inline int
+pthread_condattr_setclock(pthread_condattr_t * attr, clockid_t clk_id)
 {
        spl_t s;
 
@@ -219,7 +221,8 @@ int pthread_condattr_setclock(pthread_condattr_t * attr, 
clockid_t clk_id)
  * Specification.</a>
  *
  */
-int pthread_condattr_getpshared(const pthread_condattr_t *attr, int *pshared)
+static inline int
+pthread_condattr_getpshared(const pthread_condattr_t *attr, int *pshared)
 {
        spl_t s;
 
@@ -266,7 +269,8 @@ int pthread_condattr_getpshared(const pthread_condattr_t 
*attr, int *pshared)
  * Specification.</a>
  *
  */
-int pthread_condattr_setpshared(pthread_condattr_t *attr, int pshared)
+static inline int
+pthread_condattr_setpshared(pthread_condattr_t *attr, int pshared)
 {
        spl_t s;
 
@@ -296,11 +300,95 @@ int pthread_condattr_setpshared(pthread_condattr_t *attr, 
int pshared)
 
        return 0;
 }
-/*@}*/
 
-EXPORT_SYMBOL_GPL(pthread_condattr_init);
-EXPORT_SYMBOL_GPL(pthread_condattr_destroy);
-EXPORT_SYMBOL_GPL(pthread_condattr_getclock);
-EXPORT_SYMBOL_GPL(pthread_condattr_setclock);
-EXPORT_SYMBOL_GPL(pthread_condattr_getpshared);
-EXPORT_SYMBOL_GPL(pthread_condattr_setpshared);
+int cobalt_condattr_init(pthread_condattr_t __user *u_attr)
+{
+       pthread_condattr_t attr;
+       int err;
+
+       err = pthread_condattr_init(&attr);
+       if (err)
+               return -err;
+
+       return __xn_safe_copy_to_user(u_attr, &attr, sizeof(*u_attr));
+}
+
+int cobalt_condattr_destroy(pthread_condattr_t __user *u_attr)
+{
+       pthread_condattr_t attr;
+       int err;
+
+       if (__xn_safe_copy_from_user(&attr, u_attr, sizeof(attr)))
+               return -EFAULT;
+
+       err = pthread_condattr_destroy(&attr);
+       if (err)
+               return -err;
+
+       return __xn_safe_copy_to_user(u_attr, &attr, sizeof(*u_attr));
+}
+
+int cobalt_condattr_getclock(const pthread_condattr_t __user *u_attr,
+                            clockid_t __user *u_clock)
+{
+       pthread_condattr_t attr;
+       clockid_t clock;
+       int err;
+
+       if (__xn_safe_copy_from_user(&attr, u_attr, sizeof(attr)))
+               return -EFAULT;
+
+       err = pthread_condattr_getclock(&attr, &clock);
+       if (err)
+               return -err;
+
+       return __xn_safe_copy_to_user(u_clock, &clock, sizeof(*u_clock));
+}
+
+int cobalt_condattr_setclock(pthread_condattr_t __user *u_attr, clockid_t 
clock)
+{
+       pthread_condattr_t attr;
+       int err;
+
+       if (__xn_safe_copy_from_user(&attr, u_attr, sizeof(attr)))
+               return -EFAULT;
+
+       err = pthread_condattr_setclock(&attr, clock);
+       if (err)
+               return -err;
+
+       return __xn_safe_copy_to_user(u_attr, &attr, sizeof(*u_attr));
+}
+
+int cobalt_condattr_getpshared(const pthread_condattr_t __user *u_attr,
+                              int __user *u_pshared)
+{
+       pthread_condattr_t attr;
+       int err, pshared;
+
+       if (__xn_safe_copy_from_user(&attr, u_attr, sizeof(attr)))
+               return -EFAULT;
+
+       err = pthread_condattr_getpshared(&attr, &pshared);
+       if (err)
+               return -err;
+
+       return __xn_safe_copy_to_user(u_pshared, &pshared, sizeof(*u_pshared));
+}
+
+int cobalt_condattr_setpshared(pthread_condattr_t __user *u_attr, int pshared)
+{
+       pthread_condattr_t attr;
+       int err;
+
+       if (__xn_safe_copy_from_user(&attr, u_attr, sizeof(attr)))
+               return -EFAULT;
+
+       err = pthread_condattr_setpshared(&attr, pshared);
+       if (err)
+               return -err;
+
+       return __xn_safe_copy_to_user(u_attr, &attr, sizeof(*u_attr));
+}
+
+/*@}*/
diff --git a/kernel/cobalt/syscall.c b/kernel/cobalt/syscall.c
index 7263eba..8127469 100644
--- a/kernel/cobalt/syscall.c
+++ b/kernel/cobalt/syscall.c
@@ -43,98 +43,6 @@
 
 int cobalt_muxid;
 
-static int __pthread_condattr_init(pthread_condattr_t __user *u_attr)
-{
-       pthread_condattr_t attr;
-       int err;
-
-       err = pthread_condattr_init(&attr);
-       if (err)
-               return -err;
-
-       return __xn_safe_copy_to_user(u_attr, &attr, sizeof(*u_attr));
-}
-
-static int __pthread_condattr_destroy(pthread_condattr_t __user *u_attr)
-{
-       pthread_condattr_t attr;
-       int err;
-
-       if (__xn_safe_copy_from_user(&attr, u_attr, sizeof(attr)))
-               return -EFAULT;
-
-       err = pthread_condattr_destroy(&attr);
-       if (err)
-               return -err;
-
-       return __xn_safe_copy_to_user(u_attr, &attr, sizeof(*u_attr));
-}
-
-static int __pthread_condattr_getclock(const pthread_condattr_t __user *u_attr,
-                                      clockid_t __user *u_clock)
-{
-       pthread_condattr_t attr;
-       clockid_t clock;
-       int err;
-
-       if (__xn_safe_copy_from_user(&attr, u_attr, sizeof(attr)))
-               return -EFAULT;
-
-       err = pthread_condattr_getclock(&attr, &clock);
-       if (err)
-               return -err;
-
-       return __xn_safe_copy_to_user(u_clock, &clock, sizeof(*u_clock));
-}
-
-static int __pthread_condattr_setclock(pthread_condattr_t __user *u_attr,
-                                      clockid_t clock)
-{
-       pthread_condattr_t attr;
-       int err;
-
-       if (__xn_safe_copy_from_user(&attr, u_attr, sizeof(attr)))
-               return -EFAULT;
-
-       err = pthread_condattr_setclock(&attr, clock);
-       if (err)
-               return -err;
-
-       return __xn_safe_copy_to_user(u_attr, &attr, sizeof(*u_attr));
-}
-
-static int __pthread_condattr_getpshared(const pthread_condattr_t __user 
*u_attr,
-                                        int __user *u_pshared)
-{
-       pthread_condattr_t attr;
-       int err, pshared;
-
-       if (__xn_safe_copy_from_user(&attr, u_attr, sizeof(attr)))
-               return -EFAULT;
-
-       err = pthread_condattr_getpshared(&attr, &pshared);
-       if (err)
-               return -err;
-
-       return __xn_safe_copy_to_user(u_pshared, &pshared, sizeof(*u_pshared));
-}
-
-static int __pthread_condattr_setpshared(pthread_condattr_t __user *u_attr,
-                                        int pshared)
-{
-       pthread_condattr_t attr;
-       int err;
-
-       if (__xn_safe_copy_from_user(&attr, u_attr, sizeof(attr)))
-               return -EFAULT;
-
-       err = pthread_condattr_setpshared(&attr, pshared);
-       if (err)
-               return -err;
-
-       return __xn_safe_copy_to_user(u_attr, &attr, sizeof(*u_attr));
-}
-
 /* mq_open(name, oflags, mode, attr, ufd) */
 static int __mq_open(const char __user *u_name,
                     int oflags,
@@ -786,12 +694,12 @@ static struct xnsysent __systab[] = {
        SKINCALL_DEF(sc_cobalt_mutexattr_setprotocol, 
cobalt_mutexattr_setprotocol, any),
        SKINCALL_DEF(sc_cobalt_mutexattr_getpshared, 
cobalt_mutexattr_getpshared, any),
        SKINCALL_DEF(sc_cobalt_mutexattr_setpshared, 
cobalt_mutexattr_setpshared, any),
-       SKINCALL_DEF(sc_cobalt_condattr_init, __pthread_condattr_init, any),
-       SKINCALL_DEF(sc_cobalt_condattr_destroy, __pthread_condattr_destroy, 
any),
-       SKINCALL_DEF(sc_cobalt_condattr_getclock, __pthread_condattr_getclock, 
any),
-       SKINCALL_DEF(sc_cobalt_condattr_setclock, __pthread_condattr_setclock, 
any),
-       SKINCALL_DEF(sc_cobalt_condattr_getpshared, 
__pthread_condattr_getpshared, any),
-       SKINCALL_DEF(sc_cobalt_condattr_setpshared, 
__pthread_condattr_setpshared, any),
+       SKINCALL_DEF(sc_cobalt_condattr_init, cobalt_condattr_init, any),
+       SKINCALL_DEF(sc_cobalt_condattr_destroy, cobalt_condattr_destroy, any),
+       SKINCALL_DEF(sc_cobalt_condattr_getclock, cobalt_condattr_getclock, 
any),
+       SKINCALL_DEF(sc_cobalt_condattr_setclock, cobalt_condattr_setclock, 
any),
+       SKINCALL_DEF(sc_cobalt_condattr_getpshared, cobalt_condattr_getpshared, 
any),
+       SKINCALL_DEF(sc_cobalt_condattr_setpshared, cobalt_condattr_setpshared, 
any),
        SKINCALL_DEF(sc_cobalt_select, __select, primary),
        SKINCALL_DEF(sc_cobalt_sched_minprio, cobalt_sched_min_prio, any),
        SKINCALL_DEF(sc_cobalt_sched_maxprio, cobalt_sched_max_prio, any),


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

Reply via email to