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

Author: Philippe Gerum <r...@xenomai.org>
Date:   Tue Aug  5 17:16:01 2014 +0200

copperplate/init: introduce switches to control sanity checks

Copperplate performs sanity checks at application startup
(e.g. detection of single-processor code over SMP kernel).

--[no-]sanity can be used to control their execution at runtime.

Passing the --enable/disable-sanity switch when building can be used
to set the default mode when unspecified on the command line.

---

 configure                  |   27 +++++++++++++++++++++++++++
 configure.ac               |   18 ++++++++++++++++++
 include/xeno_config.h.in   |    3 +++
 lib/copperplate/init.c     |   31 ++++++++++++++++++++++++++-----
 lib/copperplate/internal.h |    1 +
 5 files changed, 75 insertions(+), 5 deletions(-)

diff --git a/configure b/configure
index 9ce243d..cf85a92 100755
--- a/configure
+++ b/configure
@@ -851,6 +851,7 @@ enable_async_cancel
 enable_pshared
 enable_registry
 enable_smp
+enable_sanity
 enable_x86_vsyscall
 enable_arm_quirks
 enable_doc_build
@@ -1521,6 +1522,7 @@ Optional Features:
   --enable-pshared        Enable shared multi-processing for capable skins
   --enable-registry       Export real-time objects to a registry
   --enable-smp            Enable SMP support
+  --enable-sanity         Enable sanity checks at runtime
   --enable-x86-vsyscall   Assume VSYSCALL enabled for issuing syscalls
   --enable-arm-quirks     Enable quirks for specific systems. Currently
                           supported quirks are for sa1100 and xscale3.
@@ -13286,6 +13288,31 @@ fi
 $as_echo "${CONFIG_SMP:-no}" >&6; }
 
 
+CONFIG_XENO_SANITY=y
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable sanity 
checks" >&5
+$as_echo_n "checking whether to enable sanity checks... " >&6; }
+# Check whether --enable-sanity was given.
+if test "${enable_sanity+set}" = set; then :
+  enableval=$enable_sanity; case "$enableval" in
+       y | yes) CONFIG_XENO_SANITY=y ;;
+       *) unset CONFIG_XENO_SANITY= ;;
+       esac
+fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: ${CONFIG_XENO_SANITY:-no}" >&5
+$as_echo "${CONFIG_XENO_SANITY:-no}" >&6; }
+
+if test x$CONFIG_XENO_SANITY = xy; then
+
+$as_echo "#define CONFIG_XENO_SANITY 1" >>confdefs.h
+
+else
+
+$as_echo "#define CONFIG_XENO_SANITY 0" >>confdefs.h
+
+fi
+
+
 CONFIG_XENO_X86_VSYSCALL=y
 
 if test $XENO_TARGET_ARCH = x86; then
diff --git a/configure.ac b/configure.ac
index 8dce673..10584bb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -307,6 +307,24 @@ AC_ARG_ENABLE(smp,
        esac])
 AC_MSG_RESULT(${CONFIG_SMP:-no})
 
+dnl Runtime sanity checks (default: on)
+
+CONFIG_XENO_SANITY=y
+AC_MSG_CHECKING(whether to enable sanity checks)
+AC_ARG_ENABLE(sanity,
+       AS_HELP_STRING([--enable-sanity], [Enable sanity checks at runtime]),
+       [case "$enableval" in
+       y | yes) CONFIG_XENO_SANITY=y ;;
+       *) unset CONFIG_XENO_SANITY= ;;
+       esac])
+AC_MSG_RESULT(${CONFIG_XENO_SANITY:-no})
+
+if test x$CONFIG_XENO_SANITY = xy; then
+  AC_DEFINE(CONFIG_XENO_SANITY,1,[config])
+else
+  AC_DEFINE(CONFIG_XENO_SANITY,0,[config])
+fi
+
 dnl VSYSCALL (default: enabled) for x86
 
 CONFIG_XENO_X86_VSYSCALL=y
diff --git a/include/xeno_config.h.in b/include/xeno_config.h.in
index b712cc8..80446b5 100644
--- a/include/xeno_config.h.in
+++ b/include/xeno_config.h.in
@@ -67,6 +67,9 @@
 #undef CONFIG_XENO_REVISION_LEVEL
 
 /* config */
+#undef CONFIG_XENO_SANITY
+
+/* config */
 #undef CONFIG_XENO_TLSF
 
 /* TLS model */
diff --git a/lib/copperplate/init.c b/lib/copperplate/init.c
index 665e6f4..09507b0 100644
--- a/lib/copperplate/init.c
+++ b/lib/copperplate/init.c
@@ -44,6 +44,7 @@ struct coppernode __node_info = {
        .registry_root = "/mnt/xenomai",
        .no_mlock = 0,
        .no_registry = 0,
+       .no_sanity = !CONFIG_XENO_SANITY,
        .reset_session = 0,
        .silent_mode = 0,
 };
@@ -135,6 +136,20 @@ static const struct option base_options[] = {
                .val = 0
        },
        {
+#define no_sanity_opt  11
+               .name = "no-sanity",
+               .has_arg = 0,
+               .flag = &__node_info.no_sanity,
+               .val = 1
+       },
+       {
+#define sanity_opt     12
+               .name = "sanity",
+               .has_arg = 0,
+               .flag = &__node_info.no_sanity,
+               .val = 0
+       },
+       {
                .name = NULL,
                .has_arg = 0,
                .flag = NULL,
@@ -169,6 +184,7 @@ static void usage(void)
         fprintf(stderr, "--session=<label>                label of shared 
multi-processing session\n");
         fprintf(stderr, "--reset                          remove any older 
session\n");
         fprintf(stderr, "--cpu-affinity=<cpu[,cpu]...>    set CPU affinity of 
threads\n");
+        fprintf(stderr, "--no-check                       disable sanity 
checks\n");
         fprintf(stderr, "--silent                         tame down 
verbosity\n");
         fprintf(stderr, "--version                        get version 
information\n");
         fprintf(stderr, "--dump-config                    dump configuration 
settings\n");
@@ -368,8 +384,10 @@ static int parse_base_options(int *argcp, char *const 
**argvp,
                                return ret;
                        break;
                case no_mlock_opt:
+               case no_sanity_opt:
                case no_registry_opt:
                case reset_session_opt:
+               case sanity_opt:
                case silent_opt:
                        break;
                case version_opt:
@@ -504,11 +522,6 @@ void copperplate_init(int *argcp, char *const **argvp)
                return;
        }
 
-#if defined(CONFIG_MERCURY) && !defined(CONFIG_SMP)
-       ret = get_static_cpu_count();
-       if (ret > 0)
-               early_panic("running non-SMP libraries on SMP kernel?");
-#endif
        boilerplate_init();
 
        threadobj_init_key();
@@ -547,6 +560,14 @@ void copperplate_init(int *argcp, char *const **argvp)
        if (ret)
                goto fail;
 
+#if defined(CONFIG_XENO_MERCURY) && !defined(CONFIG_SMP)
+       if (__node_info.no_sanity == 0) {
+               ret = get_static_cpu_count();
+               if (ret > 0)
+                       early_panic("running non-SMP libraries on SMP kernel?");
+       }
+#endif
+
        ret = debug_init();
        if (ret) {
                warning("failed to initialize debugging features");
diff --git a/lib/copperplate/internal.h b/lib/copperplate/internal.h
index 9ac9848..8c5e943 100644
--- a/lib/copperplate/internal.h
+++ b/lib/copperplate/internal.h
@@ -37,6 +37,7 @@ struct coppernode {
        cpu_set_t cpu_affinity;
        int no_mlock;
        int no_registry;
+       int no_sanity;
        int reset_session;
        int silent_mode;
 };


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

Reply via email to