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

Author: Gilles Chanteperdrix <gilles.chanteperd...@xenomai.org>
Date:   Fri Aug 21 23:37:54 2015 +0200

cobalt: declare missing libc functions when wrapping

When compiling with a toolchain which does not implement
pthread_setname_np or clock_nanosleep, these functions are not declared
as a result of including their respective header.

However, when passing --skin=posix to xeno-config, an application
expects these functions to be declared, since they are wrapped and
implemented by libcobalt.

Fix this by moving their declaration in boilerplate/libc.h out of the
ifdef __IN_XENO__ section, but making it depend on a __COBALT_WRAP__
symbol, set in xeno-config when --skin=posix is passed.

---

 include/boilerplate/libc.h    |   32 +++++++++++++++++++-------------
 scripts/xeno-config-cobalt.in |    1 +
 2 files changed, 20 insertions(+), 13 deletions(-)

diff --git a/include/boilerplate/libc.h b/include/boilerplate/libc.h
index 4d85ee9..7dd305f 100644
--- a/include/boilerplate/libc.h
+++ b/include/boilerplate/libc.h
@@ -144,15 +144,7 @@ __weak inline int clock_nanosleep(clockid_t clock_id, int 
flags,
 
        return nanosleep(&tmp, remain);
 }
-#else  /* HAVE_CLOCK_NANOSLEEP || COBALT */
-/*
- * Either libcobalt or the libc implements this, we only want the
- * possibly missing declaration from the libc headers.
- */
-int clock_nanosleep(clockid_t clock_id, int flags,
-                   const struct timespec *request,
-                   struct timespec *remain);
-#endif /* HAVE_CLOCK_NANOSLEEP || COBALT */
+#endif /* !HAVE_CLOCK_NANOSLEEP && MERCURY */
 
 #ifndef HAVE_SCHED_GETCPU
 /*
@@ -192,11 +184,25 @@ int pthread_setname_np(pthread_t thread, const char *name)
 {
        return ENOSYS;
 }
-#else /* HAVE_PTHREAD_SETNAME_NP || COBALT */
-/* Same as clock_nanosleep() */
-int pthread_setname_np(pthread_t thread, const char *name);
-#endif /* HAVE_PTHREAD_SETNAME_NP || COBALT */
+#endif /* !HAVE_PTHREAD_SETNAME_NP && MERCURY */
 
 #endif /* __IN_XENO__ */
 
+#if defined(__COBALT_WRAP__) || defined(__IN_XENO__)
+/*
+ * clock_nanosleep() and pthread_setname_np() must be declared when the libc
+ * does not declare them, both for compiling xenomai, and for compiling
+ * applications wrapping these symbols to the libcobalt versions.
+ */
+#ifndef HAVE_CLOCK_NANOSLEEP
+int clock_nanosleep(clockid_t clock_id, int flags,
+                   const struct timespec *request,
+                   struct timespec *remain);
+#endif /* !HAVE_CLOCK_NANOSLEEP */
+
+#ifndef HAVE_PTHREAD_SETNAME_NP
+int pthread_setname_np(pthread_t thread, const char *name);
+#endif /* !HAVE_PTHREAD_SETNAME_NP */
+#endif /* __COBALT_WRAP__ || __IN_XENO__ */
+
 #endif /* _BOILERPLATE_LIBC_H */
diff --git a/scripts/xeno-config-cobalt.in b/scripts/xeno-config-cobalt.in
index d0da716..eefc0d9 100644
--- a/scripts/xeno-config-cobalt.in
+++ b/scripts/xeno-config-cobalt.in
@@ -195,6 +195,7 @@ if test x$do_cflags = xy; then
        case "$skin" in
            posix|rtdm)
                test x$compat = xy && cflags="$cflags 
-I$XENO_INCLUDE_DIR/trank/posix"
+               cflags="$cflags -D__COBALT_WRAP__"
                ;;
            cobalt)
                ;;


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

Reply via email to