Module: xenomai-head
Branch: master
Commit: 4a2188f049e96fc59aa7c4a7a9d058075f3d79e8
URL:    
http://git.xenomai.org/?p=xenomai-head.git;a=commit;h=4a2188f049e96fc59aa7c4a7a9d058075f3d79e8

Author: Gilles Chanteperdrix <gilles.chanteperd...@xenomai.org>
Date:   Tue Sep 27 23:16:37 2011 +0200

psos: fix short/long name issues

While psos interface accepts 4 character ids, non null terminated,
xenomai uses longer ids which must be null terminated. Revert to
the behaviour of psos interface, while allowing long id strings if
the global variable psos_long_names is set to non-zero.

---

 include/psos+/Makefile.am  |    1 +
 include/psos+/Makefile.in  |    1 +
 include/psos+/long_names.h |   14 ++++++++++++++
 include/psos+/psos.h       |    2 ++
 src/skins/psos+/init.c     |   13 +++++++++++++
 src/skins/psos+/queue.c    |    5 +++++
 src/skins/psos+/rn.c       |    4 ++++
 src/skins/psos+/sem.c      |    5 +++++
 src/skins/psos+/task.c     |    4 ++++
 9 files changed, 49 insertions(+), 0 deletions(-)

diff --git a/include/psos+/Makefile.am b/include/psos+/Makefile.am
index 03915c2..8b362b0 100644
--- a/include/psos+/Makefile.am
+++ b/include/psos+/Makefile.am
@@ -4,6 +4,7 @@ includesub_HEADERS = \
        asr.h \
        defs.h \
        event.h \
+       long_names.h \
        ppd.h \
        psos.h \
        pt.h \
diff --git a/include/psos+/Makefile.in b/include/psos+/Makefile.in
index a643804..180d28c 100644
--- a/include/psos+/Makefile.in
+++ b/include/psos+/Makefile.in
@@ -240,6 +240,7 @@ includesub_HEADERS = \
        asr.h \
        defs.h \
        event.h \
+       long_names.h \
        ppd.h \
        psos.h \
        pt.h \
diff --git a/include/psos+/long_names.h b/include/psos+/long_names.h
new file mode 100644
index 0000000..a59d94f
--- /dev/null
+++ b/include/psos+/long_names.h
@@ -0,0 +1,14 @@
+#ifndef LONG_NAMES_H
+#define LONG_NAMES_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+const char *__psos_maybe_short_name(char shrt[5], const char *lng);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* LONG_NAMES_H */
diff --git a/include/psos+/psos.h b/include/psos+/psos.h
index 32281bc..4a3921a 100644
--- a/include/psos+/psos.h
+++ b/include/psos+/psos.h
@@ -197,6 +197,8 @@ u_long t_restart(u_long tid,
 
 #include <psos+/syscall.h>
 
+extern unsigned psos_long_names;
+
 #endif /* __KERNEL__ || __XENO_SIM__ */
 
 /*
diff --git a/src/skins/psos+/init.c b/src/skins/psos+/init.c
index 978a4f1..e53967b 100644
--- a/src/skins/psos+/init.c
+++ b/src/skins/psos+/init.c
@@ -26,6 +26,8 @@ int __psos_muxid = -1;
 
 xnsysinfo_t __psos_sysinfo;
 
+unsigned psos_long_names;
+
 static __attribute__ ((constructor))
 void __init_xeno_interface(void)
 {
@@ -68,3 +70,14 @@ void k_fatal(u_long err_code, u_long flags)
 {
        exit(1);
 }
+
+const char *__psos_maybe_short_name(char shrt[5], const char *lng)
+{
+       if (psos_long_names)
+               return lng;
+
+       strncpy(shrt, lng, sizeof(shrt) - 1);
+       shrt[4] = '\0';
+
+       return (const char *)shrt;
+}
diff --git a/src/skins/psos+/queue.c b/src/skins/psos+/queue.c
index c54f966..f21a599 100644
--- a/src/skins/psos+/queue.c
+++ b/src/skins/psos+/queue.c
@@ -17,11 +17,16 @@
  */
 
 #include <psos+/psos.h>
+#include <psos+/long_names.h>
 
 extern int __psos_muxid;
 
 u_long q_create(const char *name, u_long maxnum, u_long flags, u_long *qid_r)
 {
+       char short_name[5];
+
+       name = __psos_maybe_short_name(short_name, name);
+
        return XENOMAI_SKINCALL4(__psos_muxid, __psos_q_create,
                                 name, maxnum, flags, qid_r);
 }
diff --git a/src/skins/psos+/rn.c b/src/skins/psos+/rn.c
index f254e37..2219f36 100644
--- a/src/skins/psos+/rn.c
+++ b/src/skins/psos+/rn.c
@@ -24,6 +24,7 @@
 #include <stdio.h>
 #include <nucleus/heap.h>
 #include <psos+/psos.h>
+#include <psos+/long_names.h>
 
 extern int __psos_muxid;
 
@@ -59,6 +60,7 @@ u_long rn_create(const char name[4],
                 u_long usize, u_long flags, u_long *rnid, u_long *allocsz)
 {
        struct rninfo rninfo;
+       char short_name[5];
        struct {
                u_long rnsize;
                u_long usize;
@@ -66,6 +68,8 @@ u_long rn_create(const char name[4],
        } sizeopt;
        u_long err;
 
+       name = __psos_maybe_short_name(short_name, name);
+
        if (rnaddr)
                fprintf(stderr,
                        "rn_create() - rnaddr parameter ignored from user-space 
context\n");
diff --git a/src/skins/psos+/sem.c b/src/skins/psos+/sem.c
index 5020274..0fad0ea 100644
--- a/src/skins/psos+/sem.c
+++ b/src/skins/psos+/sem.c
@@ -17,11 +17,16 @@
  */
 
 #include <psos+/psos.h>
+#include <psos+/long_names.h>
 
 extern int __psos_muxid;
 
 u_long sm_create(const char name[4], u_long icount, u_long flags, u_long 
*smid_r)
 {
+       char short_name[5];
+
+       name = __psos_maybe_short_name(short_name, name);
+
        return XENOMAI_SKINCALL4(__psos_muxid, __psos_sm_create,
                                 name, icount, flags, smid_r);
 }
diff --git a/src/skins/psos+/task.c b/src/skins/psos+/task.c
index a43f7fb..2b70b31 100644
--- a/src/skins/psos+/task.c
+++ b/src/skins/psos+/task.c
@@ -26,6 +26,7 @@
 #include <memory.h>
 #include <string.h>
 #include <psos+/psos.h>
+#include <psos+/long_names.h>
 #include <asm-generic/bits/sigshadow.h>
 #include <asm-generic/bits/current.h>
 #include <asm-generic/stack.h>
@@ -124,10 +125,13 @@ u_long t_create(const char *name,
        xncompletion_t completion;
        struct sched_param param;
        pthread_attr_t thattr;
+       char short_name[5];
        pthread_t thid;
        int policy;
        long err;
 
+       name = __psos_maybe_short_name(short_name, name);
+
        /* Migrate this thread to the Linux domain since we are about
           to issue a series of regular kernel syscalls in order to
           create the new Linux thread, which in turn will be mapped


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

Reply via email to