On Fri, 2011-01-21 at 14:09 +0100, Kolja Waschk wrote:
> >>> program, since you should be using #include <pthread.h>, instead of
> >>> #include <posix/pthread.h>, and more importantly, this program is
> >>
> >> Yes. That's an artefact of another problem which seems more 
> >> toolchain-related
> >> in my case. Already noted in our issue tracking system. However, I tried to
> >
> > As reminder, the correct way to compile a xenomai posix skin program is
> > described here:
> > http://www.xenomai.org/index.php/Porting_POSIX_applications_to_Xenomai#Compilation_flags.
> 
> 
> It is impossible for me to use -I$(PREFIX)/include/posix so that I could 
> simply
> #include <pthread.h> when using bfin-linux-uclibc-g++(!). The result whenever 
> I
> just try to do something like #include <stdio.h> would be the following. It
> does work when using gcc instead of g++ (but that's obviously no option for 
> C++
> code)
> 
> 
> a.c: #include <stdio.h>
> 
> bfin-linux-uclibc-g++ -D_GNU_SOURCE -D_REENTRANT -D__XENO__ \
>      -I$PREFIX/usr/include -I$PREFIX/usr/include/posix -c a.c
> 
> 
> In file included from 
> /opt/uClinux/blackfin-linux-dist/staging/usr/include/nucleus/thread.h:25,
>                   from 
> /opt/uClinux/blackfin-linux-dist/staging/usr/include/posix/pthread.h:136,
>                   from 
> /opt/uClinux-2010R1-RC5_tools-RC4/bfin-linux-uclibc/bin/../bfin-linux-uclibc/runtime/usr/include/bits/uClibc_mutex.h:15,
>                   from 
> /opt/uClinux-2010R1-RC5_tools-RC4/bfin-linux-uclibc/bin/../bfin-linux-uclibc/runtime/usr/include/bits/uClibc_stdio.h:107,
>                   from 
> /opt/uClinux-2010R1-RC5_tools-RC4/bfin-linux-uclibc/bin/../bfin-linux-uclibc/runtime/usr/include/stdio.h:72,
>                   from a.c:1:
> /opt/uClinux/blackfin-linux-dist/staging/usr/include/nucleus/types.h: In 
> function ‘void xnobject_copy_name(char*, const char*)’:
> /opt/uClinux/blackfin-linux-dist/staging/usr/include/nucleus/types.h:113: 
> error: ‘snprintf’ was not declared in this scope
> 

diff --git a/include/nucleus/types.h b/include/nucleus/types.h
index f49131c..28726df 100644
--- a/include/nucleus/types.h
+++ b/include/nucleus/types.h
@@ -29,6 +29,7 @@
 #endif /* !CONFIG_PREEMPT_RT */
 #else /* !__KERNEL__ */
 #include <stdio.h>
+#include <string.h>
 #include <sys/types.h>
 #include <errno.h>
 #ifndef BITS_PER_LONG
@@ -107,16 +108,14 @@ typedef atomic_flags_t xnflags_t;
 
 #define XNOBJECT_NAME_LEN 32
 
-static inline void xnobject_copy_name(char *dst, const char *src)
-{
-    if (src)
-       snprintf(dst, XNOBJECT_NAME_LEN, "%s", src);
-    else
-        *dst = '\0';
-}
+#define xnobject_copy_name(dst, src)                                   \
+       do {                                                            \
+               strncpy((dst), (src) ?: "", XNOBJECT_NAME_LEN-1)        \
+                       [XNOBJECT_NAME_LEN-1] = '\0';                   \
+       } while (0)
 
-#define xnobject_create_name(dst, n, obj) \
-    snprintf(dst, n, "%p", obj)
+#define xnobject_create_name(dst, n, obj)      \
+       snprintf(dst, n, "%p", obj)
 
 #define minval(a,b) ((a) < (b) ? (a) : (b))
 #define maxval(a,b) ((a) > (b) ? (a) : (b))

> 
> 
> 
> 
> 
> _______________________________________________
> Xenomai-help mailing list
> [email protected]
> https://mail.gna.org/listinfo/xenomai-help

-- 
Philippe.



_______________________________________________
Xenomai-help mailing list
[email protected]
https://mail.gna.org/listinfo/xenomai-help

Reply via email to