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

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

copperplate/threadobj: 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/copperplate/threadobj.h |    2 +-
 lib/alchemy/task.c              |    4 ++--
 lib/copperplate/internal.c      |   16 ++++++++--------
 lib/copperplate/internal.h      |    4 ++--
 lib/copperplate/threadobj.c     |   30 +++++++++++++++---------------
 lib/psos/task.c                 |    2 +-
 lib/vxworks/taskInfo.c          |    2 +-
 lib/vxworks/taskLib.c           |    2 +-
 8 files changed, 31 insertions(+), 31 deletions(-)

diff --git a/include/copperplate/threadobj.h b/include/copperplate/threadobj.h
index b58196d..a8e049f 100644
--- a/include/copperplate/threadobj.h
+++ b/include/copperplate/threadobj.h
@@ -154,7 +154,7 @@ struct syncobj;
 
 struct threadobj {
        unsigned int magic;     /* Must be first. */
-       pthread_t tid;
+       pthread_t ptid;
        pthread_mutex_t lock;
 
        int schedlock_depth;
diff --git a/lib/alchemy/task.c b/lib/alchemy/task.c
index 983cfef..18c11dc 100644
--- a/lib/alchemy/task.c
+++ b/lib/alchemy/task.c
@@ -424,11 +424,11 @@ int rt_task_create(RT_TASK *task, const char *name,
        cta.arg = tcb;
        cta.stacksize = stksize;
 
-       ret = __bt(copperplate_create_thread(&cta, &tcb->thobj.tid));
+       ret = __bt(copperplate_create_thread(&cta, &tcb->thobj.ptid));
        if (ret)
                delete_tcb(tcb);
        else
-               task->thread = tcb->thobj.tid;
+               task->thread = tcb->thobj.ptid;
 out:
        CANCEL_RESTORE(svc);
 
diff --git a/lib/copperplate/internal.c b/lib/copperplate/internal.c
index a0c158a..b72ff45 100644
--- a/lib/copperplate/internal.c
+++ b/lib/copperplate/internal.c
@@ -53,7 +53,7 @@ pid_t copperplate_get_tid(void)
 #include "cobalt/internal.h"
 
 int copperplate_create_thread(struct corethread_attributes *cta,
-                             pthread_t *tid)
+                             pthread_t *ptid_r)
 {
        pthread_attr_ex_t attr_ex;
        size_t stacksize;
@@ -71,7 +71,7 @@ int copperplate_create_thread(struct corethread_attributes 
*cta,
        pthread_attr_setinheritsched_ex(&attr_ex, PTHREAD_INHERIT_SCHED);
        pthread_attr_setstacksize_ex(&attr_ex, stacksize);
        pthread_attr_setdetachstate_ex(&attr_ex, cta->detachstate);
-       ret = __bt(-pthread_create_ex(tid, &attr_ex, thread_trampoline, cta));
+       ret = __bt(-pthread_create_ex(ptid_r, &attr_ex, thread_trampoline, 
cta));
        pthread_attr_destroy_ex(&attr_ex);
        if (ret)
                return __bt(ret);
@@ -79,10 +79,10 @@ int copperplate_create_thread(struct corethread_attributes 
*cta,
        return __bt(thread_spawn_epilogue(cta));
 }
 
-int copperplate_renice_local_thread(pthread_t tid, int policy,
+int copperplate_renice_local_thread(pthread_t ptid, int policy,
                                    const struct sched_param_ex *param_ex)
 {
-       return __bt(-pthread_setschedparam_ex(tid, policy, param_ex));
+       return __bt(-pthread_setschedparam_ex(ptid, policy, param_ex));
 }
 
 static inline void prepare_wait_corespec(void)
@@ -110,7 +110,7 @@ int copperplate_kill_tid(pid_t tid, int sig)
 }
 
 int copperplate_create_thread(struct corethread_attributes *cta,
-                             pthread_t *tid)
+                             pthread_t *ptid_r)
 {
        pthread_attr_t attr;
        size_t stacksize;
@@ -128,7 +128,7 @@ int copperplate_create_thread(struct corethread_attributes 
*cta,
        pthread_attr_setinheritsched(&attr, PTHREAD_INHERIT_SCHED);
        pthread_attr_setstacksize(&attr, stacksize);
        pthread_attr_setdetachstate(&attr, cta->detachstate);
-       ret = __bt(-pthread_create(tid, &attr, thread_trampoline, cta));
+       ret = __bt(-pthread_create(ptid_r, &attr, thread_trampoline, cta));
        pthread_attr_destroy(&attr);
 
        if (ret)
@@ -137,14 +137,14 @@ int copperplate_create_thread(struct 
corethread_attributes *cta,
        return __bt(thread_spawn_epilogue(cta));
 }
 
-int copperplate_renice_local_thread(pthread_t tid, int policy,
+int copperplate_renice_local_thread(pthread_t ptid, int policy,
                                    const struct sched_param_ex *param_ex)
 {
        struct sched_param param = {
                .sched_priority = param_ex->sched_priority,
        };
 
-       return __bt(-__RT(pthread_setschedparam(tid, policy, &param)));
+       return __bt(-__RT(pthread_setschedparam(ptid, policy, &param)));
 }
 
 static inline void prepare_wait_corespec(void)
diff --git a/lib/copperplate/internal.h b/lib/copperplate/internal.h
index 034be93..3840ebe 100644
--- a/lib/copperplate/internal.h
+++ b/lib/copperplate/internal.h
@@ -81,9 +81,9 @@ pid_t copperplate_get_tid(void);
 int copperplate_kill_tid(pid_t tid, int sig);
 
 int copperplate_create_thread(struct corethread_attributes *cta,
-                             pthread_t *tid);
+                             pthread_t *ptid);
 
-int copperplate_renice_local_thread(pthread_t tid, int policy,
+int copperplate_renice_local_thread(pthread_t ptid, int policy,
                                    const struct sched_param_ex *param_ex);
 
 void copperplate_bootstrap_minimal(const char *arg0,
diff --git a/lib/copperplate/threadobj.c b/lib/copperplate/threadobj.c
index ba0e4a3..22ea649 100644
--- a/lib/copperplate/threadobj.c
+++ b/lib/copperplate/threadobj.c
@@ -87,11 +87,11 @@ static pid_t agent_pid;
 #define RMT_CANCEL     1
 
 struct remote_cancel {
-       pthread_t tid;
+       pthread_t ptid;
 };
 
 struct remote_setsched {
-       pthread_t tid;
+       pthread_t ptid;
        int policy;
        struct sched_param_ex param_ex;
 };
@@ -150,12 +150,12 @@ static void *agent_loop(void *arg)
                rq = si.si_ptr;
                switch (rq->req) {
                case RMT_SETSCHED:
-                       ret = 
copperplate_renice_local_thread(rq->u.setsched.tid,
+                       ret = 
copperplate_renice_local_thread(rq->u.setsched.ptid,
                                                              
rq->u.setsched.policy,
                                                              
&rq->u.setsched.param_ex);
                        break;
                case RMT_CANCEL:
-                       ret = pthread_cancel(rq->u.cancel.tid);
+                       ret = pthread_cancel(rq->u.cancel.ptid);
                        break;
                default:
                        panic("invalid remote request #%d", rq->req);
@@ -187,7 +187,7 @@ static inline int send_agent(struct threadobj *thobj,
 static void start_agent(void)
 {
        struct corethread_attributes cta;
-       pthread_t tid;
+       pthread_t ptid;
        sigset_t set;
        int ret;
 
@@ -210,7 +210,7 @@ static void start_agent(void)
        cta.stacksize = PTHREAD_STACK_MIN * 4;
        cta.detachstate = PTHREAD_CREATE_DETACHED;
 
-       ret = copperplate_create_thread(&cta, &tid);
+       ret = copperplate_create_thread(&cta, &ptid);
        if (ret)
                panic("failed to start agent thread, %s", symerror(ret));
 }
@@ -454,7 +454,7 @@ int threadobj_set_periodic(struct threadobj *thobj,
 {                              /* thobj->lock held */
        __threadobj_check_locked(thobj);
 
-       return -pthread_make_periodic_np(thobj->tid,
+       return -pthread_make_periodic_np(thobj->ptid,
                                         CLOCK_COPPERPLATE, idate, period);
 }
 
@@ -942,7 +942,7 @@ static int request_setschedparam(struct threadobj *thobj, 
int policy,
                        return -ENOMEM;
 
                rq->req = RMT_SETSCHED;
-               rq->u.setsched.tid = thobj->tid;
+               rq->u.setsched.ptid = thobj->ptid;
                rq->u.setsched.policy = policy;
                rq->u.setsched.param_ex = *param_ex;
 
@@ -952,12 +952,12 @@ static int request_setschedparam(struct threadobj *thobj, 
int policy,
                return ret;
        }
 #endif
-       return __bt(copperplate_renice_local_thread(thobj->tid, policy, 
param_ex));
+       return __bt(copperplate_renice_local_thread(thobj->ptid, policy, 
param_ex));
 }
 
 static int request_cancel(struct threadobj *thobj) /* thobj->lock held, 
dropped. */
 {
-       pthread_t tid = thobj->tid;
+       pthread_t ptid = thobj->ptid;
 #ifdef CONFIG_XENO_PSHARED
        struct remote_request *rq;
        int ret;
@@ -969,7 +969,7 @@ static int request_cancel(struct threadobj *thobj) /* 
thobj->lock held, dropped.
                        return -ENOMEM;
 
                rq->req = RMT_CANCEL;
-               rq->u.cancel.tid = tid;
+               rq->u.cancel.ptid = ptid;
 
                ret = __bt(send_agent(thobj, rq));
                if (ret)
@@ -981,7 +981,7 @@ static int request_cancel(struct threadobj *thobj) /* 
thobj->lock held, dropped.
 
        /* We might race, glibc will check. */
 
-       pthread_cancel(tid);
+       pthread_cancel(ptid);
 
        return 0;
 }
@@ -1025,7 +1025,7 @@ int threadobj_init(struct threadobj *thobj,
        int ret;
 
        thobj->magic = idata->magic;
-       thobj->tid = 0;
+       thobj->ptid = 0;
        thobj->tracer = NULL;
        thobj->wait_sobj = NULL;
        thobj->finalizer = idata->finalizer;
@@ -1237,7 +1237,7 @@ int threadobj_prologue(struct threadobj *thobj, const 
char *name)
        } else
                *thobj->name = '\0';
 
-       thobj->tid = pthread_self();
+       thobj->ptid = pthread_self();
        thobj->pid = copperplate_get_tid();
        thobj->errno_pointer = &errno;
        threadobj_set_agent(thobj);
@@ -1445,7 +1445,7 @@ int threadobj_unblock(struct threadobj *thobj) /* 
thobj->lock held */
        if (!threadobj_local_p(thobj))
                return __bt(-copperplate_kill_tid(thobj->pid, SIGRELS));
 
-       return __bt(-__RT(pthread_kill(thobj->tid, SIGRELS)));
+       return __bt(-__RT(pthread_kill(thobj->ptid, SIGRELS)));
 }
 
 int threadobj_sleep(const struct timespec *ts)
diff --git a/lib/psos/task.c b/lib/psos/task.c
index 1eaf86b..e705a93 100644
--- a/lib/psos/task.c
+++ b/lib/psos/task.c
@@ -345,7 +345,7 @@ u_long t_create(const char *name, u_long prio,
        cta.stacksize = ustack;
        cta.detachstate = PTHREAD_CREATE_DETACHED;
 
-       ret = __bt(copperplate_create_thread(&cta, &task->thobj.tid));
+       ret = __bt(copperplate_create_thread(&cta, &task->thobj.ptid));
        if (ret) {
                cluster_delobj(&psos_task_table, &task->cobj);
        fail_register:
diff --git a/lib/vxworks/taskInfo.c b/lib/vxworks/taskInfo.c
index ae5b5be..e5fa90b 100644
--- a/lib/vxworks/taskInfo.c
+++ b/lib/vxworks/taskInfo.c
@@ -123,7 +123,7 @@ STATUS taskGetInfo(TASK_ID task_id, TASK_DESC *desc)
        strncpy(desc->td_name, task->name, sizeof(desc->td_name));
        desc->td_entry = tcb->entry;
        desc->td_errorStatus = *task->thobj.errno_pointer;
-       ret = pthread_getattr_np(task->thobj.tid, &attr);
+       ret = pthread_getattr_np(task->thobj.ptid, &attr);
        put_wind_task(task);
 
        /*
diff --git a/lib/vxworks/taskLib.c b/lib/vxworks/taskLib.c
index 41001cf..e1683e6 100644
--- a/lib/vxworks/taskLib.c
+++ b/lib/vxworks/taskLib.c
@@ -396,7 +396,7 @@ static STATUS __taskInit(struct wind_task *task,
        cta.arg = task;
        cta.stacksize = stacksize;
        cta.detachstate = PTHREAD_CREATE_DETACHED;
-       ret = __bt(copperplate_create_thread(&cta, &task->thobj.tid));
+       ret = __bt(copperplate_create_thread(&cta, &task->thobj.ptid));
        if (ret) {
                registry_destroy_file(&task->fsobj);
                cluster_delobj(&wind_task_table, &task->cobj);


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

Reply via email to