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

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

cobalt: move mutexattr system calls to mutex_attr.c

---

 include/cobalt/pthread.h   |   34 ----------
 kernel/cobalt/mutex.c      |    3 -
 kernel/cobalt/mutex.h      |   22 ++++++
 kernel/cobalt/mutex_attr.c |  158 ++++++++++++++++++++++++++++++++++++++-----
 kernel/cobalt/syscall.c    |  139 ++------------------------------------
 5 files changed, 169 insertions(+), 187 deletions(-)

diff --git a/include/cobalt/pthread.h b/include/cobalt/pthread.h
index 3a39fbe..62a7134 100644
--- a/include/cobalt/pthread.h
+++ b/include/cobalt/pthread.h
@@ -273,40 +273,6 @@ int pthread_attr_getaffinity_np(const pthread_attr_t *attr,
 int pthread_attr_setaffinity_np(pthread_attr_t *attr,
                                xnarch_cpumask_t mask);
 
-int pthread_mutexattr_init(pthread_mutexattr_t *attr);
-
-int pthread_mutexattr_destroy(pthread_mutexattr_t *attr);
-
-int pthread_mutexattr_gettype(const pthread_mutexattr_t *attr,
-                             int *type);
-
-int pthread_mutexattr_settype(pthread_mutexattr_t *attr,
-                             int type);
-
-int pthread_mutexattr_getprotocol(const pthread_mutexattr_t *attr,
-                                 int *proto);
-
-int pthread_mutexattr_setprotocol(pthread_mutexattr_t *attr,
-                                 int proto);
-
-int pthread_mutexattr_getpshared(const pthread_mutexattr_t *attr, int 
*pshared);
-
-int pthread_mutexattr_setpshared(pthread_mutexattr_t *attr, int pshared);
-
-int pthread_mutex_init(pthread_mutex_t *mutex,
-                      const pthread_mutexattr_t *attr);
-
-int pthread_mutex_destroy(pthread_mutex_t *mutex);
-
-int pthread_mutex_trylock(pthread_mutex_t *mutex);
-
-int pthread_mutex_lock(pthread_mutex_t *mutex);
-
-int pthread_mutex_timedlock(pthread_mutex_t *mutex,
-                           const struct timespec *to);
-
-int pthread_mutex_unlock(pthread_mutex_t *mutex);
-
 int pthread_condattr_init(pthread_condattr_t *attr);
 
 int pthread_condattr_destroy(pthread_condattr_t *attr);
diff --git a/kernel/cobalt/mutex.c b/kernel/cobalt/mutex.c
index 28bcaac..3da89a3 100644
--- a/kernel/cobalt/mutex.c
+++ b/kernel/cobalt/mutex.c
@@ -51,8 +51,6 @@
 #include "mutex.h"
 #include "cond.h"
 
-pthread_mutexattr_t cobalt_default_mutex_attr;
-
 static int cobalt_mutex_init_inner(struct __shadow_mutex *shadow,
                                   cobalt_mutex_t *mutex,
                                   struct mutex_dat *datp,
@@ -411,7 +409,6 @@ void cobalt_mutexq_cleanup(cobalt_kqueues_t *q)
 void cobalt_mutex_pkg_init(void)
 {
        initq(&cobalt_global_kqueues.mutexq);
-       pthread_mutexattr_init(&cobalt_default_mutex_attr);
 }
 
 void cobalt_mutex_pkg_cleanup(void)
diff --git a/kernel/cobalt/mutex.h b/kernel/cobalt/mutex.h
index feba86f..0fbd977 100644
--- a/kernel/cobalt/mutex.h
+++ b/kernel/cobalt/mutex.h
@@ -124,6 +124,28 @@ static inline int cobalt_mutex_release(xnthread_t *cur, 
cobalt_mutex_t *mutex)
        return need_resched;
 }
 
+int cobalt_mutexattr_init(pthread_mutexattr_t __user *u_attr);
+
+int cobalt_mutexattr_destroy(pthread_mutexattr_t __user *u_attr);
+
+int cobalt_mutexattr_gettype(const pthread_mutexattr_t __user *u_attr,
+                            int __user *u_type);
+
+int cobalt_mutexattr_settype(pthread_mutexattr_t __user *u_attr,
+                            int type);
+
+int cobalt_mutexattr_getprotocol(const pthread_mutexattr_t __user *u_attr,
+                                int __user *u_proto);
+
+int cobalt_mutexattr_setprotocol(pthread_mutexattr_t __user *u_attr,
+                                int proto);
+
+int cobalt_mutexattr_getpshared(const pthread_mutexattr_t __user *u_attr,
+                               int __user *u_pshared);
+
+int cobalt_mutexattr_setpshared(pthread_mutexattr_t __user *u_attr,
+                               int pshared);
+
 int cobalt_mutex_check_init(struct __shadow_mutex __user *u_mx);
 
 int cobalt_mutex_init(struct __shadow_mutex __user *u_mx,
diff --git a/kernel/cobalt/mutex_attr.c b/kernel/cobalt/mutex_attr.c
index 3bcadf0..4729840 100644
--- a/kernel/cobalt/mutex_attr.c
+++ b/kernel/cobalt/mutex_attr.c
@@ -23,7 +23,7 @@
 
 #include "internal.h"
 
-static const pthread_mutexattr_t default_mutex_attr = {
+const pthread_mutexattr_t cobalt_default_mutex_attr = {
        magic: COBALT_MUTEX_ATTR_MAGIC,
        type: PTHREAD_MUTEX_NORMAL,
        protocol: PTHREAD_PRIO_NONE,
@@ -53,12 +53,12 @@ static const pthread_mutexattr_t default_mutex_attr = {
  * Specification.</a>
  *
  */
-int pthread_mutexattr_init(pthread_mutexattr_t * attr)
+static inline int pthread_mutexattr_init(pthread_mutexattr_t * attr)
 {
        if (!attr)
                return ENOMEM;
 
-       *attr = default_mutex_attr;
+       *attr = cobalt_default_mutex_attr;
 
        return 0;
 }
@@ -81,7 +81,7 @@ int pthread_mutexattr_init(pthread_mutexattr_t * attr)
  * Specification.</a>
  *
  */
-int pthread_mutexattr_destroy(pthread_mutexattr_t * attr)
+static inline int pthread_mutexattr_destroy(pthread_mutexattr_t * attr)
 {
        spl_t s;
 
@@ -123,7 +123,8 @@ int pthread_mutexattr_destroy(pthread_mutexattr_t * attr)
  * Specification.</a>
  *
  */
-int pthread_mutexattr_gettype(const pthread_mutexattr_t * attr, int *type)
+static inline int
+pthread_mutexattr_gettype(const pthread_mutexattr_t * attr, int *type)
 {
        spl_t s;
 
@@ -173,7 +174,8 @@ int pthread_mutexattr_gettype(const pthread_mutexattr_t * 
attr, int *type)
  * Specification.</a>
  *
  */
-int pthread_mutexattr_settype(pthread_mutexattr_t * attr, int type)
+static inline int
+pthread_mutexattr_settype(pthread_mutexattr_t * attr, int type)
 {
        spl_t s;
 
@@ -231,7 +233,8 @@ int pthread_mutexattr_settype(pthread_mutexattr_t * attr, 
int type)
  * Specification.</a>
  *
  */
-int pthread_mutexattr_getprotocol(const pthread_mutexattr_t * attr, int *proto)
+static inline int
+pthread_mutexattr_getprotocol(const pthread_mutexattr_t * attr, int *proto)
 {
        spl_t s;
 
@@ -279,7 +282,8 @@ int pthread_mutexattr_getprotocol(const pthread_mutexattr_t 
* attr, int *proto)
  * Specification.</a>
  *
  */
-int pthread_mutexattr_setprotocol(pthread_mutexattr_t * attr, int proto)
+static inline int
+pthread_mutexattr_setprotocol(pthread_mutexattr_t * attr, int proto)
 {
        spl_t s;
 
@@ -341,7 +345,8 @@ int pthread_mutexattr_setprotocol(pthread_mutexattr_t * 
attr, int proto)
  * Specification.</a>
  *
  */
-int pthread_mutexattr_getpshared(const pthread_mutexattr_t *attr, int *pshared)
+static inline int
+pthread_mutexattr_getpshared(const pthread_mutexattr_t *attr, int *pshared)
 {
        spl_t s;
 
@@ -388,7 +393,8 @@ int pthread_mutexattr_getpshared(const pthread_mutexattr_t 
*attr, int *pshared)
  * Specification.</a>
  *
  */
-int pthread_mutexattr_setpshared(pthread_mutexattr_t *attr, int pshared)
+static inline int
+pthread_mutexattr_setpshared(pthread_mutexattr_t *attr, int pshared)
 {
        spl_t s;
 
@@ -419,14 +425,128 @@ int pthread_mutexattr_setpshared(pthread_mutexattr_t 
*attr, int pshared)
        return 0;
 }
 
+int cobalt_mutexattr_init(pthread_mutexattr_t __user *u_attr)
+{
+       pthread_mutexattr_t attr;
+       int err;
 
-/*@}*/
+       err = pthread_mutexattr_init(&attr);
+       if (err)
+               return -err;
+
+       return __xn_safe_copy_to_user(u_attr, &attr, sizeof(*u_attr));
+}
+
+int cobalt_mutexattr_destroy(pthread_mutexattr_t __user *u_attr)
+{
+       pthread_mutexattr_t attr;
+       int err;
+
+       if (__xn_safe_copy_from_user(&attr, u_attr, sizeof(attr)))
+               return -EFAULT;
+
+       err = pthread_mutexattr_destroy(&attr);
+       if (err)
+               return -err;
+
+       return __xn_safe_copy_to_user(u_attr, &attr, sizeof(*u_attr));
+}
+
+int cobalt_mutexattr_gettype(const pthread_mutexattr_t __user *u_attr,
+                            int __user *u_type)
+{
+       pthread_mutexattr_t attr;
+       int err, type;
+
+       if (__xn_safe_copy_from_user(&attr, u_attr, sizeof(attr)))
+               return -EFAULT;
+
+       err = pthread_mutexattr_gettype(&attr, &type);
+       if (err)
+               return -err;
+
+       return __xn_safe_copy_to_user(u_type, &type, sizeof(*u_type));
+}
+
+int cobalt_mutexattr_settype(pthread_mutexattr_t __user *u_attr,
+                            int type)
+{
+       pthread_mutexattr_t attr;
+       int err;
+
+       if (__xn_safe_copy_from_user(&attr, u_attr, sizeof(attr)))
+               return -EFAULT;
+
+       err = pthread_mutexattr_settype(&attr, type);
+       if (err)
+               return -err;
+
+       return __xn_safe_copy_to_user(u_attr, &attr, sizeof(*u_attr));
+}
+
+int cobalt_mutexattr_getprotocol(const pthread_mutexattr_t __user *u_attr,
+                                int __user *u_proto)
+{
+       pthread_mutexattr_t attr;
+       int err, proto;
 
-EXPORT_SYMBOL_GPL(pthread_mutexattr_init);
-EXPORT_SYMBOL_GPL(pthread_mutexattr_destroy);
-EXPORT_SYMBOL_GPL(pthread_mutexattr_gettype);
-EXPORT_SYMBOL_GPL(pthread_mutexattr_settype);
-EXPORT_SYMBOL_GPL(pthread_mutexattr_getprotocol);
-EXPORT_SYMBOL_GPL(pthread_mutexattr_setprotocol);
-EXPORT_SYMBOL_GPL(pthread_mutexattr_getpshared);
-EXPORT_SYMBOL_GPL(pthread_mutexattr_setpshared);
+       if (__xn_safe_copy_from_user(&attr, u_attr, sizeof(attr)))
+               return -EFAULT;
+
+       err = pthread_mutexattr_getprotocol(&attr, &proto);
+       if (err)
+               return -err;
+
+       return __xn_safe_copy_to_user(u_proto, &proto, sizeof(*u_proto));
+}
+
+int cobalt_mutexattr_setprotocol(pthread_mutexattr_t __user *u_attr,
+                                int proto)
+{
+       pthread_mutexattr_t attr;
+       int err;
+
+       if (__xn_safe_copy_from_user(&attr, u_attr, sizeof(attr)))
+               return -EFAULT;
+
+       err = pthread_mutexattr_setprotocol(&attr, proto);
+       if (err)
+               return -err;
+
+       return __xn_safe_copy_to_user(u_attr, &attr, sizeof(*u_attr));
+}
+
+int cobalt_mutexattr_getpshared(const pthread_mutexattr_t __user *u_attr,
+                               int __user *u_pshared)
+{
+       pthread_mutexattr_t attr;
+       int err, pshared;
+
+       if (__xn_safe_copy_from_user(&attr, u_attr, sizeof(attr)))
+               return -EFAULT;
+
+       err = pthread_mutexattr_getpshared(&attr, &pshared);
+       if (err)
+               return -err;
+
+       return __xn_safe_copy_to_user(u_pshared, &pshared, sizeof(*u_pshared));
+}
+
+int cobalt_mutexattr_setpshared(pthread_mutexattr_t __user *u_attr,
+                               int pshared)
+{
+       pthread_mutexattr_t attr;
+       int err;
+
+       if (__xn_safe_copy_from_user(&attr, u_attr, sizeof(attr)))
+               return -EFAULT;
+
+       err = pthread_mutexattr_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 26116f6..7263eba 100644
--- a/kernel/cobalt/syscall.c
+++ b/kernel/cobalt/syscall.c
@@ -43,129 +43,6 @@
 
 int cobalt_muxid;
 
-static int __pthread_mutexattr_init(pthread_mutexattr_t __user *u_attr)
-{
-       pthread_mutexattr_t attr;
-       int err;
-
-       err = pthread_mutexattr_init(&attr);
-       if (err)
-               return -err;
-
-       return __xn_safe_copy_to_user(u_attr, &attr, sizeof(*u_attr));
-}
-
-static int __pthread_mutexattr_destroy(pthread_mutexattr_t __user *u_attr)
-{
-       pthread_mutexattr_t attr;
-       int err;
-
-       if (__xn_safe_copy_from_user(&attr, u_attr, sizeof(attr)))
-               return -EFAULT;
-
-       err = pthread_mutexattr_destroy(&attr);
-       if (err)
-               return -err;
-
-       return __xn_safe_copy_to_user(u_attr, &attr, sizeof(*u_attr));
-}
-
-static int __pthread_mutexattr_gettype(const pthread_mutexattr_t __user 
*u_attr,
-                                      int __user *u_type)
-{
-       pthread_mutexattr_t attr;
-       int err, type;
-
-       if (__xn_safe_copy_from_user(&attr, u_attr, sizeof(attr)))
-               return -EFAULT;
-
-       err = pthread_mutexattr_gettype(&attr, &type);
-       if (err)
-               return -err;
-
-       return __xn_safe_copy_to_user(u_type, &type, sizeof(*u_type));
-}
-
-static int __pthread_mutexattr_settype(pthread_mutexattr_t __user *u_attr,
-                                      int type)
-{
-       pthread_mutexattr_t attr;
-       int err;
-
-       if (__xn_safe_copy_from_user(&attr, u_attr, sizeof(attr)))
-               return -EFAULT;
-
-       err = pthread_mutexattr_settype(&attr, type);
-       if (err)
-               return -err;
-
-       return __xn_safe_copy_to_user(u_attr, &attr, sizeof(*u_attr));
-}
-
-static int __pthread_mutexattr_getprotocol(const pthread_mutexattr_t __user 
*u_attr,
-                                          int __user *u_proto)
-{
-       pthread_mutexattr_t attr;
-       int err, proto;
-
-       if (__xn_safe_copy_from_user(&attr, u_attr, sizeof(attr)))
-               return -EFAULT;
-
-       err = pthread_mutexattr_getprotocol(&attr, &proto);
-       if (err)
-               return -err;
-
-       return __xn_safe_copy_to_user(u_proto, &proto, sizeof(*u_proto));
-}
-
-static int __pthread_mutexattr_setprotocol(pthread_mutexattr_t __user *u_attr,
-                                          int proto)
-{
-       pthread_mutexattr_t attr;
-       int err;
-
-       if (__xn_safe_copy_from_user(&attr, u_attr, sizeof(attr)))
-               return -EFAULT;
-
-       err = pthread_mutexattr_setprotocol(&attr, proto);
-       if (err)
-               return -err;
-
-       return __xn_safe_copy_to_user(u_attr, &attr, sizeof(*u_attr));
-}
-
-static int __pthread_mutexattr_getpshared(const pthread_mutexattr_t __user 
*u_attr,
-                                          int __user *u_pshared)
-{
-       pthread_mutexattr_t attr;
-       int err, pshared;
-
-       if (__xn_safe_copy_from_user(&attr, u_attr, sizeof(attr)))
-               return -EFAULT;
-
-       err = pthread_mutexattr_getpshared(&attr, &pshared);
-       if (err)
-               return -err;
-
-       return __xn_safe_copy_to_user(u_pshared, &pshared, sizeof(*u_pshared));
-}
-
-static int __pthread_mutexattr_setpshared(pthread_mutexattr_t __user *u_attr,
-                                         int pshared)
-{
-       pthread_mutexattr_t attr;
-       int err;
-
-       if (__xn_safe_copy_from_user(&attr, u_attr, sizeof(attr)))
-               return -EFAULT;
-
-       err = pthread_mutexattr_setpshared(&attr, pshared);
-       if (err)
-               return -err;
-
-       return __xn_safe_copy_to_user(u_attr, &attr, sizeof(*u_attr));
-}
-
 static int __pthread_condattr_init(pthread_condattr_t __user *u_attr)
 {
        pthread_condattr_t attr;
@@ -901,14 +778,14 @@ static struct xnsysent __systab[] = {
        SKINCALL_DEF(sc_cobalt_timer_settime, __timer_settime, primary),
        SKINCALL_DEF(sc_cobalt_timer_gettime, __timer_gettime, any),
        SKINCALL_DEF(sc_cobalt_timer_getoverrun, __timer_getoverrun, any),
-       SKINCALL_DEF(sc_cobalt_mutexattr_init, __pthread_mutexattr_init, any),
-       SKINCALL_DEF(sc_cobalt_mutexattr_destroy, __pthread_mutexattr_destroy, 
any),
-       SKINCALL_DEF(sc_cobalt_mutexattr_gettype, __pthread_mutexattr_gettype, 
any),
-       SKINCALL_DEF(sc_cobalt_mutexattr_settype, __pthread_mutexattr_settype, 
any),
-       SKINCALL_DEF(sc_cobalt_mutexattr_getprotocol, 
__pthread_mutexattr_getprotocol, any),
-       SKINCALL_DEF(sc_cobalt_mutexattr_setprotocol, 
__pthread_mutexattr_setprotocol, any),
-       SKINCALL_DEF(sc_cobalt_mutexattr_getpshared, 
__pthread_mutexattr_getpshared, any),
-       SKINCALL_DEF(sc_cobalt_mutexattr_setpshared, 
__pthread_mutexattr_setpshared, any),
+       SKINCALL_DEF(sc_cobalt_mutexattr_init, cobalt_mutexattr_init, any),
+       SKINCALL_DEF(sc_cobalt_mutexattr_destroy, cobalt_mutexattr_destroy, 
any),
+       SKINCALL_DEF(sc_cobalt_mutexattr_gettype, cobalt_mutexattr_gettype, 
any),
+       SKINCALL_DEF(sc_cobalt_mutexattr_settype, cobalt_mutexattr_settype, 
any),
+       SKINCALL_DEF(sc_cobalt_mutexattr_getprotocol, 
cobalt_mutexattr_getprotocol, any),
+       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),


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

Reply via email to