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

Author: Philippe Gerum <r...@xenomai.org>
Date:   Fri Jan 21 15:14:55 2011 +0100

nucleus/types.h: fix for uClibc/C++ inclusion (via stdio.h)

uClibc may cause early inclusion of nucleus/types.h from stdio.h, thus
leading to a chicken-and-egg issue when inline routines in the former
refer to stdio symbols (e.g. C++ via mutex support dragged in by
stdio.h).

Turn those inlines into to macros to defer actual references.

---

 include/nucleus/types.h |   17 ++++++++---------
 1 files changed, 8 insertions(+), 9 deletions(-)

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-git mailing list
Xenomai-git@gna.org
https://mail.gna.org/listinfo/xenomai-git

Reply via email to