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

Author: Philippe Gerum <r...@xenomai.org>
Date:   Tue Jul  1 09:09:40 2014 +0200

cobalt: fix naming consistency issues with *_np() calls

To match the GNU extension equivalent, pthread_set_name_np() is
renamed to pthread_setname_np(). For consistency with the previous
change, pthread_set_mode_np() becomes pthread_setmode_np().

The former calls will be available from the upcoming transition kit.

---

 demo/posix/can-rtt.c                       |    4 ++--
 include/cobalt/pthread.h                   |    8 +++----
 include/cobalt/uapi/syscall.h              |    4 ++--
 kernel/cobalt/Kconfig                      |    2 +-
 kernel/cobalt/posix/sched.c                |    2 +-
 kernel/cobalt/posix/syscall.c              |    4 ++--
 kernel/cobalt/posix/thread.c               |   12 +++++------
 kernel/cobalt/posix/thread.h               |    4 ++--
 kernel/cobalt/trace/cobalt-posix.h         |    6 +++---
 lib/cobalt/thread.c                        |   31 ++++------------------------
 lib/copperplate/threadobj.c                |   10 ++++-----
 lib/copperplate/timerobj.c                 |    2 +-
 testsuite/latency/latency.c                |    2 +-
 testsuite/smokey/sched-quota/sched-quota.c |    4 ++--
 testsuite/smokey/sched-tp/sched-tp.c       |    2 +-
 testsuite/switchtest/switchtest.c          |   24 ++++++++++-----------
 16 files changed, 49 insertions(+), 72 deletions(-)

diff --git a/demo/posix/can-rtt.c b/demo/posix/can-rtt.c
index 62298fc..e8911b8 100644
--- a/demo/posix/can-rtt.c
+++ b/demo/posix/can-rtt.c
@@ -102,7 +102,7 @@ static void *transmitter(void *arg)
     frame.can_dlc = sizeof(*rtt_time);
 
 #ifdef CONFIG_XENO_COBALT
-    pthread_set_name_np(pthread_self(), "rtcan_rtt_transmitter");
+    pthread_setname_np(pthread_self(), "rtcan_rtt_transmitter");
 #endif
     pthread_setschedparam(pthread_self(), SCHED_FIFO, &param);
 
@@ -148,7 +148,7 @@ static void *receiver(void *arg)
                                0, 0, 0};
 
 #ifdef CONFIG_XENO_COBALT
-    pthread_set_name_np(pthread_self(), "rtcan_rtt_receiver");
+    pthread_setname_np(pthread_self(), "rtcan_rtt_receiver");
 #endif
     pthread_setschedparam(pthread_self(), SCHED_FIFO, &param);
 
diff --git a/include/cobalt/pthread.h b/include/cobalt/pthread.h
index 8393bf6..58e279e 100644
--- a/include/cobalt/pthread.h
+++ b/include/cobalt/pthread.h
@@ -96,11 +96,11 @@ COBALT_DECL(int, pthread_kill(pthread_t ptid, int sig));
 
 COBALT_DECL(int, pthread_join(pthread_t ptid, void **retval));
 
-int pthread_set_mode_np(int clrmask, int setmask,
-                       int *mask_r);
+int pthread_setmode_np(int clrmask, int setmask,
+                      int *mask_r);
 
-int pthread_set_name_np(pthread_t thread,
-                       const char *name);
+/* May be absent from outdated glibc releases. */
+int pthread_setname_np(pthread_t thread, const char *name);
 
 COBALT_DECL(int, pthread_setname_np(pthread_t thread, const char *name));
 
diff --git a/include/cobalt/uapi/syscall.h b/include/cobalt/uapi/syscall.h
index e0b7ca0..29756b7 100644
--- a/include/cobalt/uapi/syscall.h
+++ b/include/cobalt/uapi/syscall.h
@@ -27,8 +27,8 @@
 #define sc_cobalt_sched_weightprio      2
 #define sc_cobalt_sched_yield           3
 /* 4-5 unimplemented */
-#define sc_cobalt_thread_set_mode       6
-#define sc_cobalt_thread_set_name       7
+#define sc_cobalt_thread_setmode        6
+#define sc_cobalt_thread_setname        7
 #define sc_cobalt_sem_init              8
 #define sc_cobalt_sem_destroy           9
 #define sc_cobalt_sem_post              10
diff --git a/kernel/cobalt/Kconfig b/kernel/cobalt/Kconfig
index 8212c72..2d6a564 100644
--- a/kernel/cobalt/Kconfig
+++ b/kernel/cobalt/Kconfig
@@ -403,7 +403,7 @@ config XENO_OPT_DEBUG_SYNCH_RELAX
        another thread currently running in secondary mode (i.e. plain
        Linux execution mode). The SIGDEBUG signal may be sent in such
        a case to the sleeper, provided the WARNSW flag is enabled for
-       it, as set by e.g. rt_task_set_mode() or pthread_set_mode_np().
+       it, as set by e.g. rt_task_set_mode() or pthread_setmode_np().
 
        This particular situation is a possible source of unwanted
        latency, since the current mutex owner may be unexpectedly
diff --git a/kernel/cobalt/posix/sched.c b/kernel/cobalt/posix/sched.c
index 57e5fcc..ab1da49 100644
--- a/kernel/cobalt/posix/sched.c
+++ b/kernel/cobalt/posix/sched.c
@@ -522,7 +522,7 @@ int cobalt_sched_setconfig_np(int cpu, int policy,
        union sched_config *buf;
        int ret;
 
-       trace_cobalt_sched_set_config(cpu, policy, len);
+       trace_cobalt_sched_setconfig(cpu, policy, len);
 
        if (cpu < 0 || cpu >= NR_CPUS || !cpu_online(cpu))
                return -EINVAL;
diff --git a/kernel/cobalt/posix/syscall.c b/kernel/cobalt/posix/syscall.c
index 2d60769..04be66d 100644
--- a/kernel/cobalt/posix/syscall.c
+++ b/kernel/cobalt/posix/syscall.c
@@ -92,8 +92,8 @@ static struct xnsyscall cobalt_syscalls[] = {
        SKINCALL_DEF(sc_cobalt_thread_getschedparam_ex, 
cobalt_thread_getschedparam_ex, current),
        SKINCALL_DEF(sc_cobalt_sched_weightprio, cobalt_sched_weighted_prio, 
current),
        SKINCALL_DEF(sc_cobalt_sched_yield, cobalt_sched_yield, primary),
-       SKINCALL_DEF(sc_cobalt_thread_set_mode, cobalt_thread_set_mode_np, 
primary),
-       SKINCALL_DEF(sc_cobalt_thread_set_name, cobalt_thread_set_name_np, 
current),
+       SKINCALL_DEF(sc_cobalt_thread_setmode, cobalt_thread_setmode_np, 
primary),
+       SKINCALL_DEF(sc_cobalt_thread_setname, cobalt_thread_setname_np, 
current),
        SKINCALL_DEF(sc_cobalt_thread_kill, cobalt_thread_kill, conforming),
        SKINCALL_DEF(sc_cobalt_thread_getstat, cobalt_thread_stat, current),
        SKINCALL_DEF(sc_cobalt_thread_join, cobalt_thread_join, primary),
diff --git a/kernel/cobalt/posix/thread.c b/kernel/cobalt/posix/thread.c
index 9669d19..e3cf3cc 100644
--- a/kernel/cobalt/posix/thread.c
+++ b/kernel/cobalt/posix/thread.c
@@ -417,7 +417,7 @@ static inline int pthread_create(struct cobalt_thread 
**thread_p,
        return 0;
 }
 
-static inline int pthread_set_mode_np(int clrmask, int setmask, int *mode_r)
+static inline int pthread_setmode_np(int clrmask, int setmask, int *mode_r)
 {
        const int valid_flags = XNLOCK|XNWARN|XNTRAPLB;
        struct xnthread *curr = xnshadow_current();
@@ -604,13 +604,13 @@ fail:
        return ERR_PTR(ret);
 }
 
-int cobalt_thread_set_mode_np(int clrmask, int setmask, int __user *u_mode_r)
+int cobalt_thread_setmode_np(int clrmask, int setmask, int __user *u_mode_r)
 {
        int ret, old;
 
-       trace_cobalt_pthread_set_mode(clrmask, setmask);
+       trace_cobalt_pthread_setmode(clrmask, setmask);
 
-       ret = pthread_set_mode_np(clrmask, setmask, &old);
+       ret = pthread_setmode_np(clrmask, setmask, &old);
        if (ret)
                return ret;
 
@@ -620,7 +620,7 @@ int cobalt_thread_set_mode_np(int clrmask, int setmask, int 
__user *u_mode_r)
        return 0;
 }
 
-int cobalt_thread_set_name_np(unsigned long pth, const char __user *u_name)
+int cobalt_thread_setname_np(unsigned long pth, const char __user *u_name)
 {
        struct cobalt_local_hkey hkey;
        struct cobalt_thread *thread;
@@ -636,7 +636,7 @@ int cobalt_thread_set_name_np(unsigned long pth, const char 
__user *u_name)
        hkey.u_pth = pth;
        hkey.mm = current->mm;
 
-       trace_cobalt_pthread_set_name(pth, name);
+       trace_cobalt_pthread_setname(pth, name);
 
        xnlock_get_irqsave(&nklock, s);
 
diff --git a/kernel/cobalt/posix/thread.h b/kernel/cobalt/posix/thread.h
index 90c4b0b..426231c 100644
--- a/kernel/cobalt/posix/thread.h
+++ b/kernel/cobalt/posix/thread.h
@@ -138,9 +138,9 @@ cobalt_thread_shadow(struct task_struct *p,
                     struct cobalt_local_hkey *lhkey,
                     unsigned long __user *u_window_offset);
 
-int cobalt_thread_set_mode_np(int clrmask, int setmask, int __user *u_mode_r);
+int cobalt_thread_setmode_np(int clrmask, int setmask, int __user *u_mode_r);
 
-int cobalt_thread_set_name_np(unsigned long tid, const char __user *u_name);
+int cobalt_thread_setname_np(unsigned long tid, const char __user *u_name);
 
 int cobalt_thread_probe_np(pid_t h_tid);
 
diff --git a/kernel/cobalt/trace/cobalt-posix.h 
b/kernel/cobalt/trace/cobalt-posix.h
index b3a5654..e731dc6 100644
--- a/kernel/cobalt/trace/cobalt-posix.h
+++ b/kernel/cobalt/trace/cobalt-posix.h
@@ -135,7 +135,7 @@ DEFINE_EVENT(cobalt_posix_schedparam, 
cobalt_pthread_getschedparam,
                      {PTHREAD_LOCK_SCHED, "lock"},             \
                      {PTHREAD_DISABLE_LOCKBREAK, "nolockbreak"})
 
-TRACE_EVENT(cobalt_pthread_set_mode,
+TRACE_EVENT(cobalt_pthread_setmode,
        TP_PROTO(int clrmask, int setmask),
        TP_ARGS(clrmask, setmask),
        TP_STRUCT__entry(
@@ -151,7 +151,7 @@ TRACE_EVENT(cobalt_pthread_set_mode,
                  __entry->setmask, cobalt_print_thread_mode(__entry->setmask))
 );
 
-TRACE_EVENT(cobalt_pthread_set_name,
+TRACE_EVENT(cobalt_pthread_setname,
        TP_PROTO(unsigned long pth, const char *name),
        TP_ARGS(pth, name),
        TP_STRUCT__entry(
@@ -246,7 +246,7 @@ DEFINE_EVENT(cobalt_void, cobalt_pthread_yield,
        TP_ARGS(dummy)
 );
 
-TRACE_EVENT(cobalt_sched_set_config,
+TRACE_EVENT(cobalt_sched_setconfig,
        TP_PROTO(int cpu, int policy, size_t len),
        TP_ARGS(cpu, policy, len),
        TP_STRUCT__entry(
diff --git a/lib/cobalt/thread.c b/lib/cobalt/thread.c
index c46a051..1ec55c2 100644
--- a/lib/cobalt/thread.c
+++ b/lib/cobalt/thread.c
@@ -169,7 +169,7 @@ sync_with_creator:
 
        retval = start(arg);
 
-       pthread_set_mode_np(PTHREAD_WARNSW, 0, NULL);
+       pthread_setmode_np(PTHREAD_WARNSW, 0, NULL);
 
        return retval;
 }
@@ -378,10 +378,10 @@ COBALT_IMPL(int, pthread_create, (pthread_t *ptid_r,
  * @note Setting @a clrmask and @a setmask to zero leads to a nop,
  * only returning the previous mode if @a mode_r is a valid address.
  */
-int pthread_set_mode_np(int clrmask, int setmask, int *mode_r)
+int pthread_setmode_np(int clrmask, int setmask, int *mode_r)
 {
        return -XENOMAI_SKINCALL3(__cobalt_muxid,
-                                 sc_cobalt_thread_set_mode,
+                                 sc_cobalt_thread_setmode,
                                  clrmask, setmask, mode_r);
 }
 
@@ -402,33 +402,10 @@ int pthread_set_mode_np(int clrmask, int setmask, int 
*mode_r)
  * - ESRCH, @a thread is invalid.
  *
  */
-int pthread_set_name_np(pthread_t thread, const char *name)
-{
-       return -XENOMAI_SKINCALL2(__cobalt_muxid,
-                                 sc_cobalt_thread_set_name, thread, name);
-}
-
-/**
- * Set a thread name.
- *
- * This service set to @a name, the name of @a thread. This name is used for
- * displaying information in /proc/xenomai/sched.
- *
- * This service is a non-portable extension of the POSIX interface.
- *
- * @param thread target thread;
- *
- * @param name name of the thread.
- *
- * @return 0 on success;
- * @return an error number if:
- * - ESRCH, @a thread is invalid.
- *
- */
 COBALT_IMPL(int, pthread_setname_np, (pthread_t thread, const char *name))
 {
        return -XENOMAI_SKINCALL2(__cobalt_muxid,
-                                 sc_cobalt_thread_set_name, thread, name);
+                                 sc_cobalt_thread_setname, thread, name);
 }
 
 /**
diff --git a/lib/copperplate/threadobj.c b/lib/copperplate/threadobj.c
index 28cd9d5..881b3ce 100644
--- a/lib/copperplate/threadobj.c
+++ b/lib/copperplate/threadobj.c
@@ -110,7 +110,7 @@ struct remote_request {
 
 static inline void agent_init_corespec(const char *name)
 {
-       pthread_set_name_np(pthread_self(), name);
+       __RT(pthread_setname_np(pthread_self(), name));
 }
 
 #else /* CONFIG_XENO_MERCURY */
@@ -255,7 +255,7 @@ static inline void threadobj_uninit_corespec(struct 
threadobj *thobj)
 
 static inline int threadobj_setup_corespec(struct threadobj *thobj)
 {
-       pthread_set_name_np(pthread_self(), thobj->name);
+       __RT(pthread_setname_np(pthread_self(), thobj->name));
        thobj->core.handle = cobalt_get_current();
        thobj->core.u_window = cobalt_get_current_window();
 
@@ -356,7 +356,7 @@ int __threadobj_lock_sched(struct threadobj *current)
         * locking the scheduler, so no need to drop the thread lock
         * across this call.
         */
-       return __bt(-pthread_set_mode_np(0, PTHREAD_LOCK_SCHED, NULL));
+       return __bt(-pthread_setmode_np(0, PTHREAD_LOCK_SCHED, NULL));
 }
 
 int threadobj_lock_sched(void)
@@ -383,7 +383,7 @@ int __threadobj_unlock_sched(struct threadobj *current)
        if (--current->schedlock_depth > 0)
                return 0;
 
-       return __bt(-pthread_set_mode_np(PTHREAD_LOCK_SCHED, 0, NULL));
+       return __bt(-pthread_setmode_np(PTHREAD_LOCK_SCHED, 0, NULL));
 }
 
 int threadobj_unlock_sched(void)
@@ -417,7 +417,7 @@ int threadobj_set_mode(int clrmask, int setmask, int 
*mode_r) /* current->lock h
                __threadobj_unlock_sched(current);
 
        if (mode_r || __setmask || __clrmask)
-               return __bt(-pthread_set_mode_np(__clrmask, __setmask, mode_r));
+               return __bt(-pthread_setmode_np(__clrmask, __setmask, mode_r));
 
        return 0;
 }
diff --git a/lib/copperplate/timerobj.c b/lib/copperplate/timerobj.c
index 665ff6a..0d185bc 100644
--- a/lib/copperplate/timerobj.c
+++ b/lib/copperplate/timerobj.c
@@ -47,7 +47,7 @@ static DEFINE_PRIVATE_LIST(svtimers);
 
 static inline void timersv_init_corespec(const char *name)
 {
-       pthread_set_name_np(pthread_self(), name);
+       __RT(pthread_setname_np(pthread_self(), name));
 }
 
 #else /* CONFIG_XENO_MERCURY */
diff --git a/testsuite/latency/latency.c b/testsuite/latency/latency.c
index 3c164ef..f6b537a 100644
--- a/testsuite/latency/latency.c
+++ b/testsuite/latency/latency.c
@@ -103,7 +103,7 @@ static void *latency(void *cookie)
        }
 
 #ifdef CONFIG_XENO_COBALT
-       err = pthread_set_mode_np(0, PTHREAD_WARNSW, NULL);
+       err = pthread_setmode_np(0, PTHREAD_WARNSW, NULL);
        if (err) {
                fprintf(stderr, "latency: setting WARNSW: error code %d\n", 
err);
                return NULL;
diff --git a/testsuite/smokey/sched-quota/sched-quota.c 
b/testsuite/smokey/sched-quota/sched-quota.c
index 1260e45..c06b993 100644
--- a/testsuite/smokey/sched-quota/sched-quota.c
+++ b/testsuite/smokey/sched-quota/sched-quota.c
@@ -120,7 +120,7 @@ static void __create_quota_thread(pthread_t *tid, const 
char *name,
                error(1, ret, "pthread_create_ex(SCHED_QUOTA)");
 
        pthread_attr_destroy_ex(&attr_ex);
-       pthread_set_name_np(*tid, name);
+       pthread_setname_np(*tid, name);
 }
 
 #define create_quota_thread(__tid, __label, __tgid, __count)   \
@@ -145,7 +145,7 @@ static void __create_fifo_thread(pthread_t *tid, const char 
*name,
                error(1, ret, "pthread_create(SCHED_FIFO)");
 
        pthread_attr_destroy(&attr);
-       pthread_set_name_np(*tid, name);
+       pthread_setname_np(*tid, name);
 }
 
 #define create_fifo_thread(__tid, __label, __count)    \
diff --git a/testsuite/smokey/sched-tp/sched-tp.c 
b/testsuite/smokey/sched-tp/sched-tp.c
index 6fcd38e..ee6a07f 100644
--- a/testsuite/smokey/sched-tp/sched-tp.c
+++ b/testsuite/smokey/sched-tp/sched-tp.c
@@ -87,7 +87,7 @@ static void __create_thread(pthread_t *tid, const char *name, 
int seq)
                error(1, ret, "pthread_create");
 
        pthread_attr_destroy(&attr);
-       pthread_set_name_np(*tid, name);
+       pthread_setname_np(*tid, name);
 }
 
 #define create_thread(tid, n) __create_thread(&(tid), # tid, n)
diff --git a/testsuite/switchtest/switchtest.c 
b/testsuite/switchtest/switchtest.c
index f39dc9e..b8b47a6 100644
--- a/testsuite/switchtest/switchtest.c
+++ b/testsuite/switchtest/switchtest.c
@@ -428,9 +428,9 @@ static void *rtup(void *cookie)
           allowed when suspended in ioctl. */
        pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
 
-       if ((err = pthread_set_mode_np(0, PTHREAD_CONFORMING, NULL))) {
+       if ((err = pthread_setmode_np(0, PTHREAD_CONFORMING, NULL))) {
                fprintf(stderr,
-                       "rtup: pthread_set_mode_np: %s\n",
+                       "rtup: pthread_setmode_np: %s\n",
                        strerror(err));
                clean_exit(EXIT_FAILURE);
        }
@@ -514,9 +514,9 @@ static void *rtus(void *cookie)
           allowed when suspended in ioctl. */
        pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
 
-       if ((err = pthread_set_mode_np(PTHREAD_CONFORMING, 0, NULL))) {
+       if ((err = pthread_setmode_np(PTHREAD_CONFORMING, 0, NULL))) {
                fprintf(stderr,
-                       "rtus: pthread_set_mode_np: %s\n",
+                       "rtus: pthread_setmode_np: %s\n",
                        strerror(err));
                clean_exit(EXIT_FAILURE);
        }
@@ -600,9 +600,9 @@ static void *rtuo(void *cookie)
           allowed when suspended in ioctl. */
        pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
 
-       if ((err = pthread_set_mode_np(0, PTHREAD_CONFORMING, NULL))) {
+       if ((err = pthread_setmode_np(0, PTHREAD_CONFORMING, NULL))) {
                fprintf(stderr,
-                       "rtup: pthread_set_mode_np: %s\n",
+                       "rtup: pthread_setmode_np: %s\n",
                        strerror(err));
                clean_exit(EXIT_FAILURE);
        }
@@ -659,10 +659,10 @@ static void *rtuo(void *cookie)
                /* Switch mode. */
                if (i % 3 == 2) {
                        mode = PTHREAD_CONFORMING - mode;
-                       if ((err = pthread_set_mode_np
+                       if ((err = pthread_setmode_np
                             (PTHREAD_CONFORMING - mode, mode, NULL))) {
                                fprintf(stderr,
-                                       "rtuo: pthread_set_mode_np: %s\n",
+                                       "rtuo: pthread_setmode_np: %s\n",
                                        strerror(err));
                                clean_exit(EXIT_FAILURE);
                        }
@@ -881,12 +881,12 @@ static int task_create(struct cpu_tasks *cpu,
                return err;
        }
 
-       err = pthread_set_name_np(param->thread,
-                                 task_name(buffer, sizeof(buffer),
-                                 param->cpu,param->swt.index));
+       err = pthread_setname_np(param->thread,
+                                task_name(buffer, sizeof(buffer),
+                                          param->cpu,param->swt.index));
 
        if (err)
-               fprintf(stderr,"pthread_set_name_np: %s\n", strerror(err));
+               fprintf(stderr,"pthread_setname_np: %s\n", strerror(err));
 
        return err;
 }


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

Reply via email to