Module: xenomai-forge
Branch: next
Commit: 698e707192c7d5429a5977294a734cb58da5f832
URL:    
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=698e707192c7d5429a5977294a734cb58da5f832

Author: Philippe Gerum <r...@xenomai.org>
Date:   Wed Sep  3 16:37:02 2014 +0200

cobalt/posix/thread, lib/cobalt: make user window 32/64bit-neutral

---

 include/cobalt/kernel/thread.h      |    7 ++-----
 include/cobalt/uapi/kernel/thread.h |    6 +++---
 kernel/cobalt/posix/process.c       |   11 +++++------
 kernel/cobalt/posix/process.h       |    3 +--
 kernel/cobalt/posix/thread.c        |   14 +++++++-------
 kernel/cobalt/posix/thread.h        |    7 +++----
 lib/cobalt/current.c                |    6 +++---
 lib/cobalt/current.h                |    2 +-
 lib/cobalt/thread.c                 |    4 ++--
 9 files changed, 27 insertions(+), 33 deletions(-)

diff --git a/include/cobalt/kernel/thread.h b/include/cobalt/kernel/thread.h
index 204c525..a455399 100644
--- a/include/cobalt/kernel/thread.h
+++ b/include/cobalt/kernel/thread.h
@@ -86,14 +86,11 @@ struct xnthread_personality {
 struct xnthread {
        struct xnarchtcb tcb;           /* Architecture-dependent block */
 
-       unsigned long state;            /* Thread state flags */
-
-       unsigned long info;             /* Thread information flags */
+       __u32 state;            /* Thread state flags */
+       __u32 info;             /* Thread information flags */
 
        struct xnsched *sched;          /* Thread scheduler */
-
        struct xnsched_class *sched_class; /* Current scheduling class */
-
        struct xnsched_class *base_class; /* Base scheduling class */
 
 #ifdef CONFIG_XENO_OPT_SCHED_TP
diff --git a/include/cobalt/uapi/kernel/thread.h 
b/include/cobalt/uapi/kernel/thread.h
index 9025233..8f71c0d 100644
--- a/include/cobalt/uapi/kernel/thread.h
+++ b/include/cobalt/uapi/kernel/thread.h
@@ -97,9 +97,9 @@
 #define XNTHREAD_STATE_LABELS  "SWDRU..X.HbTlrt.....L"
 
 struct xnthread_user_window {
-       unsigned long state;
-       unsigned long info;
-       unsigned long grant_value;
+       __u32 state;
+       __u32 info;
+       __u32 grant_value;
 };
 
 #endif /* !_COBALT_UAPI_KERNEL_THREAD_H */
diff --git a/kernel/cobalt/posix/process.c b/kernel/cobalt/posix/process.c
index 1714523..acac2b5 100644
--- a/kernel/cobalt/posix/process.c
+++ b/kernel/cobalt/posix/process.c
@@ -613,7 +613,7 @@ static inline int disable_ondemand_memory(void)
 #endif /* !CONFIG_MMU */
 
 /**
- * @fn int cobalt_map_user(struct xnthread *thread, unsigned long __user 
*u_window_offset)
+ * @fn int cobalt_map_user(struct xnthread *thread, __u32 __user *u_winoff)
  * @internal
  * @brief Create a shadow thread context over a user task.
  *
@@ -627,7 +627,7 @@ static inline int disable_ondemand_memory(void)
  * mapped to current. This descriptor must have been previously
  * initialized by a call to xnthread_init().
  *
- * @param u_window_offset will receive the offset of the per-thread
+ * @param u_winoff will receive the offset of the per-thread
  * "u_window" structure in the process shared heap associated to @a
  * thread. This structure reflects thread state information visible
  * from userland through a shared memory window.
@@ -642,8 +642,7 @@ static inline int disable_ondemand_memory(void)
  *
  * @coretags{secondary-only}
  */
-int cobalt_map_user(struct xnthread *thread,
-                   unsigned long __user *u_window_offset)
+int cobalt_map_user(struct xnthread *thread, __u32 __user *u_winoff)
 {
        struct xnthread_user_window *u_window;
        struct xnthread_start_attr attr;
@@ -657,7 +656,7 @@ int cobalt_map_user(struct xnthread *thread,
        if (xnthread_current() || xnthread_test_state(thread, XNMAPPED))
                return -EBUSY;
 
-       if (!access_wok(u_window_offset, sizeof(*u_window_offset)))
+       if (!access_wok(u_winoff, sizeof(*u_winoff)))
                return -EFAULT;
 
        ret = disable_ondemand_memory();
@@ -671,7 +670,7 @@ int cobalt_map_user(struct xnthread *thread,
                return -ENOMEM;
 
        thread->u_window = u_window;
-       __xn_put_user(xnheap_mapped_offset(sem_heap, u_window), 
u_window_offset);
+       __xn_put_user(xnheap_mapped_offset(sem_heap, u_window), u_winoff);
        xnthread_pin_initial(thread);
 
        trace_cobalt_shadow_map(thread);
diff --git a/kernel/cobalt/posix/process.h b/kernel/cobalt/posix/process.h
index 066a390..87be265 100644
--- a/kernel/cobalt/posix/process.h
+++ b/kernel/cobalt/posix/process.h
@@ -73,8 +73,7 @@ int cobalt_bind_personality(unsigned int magic);
 
 struct cobalt_process *cobalt_search_process(struct mm_struct *mm);
 
-int cobalt_map_user(struct xnthread *thread,
-                   unsigned long __user *u_window_offset);
+int cobalt_map_user(struct xnthread *thread, __u32 __user *u_winoff);
 
 void *cobalt_get_context(int xid);
 
diff --git a/kernel/cobalt/posix/thread.c b/kernel/cobalt/posix/thread.c
index 7ed7f92..0395670 100644
--- a/kernel/cobalt/posix/thread.c
+++ b/kernel/cobalt/posix/thread.c
@@ -449,7 +449,7 @@ COBALT_SYSCALL(thread_setschedparam_ex, conforming,
               int, (unsigned long pth,
                     int policy,
                     const struct sched_param_ex __user *u_param,
-                    unsigned long __user *u_window_offset,
+                    __u32 __user *u_winoff,
                     int __user *u_promoted))
 {
        struct sched_param_ex param_ex;
@@ -465,8 +465,8 @@ COBALT_SYSCALL(thread_setschedparam_ex, conforming,
        trace_cobalt_pthread_setschedparam(pth, policy, &param_ex);
 
        thread = thread_lookup(&hkey);
-       if (thread == NULL && u_window_offset) {
-               thread = cobalt_thread_shadow(current, &hkey, u_window_offset);
+       if (thread == NULL && u_winoff) {
+               thread = cobalt_thread_shadow(current, &hkey, u_winoff);
                if (IS_ERR(thread))
                        return PTR_ERR(thread);
 
@@ -522,7 +522,7 @@ COBALT_SYSCALL(thread_create, init,
               int, (unsigned long pth, int policy,
                     struct sched_param_ex __user *u_param,
                     int xid,
-                    unsigned long __user *u_window_offset))
+                    __u32 __user *u_winoff))
 {
        struct cobalt_thread *thread = NULL;
        struct task_struct *p = current;
@@ -547,7 +547,7 @@ COBALT_SYSCALL(thread_create, init,
        if (ret)
                return ret;
 
-       ret = cobalt_map_user(&thread->threadbase, u_window_offset);
+       ret = cobalt_map_user(&thread->threadbase, u_winoff);
        if (ret)
                goto fail;
 
@@ -573,7 +573,7 @@ fail:
 struct cobalt_thread *
 cobalt_thread_shadow(struct task_struct *p,
                     struct cobalt_local_hkey *hkey,
-                    unsigned long __user *u_window_offset)
+                    __u32 __user *u_winoff)
 {
        struct cobalt_thread *thread = NULL;
        struct sched_param_ex param_ex;
@@ -585,7 +585,7 @@ cobalt_thread_shadow(struct task_struct *p,
        if (ret)
                return ERR_PTR(-ret);
 
-       ret = cobalt_map_user(&thread->threadbase, u_window_offset);
+       ret = cobalt_map_user(&thread->threadbase, u_winoff);
        if (ret)
                goto fail;
 
diff --git a/kernel/cobalt/posix/thread.h b/kernel/cobalt/posix/thread.h
index ee78c04..e5deadd 100644
--- a/kernel/cobalt/posix/thread.h
+++ b/kernel/cobalt/posix/thread.h
@@ -131,13 +131,12 @@ struct cobalt_thread *cobalt_thread_lookup(unsigned long 
pth);
 COBALT_SYSCALL_DECL(thread_create,
                    int, (unsigned long pth, int policy,
                          struct sched_param_ex __user *u_param,
-                         int xid,
-                         unsigned long __user *u_window_offset));
+                         int xid, __u32 __user *u_winoff));
 
 struct cobalt_thread *
 cobalt_thread_shadow(struct task_struct *p,
                     struct cobalt_local_hkey *lhkey,
-                    unsigned long __user *u_window_offset);
+                    __u32 __user *u_winoff);
 
 COBALT_SYSCALL_DECL(thread_setmode,
                    int, (int clrmask, int setmask, int __user *u_mode_r));
@@ -161,7 +160,7 @@ COBALT_SYSCALL_DECL(thread_setschedparam_ex,
                    int, (unsigned long pth,
                          int policy,
                          const struct sched_param_ex __user *u_param,
-                         unsigned long __user *u_window_offset,
+                         __u32 __user *u_winoff,
                          int __user *u_promoted));
 
 COBALT_SYSCALL_DECL(thread_getschedparam_ex,
diff --git a/lib/cobalt/current.c b/lib/cobalt/current.c
index aaf7dc9..f567335 100644
--- a/lib/cobalt/current.c
+++ b/lib/cobalt/current.c
@@ -36,7 +36,7 @@ xnhandle_t cobalt_current = XN_NO_HANDLE;
 __thread __attribute__ ((tls_model (CONFIG_XENO_TLS_MODEL)))
 struct xnthread_user_window *cobalt_current_window;
 
-static inline void __cobalt_set_tsd(xnhandle_t current, unsigned long u_winoff)
+static inline void __cobalt_set_tsd(xnhandle_t current, __u32 u_winoff)
 {
        struct xnthread_user_window *window;
 
@@ -62,7 +62,7 @@ pthread_key_t cobalt_current_window_key;
 pthread_key_t cobalt_current_key;
 
 static inline void __cobalt_set_tsd(xnhandle_t current,
-                                   unsigned long u_winoff)
+                                   __u32 u_winoff)
 {
        struct xnthread_user_window *window;
 
@@ -122,7 +122,7 @@ xnhandle_t cobalt_get_current_slow(void)
        return err ? XN_NO_HANDLE : current;
 }
 
-void cobalt_set_tsd(unsigned long u_winoff)
+void cobalt_set_tsd(__u32 u_winoff)
 {
        struct cobalt_tsd_hook *th;
        xnhandle_t current;
diff --git a/lib/cobalt/current.h b/lib/cobalt/current.h
index 0503743..d678d69 100644
--- a/lib/cobalt/current.h
+++ b/lib/cobalt/current.h
@@ -91,6 +91,6 @@ static inline struct xnthread_user_window 
*cobalt_get_current_window(void)
 
 void cobalt_init_current_keys(void);
 
-void cobalt_set_tsd(unsigned long u_winoff);
+void cobalt_set_tsd(__u32 u_winoff);
 
 #endif /* _LIB_COBALT_CURRENT_H */
diff --git a/lib/cobalt/thread.c b/lib/cobalt/thread.c
index ef28614..8eb732a 100644
--- a/lib/cobalt/thread.c
+++ b/lib/cobalt/thread.c
@@ -116,7 +116,7 @@ static void *cobalt_thread_trampoline(void *p)
        int personality, parent_prio, policy;
        struct pthread_iargs *iargs = p;
        struct sched_param_ex param_ex;
-       unsigned long u_winoff;
+       __u32 u_winoff;
        long ret;
 
        cobalt_sigshadow_install_once();
@@ -648,8 +648,8 @@ COBALT_IMPL(int, pthread_setschedparam, (pthread_t thread,
 int pthread_setschedparam_ex(pthread_t thread,
                             int policy, const struct sched_param_ex *param_ex)
 {
-       unsigned long u_winoff;
        int ret, promoted;
+       __u32 u_winoff;
 
        /*
         * First we tell the libc and the regular kernel about the


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

Reply via email to