[Xenomai-git] Philippe Gerum : lib/cobalt: modechk: fetch WARNSW flag from u_window

2017-04-15 Thread git repository hosting
Module: xenomai-3
Branch: master
Commit: bad288b6bab74cc230d1fc6e2d80f9e388be7d3e
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=bad288b6bab74cc230d1fc6e2d80f9e388be7d3e

Author: Philippe Gerum 
Date:   Mon Mar 13 12:33:37 2017 +0100

lib/cobalt: modechk: fetch WARNSW flag from u_window

---

 lib/cobalt/assert_context.c |   19 ++-
 lib/cobalt/internal.h   |5 +
 2 files changed, 7 insertions(+), 17 deletions(-)

diff --git a/lib/cobalt/assert_context.c b/lib/cobalt/assert_context.c
index 625cb76..11739db 100644
--- a/lib/cobalt/assert_context.c
+++ b/lib/cobalt/assert_context.c
@@ -28,25 +28,10 @@
 #include "current.h"
 #include "internal.h"
 
-static void assert_nrt_inner(void)
-{
-   struct cobalt_threadstat stat;
-   int ret;
-
-   ret = cobalt_thread_stat(0, );
-   if (ret) {
-   warning("cobalt_thread_stat() failed: %s", strerror(-ret));
-   return;
-   }
-
-   if (stat.status & XNWARN)
-   pthread_kill(pthread_self(), SIGDEBUG);
-}
-
 void assert_nrt(void)
 {
-   if (!cobalt_is_relaxed())
-   assert_nrt_inner();
+   if (cobalt_should_warn())
+   pthread_kill(pthread_self(), SIGDEBUG);
 }
 
 void assert_nrt_fast(void) /* OBSOLETE */
diff --git a/lib/cobalt/internal.h b/lib/cobalt/internal.h
index fee3fe1..df1f7c0 100644
--- a/lib/cobalt/internal.h
+++ b/lib/cobalt/internal.h
@@ -32,6 +32,11 @@ static inline int cobalt_is_relaxed(void)
return cobalt_get_current_mode() & XNRELAX;
 }
 
+static inline int cobalt_should_warn(void)
+{
+   return (cobalt_get_current_mode() & (XNRELAX|XNWARN)) == XNWARN;
+}
+
 static inline
 struct cobalt_mutex_state *mutex_get_state(struct cobalt_mutex_shadow *shadow)
 {


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : build: replace deprecated AC_TRY_COMPILE()

2017-04-15 Thread git repository hosting
Module: xenomai-3
Branch: master
Commit: b2a30b28d44b50e9df6615c316e328cb54d083b0
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=b2a30b28d44b50e9df6615c316e328cb54d083b0

Author: Philippe Gerum 
Date:   Sun Apr  2 11:09:21 2017 +0200

build: replace deprecated AC_TRY_COMPILE()

---

 configure.ac |   15 ---
 1 file changed, 4 insertions(+), 11 deletions(-)

diff --git a/configure.ac b/configure.ac
index 37b15a0..26a0d5b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -483,17 +483,10 @@ AC_MSG_RESULT(${CONFIG_XENO_VALGRIND_API:-no})
 
 if test \! x$CONFIG_XENO_VALGRIND_API = x ; then
AC_MSG_CHECKING([whether GCC emits sane code for Valgrind calls])
-   AC_CACHE_VAL(ac_cv_valgrind_client,
-   AC_LANG_SAVE
-   AC_LANG_C
-   save_CFLAGS="$CFLAGS"
-   CFLAGS="-O0"
-   [AC_TRY_COMPILE([#include ],
-   [return RUNNING_ON_VALGRIND;],
-   [ac_cv_valgrind_client=yes],
-   [ac_cv_valgrind_client="no (DISABLING)"])]
-   CFLAGS="$save_CFLAGS"
-   AC_LANG_RESTORE)
+   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]],
+ [[return RUNNING_ON_VALGRIND;]])],
+ [ac_cv_valgrind_client=yes],
+ [ac_cv_valgrind_client="no (DISABLING)"])
if [[ \! "$ac_cv_valgrind_client" = yes ]]; then
   unset CONFIG_XENO_VALGRIND_API
fi


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : lib/cobalt: modechk: do not wrap cxa* API

2017-04-15 Thread git repository hosting
Module: xenomai-3
Branch: master
Commit: 6f8dc4d9e95979c18f19b405774555661c2a2085
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=6f8dc4d9e95979c18f19b405774555661c2a2085

Author: Philippe Gerum 
Date:   Wed Mar 15 15:34:08 2017 +0100

lib/cobalt: modechk: do not wrap cxa* API

---

 lib/cobalt/modechk.wrappers |3 ---
 1 file changed, 3 deletions(-)

diff --git a/lib/cobalt/modechk.wrappers b/lib/cobalt/modechk.wrappers
index 65320ab..7164858 100644
--- a/lib/cobalt/modechk.wrappers
+++ b/lib/cobalt/modechk.wrappers
@@ -1,5 +1,2 @@
 --wrap malloc
 --wrap free
---wrap __cxa_guard_acquire
---wrap __cxa_guard_release
---wrap __cxa_guard_abort


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : lib/cobalt, utils: stdio: fix wrapping of inlined fputc, putchar

2017-04-15 Thread git repository hosting
Module: xenomai-3
Branch: master
Commit: d99e3f21e56b25a5e5cbccf3450c568cdfba6b1b
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=d99e3f21e56b25a5e5cbccf3450c568cdfba6b1b

Author: Philippe Gerum 
Date:   Sun Apr  2 12:29:30 2017 +0200

lib/cobalt, utils: stdio: fix wrapping of inlined fputc, putchar

Depending on the uClibc-specific, internal __STDIO_PUTC_MACRO for
detecting macro-ized *putc* services is non-portable, unlikely to work
with MUSL libc or any other libc variants.

Use a more robust approach by directly detecting the definition of
macros for those services. This change also enables non-wrapped access
to such calls, which was not available until then (__STD() calls were
routed to the wrapper regardless).

---

 configure.ac|7 +--
 include/cobalt/stdio.h  |   30 --
 lib/cobalt/printf.c |   18 ++
 lib/cobalt/wrappers.c   |8 
 utils/slackspot/Makefile.am |4 ++--
 utils/slackspot/slackspot.c |1 +
 6 files changed, 34 insertions(+), 34 deletions(-)

diff --git a/configure.ac b/configure.ac
index 26a0d5b..8222e1d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -640,7 +640,8 @@ fi
 
 dnl Internal CFLAGS and LDFLAGS, may be enhanced per-arch below
 XENO_USER_CFLAGS="$XENO_USER_APP_CFLAGS -pipe -fstrict-aliasing \
--Wall -Wstrict-prototypes -Wmissing-prototypes -Wno-long-long 
-Wno-unused-parameter -Werror"
+-Wall -Wstrict-prototypes -Wmissing-prototypes -Wno-long-long \
+-Wno-unused-parameter -Werror -D__XENO__ -D__IN_XENO__"
 if test x$want_fortify = xyes -a x$debug_mode != xfull; then
XENO_USER_CFLAGS="$XENO_USER_CFLAGS -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2"
 fi
@@ -665,7 +666,8 @@ if test x$use_assert = x; then
XENO_USER_CFLAGS="-DNDEBUG $XENO_USER_CFLAGS"
 fi
 
-XENO_USER_CFLAGS="$XENO_USER_CFLAGS -D__XENO__ -D__IN_XENO__ 
-I$topdir/include/$rtcore_type"
+XENO_USER_CFLAGS_STDLIB="$XENO_USER_CFLAGS"
+XENO_USER_CFLAGS="$XENO_USER_CFLAGS -I$topdir/include/$rtcore_type"
 
 AC_MSG_CHECKING([whether ld supports @file])
 AC_CACHE_VAL(ac_cv_ld_file_option,
@@ -834,6 +836,7 @@ AC_SUBST(XENO_HOST_STRING)
 AC_SUBST(XENO_COBALT_CFLAGS)
 AC_SUBST(XENO_LIB_LDFLAGS)
 AC_SUBST(XENO_USER_CFLAGS)
+AC_SUBST(XENO_USER_CFLAGS_STDLIB)
 AC_SUBST(XENO_USER_LDADD)
 AC_SUBST(XENO_USER_APP_CFLAGS)
 AC_SUBST(XENO_USER_APP_LDFLAGS)
diff --git a/include/cobalt/stdio.h b/include/cobalt/stdio.h
index c915e6d..7108ffb 100644
--- a/include/cobalt/stdio.h
+++ b/include/cobalt/stdio.h
@@ -63,20 +63,30 @@ COBALT_DECL(int, puts(const char *s));
 
 COBALT_DECL(int, fputs(const char *s, FILE *stream));
 
-#if !defined(__UCLIBC__) || !defined(__STDIO_PUTC_MACRO)
-
-COBALT_DECL(int, fputc(int c, FILE *stream));
-
+#ifndef putchar
 COBALT_DECL(int, putchar(int c));
-
 #else
-
-int __wrap_fputc(int c, FILE *stream);
-#define __real_fputc __wrap_fputc
-
+static inline int __real_putchar(int c)
+{
+   return putchar(c);
+}
 int __wrap_putchar(int c);
-#define __real_putchar __wrap_putchar
+int __cobalt_putchar(int c);
+#undef putchar
+#define putchar __wrap_putchar
+#endif
 
+#ifndef fputc
+COBALT_DECL(int, fputc(int c, FILE *stream));
+#else
+static inline int __real_fputc(int c, FILE *stream)
+{
+   return fputc(c, stream);
+}
+int __wrap_fputc(int c, FILE *stream);
+int __cobalt_fputc(int c, FILE *stream);
+#undef fputc
+#define fputc __wrap_fputc
 #endif
 
 COBALT_DECL(size_t,
diff --git a/lib/cobalt/printf.c b/lib/cobalt/printf.c
index 330c964..e52a5a5 100644
--- a/lib/cobalt/printf.c
+++ b/lib/cobalt/printf.c
@@ -787,8 +787,7 @@ COBALT_IMPL(int, puts, (const char *s))
}
 }
 
-#if !defined(__UCLIBC__) || !defined(__STDIO_PUTC_MACRO)
-
+#undef fputc
 COBALT_IMPL(int, fputc, (int c, FILE *stream))
 {
if (!cobalt_is_relaxed())
@@ -799,6 +798,7 @@ COBALT_IMPL(int, fputc, (int c, FILE *stream))
}
 }
 
+#undef putchar
 COBALT_IMPL(int, putchar, (int c))
 {
if (!cobalt_is_relaxed())
@@ -809,20 +809,6 @@ COBALT_IMPL(int, putchar, (int c))
}
 }
 
-#else
-
-COBALT_IMPL(int, fputc, (int c, FILE *stream))
-{
-   return fputc(c, stream);
-}
-
-COBALT_IMPL(int, putchar, (int c))
-{
-   return putchar(c);
-}
-
-#endif /* !(__UCLIBC__ && __STDIO_PUTC_MACRO) */
-
 COBALT_IMPL(size_t, fwrite, (const void *ptr, size_t size, size_t nmemb, FILE 
*stream))
 {
if (!cobalt_is_relaxed())
diff --git a/lib/cobalt/wrappers.c b/lib/cobalt/wrappers.c
index bf1fdf4..5fa313b 100644
--- a/lib/cobalt/wrappers.c
+++ b/lib/cobalt/wrappers.c
@@ -428,21 +428,21 @@ int __real_fputs(const char *s, FILE *stream)
return fputs(s, stream);
 }
 
-#if !defined(__UCLIBC__) || !defined(__STDIO_PUTC_MACRO)
-
+#ifndef fputc
 __weak
 int __real_fputc(int c, FILE *stream)
 {
return fputc(c, stream);
 }
+#endif
 
+#ifndef putchar
 __weak
 int __real_putchar(int c)
 {
return putchar(c);
 }
-
-#endif /* !(__UCLIBC__ && __STDIO_PUTC_MACRO) */
+#endif
 
 __weak
 

[Xenomai-git] Philippe Gerum : boilerplate/setup: postpone detection of late setup calls

2017-04-15 Thread git repository hosting
Module: xenomai-3
Branch: master
Commit: 2353e59f2e016879a33da96f4583c49ad521a864
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=2353e59f2e016879a33da96f4583c49ad521a864

Author: Philippe Gerum 
Date:   Wed Mar 22 09:21:07 2017 +0100

boilerplate/setup: postpone detection of late setup calls

Since #d6d8047, setup descriptors may be registered after the base
inits have been performed, if DSO bootstrap modules were activated.
Postpone the detection of late setup calls after the main bootstrap
module has run instead.

This fixes an issue with --enable-assert in presence of DSO bootstrap
code.

---

 lib/boilerplate/setup.c |9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/lib/boilerplate/setup.c b/lib/boilerplate/setup.c
index 1992826..e534e66 100644
--- a/lib/boilerplate/setup.c
+++ b/lib/boilerplate/setup.c
@@ -50,6 +50,8 @@ const int __weak xenomai_auto_bootstrap = 0;
 
 static int base_init_done;
 
+static int main_init_done;
+
 static DEFINE_PRIVATE_LIST(setup_list);
 
 static const struct option base_options[] = {
@@ -617,16 +619,15 @@ fail:
 void xenomai_init(int *argcp, char *const **argvp)
 {
const char *me = get_program_name();
-   static int init_done;
 
-   if (init_done) {
+   if (main_init_done) {
early_warning("duplicate call from main program "
  "to %s() ignored", __func__);
early_warning("(xeno-config --no-auto-init disables implicit 
call)");
}
 
__xenomai_init(argcp, argvp, me);
-   init_done = 1;
+   main_init_done = 1;
trace_me("%s bootstrap done", me);
 }
 
@@ -655,7 +656,7 @@ void __register_setup_call(struct setup_descriptor *p, int 
id)
/*
 * Trap late registration due to wrong constructor priorities.
 */
-   assert(!base_init_done);
+   assert(!main_init_done);
p->__reserved.id = id;
p->__reserved.done = 0;
 


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : alchemy/testsuite: pipe: fortify source code

2017-04-15 Thread git repository hosting
Module: xenomai-3
Branch: master
Commit: b326c59df2b8511ccf5ba123a7d9039003f021d2
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=b326c59df2b8511ccf5ba123a7d9039003f021d2

Author: Philippe Gerum 
Date:   Wed Mar 15 09:58:46 2017 +0100

alchemy/testsuite: pipe: fortify source code

---

 lib/alchemy/testsuite/pipe-1.c |   17 +
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/lib/alchemy/testsuite/pipe-1.c b/lib/alchemy/testsuite/pipe-1.c
index 1fa028a..7272079 100644
--- a/lib/alchemy/testsuite/pipe-1.c
+++ b/lib/alchemy/testsuite/pipe-1.c
@@ -1,6 +1,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -9,7 +10,7 @@ static struct traceobj trobj;
 
 static RT_TASK t_real;
 
-static RT_PIPE pipe;
+static RT_PIPE mpipe;
 
 static pthread_t t_reg;
 
@@ -26,14 +27,14 @@ static void realtime_task(void *arg)
 
traceobj_enter();
 
-   ret = rt_pipe_bind(, "pipe", TM_INFINITE);
+   ret = rt_pipe_bind(, "pipe", TM_INFINITE);
traceobj_check(, ret, 0);
 
while (seq < 8192) {
-   ret = rt_pipe_read(, , sizeof(m), TM_INFINITE);
+   ret = rt_pipe_read(, , sizeof(m), TM_INFINITE);
traceobj_assert(, ret == sizeof(m));
traceobj_assert(, m.value == seq);
-   ret = rt_pipe_write(, , sizeof(m),
+   ret = rt_pipe_write(, , sizeof(m),
(seq & 1) ? P_URGENT : P_NORMAL);
traceobj_assert(, ret == sizeof(m));
seq++;
@@ -77,10 +78,10 @@ int main(int argc, char *const argv[])
 
traceobj_init(, argv[0], 0);
 
-   ret = rt_pipe_create(, "pipe", P_MINOR_AUTO, 0);
+   ret = rt_pipe_create(, "pipe", P_MINOR_AUTO, 0);
traceobj_assert(, ret >= 0);
 
-   ret = rt_pipe_delete();
+   ret = rt_pipe_delete();
traceobj_check(, ret, 0);
 
ret = rt_task_create(_real, "realtime", 0,  10, 0);
@@ -89,11 +90,11 @@ int main(int argc, char *const argv[])
ret = rt_task_start(_real, realtime_task, NULL);
traceobj_check(, ret, 0);
 
-   ret = rt_pipe_create(, "pipe", P_MINOR_AUTO, 16384);
+   ret = rt_pipe_create(, "pipe", P_MINOR_AUTO, 16384);
traceobj_assert(, ret >= 0);
minor = ret;
 
-   ret = rt_pipe_read(, , sizeof(m), TM_NONBLOCK);
+   ret = rt_pipe_read(, , sizeof(m), TM_NONBLOCK);
traceobj_check(, ret, -EWOULDBLOCK);
 
ret = pthread_create(_reg, NULL, regular_thread, NULL);


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : doc: build

2017-04-15 Thread git repository hosting
Module: xenomai-3
Branch: master
Commit: f68a02088ef2286178485b51d1df8b56908e3861
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=f68a02088ef2286178485b51d1df8b56908e3861

Author: Philippe Gerum 
Date:   Sun Apr  2 16:46:34 2017 +0200

doc: build

---

 doc/prebuilt/html/MIGRATION/index.html |2 +-
 doc/prebuilt/html/README.APPLICATIONS/index.html   |2 +-
 doc/prebuilt/html/README.INSTALL/index.html|2 +-
 .../html/TROUBLESHOOTING.COBALT/index.html |2 +-
 .../html/TROUBLESHOOTING.MERCURY/index.html|2 +-
 doc/prebuilt/html/man1/xeno-config/index.html  |   28 +---
 doc/prebuilt/html/xeno3prm/driver_8h_source.html   |2 +-
 .../html/xeno3prm/group__cobalt__core__synch.html  |6 ++---
 .../kernel_2drivers_2ipc_2internal_8h_source.html  |2 +-
 .../html/xeno3prm/kernel_2synch_8h_source.html |8 +++---
 .../xeno3prm/lib_2cobalt_2internal_8h_source.html  |3 ++-
 doc/prebuilt/html/xeno3prm/search/search.idx   |  Bin 1376757 -> 1376801 
bytes
 doc/prebuilt/html/xeno3prm/setup_8h_source.html|2 +-
 doc/prebuilt/html/xeno3prm/stdio_8h_source.html|2 +-
 .../html/xeno3prm/sys_2cobalt_8h_source.html   |2 +-
 .../html/xeno3prm/xenomai_2init_8h_source.html |2 +-
 doc/prebuilt/man/man1/dohell.1 |4 +--
 doc/prebuilt/man/man1/xeno-config.1|   13 -
 doc/prebuilt/man/man1/xeno-test.1  |4 +--
 doc/prebuilt/pdf/MIGRATION.pdf |  Bin 222092 -> 222092 
bytes
 doc/prebuilt/pdf/README.APPLICATIONS.pdf   |  Bin 79327 -> 79327 bytes
 doc/prebuilt/pdf/README.INSTALL.pdf|  Bin 165538 -> 165538 
bytes
 doc/prebuilt/pdf/TROUBLESHOOTING.COBALT.pdf|  Bin 142103 -> 142103 
bytes
 doc/prebuilt/pdf/TROUBLESHOOTING.MERCURY.pdf   |  Bin 45603 -> 45603 bytes
 doc/prebuilt/pdf/xeno3prm.pdf  |  Bin 2215487 -> 2215637 
bytes
 25 files changed, 61 insertions(+), 27 deletions(-)

Diff:   
http://git.xenomai.org/?p=xenomai-3.git;a=commitdiff;h=f68a02088ef2286178485b51d1df8b56908e3861

___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : cobalt/synch: add __must_check annotation to sleep_on call

2017-04-15 Thread git repository hosting
Module: xenomai-3
Branch: master
Commit: 4336b93138754b0f4a6f4373ef187212948c1974
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=4336b93138754b0f4a6f4373ef187212948c1974

Author: Philippe Gerum 
Date:   Sun Mar 12 10:24:58 2017 +0100

cobalt/synch: add __must_check annotation to sleep_on call

---

 include/cobalt/kernel/synch.h |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/include/cobalt/kernel/synch.h b/include/cobalt/kernel/synch.h
index f419698..f5ac217 100644
--- a/include/cobalt/kernel/synch.h
+++ b/include/cobalt/kernel/synch.h
@@ -138,9 +138,9 @@ static inline void xnsynch_register_cleanup(struct xnsynch 
*synch,
synch->cleanup = handler;
 }
 
-int xnsynch_sleep_on(struct xnsynch *synch,
-xnticks_t timeout,
-xntmode_t timeout_mode);
+int __must_check xnsynch_sleep_on(struct xnsynch *synch,
+ xnticks_t timeout,
+ xntmode_t timeout_mode);
 
 struct xnthread *xnsynch_wakeup_one_sleeper(struct xnsynch *synch);
 


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : lib/cobalt: modechk: switch to shared object, drop cxa wrappers

2017-04-15 Thread git repository hosting
Module: xenomai-3
Branch: master
Commit: 8c82454cd6bed496a8c4d6e1d059b0b5c87bb6c7
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=8c82454cd6bed496a8c4d6e1d059b0b5c87bb6c7

Author: Philippe Gerum 
Date:   Tue Mar 14 19:01:20 2017 +0100

lib/cobalt: modechk: switch to shared object, drop cxa wrappers

Dynamically linked code from shared libraries which may reference mode
checking wrappers cannot depend on symbols which are only visible from
the static link phase, such as those defined by the libmodechk.a
library. Otherwise, unresolved references to symbols from libmodechk.a
may exist in shared objects such as libcopperplate.so.

Unfortunately, we can't interpose on the cxa* API from a dynamic
library, since the latter would create references to "real"
__cxa_acquire/release/abort() routines, which are not available from
plain C builds since only libstdc++ defines them.

Providing placeholders for the cxa* API calls in a dynamic object is
not an option either, since that would create a dependency on the link
order between libmodechk and libstdc++ for pulling the actual symbols
instead of the dummy ones, which is not acceptable. Besides, relying
on LD_DYNAMIC_WEAK is fragile, unpractical, and won't work in secured
execution mode.

To work around this chicken-and-egg issue, make libmodechk a shared
object, and drop mode checking for the cxa* API for now. We'll revisit
the issue of enabling back the cxa* API later.

---

 configure.ac   |2 +-
 lib/cobalt/Makefile.am |   16 +++---
 lib/cobalt/cxaguard.c  |   54 
 3 files changed, 4 insertions(+), 68 deletions(-)

diff --git a/configure.ac b/configure.ac
index d5c5aaa..37b15a0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -820,7 +820,7 @@ AC_SUBST(XENO_AUTOINIT_LDFLAGS)
 
 XENO_CORE_LDADD="\$(top_builddir)/lib/$rtcore_type/lib${rtcore_type}.la"
 if test $rtcore_type = cobalt; then
-   XENO_CORE_LDADD="$XENO_CORE_LDADD \$(top_builddir)/lib/cobalt/libmodechk.a"
+   XENO_CORE_LDADD="$XENO_CORE_LDADD \$(top_builddir)/lib/cobalt/libmodechk.la"
 fi
 AC_SUBST(XENO_CORE_LDADD)
 
diff --git a/lib/cobalt/Makefile.am b/lib/cobalt/Makefile.am
index c2d5956..5230a38 100644
--- a/lib/cobalt/Makefile.am
+++ b/lib/cobalt/Makefile.am
@@ -5,7 +5,7 @@ noinst_HEADERS =\
umm.h   \
internal.h
 
-lib_LTLIBRARIES = libcobalt.la
+lib_LTLIBRARIES = libcobalt.la libmodechk.la
 
 libcobalt_la_LDFLAGS = @XENO_LIB_LDFLAGS@ -version-info 2:0:0 -lpthread -lrt
 
@@ -42,21 +42,11 @@ libcobalt_la_CPPFLAGS = \
-I$(top_srcdir)/include/cobalt  \
-I$(top_srcdir)/include
 
-# The mode checking wrappers must reside in a static archive, so that
-# the linker will pull them on demand, dropping the requirement for
-# providing potentially conflicting placeholders for wrapped symbols
-# which may not be present in both C and C++ support libraries
-# (e.g. __cxa_guard_acquire/release/abort from the one-time C++
-# constructor API).
-
-lib_LIBRARIES = libmodechk.a
-
-libmodechk_a_SOURCES = \
-   cxaguard.c  \
+libmodechk_la_SOURCES =\
malloc.c\
malloc-nowrap.c
 
-libmodechk_a_CPPFLAGS =\
+libmodechk_la_CPPFLAGS =   \
@XENO_COBALT_CFLAGS@\
-I$(top_srcdir)/include/cobalt  \
-I$(top_srcdir)/include
diff --git a/lib/cobalt/cxaguard.c b/lib/cobalt/cxaguard.c
deleted file mode 100644
index 6df471a..000
--- a/lib/cobalt/cxaguard.c
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (C) 2017 Henning Schild 
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
-
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
- */
-#include 
-#include 
-#include 
-
-#ifdef __ARM_EABI__
-typedef uint32_t __cxa_guard_type;
-#else
-typedef uint64_t __cxa_guard_type;
-#endif
-
-COBALT_DECL(int, __cxa_guard_acquire(__cxa_guard_type *g));
-int __real_cxa_guard_acquire(__cxa_guard_type *g);
-
-/* CXXABI 3.3.2 One-time Construction API */
-COBALT_IMPL(int, __cxa_guard_acquire, (__cxa_guard_type *g))
-{
-   cobalt_assert_nrt();
-   return __STD(__cxa_guard_acquire(g));
-}
-
-COBALT_DECL(void, __cxa_guard_release(__cxa_guard_type *g));
-void __real_cxa_guard_release(__cxa_guard_type *g);
-

[Xenomai-git] Philippe Gerum : scripts/xeno-config: cobalt: add --[no-]mode-check switch

2017-04-15 Thread git repository hosting
Module: xenomai-3
Branch: master
Commit: d8f5eee72c5d4fb349d23f2d924645ccd12f8c9c
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=d8f5eee72c5d4fb349d23f2d924645ccd12f8c9c

Author: Philippe Gerum 
Date:   Mon Mar 13 10:50:34 2017 +0100

scripts/xeno-config: cobalt: add --[no-]mode-check switch

These switches control whether xeno-config should emit the linker
flags for interposing on a set of standard routines which may invoke
regular Linux system calls, triggering an assertion failure on entry
if the caller must switch to secondary mode.

For the assertion failure to trigger, PTHREAD_WARNSW must have been
set for the calling thread.

---

 doc/asciidoc/man1/xeno-config.adoc |   21 +++--
 scripts/xeno-config-cobalt.in  |   21 +
 2 files changed, 36 insertions(+), 6 deletions(-)

diff --git a/doc/asciidoc/man1/xeno-config.adoc 
b/doc/asciidoc/man1/xeno-config.adoc
index 62ab888..14acc67 100644
--- a/doc/asciidoc/man1/xeno-config.adoc
+++ b/doc/asciidoc/man1/xeno-config.adoc
@@ -35,7 +35,7 @@ SYNOPSIS
 
 *xeno-config* *--version*
 
-*xeno-config* [*--cc*] [*--ccld*] [*--arch*] [*--prefix*] 
[*--posix|alchemy|rtdm|psos|vxworks|smokey*] [*--compat*] 
[*--auto-init*|*no-auto-init*] [*--auto-init-solib*] [*--cflags*] [*--ldflags*] 
[*--library-dir*|*--libdir*|*--user-libdir*]
+*xeno-config* [*--cc*] [*--ccld*] [*--arch*] [*--prefix*] 
[*--posix|alchemy|rtdm|psos|vxworks|smokey*] [*--compat*] 
[*--auto-init*|*no-auto-init*] [*--auto-init-solib*] 
[*--mode-check*|*no-mode-check*] [*--cflags*] [*--ldflags*] 
[*--library-dir*|*libdir*|*user-libdir*]
 
 DESCRIPTION
 
@@ -130,6 +130,23 @@ This flag makes sense when passed along with --ldflags
 only. *xeno-config* enables the Copperplate auto-init feature by
 default.
 
+*--mode-check*::
+*--no-mode-check*::
+
+Over Cobalt, a set of standard routines which may invoke regular Linux
+system calls can trigger an assertion failure on entry, if the caller
+must leave the real-time mode (aka "secondary mode switch") to execute
+such routine.
+
+The assertion failure is triggered if the calling thread has set the
+PTHREAD_WARNSW flag by a call to +pthread_setmode_np()+.
+
+By default, the mode checking routines are substituted to the original
+ones using the symbol wrapping mechanism also used for interposing on
+POSIX services. *--no-mode-check* disables such substitution.
+
+These flags make sense when passed along with --ldflags only.
+
 *--auto-init-solib*::
 
 This switch enables the auto-initialization feature described above
@@ -140,7 +157,7 @@ used for bootstrapping the initialization.
 The bootstrap code runs when the shared library is attached to a
 running executable, either because it appears in the static
 dependencies of this executable, or when loaded dynamically via the
-dlopen() interface.
++dlopen()+ interface.
 
 *--core*::
 Output the name of the real-time core the current Xenomai installation
diff --git a/scripts/xeno-config-cobalt.in b/scripts/xeno-config-cobalt.in
index c014176..82815e1 100644
--- a/scripts/xeno-config-cobalt.in
+++ b/scripts/xeno-config-cobalt.in
@@ -52,9 +52,10 @@ Options :
 --prefix
 --[skin=]posix|vxworks|psos|alchemy|rtdm|smokey|cobalt
 --auto-init|auto-init-solib|no-auto-init
+--mode-check|no-mode-check
 --cflags
 --ldflags
---lib*-dir,--libdir,--user-libdir
+--lib*-dir|libdir|user-libdir
 --core
 --info
 --compat
@@ -109,6 +110,7 @@ do_cflags=
 do_setinit=
 do_autoinit=y
 do_autoinit_solib=
+do_mode_check=y
 
 while test $# -gt 0; do
 case "$1" in
@@ -191,6 +193,12 @@ while test $# -gt 0; do
--compat)
compat=y
 ;;
+   --mode-check)
+   do_mode_check=y
+   ;;
+   --no-mode-check)
+   do_mode_check=
+   ;;
 *)
  usage 1 1>&2
  ;;
@@ -235,7 +243,10 @@ if test x$do_ldflags = xy; then
echo "no API specified, missing --skin before --ldflags" 1>&2
exit 1
 fi
-ldflags="`dump_wrappers modechk.wrappers`"
+ldflags=
+if test x$do_mode_check = xy; then
+   ldflags="`dump_wrappers modechk.wrappers`"
+fi
 test x$compat = xy && ldflags="-ltrank $ldflags"
 copperplate=
 for skin in $skin_list; do
@@ -244,8 +255,10 @@ if test x$do_ldflags = xy; then
ldflags="`dump_wrappers cobalt.wrappers` $ldflags"
;;
cobalt)
-   # do NOT wrap POSIX symbols in application code
-   # with --cobalt. On the contrary, --posix does.
+   # do NOT wrap POSIX symbols in application code with
+   # --cobalt. On the contrary, --posix does. This switch
+   # does not affect mode checking wrappers,
+   # --[no-]mode-check does.
;;
vxworks|psos|alchemy|smokey)
copperplate="-lcopperplate"



[Xenomai-git] Philippe Gerum : boilerplate/setup: allow DSO bootstrap modules to coexist with main one

2017-04-15 Thread git repository hosting
Module: xenomai-3
Branch: master
Commit: d6d8047ecd093bd827026678b3c7619b08dd7dd2
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=d6d8047ecd093bd827026678b3c7619b08dd7dd2

Author: Philippe Gerum 
Date:   Tue Mar 21 15:20:29 2017 +0100

boilerplate/setup: allow DSO bootstrap modules to coexist with main one

Gluing a PIC bootstrap module to a DSO is a common way to start the
Xenomai services before constructors of static C++ objects
instantiated by the DSO and which depend on such services, are
invoked.

With such module present in the DSO, a Cobalt-based application
process would attach itself to the Cobalt core via the bootstrapping
sequence, enabling the real-time services for the whole process,
including the static C++ constructors which may be invoked when
attaching the shared object.

e.g. in libfoo.so:

class FOO {
protected:
sem_t sem;
public:
static FOO bar;
};

...

FOO FOO::bar;

FOO::FOO()
{
// Initialize a Cobalt semaphore
sem_init(, 0, 0);
}

However, adding a bootstrap module to a DSO currently prevents from
merging a second bootstrap module aimed at kickstarting the main
program's setup code and early inits, due to conflicting symbols and
the restriction on invoking xenomai_init() only once for any given
process.

The changes introduce a DSO-specific initialization service
(xenomai_init_dso()), which may be called from the context of the
dynamic linker attaching a shared object to the current
executable. The DSO-specific bootstrap module - if present - will call
xenomai_init_dso(), there is no restriction on the number of DSOs
calling this service.

The non-DSO bootstrap module invokes xenomai_init() as previously, for
kickstarting the main program's early inits.

---

 include/boilerplate/setup.h  |1 +
 include/xenomai/init.h   |2 +
 lib/boilerplate/init/Makefile.am |2 +-
 lib/boilerplate/init/bootstrap.c |   28 +++---
 lib/boilerplate/setup.c  |  104 --
 5 files changed, 91 insertions(+), 46 deletions(-)

diff --git a/include/boilerplate/setup.h b/include/boilerplate/setup.h
index 374758b..7df3cfe 100644
--- a/include/boilerplate/setup.h
+++ b/include/boilerplate/setup.h
@@ -46,6 +46,7 @@ struct setup_descriptor {
int opt_start;
int opt_end;
struct pvholder next;
+   int done;
} __reserved;
 };
 
diff --git a/include/xenomai/init.h b/include/xenomai/init.h
index 9adc90d..598bf53 100644
--- a/include/xenomai/init.h
+++ b/include/xenomai/init.h
@@ -27,6 +27,8 @@ extern "C" {
 
 void xenomai_init(int *argcp, char *const **argvp);
 
+void xenomai_init_dso(int *argcp, char *const **argvp);
+
 int xenomai_main(int argc, char *const argv[]);
 
 void xenomai_usage(void);
diff --git a/lib/boilerplate/init/Makefile.am b/lib/boilerplate/init/Makefile.am
index 702c900..b78dd61 100644
--- a/lib/boilerplate/init/Makefile.am
+++ b/lib/boilerplate/init/Makefile.am
@@ -3,7 +3,6 @@ noinst_LIBRARIES = libbootstrap.a
 libbootstrap_a_SOURCES = bootstrap.c
 
 libbootstrap_a_CPPFLAGS =  \
-   -D__INTERCEPT_MAIN__\
@XENO_USER_CFLAGS@  \
-I$(top_srcdir)/include \
-I$(top_srcdir)/lib
@@ -13,6 +12,7 @@ noinst_LTLIBRARIES = libbootstrap-pic.la
 libbootstrap_pic_la_SOURCES = bootstrap.c
 
 libbootstrap_pic_la_CPPFLAGS = \
+   -D__BOOTSTRAP_DSO__ \
@XENO_USER_CFLAGS@  \
-I$(top_srcdir)/include \
-I$(top_srcdir)/lib
diff --git a/lib/boilerplate/init/bootstrap.c b/lib/boilerplate/init/bootstrap.c
index 54d1c46..e72a7b8 100644
--- a/lib/boilerplate/init/bootstrap.c
+++ b/lib/boilerplate/init/bootstrap.c
@@ -26,8 +26,6 @@ static int early_argc;
 
 static char *const *early_argv;
 
-const int xenomai_auto_bootstrap = 1;
-
 /*
  * The bootstrap module object is built in two forms:
  *
@@ -41,11 +39,22 @@ const int xenomai_auto_bootstrap = 1;
  *   any wrapper to a main() routine - which does not exist - but only
  *   a constructor routine performing the inits.
  *
- * The dedicated macro __INTERCEPT_MAIN__ tells us whether the main()
- * interception code should be present in the relocatable object.
+ * The macro __BOOTSTRAP_DSO__ tells us whether we are building the
+ * bootstrap module to be glued into a dynamic shared object. If not,
+ * the main() interception code should be present in the relocatable
+ * object.
  */
 
-#ifdef __INTERCEPT_MAIN__
+#ifdef __BOOTSTRAP_DSO__
+
+static inline void call_init(int *argcp, char *const **argvp)
+{
+   xenomai_init_dso(argcp, argvp);
+}
+
+#else
+
+const int xenomai_auto_bootstrap = 1;
 
 int __real_main(int argc, char *const argv[]);
 
@@ -62,7 +71,12 @@ int xenomai_main(int argc, char *const argv[])
return __real_main(argc, argv);
 }
 
-#endif /* !__INTERCEPT_MAIN__ */
+static inline void call_init(int *argcp, char *const 

[Xenomai-git] Philippe Gerum : cobalt/synch: add __must_check annotation to lock acquisition routines

2017-04-15 Thread git repository hosting
Module: xenomai-3
Branch: master
Commit: 9000dc953d740fa4bf48db88d9c7c0b4de69407b
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=9000dc953d740fa4bf48db88d9c7c0b4de69407b

Author: Philippe Gerum 
Date:   Sun Mar 12 10:23:47 2017 +0100

cobalt/synch: add __must_check annotation to lock acquisition routines

---

 include/cobalt/kernel/synch.h |8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/include/cobalt/kernel/synch.h b/include/cobalt/kernel/synch.h
index ffb884a..f419698 100644
--- a/include/cobalt/kernel/synch.h
+++ b/include/cobalt/kernel/synch.h
@@ -149,11 +149,11 @@ int xnsynch_wakeup_many_sleepers(struct xnsynch *synch, 
int nr);
 void xnsynch_wakeup_this_sleeper(struct xnsynch *synch,
 struct xnthread *sleeper);
 
-int xnsynch_acquire(struct xnsynch *synch,
-   xnticks_t timeout,
-   xntmode_t timeout_mode);
+int __must_check xnsynch_acquire(struct xnsynch *synch,
+xnticks_t timeout,
+xntmode_t timeout_mode);
 
-int xnsynch_try_acquire(struct xnsynch *synch);
+int __must_check xnsynch_try_acquire(struct xnsynch *synch);
 
 struct xnthread *xnsynch_release(struct xnsynch *synch,
 struct xnthread *thread);


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : lib/cobalt: move mode checking wrappers to static archive

2017-04-15 Thread git repository hosting
Module: xenomai-3
Branch: master
Commit: a7243543ecca5d8cfe9b7a4d76cdb57ae252f6a9
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=a7243543ecca5d8cfe9b7a4d76cdb57ae252f6a9

Author: Philippe Gerum 
Date:   Sun Mar 12 12:21:18 2017 +0100

lib/cobalt: move mode checking wrappers to static archive

The mode checking wrappers must reside in a static archive, so that
the linker will pull them on demand, dropping the requirement for
providing potentially conflicting placeholders for wrapped symbols
which may not be present in both C and C++ support libraries
(e.g. __cxa_guard_acquire/release/abort from the one-time C++
constructor API).

See http://www.xenomai.org/pipermail/xenomai/2017-March/037184.html

---

 configure.ac |   15 ++
 debian/libxenomai-dev.install|2 +-
 demo/alchemy/Makefile.am |5 ++--
 demo/alchemy/cobalt/Makefile.am  |   16 +--
 demo/posix/cobalt/Makefile.am|2 +-
 demo/posix/cyclictest/Makefile.am|6 ++--
 lib/boilerplate/init/bootstrap.c |   12 
 lib/cobalt/Makefile.am   |   24 ++--
 lib/cobalt/assert_context.c  |   13 -
 lib/cobalt/malloc-nowrap.c   |   30 
 lib/cobalt/malloc.c  |   33 ++
 lib/cobalt/{assert.wrappers => modechk.wrappers} |0
 lib/cobalt/wrappers.c|   12 
 lib/copperplate/regd/Makefile.am |2 +-
 scripts/wrap-link.sh |6 ++--
 scripts/xeno-config-cobalt.in|4 +--
 testsuite/clocktest/Makefile.am  |2 +-
 testsuite/gpiotest/Makefile.am   |4 +--
 testsuite/latency/Makefile.am|6 ++--
 testsuite/smokey/Makefile.am |2 +-
 testsuite/smokey/net_common/Makefile.am  |2 +-
 testsuite/spitest/Makefile.am|4 +--
 testsuite/switchtest/Makefile.am |6 ++--
 utils/analogy/Makefile.am|   18 ++--
 utils/autotune/Makefile.am   |2 +-
 utils/can/Makefile.am|6 ++--
 utils/corectl/Makefile.am|2 +-
 utils/hdb/Makefile.am|4 +--
 28 files changed, 150 insertions(+), 90 deletions(-)

diff --git a/configure.ac b/configure.ac
index 4792e46..d5c5aaa 100644
--- a/configure.ac
+++ b/configure.ac
@@ -796,19 +796,19 @@ dnl Build wrapping information. XENO_POSIX_WRAPPERS lists 
all wrapping
 dnl directives in a format the linker understands, for building the
 dnl in-tree executables which require POSIX symbol wrapping.
 
-   assert_wrappers="$topdir/lib/cobalt/assert.wrappers"
+   modechk_wrappers="$topdir/lib/cobalt/modechk.wrappers"
cobalt_wrappers="$topdir/lib/cobalt/cobalt.wrappers"
if [[ $ac_cv_ld_file_option = yes ]]; then
-   XENO_POSIX_WRAPPERS="-Wl,@$assert_wrappers -Wl,@$cobalt_wrappers"
+   XENO_POSIX_WRAPPERS="-Wl,@$modechk_wrappers -Wl,@$cobalt_wrappers"
else
-   XENO_POSIX_WRAPPERS=`cat $assert_wrappers $cobalt_wrappers | \
+   XENO_POSIX_WRAPPERS=`cat $modechk_wrappers $cobalt_wrappers | \
while read wrap_option symbol ; do \
echo -n "-Wl,$wrap_option,$symbol " ; \
done`
fi
 
AC_SUBST(XENO_POSIX_WRAPPERS)
-   AC_SUBST([CONFIG_STATUS_DEPENDENCIES], ["$assert_wrappers 
$cobalt_wrappers"])
+   AC_SUBST([CONFIG_STATUS_DEPENDENCIES], ["$modechk_wrappers 
$cobalt_wrappers"])
 fi
 
 dnl
@@ -818,8 +818,11 @@ dnl
 
XENO_AUTOINIT_LDFLAGS='$(top_builddir)/lib/boilerplate/init/bootstrap-internal.o'"
 -Wl,--wrap=main -Wl,--dynamic-list=$topdir/scripts/dynlist.ld"
 AC_SUBST(XENO_AUTOINIT_LDFLAGS)
 
-XENO_CORE_LIB=$rtcore_type/lib${rtcore_type}.la
-AC_SUBST(XENO_CORE_LIB)
+XENO_CORE_LDADD="\$(top_builddir)/lib/$rtcore_type/lib${rtcore_type}.la"
+if test $rtcore_type = cobalt; then
+   XENO_CORE_LDADD="$XENO_CORE_LDADD \$(top_builddir)/lib/cobalt/libmodechk.a"
+fi
+AC_SUBST(XENO_CORE_LDADD)
 
 AC_SUBST(DOXYGEN_SHOW_INCLUDE_FILES)
 AC_SUBST(DOXYGEN_HAVE_DOT)
diff --git a/debian/libxenomai-dev.install b/debian/libxenomai-dev.install
index 6d7eb7b..9f95c35 100644
--- a/debian/libxenomai-dev.install
+++ b/debian/libxenomai-dev.install
@@ -2,6 +2,6 @@ usr/include
 usr/lib/*.la
 usr/lib/*.a
 usr/lib/*.so
-usr/lib/assert.wrappers
+usr/lib/modechk.wrappers
 usr/lib/cobalt.wrappers
 usr/lib/dynlist.ld
diff --git a/demo/alchemy/Makefile.am b/demo/alchemy/Makefile.am
index e6cda07..80def4f 100644
--- a/demo/alchemy/Makefile.am
+++ b/demo/alchemy/Makefile.am
@@ -13,8 +13,9 @@ cppflags =\
 ldadd =

[Xenomai-git] Philippe Gerum : drivers/ipc: reduce stack footprint of I/O vectors

2017-04-15 Thread git repository hosting
Module: xenomai-3
Branch: master
Commit: 1ba2fc8ef98d927f07a8d7465fe9ea541f501e39
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=1ba2fc8ef98d927f07a8d7465fe9ea541f501e39

Author: Philippe Gerum 
Date:   Sun Mar 12 11:37:20 2017 +0100

drivers/ipc: reduce stack footprint of I/O vectors

Resort to dynamic allocation of the I/O vector when more than 16
entries are needed, otherwise stick to a stack-based fast vector as
previously.

As a by-product of this change, we can now align on the regular
UIO_MAXIOV limit for all RTIPC protocols.

---

 kernel/drivers/ipc/bufp.c |   24 +-
 kernel/drivers/ipc/iddp.c |   24 +-
 kernel/drivers/ipc/internal.h |   20 +-
 kernel/drivers/ipc/rtipc.c|   45 +
 kernel/drivers/ipc/xddp.c |   24 +-
 5 files changed, 89 insertions(+), 48 deletions(-)

diff --git a/kernel/drivers/ipc/bufp.c b/kernel/drivers/ipc/bufp.c
index 2e7f5ad..3b565bd 100644
--- a/kernel/drivers/ipc/bufp.c
+++ b/kernel/drivers/ipc/bufp.c
@@ -359,7 +359,7 @@ static ssize_t __bufp_recvmsg(struct rtdm_fd *fd,
 static ssize_t bufp_recvmsg(struct rtdm_fd *fd,
struct user_msghdr *msg, int flags)
 {
-   struct iovec iov[RTIPC_IOV_MAX];
+   struct iovec iov_fast[RTIPC_IOV_FASTMAX], *iov;
struct sockaddr_ipc saddr;
ssize_t ret;
 
@@ -372,20 +372,22 @@ static ssize_t bufp_recvmsg(struct rtdm_fd *fd,
} else if (msg->msg_namelen != 0)
return -EINVAL;
 
-   if (msg->msg_iovlen >= RTIPC_IOV_MAX)
+   if (msg->msg_iovlen >= UIO_MAXIOV)
return -EINVAL;
 
/* Copy I/O vector in */
-   ret = rtipc_get_iovec(fd, iov, msg);
+   ret = rtipc_get_iovec(fd, , msg, iov_fast);
if (ret)
return ret;
 
ret = __bufp_recvmsg(fd, iov, msg->msg_iovlen, flags, );
-   if (ret <= 0)
+   if (ret <= 0) {
+   rtipc_drop_iovec(iov, iov_fast);
return ret;
+   }
 
/* Copy the updated I/O vector back */
-   if (rtipc_put_iovec(fd, iov, msg))
+   if (rtipc_put_iovec(fd, iov, msg, iov_fast))
return -EFAULT;
 
/* Copy the source address if required. */
@@ -607,8 +609,8 @@ static ssize_t bufp_sendmsg(struct rtdm_fd *fd,
const struct user_msghdr *msg, int flags)
 {
struct rtipc_private *priv = rtdm_fd_to_private(fd);
+   struct iovec iov_fast[RTIPC_IOV_FASTMAX], *iov;
struct bufp_socket *sk = priv->state;
-   struct iovec iov[RTIPC_IOV_MAX];
struct sockaddr_ipc daddr;
ssize_t ret;
 
@@ -634,20 +636,22 @@ static ssize_t bufp_sendmsg(struct rtdm_fd *fd,
return -EDESTADDRREQ;
}
 
-   if (msg->msg_iovlen >= RTIPC_IOV_MAX)
+   if (msg->msg_iovlen >= UIO_MAXIOV)
return -EINVAL;
 
/* Copy I/O vector in */
-   ret = rtipc_get_iovec(fd, iov, msg);
+   ret = rtipc_get_iovec(fd, , msg, iov_fast);
if (ret)
return ret;
 
ret = __bufp_sendmsg(fd, iov, msg->msg_iovlen, flags, );
-   if (ret <= 0)
+   if (ret <= 0) {
+   rtipc_drop_iovec(iov, iov_fast);
return ret;
+   }
 
/* Copy updated I/O vector back */
-   return rtipc_put_iovec(fd, iov, msg) ?: ret;
+   return rtipc_put_iovec(fd, iov, msg, iov_fast) ?: ret;
 }
 
 static ssize_t bufp_write(struct rtdm_fd *fd,
diff --git a/kernel/drivers/ipc/iddp.c b/kernel/drivers/ipc/iddp.c
index 6d3da57..5e2a2a1 100644
--- a/kernel/drivers/ipc/iddp.c
+++ b/kernel/drivers/ipc/iddp.c
@@ -326,7 +326,7 @@ static ssize_t __iddp_recvmsg(struct rtdm_fd *fd,
 static ssize_t iddp_recvmsg(struct rtdm_fd *fd,
struct user_msghdr *msg, int flags)
 {
-   struct iovec iov[RTIPC_IOV_MAX];
+   struct iovec iov_fast[RTIPC_IOV_FASTMAX], *iov;
struct sockaddr_ipc saddr;
ssize_t ret;
 
@@ -339,20 +339,22 @@ static ssize_t iddp_recvmsg(struct rtdm_fd *fd,
} else if (msg->msg_namelen != 0)
return -EINVAL;
 
-   if (msg->msg_iovlen >= RTIPC_IOV_MAX)
+   if (msg->msg_iovlen >= UIO_MAXIOV)
return -EINVAL;
 
/* Copy I/O vector in */
-   ret = rtipc_get_iovec(fd, iov, msg);
+   ret = rtipc_get_iovec(fd, , msg, iov_fast);
if (ret)
return ret;
 
ret = __iddp_recvmsg(fd, iov, msg->msg_iovlen, flags, );
-   if (ret <= 0)
+   if (ret <= 0) {
+   rtipc_drop_iovec(iov, iov_fast);
return ret;
+   }
 
/* Copy the updated I/O vector back */
-   if (rtipc_put_iovec(fd, iov, msg))
+   if (rtipc_put_iovec(fd, iov, msg, iov_fast))
return -EFAULT;
 
/* Copy the source address if required. */
@@ -468,8 +470,8 @@ static ssize_t iddp_sendmsg(struct 

[Xenomai-git] Philippe Gerum : lib/cobalt: better detect lack of backtrace() support

2017-04-15 Thread git repository hosting
Module: xenomai-3
Branch: stable-3.0.x
Commit: 8cb527787b37b31dc20afee8b2e9c425d74b5978
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=8cb527787b37b31dc20afee8b2e9c425d74b5978

Author: Philippe Gerum 
Date:   Sat Apr 15 15:33:00 2017 +0200

lib/cobalt: better detect lack of backtrace() support

---

 configure.ac   |3 ++-
 lib/cobalt/sigshadow.c |   10 --
 2 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/configure.ac b/configure.ac
index bc586e9..f8b2da8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -519,7 +519,8 @@ AC_CHECK_FUNCS([pthread_mutexattr_setprotocol   \
sched_getcpu\
clock_nanosleep \
shm_open\
-   shm_unlink])
+   shm_unlink  \
+   backtrace])
 LIBS="$save_LIBS"
 
 save_CPPFLAGS="$CPPFLAGS"
diff --git a/lib/cobalt/sigshadow.c b/lib/cobalt/sigshadow.c
index 3f4e9c5..f58e341 100644
--- a/lib/cobalt/sigshadow.c
+++ b/lib/cobalt/sigshadow.c
@@ -20,17 +20,15 @@
 #include 
 #include "internal.h"
 
-#ifdef __UCLIBC__
+#if !HAVE_BACKTRACE
 static inline int backtrace(void **buffer, int size)
 {
-   /*
-* We have no backtrace support in uClibc.
-*/
+   /* Not all *libcs support backtrace(). */
return 0;
 }
-#else /* !__UCLIBC__ */
+#else
 #include 
-#endif /* !__UCLIBC__ */
+#endif
 
 static struct sigaction sigshadow_action_orig;
 


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : lib/cobalt: check for valid mutex init decls

2017-04-15 Thread git repository hosting
Module: xenomai-3
Branch: stable-3.0.x
Commit: 00ea14550cf6967655489669fb4c7aab1f8451fa
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=00ea14550cf6967655489669fb4c7aab1f8451fa

Author: Philippe Gerum 
Date:   Sat Apr 15 14:57:45 2017 +0200

lib/cobalt: check for valid mutex init decls

Not all mutex types may be supported by the underlying *libc
implementation.

---

 configure.ac   |2 ++
 lib/cobalt/mutex.c |   15 ---
 2 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/configure.ac b/configure.ac
index fbfb60f..bc586e9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -525,6 +525,8 @@ LIBS="$save_LIBS"
 save_CPPFLAGS="$CPPFLAGS"
 CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
 AC_CHECK_DECLS([PTHREAD_PRIO_NONE], [], [], [#include ])
+AC_CHECK_DECLS([PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP], [], [], [#include 
])
+AC_CHECK_DECLS([PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP], [], [], [#include 
])
 CPPFLAGS=$save_CPPFLAGS
 
 dnl If we can't set the clock for condvar timeouts, then
diff --git a/lib/cobalt/mutex.c b/lib/cobalt/mutex.c
index 9d8a914..eba236b 100644
--- a/lib/cobalt/mutex.c
+++ b/lib/cobalt/mutex.c
@@ -192,23 +192,32 @@ COBALT_IMPL(int, pthread_mutex_destroy, (pthread_mutex_t 
*mutex))
 
 static int __attribute__((cold)) cobalt_mutex_autoinit(pthread_mutex_t *mutex)
 {
-   static pthread_mutex_t uninit_normal_mutex = PTHREAD_MUTEX_INITIALIZER;
-   struct cobalt_mutex_shadow *_mutex =
-   &((union cobalt_mutex_union *)mutex)->shadow_mutex;
+   static pthread_mutex_t uninit_normal_mutex =
+   PTHREAD_MUTEX_INITIALIZER;
+#if HAVE_DECL_PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
static pthread_mutex_t uninit_recursive_mutex =
PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
+#endif
+#if HAVE_DECL_PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP
static pthread_mutex_t uninit_errorcheck_mutex =
PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP;
+#endif
+   struct cobalt_mutex_shadow *_mutex =
+   &((union cobalt_mutex_union *)mutex)->shadow_mutex;
int err __attribute__((unused));
pthread_mutexattr_t mattr;
int ret = 0, type;
 
if (memcmp(mutex, _normal_mutex, sizeof(*mutex)) == 0)
type = PTHREAD_MUTEX_DEFAULT;
+#if HAVE_DECL_PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
else if (memcmp(mutex, _recursive_mutex, sizeof(*mutex)) == 0)
type = PTHREAD_MUTEX_RECURSIVE_NP;
+#endif
+#if HAVE_DECL_PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP
else if (memcmp(mutex, _errorcheck_mutex, sizeof(*mutex)) == 0)
type = PTHREAD_MUTEX_ERRORCHECK_NP;
+#endif
else
return EINVAL;
 


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : lib/cobalt: handle direct mmap64(), open64() wrapping to 32bit versions

2017-04-15 Thread git repository hosting
Module: xenomai-3
Branch: stable-3.0.x
Commit: 8e7aa675267a4d7756cf122914230908a5bf7c68
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=8e7aa675267a4d7756cf122914230908a5bf7c68

Author: Philippe Gerum 
Date:   Sat Apr 15 15:22:55 2017 +0200

lib/cobalt: handle direct mmap64(), open64() wrapping to 32bit versions

---

 lib/cobalt/rtdm.c |4 
 lib/cobalt/wrappers.c |5 -
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/lib/cobalt/rtdm.c b/lib/cobalt/rtdm.c
index 7bdbffd..1907090 100644
--- a/lib/cobalt/rtdm.c
+++ b/lib/cobalt/rtdm.c
@@ -480,7 +480,11 @@ COBALT_IMPL(void *, mmap64, (void *addr, size_t length, 
int prot, int flags,
}
 
 regular:
+#if mmap64 == mmap
+   return __STD(mmap(addr, length, prot, flags, fd, offset));
+#else
return __STD(mmap64(addr, length, prot, flags, fd, offset));
+#endif
 }
 
 COBALT_IMPL(void *, mmap, (void *addr, size_t length, int prot, int flags,
diff --git a/lib/cobalt/wrappers.c b/lib/cobalt/wrappers.c
index 5fa313b..8bd9190 100644
--- a/lib/cobalt/wrappers.c
+++ b/lib/cobalt/wrappers.c
@@ -177,7 +177,7 @@ int __real_open(const char *path, int oflag, ...)
return open(path, oflag, mode);
 }
 
-/* rtdm */
+#if open64 != open
 __weak
 int __real_open64(const char *path, int oflag, ...)
 {
@@ -192,6 +192,7 @@ int __real_open64(const char *path, int oflag, ...)
 
return open64(path, oflag, mode);
 }
+#endif
 
 __weak
 int __real_socket(int protocol_family, int socket_type, int protocol)
@@ -353,12 +354,14 @@ void *__real_mmap(void *addr, size_t length, int prot, 
int flags,
return mmap(addr, length, prot, flags, fd, offset);
 }
 
+#if mmap64 != mmap
 __weak
 void *__real_mmap64(void *addr, size_t length, int prot, int flags,
  int fd, off64_t offset)
 {
return mmap64(addr, length, prot, flags, fd, offset);
 }
+#endif
 
 __weak
 int __real_vfprintf(FILE *stream, const char *fmt, va_list args)


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Romain Naour : arm: enable armv5tej support

2017-04-15 Thread git repository hosting
Module: xenomai-3
Branch: stable-3.0.x
Commit: 3fa4dcdc397c35d27b67534c04e0ffb6e9d6d1d2
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=3fa4dcdc397c35d27b67534c04e0ffb6e9d6d1d2

Author: Romain Naour 
Date:   Fri Apr 14 15:08:00 2017 +0200

arm: enable armv5tej support

armv5tej are not detected in lib/cobalt/arch/arm/include/asm/xenomai/features.h

Apply the same patch from xenomai-2.6:
https://git.xenomai.org/xenomai-2.6.git/commit/?id=ebc2779baa222db4a5936c3d3022803355585b8c

Signed-off-by: Romain Naour 

---

 lib/cobalt/arch/arm/include/asm/xenomai/features.h |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lib/cobalt/arch/arm/include/asm/xenomai/features.h 
b/lib/cobalt/arch/arm/include/asm/xenomai/features.h
index 10bd0c7..e84b809 100644
--- a/lib/cobalt/arch/arm/include/asm/xenomai/features.h
+++ b/lib/cobalt/arch/arm/include/asm/xenomai/features.h
@@ -34,7 +34,8 @@
 #endif /* armv4 */
 
 #if defined(__ARM_ARCH_5__) || defined(__ARM_ARCH_5T__) \
-   || defined(__ARM_ARCH_5E__) || defined(__ARM_ARCH_5TE__)
+   || defined(__ARM_ARCH_5E__) || defined(__ARM_ARCH_5TE__) \
+   || defined(__ARM_ARCH_5TEJ__)
 #define __LINUX_ARM_ARCH__ 5
 #endif /* armv5 */
 


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : lib, utils: prefer X/Open LONG_BIT over __WORDSIZE

2017-04-15 Thread git repository hosting
Module: xenomai-3
Branch: stable-3.0.x
Commit: 249a27e5a3610297d213a80f49cd6f33648d91f2
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=249a27e5a3610297d213a80f49cd6f33648d91f2

Author: Philippe Gerum 
Date:   Sat Apr 15 15:06:07 2017 +0200

lib, utils: prefer X/Open LONG_BIT over __WORDSIZE

---

 lib/cobalt/printf.c|   14 +++---
 lib/copperplate/heapobj-tlsf.c |2 +-
 utils/slackspot/slackspot.c|2 +-
 3 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/lib/cobalt/printf.c b/lib/cobalt/printf.c
index e52a5a5..e109dea 100644
--- a/lib/cobalt/printf.c
+++ b/lib/cobalt/printf.c
@@ -434,7 +434,7 @@ int rt_print_init(size_t buffer_size, const char 
*buffer_name)
bitmap,
bitmap & ~(1UL << j));
} while (old_bitmap != bitmap && old_bitmap);
-   j += i * __WORDSIZE;
+   j += i * LONG_BIT;
} while (!old_bitmap);
 
buffer = (struct print_buffer *)(pool_start + j * pool_buf_size);
@@ -508,8 +508,8 @@ static void release_buffer(struct print_buffer *buffer)
goto dofree;
 
j = ((unsigned long)buffer - pool_start) / pool_buf_size;
-   i = j / __WORDSIZE;
-   j = j % __WORDSIZE;
+   i = j / LONG_BIT;
+   j = j % LONG_BIT;
 
old_bitmap = atomic_long_read(_bitmap[i]);
do {
@@ -687,7 +687,7 @@ void cobalt_print_init(void)
syncdelay.tv_nsec = (__cobalt_print_syncdelay % 1000) * 100;
 
/* Fill the buffer pool */
-   pool_bitmap_len = (__cobalt_print_bufcount+__WORDSIZE-1)/__WORDSIZE;
+   pool_bitmap_len = (__cobalt_print_bufcount+LONG_BIT-1)/LONG_BIT;
if (!pool_bitmap_len)
goto done;
 
@@ -701,11 +701,11 @@ void cobalt_print_init(void)
if (!pool_start)
early_panic("error allocating print relay buffers");
 
-   for (i = 0; i < __cobalt_print_bufcount / __WORDSIZE; i++)
+   for (i = 0; i < __cobalt_print_bufcount / LONG_BIT; i++)
atomic_long_set(_bitmap[i], ~0UL);
-   if (__cobalt_print_bufcount % __WORDSIZE)
+   if (__cobalt_print_bufcount % LONG_BIT)
atomic_long_set(_bitmap[i],
-   (1UL << (__cobalt_print_bufcount % __WORDSIZE)) 
- 1);
+   (1UL << (__cobalt_print_bufcount % LONG_BIT)) - 
1);
 
for (i = 0; i < __cobalt_print_bufcount; i++) {
struct print_buffer *buffer =
diff --git a/lib/copperplate/heapobj-tlsf.c b/lib/copperplate/heapobj-tlsf.c
index e573380..e24db15 100644
--- a/lib/copperplate/heapobj-tlsf.c
+++ b/lib/copperplate/heapobj-tlsf.c
@@ -26,7 +26,7 @@
 #include "xenomai/init.h"
 #include "internal.h"
 
-#if __WORDSIZE == 32
+#if LONG_BIT == 32
 #define TLSF_BLOCK_ALIGN  (8 * 2)
 #else
 #define TLSF_BLOCK_ALIGN  (16 * 2)
diff --git a/utils/slackspot/slackspot.c b/utils/slackspot/slackspot.c
index 88ace13..031b97f 100644
--- a/utils/slackspot/slackspot.c
+++ b/utils/slackspot/slackspot.c
@@ -549,7 +549,7 @@ static inline void put_location(struct relax_spot *p, int 
depth)
struct backtrace *b = p->backtrace + depth;
const struct location *where = b->where;
 
-   printf("   #%-2d 0x%.*lx ", depth, __WORDSIZE / 4, where->pc);
+   printf("   #%-2d 0x%.*lx ", depth, LONG_BIT / 4, where->pc);
if (where->function)
printf("%s() ", where->function);
if (where->file) {


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : boilerplate: remove potentially conflicting PAGE_SIZE definition

2017-04-15 Thread git repository hosting
Module: xenomai-3
Branch: stable-3.0.x
Commit: d723497fb855f31b88e007b283017d9579851b0d
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=d723497fb855f31b88e007b283017d9579851b0d

Author: Philippe Gerum 
Date:   Sat Apr 15 12:46:58 2017 +0200

boilerplate: remove potentially conflicting PAGE_SIZE definition

*libc implementations may define PAGE_SIZE.

---

 lib/boilerplate/tlsf/tlsf.c |6 +-
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/lib/boilerplate/tlsf/tlsf.c b/lib/boilerplate/tlsf/tlsf.c
index 2dddc1e..92e651a 100644
--- a/lib/boilerplate/tlsf/tlsf.c
+++ b/lib/boilerplate/tlsf/tlsf.c
@@ -163,10 +163,6 @@
 
 #define DEFAULT_AREA_SIZE (1024*10)
 
-#ifdef USE_MMAP
-#define PAGE_SIZE (getpagesize())
-#endif
-
 #ifdef USE_PRINTF
 #include 
 # define PRINT_MSG(fmt, args...) printf(fmt, ## args)
@@ -418,7 +414,7 @@ static __inline__ void *get_new_area(size_t * size)
 
 
 #if USE_MMAP
-*size = ROUNDUP(*size, PAGE_SIZE);
+*size = ROUNDUP(*size, getpagesize());
 if ((area = __STD(mmap(0, *size, PROT_READ | PROT_WRITE, MAP_PRIVATE | 
MAP_ANONYMOUS, -1, 0))) != MAP_FAILED)
return area;
 #endif


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : lib/cobalt: use designated initializers for socket types

2017-04-15 Thread git repository hosting
Module: xenomai-3
Branch: stable-3.0.x
Commit: eeca7bcf489379393343faf66e91b20b96fa4767
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=eeca7bcf489379393343faf66e91b20b96fa4767

Author: Philippe Gerum 
Date:   Sat Apr 15 15:15:17 2017 +0200

lib/cobalt: use designated initializers for socket types

---

 lib/cobalt/rtdm.c |   58 -
 1 file changed, 48 insertions(+), 10 deletions(-)

diff --git a/lib/cobalt/rtdm.c b/lib/cobalt/rtdm.c
index aced887..7bdbffd 100644
--- a/lib/cobalt/rtdm.c
+++ b/lib/cobalt/rtdm.c
@@ -254,9 +254,18 @@ COBALT_IMPL(ssize_t, sendmsg, (int fd, const struct msghdr 
*msg, int flags))
 COBALT_IMPL(ssize_t, recvfrom, (int fd, void *buf, size_t len, int flags,
struct sockaddr *from, socklen_t *fromlen))
 {
-   struct iovec iov = { buf, len };
-   struct msghdr msg =
-   { from, (from != NULL) ? *fromlen : 0, , 1, NULL, 0 };
+   struct iovec iov = {
+   .iov_base = buf,
+   .iov_len = len,
+   };
+   struct msghdr msg = {
+   .msg_name = from,
+   .msg_namelen = from != NULL ? *fromlen : 0,
+   .msg_iov = ,
+   .msg_iovlen = 1,
+   .msg_control = NULL,
+   .msg_controllen = 0,
+   };
int ret;
 
ret = do_recvmsg(fd, , flags);
@@ -269,9 +278,18 @@ COBALT_IMPL(ssize_t, recvfrom, (int fd, void *buf, size_t 
len, int flags,
 COBALT_IMPL(ssize_t, sendto, (int fd, const void *buf, size_t len, int flags,
  const struct sockaddr *to, socklen_t tolen))
 {
-   struct iovec iov = { (void *)buf, len };
-   struct msghdr msg =
-   { (struct sockaddr *)to, tolen, , 1, NULL, 0 };
+   struct iovec iov = {
+   .iov_base = (void *)buf,
+   .iov_len = len,
+   };
+   struct msghdr msg = {
+   .msg_name = (struct sockaddr *)to,
+   .msg_namelen = tolen,
+   .msg_iov = ,
+   .msg_iovlen = 1,
+   .msg_control = NULL,
+   .msg_controllen = 0,
+   };
int ret;
 
ret = do_sendmsg(fd, , flags);
@@ -283,8 +301,18 @@ COBALT_IMPL(ssize_t, sendto, (int fd, const void *buf, 
size_t len, int flags,
 
 COBALT_IMPL(ssize_t, recv, (int fd, void *buf, size_t len, int flags))
 {
-   struct iovec iov = { buf, len };
-   struct msghdr msg = { NULL, 0, , 1, NULL, 0 };
+   struct iovec iov = {
+   .iov_base = (void *)buf,
+   .iov_len = len,
+   };
+   struct msghdr msg = {
+   .msg_name = NULL,
+   .msg_namelen = 0,
+   .msg_iov = ,
+   .msg_iovlen = 1,
+   .msg_control = NULL,
+   .msg_controllen = 0,
+   };
int ret;
 
ret = do_recvmsg(fd, , flags);
@@ -296,8 +324,18 @@ COBALT_IMPL(ssize_t, recv, (int fd, void *buf, size_t len, 
int flags))
 
 COBALT_IMPL(ssize_t, send, (int fd, const void *buf, size_t len, int flags))
 {
-   struct iovec iov = { (void *)buf, len };
-   struct msghdr msg = { NULL, 0, , 1, NULL, 0 };
+   struct iovec iov = {
+   .iov_base = (void *)buf,
+   .iov_len = len,
+   };
+   struct msghdr msg = {
+   .msg_name = NULL,
+   .msg_namelen = 0,
+   .msg_iov = ,
+   .msg_iovlen = 1,
+   .msg_control = NULL,
+   .msg_controllen = 0,
+   };
int ret;
 
ret = do_sendmsg(fd, , flags);


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : boilerplate: build obstack support conditionally

2017-04-15 Thread git repository hosting
Module: xenomai-3
Branch: stable-3.0.x
Commit: 4c593544d2ff39ba6631cc3fa0b91493973674d4
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=4c593544d2ff39ba6631cc3fa0b91493973674d4

Author: Philippe Gerum 
Date:   Fri Apr 14 18:28:36 2017 +0200

boilerplate: build obstack support conditionally

If the underlying *libc does not support obstacks, build a private
implementation, otherwise fully rely on the native support.

This fixes a long-standing issue building replacement code for the
native obstack support, which ended up breaking builds over uClibc
1.0.21 and later.  See https://patchwork.ozlabs.org/patch/745792/.

---

 configure.ac  |4 ++
 include/boilerplate/obstack.h |   12 +++--
 lib/boilerplate/Makefile.am   |5 +-
 lib/boilerplate/obstack.c |  111 +++--
 4 files changed, 34 insertions(+), 98 deletions(-)

diff --git a/configure.ac b/configure.ac
index 8222e1d..fbfb60f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -495,6 +495,10 @@ fi
 
 test x$CONFIG_XENO_VALGRIND_API = xy && 
AC_DEFINE(CONFIG_XENO_VALGRIND_API,1,[config])
 
+dnl Check for obstack support in *libc
+AC_CHECK_HEADERS(obstack.h,libc_has_obstack=y)
+AM_CONDITIONAL(XENO_PRIVATE_OBSTACK,[test x$libc_has_obstack = x])
+
 dnl Check for presence of some headers
 AC_CHECK_HEADERS(mqueue.h)
 
diff --git a/include/boilerplate/obstack.h b/include/boilerplate/obstack.h
index 206fe55..95eb792 100644
--- a/include/boilerplate/obstack.h
+++ b/include/boilerplate/obstack.h
@@ -103,8 +103,12 @@ Summary:
 
 /* Don't do the contents of this file more than once.  */
 
-#ifndef _OBSTACK_H
-#define _OBSTACK_H 1
+#ifndef _BOILERPLATE_OBSTACK_H
+#define _BOILERPLATE_OBSTACK_H 1
+
+#ifdef HAVE_OBSTACK_H
+#include_next 
+#else
 
 #ifdef __cplusplus
 extern "C" {
@@ -506,4 +510,6 @@ __extension__   
\
 }  /* C++ */
 #endif
 
-#endif /* obstack.h */
+#endif /* !HAVE_OBSTACK_H */
+
+#endif /* _BOILERPLATE_OBSTACK_H */
diff --git a/lib/boilerplate/Makefile.am b/lib/boilerplate/Makefile.am
index 9b8612d..d7e6324 100644
--- a/lib/boilerplate/Makefile.am
+++ b/lib/boilerplate/Makefile.am
@@ -6,10 +6,13 @@ libboilerplate_la_LIBADD = libversion.la libiniparser.la
 libboilerplate_la_SOURCES =\
ancillaries.c   \
hash.c  \
-   obstack.c   \
setup.c \
time.c
 
+if XENO_PRIVATE_OBSTACK
+libboilerplate_la_SOURCES += obstack.c
+endif
+
 if XENO_DEBUG
 libboilerplate_la_SOURCES += debug.c
 endif
diff --git a/lib/boilerplate/obstack.c b/lib/boilerplate/obstack.c
index 4c645b2..fab62ce 100644
--- a/lib/boilerplate/obstack.c
+++ b/lib/boilerplate/obstack.c
@@ -22,39 +22,11 @@
 #include 
 #include 
 
-/* NOTE BEFORE MODIFYING THIS FILE: This version number must be
-   incremented whenever callers compiled using an old obstack.h can no
-   longer properly call the functions in this obstack.c.  */
-#define OBSTACK_INTERFACE_VERSION 1
-
-/* Comment out all this code if we are using the GNU C Library, and are not
-   actually compiling the library itself, and the installed library
-   supports the same library interface we do.  This code is part of the GNU
-   C Library, but also included in many other GNU distributions.  Compiling
-   and linking in this code is a waste when using the GNU C library
-   (especially if it is a shared library).  Rather than having every GNU
-   program understand `configure --with-gnu-libc' and omit the object
-   files, it is simpler to just do this in the source for each such file.  */
-
-#include  /* Random thing to get __GNU_LIBRARY__.  */
-#if !defined _LIBC && defined __GNU_LIBRARY__ && __GNU_LIBRARY__ > 1
-# include 
-# if _GNU_OBSTACK_INTERFACE_VERSION == OBSTACK_INTERFACE_VERSION
-#  define ELIDE_CODE
-# endif
-#endif
+/* Use this obstack implementation unconditionally.  */
 
+#include 
 #include 
-
-#ifndef ELIDE_CODE
-
-
-# if HAVE_INTTYPES_H
-#  include 
-# endif
-# if HAVE_STDINT_H || defined _LIBC
-#  include 
-# endif
+#include 
 
 /* Determine default alignment.  */
 union fooround
@@ -97,22 +69,7 @@ void (*obstack_alloc_failed_handler) (void) = 
print_and_abort;
 
 /* Exit value used when `print_and_abort' is used.  */
 # include 
-# ifdef _LIBC
 int obstack_exit_failure = EXIT_FAILURE;
-# else
-#  include "exitfail.h"
-#  define obstack_exit_failure exit_failure
-# endif
-
-# ifdef _LIBC
-#  if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_3_4)
-/* A looong time ago (before 1994, anyway; we're not sure) this global variable
-   was used by non-GNU-C macros to avoid multiple evaluation.  The GNU C
-   library still exports it because somebody might use it.  */
-struct obstack *_obstack_compat;
-compat_symbol (libc, _obstack_compat, _obstack, GLIBC_2_0);
-#  endif
-# endif
 
 /* Define a macro that either calls functions with the traditional malloc/free
calling interface, or calls 

[Xenomai-git] Göktürk Yüksek : configure: fix the help string for demodir

2017-04-15 Thread git repository hosting
Module: xenomai-3
Branch: stable-3.0.x
Commit: f850c26c6e11f864dc74a3a5fa8e34bf2664a9b7
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=f850c26c6e11f864dc74a3a5fa8e34bf2664a9b7

Author: Göktürk Yüksek 
Date:   Fri Apr 14 19:54:00 2017 +0200

configure: fix the help string for demodir

The help string uses '--with-demo' instead of '--with-demodir',
misinforming the user about the correct option to pass.

---

 configure.ac |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index f8b2da8..6593f5d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -748,7 +748,7 @@ AC_MSG_RESULT($XENO_TEST_DIR)
 demodir='${exec_prefix}/demo'
 AC_MSG_CHECKING(location for demo programs)
 AC_ARG_WITH(demodir,
-AS_HELP_STRING([--with-demo=],[location for demo 
programs (defaults to $prefix/demo)]),
+AS_HELP_STRING([--with-demodir=],[location for demo 
programs (defaults to $prefix/demo)]),
 [
case "$withval" in
"" | y | ye | yes | n | no)


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git

[Xenomai-git] Philippe Gerum : boilerplate: decouple pthread_setaffinity_np(), pthread_attr_setaffinity_np() placeholders

2017-04-15 Thread git repository hosting
Module: xenomai-3
Branch: stable-3.0.x
Commit: 0b5bb07cd8ca264638b041f15170357337c60b7c
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=0b5bb07cd8ca264638b041f15170357337c60b7c

Author: Philippe Gerum 
Date:   Sat Apr 15 12:47:54 2017 +0200

boilerplate: decouple pthread_setaffinity_np(), pthread_attr_setaffinity_np() 
placeholders

---

 include/boilerplate/libc.h |5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/include/boilerplate/libc.h b/include/boilerplate/libc.h
index d8b0334..134176e 100644
--- a/include/boilerplate/libc.h
+++ b/include/boilerplate/libc.h
@@ -118,7 +118,9 @@ int pthread_attr_setaffinity_np(pthread_attr_t *attr,
return 0;
return ENOSYS;
 }
+#endif /* !HAVE_PTHREAD_ATTR_SETAFFINITY_NP */
 
+#ifndef HAVE_PTHREAD_SETAFFINITY_NP
 static inline
 int pthread_setaffinity_np(pthread_t thread, size_t cpusetsize,
   const cpu_set_t *cpuset)
@@ -127,8 +129,7 @@ int pthread_setaffinity_np(pthread_t thread, size_t 
cpusetsize,
return 0;
return ENOSYS;
 }
-
-#endif /* !HAVE_PTHREAD_ATTR_SETAFFINITY_NP */
+#endif /* !HAVE_PTHREAD_SETAFFINITY_NP */
 
 #if !defined(HAVE_CLOCK_NANOSLEEP) && defined(CONFIG_XENO_MERCURY)
 /*


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git