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

Author: Philippe Gerum <r...@xenomai.org>
Date:   Tue May 27 09:39:23 2014 +0200

lib/cobalt: substitute ambiguous 'tid' with ptid

We have several sorts of thread ids in tree, including POSIX thread
ids, kernel thread ids, and emulator-specific task/thread ids.

Use ptid all over the place to unambiguously refer to a POSIX thread
identifier.

---

 include/cobalt/pthread.h |   14 +++++++-------
 lib/cobalt/init.c        |   10 +++++-----
 lib/cobalt/internal.h    |    2 +-
 lib/cobalt/thread.c      |   20 ++++++++++----------
 lib/cobalt/wrappers.c    |   12 ++++++------
 5 files changed, 29 insertions(+), 29 deletions(-)

diff --git a/include/cobalt/pthread.h b/include/cobalt/pthread.h
index 2a981cc..9021630 100644
--- a/include/cobalt/pthread.h
+++ b/include/cobalt/pthread.h
@@ -43,7 +43,7 @@ COBALT_DECL(int, pthread_attr_setschedpolicy(pthread_attr_t 
*attr,
 COBALT_DECL(int, pthread_attr_setschedparam(pthread_attr_t *attr,
                                            const struct sched_param *par));
 
-COBALT_DECL(int, pthread_create(pthread_t *tid,
+COBALT_DECL(int, pthread_create(pthread_t *ptid_r,
                                const pthread_attr_t *attr,
                                void *(*start) (void *),
                                void *arg));
@@ -124,9 +124,9 @@ COBALT_DECL(int, pthread_cond_signal(pthread_cond_t *cond));
 
 COBALT_DECL(int, pthread_cond_broadcast(pthread_cond_t *cond));
 
-COBALT_DECL(int, pthread_kill(pthread_t tid, int sig));
+COBALT_DECL(int, pthread_kill(pthread_t ptid, int sig));
 
-COBALT_DECL(int, pthread_join(pthread_t tid, void **retval));
+COBALT_DECL(int, pthread_join(pthread_t ptid, void **retval));
 
 COBALT_DECL(int, pthread_mutexattr_getprotocol(const pthread_mutexattr_t *attr,
                                               int *proto));
@@ -155,18 +155,18 @@ int pthread_set_name_np(pthread_t thread,
 
 COBALT_DECL(int, pthread_setname_np(pthread_t thread, const char *name));
 
-int pthread_probe_np(pid_t tid);
+int pthread_probe_np(pid_t ptid);
 
-int pthread_create_ex(pthread_t *tid,
+int pthread_create_ex(pthread_t *ptid_r,
                      const pthread_attr_ex_t *attr_ex,
                      void *(*start)(void *),
                      void *arg);
 
-int pthread_getschedparam_ex(pthread_t tid,
+int pthread_getschedparam_ex(pthread_t ptid,
                             int *pol,
                             struct sched_param_ex *par);
 
-int pthread_setschedparam_ex(pthread_t tid,
+int pthread_setschedparam_ex(pthread_t ptid,
                             int pol,
                             const struct sched_param_ex *par);
 
diff --git a/lib/cobalt/init.c b/lib/cobalt/init.c
index e263e25..573ff35 100644
--- a/lib/cobalt/init.c
+++ b/lib/cobalt/init.c
@@ -45,7 +45,7 @@ int __cobalt_muxid = -1;
 
 struct sigaction __cobalt_orig_sigdebug;
 
-pthread_t __cobalt_main_tid;
+pthread_t __cobalt_main_ptid;
 
 int __rtdm_muxid = -1;
 
@@ -200,7 +200,7 @@ static inline void dump_configuration(void)
 
 static __libcobalt_ctor void __init_cobalt(void)
 {
-       pthread_t tid = pthread_self();
+       pthread_t ptid = pthread_self();
        struct sched_param parm;
        int policy, ret;
        const char *p;
@@ -217,7 +217,7 @@ static __libcobalt_ctor void __init_cobalt(void)
                report_error("running non-SMP libraries on SMP kernel?");
 #endif
 
-       __cobalt_main_tid = tid;
+       __cobalt_main_ptid = ptid;
 
        if (__cobalt_defer_init)
                return;
@@ -233,7 +233,7 @@ static __libcobalt_ctor void __init_cobalt(void)
                exit(EXIT_FAILURE);
        }
 
-       ret = __STD(pthread_getschedparam(tid, &policy, &parm));
+       ret = __STD(pthread_getschedparam(ptid, &policy, &parm));
        if (ret) {
                report_error("pthread_getschedparam: %s", strerror(ret));
                exit(EXIT_FAILURE);
@@ -257,7 +257,7 @@ static __libcobalt_ctor void __init_cobalt(void)
                parm.sched_priority = 0;
        }
        
-       ret = __RT(pthread_setschedparam(tid, policy, &parm));
+       ret = __RT(pthread_setschedparam(ptid, policy, &parm));
        if (ret) {
                report_error("pthread_setschedparam: %s", strerror(ret));
                exit(EXIT_FAILURE);
diff --git a/lib/cobalt/internal.h b/lib/cobalt/internal.h
index cdd8cec..e89531a 100644
--- a/lib/cobalt/internal.h
+++ b/lib/cobalt/internal.h
@@ -145,7 +145,7 @@ struct xnfeatinfo;
 
 void cobalt_check_features(struct xnfeatinfo *finfo);
 
-extern pthread_t __cobalt_main_tid;
+extern pthread_t __cobalt_main_ptid;
 
 extern struct sigaction __cobalt_orig_sigdebug;
 
diff --git a/lib/cobalt/thread.c b/lib/cobalt/thread.c
index b461058..dff0178 100644
--- a/lib/cobalt/thread.c
+++ b/lib/cobalt/thread.c
@@ -38,7 +38,7 @@ static int std_maxpri;
 
 static void prefault_stack(void)
 {
-       if (pthread_self() == __cobalt_main_tid) {
+       if (pthread_self() == __cobalt_main_ptid) {
                char stk[cobalt_get_stacksize(1)];
                __cobalt_prefault(stk);
        }
@@ -232,7 +232,7 @@ static void *cobalt_thread_trampoline(void *p)
         * Volatile is to prevent (too) smart gcc releases from
         * trashing the syscall registers (see later comment).
         */
-       volatile pthread_t tid = pthread_self();
+       volatile pthread_t ptid = pthread_self();
        void *(*start)(void *), *arg, *retval;
        int personality, parent_prio, policy;
        struct pthread_iargs *iargs = p;
@@ -251,7 +251,7 @@ static void *cobalt_thread_trampoline(void *p)
        arg = iargs->arg;
 
        /* Set our scheduling parameters for the host kernel first. */
-       ret = libc_setschedparam(tid, policy, &param_ex);
+       ret = libc_setschedparam(ptid, policy, &param_ex);
        if (ret)
                goto sync_with_creator;
 
@@ -259,7 +259,7 @@ static void *cobalt_thread_trampoline(void *p)
         * Do _not_ inline the call to pthread_self() in the syscall
         * macro: this trashes the syscall regs on some archs.
         */
-       ret = -XENOMAI_SKINCALL5(__cobalt_muxid, sc_cobalt_thread_create, tid,
+       ret = -XENOMAI_SKINCALL5(__cobalt_muxid, sc_cobalt_thread_create, ptid,
                                 policy, &param_ex, personality, &u_winoff);
        if (ret == 0) {
                cobalt_set_current();
@@ -295,7 +295,7 @@ sync_with_creator:
        return retval;
 }
 
-int pthread_create_ex(pthread_t *tid,
+int pthread_create_ex(pthread_t *ptid_r,
                      const pthread_attr_ex_t *attr_ex,
                      void *(*start) (void *), void *arg)
 {
@@ -303,7 +303,7 @@ int pthread_create_ex(pthread_t *tid,
        struct pthread_iargs iargs;
        struct sched_param param;
        pthread_attr_t attr;
-       pthread_t ltid;
+       pthread_t lptid;
        size_t stksz;
 
        if (attr_ex == NULL)
@@ -351,7 +351,7 @@ int pthread_create_ex(pthread_t *tid,
        iargs.ret = EAGAIN;
        __STD(sem_init(&iargs.sync, 0, 0));
 
-       ret = __STD(pthread_create(&ltid, &attr, cobalt_thread_trampoline, 
&iargs));
+       ret = __STD(pthread_create(&lptid, &attr, cobalt_thread_trampoline, 
&iargs));
        if (ret)
                goto fail;
 
@@ -362,7 +362,7 @@ int pthread_create_ex(pthread_t *tid,
                if (ret == 0) {
                        ret = iargs.ret;
                        if (ret == 0)
-                               *tid = ltid;
+                               *ptid_r = lptid;
                        break;
                }
                ret = -errno;
@@ -376,7 +376,7 @@ fail:
        return ret;
 }
 
-COBALT_IMPL(int, pthread_create, (pthread_t *tid,
+COBALT_IMPL(int, pthread_create, (pthread_t *ptid_r,
                                  const pthread_attr_t *attr,
                                  void *(*start) (void *), void *arg))
 {
@@ -394,7 +394,7 @@ COBALT_IMPL(int, pthread_create, (pthread_t *tid,
        attr_ex.nonstd.sched_param.sched_priority = param.sched_priority;
        attr_ex.nonstd.personality = 0; /* Default: use Cobalt. */
 
-       return pthread_create_ex(tid, &attr_ex, start, arg);
+       return pthread_create_ex(ptid_r, &attr_ex, start, arg);
 }
 
 int pthread_make_periodic_np(pthread_t thread,
diff --git a/lib/cobalt/wrappers.c b/lib/cobalt/wrappers.c
index bf07a04..55e120d 100644
--- a/lib/cobalt/wrappers.c
+++ b/lib/cobalt/wrappers.c
@@ -77,23 +77,23 @@ int __real_sched_get_priority_max(int policy)
 
 /* pthread */
 __attribute__ ((weak))
-int __real_pthread_create(pthread_t *tid,
+int __real_pthread_create(pthread_t *ptid_r,
                          const pthread_attr_t * attr,
                          void *(*start) (void *), void *arg)
 {
-       return pthread_create(tid, attr, start, arg);
+       return pthread_create(ptid_r, attr, start, arg);
 }
 
 __attribute__ ((weak))
-int __real_pthread_kill(pthread_t tid, int sig)
+int __real_pthread_kill(pthread_t ptid, int sig)
 {
-       return pthread_kill(tid, sig);
+       return pthread_kill(ptid, sig);
 }
 
 __attribute__ ((weak))
-int __real_pthread_join(pthread_t tid, void **retval)
+int __real_pthread_join(pthread_t ptid, void **retval)
 {
-       return pthread_join(tid, retval);
+       return pthread_join(ptid, retval);
 }
 
 /* semaphores */


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

Reply via email to