[PATCH 12/25] sapi: Add rtems_configuration_is_smp_enabled()

Sebastian Huber sebastian.huber at embedded-brains.de
Thu Jul 18 14:26:00 UTC 2013


Add a configuration field which indicates if the SMP mode of operation
is enabled.  This can be used to disable features unsupported on SMP,
e.g task variables.
---
 cpukit/sapi/include/confdefs.h                     |    7 +++
 cpukit/sapi/include/rtems/config.h                 |   25 ++++++++++
 testsuites/smptests/Makefile.am                    |    1 +
 testsuites/smptests/configure.ac                   |    1 +
 testsuites/smptests/smpunsupported01/Makefile.am   |   19 +++++++
 testsuites/smptests/smpunsupported01/init.c        |   50 ++++++++++++++++++++
 .../smptests/smpunsupported01/smpunsupported01.doc |   11 ++++
 .../smptests/smpunsupported01/smpunsupported01.scn |    2 +
 8 files changed, 116 insertions(+), 0 deletions(-)
 create mode 100644 testsuites/smptests/smpunsupported01/Makefile.am
 create mode 100644 testsuites/smptests/smpunsupported01/init.c
 create mode 100644 testsuites/smptests/smpunsupported01/smpunsupported01.doc
 create mode 100644 testsuites/smptests/smpunsupported01/smpunsupported01.scn

diff --git a/cpukit/sapi/include/confdefs.h b/cpukit/sapi/include/confdefs.h
index 1585548..b7cbfaa 100644
--- a/cpukit/sapi/include/confdefs.h
+++ b/cpukit/sapi/include/confdefs.h
@@ -2364,6 +2364,13 @@ const rtems_libio_helper rtems_fs_init_helper =
     #else
       false,
     #endif
+    #ifdef RTEMS_SMP
+      #ifdef CONFIGURE_SMP_APPLICATION
+        true,
+      #else
+        false,
+      #endif
+    #endif
     CONFIGURE_MAXIMUM_DRIVERS,                /* maximum device drivers */
     CONFIGURE_NUMBER_OF_DRIVERS,              /* static device drivers */
     Device_drivers,                           /* pointer to driver table */
diff --git a/cpukit/sapi/include/rtems/config.h b/cpukit/sapi/include/rtems/config.h
index d483471..d25b905 100644
--- a/cpukit/sapi/include/rtems/config.h
+++ b/cpukit/sapi/include/rtems/config.h
@@ -222,6 +222,10 @@ typedef struct {
    */
   bool                           stack_allocator_avoids_work_space;
 
+  #ifdef RTEMS_SMP
+    bool                         smp_enabled;
+  #endif
+
   uint32_t                       maximum_drivers;
   uint32_t                       number_of_device_drivers;
   rtems_driver_address_table    *Device_driver_table;
@@ -339,11 +343,32 @@ extern const rtems_configuration_table Configuration;
 #endif
 
 /**
+ * @brief Returns true if the SMP mode of operation is enabled, and false
+ * otherwise.
+ *
+ * On single-processor configurations this is a compile time constant which
+ * evaluates to false.
+ *
+ * @retval true SMP mode of operation is enabled.
+ * @retval false Otherwise.
+ */
+#ifdef RTEMS_SMP
+  #define rtems_configuration_is_smp_enabled() \
+        (Configuration.smp_enabled)
+#else
+  #define rtems_configuration_is_smp_enabled() \
+        false
+#endif
+
+/**
  * @brief Returns the configured maximum count of processors.
  *
  * The actual number of processors available for the application will be less
  * than or equal to the configured maximum count of processors.
  *
+ * On single-processor configurations this is a compile time constant which
+ * evaluates to one.
+ *
  * @return The configured maximum count of processors.
  */
 #ifdef RTEMS_SMP
diff --git a/testsuites/smptests/Makefile.am b/testsuites/smptests/Makefile.am
index 8699167..6760432 100644
--- a/testsuites/smptests/Makefile.am
+++ b/testsuites/smptests/Makefile.am
@@ -21,6 +21,7 @@ SUBDIRS += smpatomic06
 SUBDIRS += smpatomic07
 SUBDIRS += smplock01
 SUBDIRS += smpschedule01
+SUBDIRS += smpunsupported01
 endif
 
 include $(top_srcdir)/../automake/subdirs.am
diff --git a/testsuites/smptests/configure.ac b/testsuites/smptests/configure.ac
index 19e1eff..9d7a6ca 100644
--- a/testsuites/smptests/configure.ac
+++ b/testsuites/smptests/configure.ac
@@ -54,5 +54,6 @@ smpatomic06/Makefile
 smpatomic07/Makefile
 smplock01/Makefile
 smpschedule01/Makefile
+smpunsupported01/Makefile
 ])
 AC_OUTPUT
diff --git a/testsuites/smptests/smpunsupported01/Makefile.am b/testsuites/smptests/smpunsupported01/Makefile.am
new file mode 100644
index 0000000..6f1826c
--- /dev/null
+++ b/testsuites/smptests/smpunsupported01/Makefile.am
@@ -0,0 +1,19 @@
+rtems_tests_PROGRAMS = smpunsupported01
+smpunsupported01_SOURCES = init.c
+
+dist_rtems_tests_DATA = smpunsupported01.scn smpunsupported01.doc
+
+include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP at .cfg
+include $(top_srcdir)/../automake/compile.am
+include $(top_srcdir)/../automake/leaf.am
+
+AM_CPPFLAGS += -I$(top_srcdir)/../support/include
+
+LINK_OBJS = $(smpunsupported01_OBJECTS)
+LINK_LIBS = $(smpunsupported01_LDLIBS)
+
+smpunsupported01$(EXEEXT): $(smpunsupported01_OBJECTS) $(smpunsupported01_DEPENDENCIES)
+	@rm -f smpunsupported01$(EXEEXT)
+	$(make-exe)
+
+include $(top_srcdir)/../automake/local.am
diff --git a/testsuites/smptests/smpunsupported01/init.c b/testsuites/smptests/smpunsupported01/init.c
new file mode 100644
index 0000000..0f1a102
--- /dev/null
+++ b/testsuites/smptests/smpunsupported01/init.c
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2013 embedded brains GmbH.  All rights reserved.
+ *
+ *  embedded brains GmbH
+ *  Dornierstr. 4
+ *  82178 Puchheim
+ *  Germany
+ *  <rtems at embedded-brains.de>
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ */
+
+#ifdef HAVE_CONFIG_H
+  #include "config.h"
+#endif
+
+#include "tmacros.h"
+
+static void test(void)
+{
+  rtems_test_assert(rtems_configuration_is_smp_enabled());
+}
+
+static void Init(rtems_task_argument arg)
+{
+  puts("\n\n*** TEST SMPUNSUPPORTED 1 ***");
+
+  test();
+
+  puts("*** END OF TEST SMPUNSUPPORTED 1 ***");
+
+  rtems_test_exit(0);
+}
+
+#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
+#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
+
+#define CONFIGURE_SMP_APPLICATION
+
+#define CONFIGURE_SMP_MAXIMUM_PROCESSORS 1
+
+#define CONFIGURE_MAXIMUM_TASKS 1
+
+#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
+
+#define CONFIGURE_INIT
+
+#include <rtems/confdefs.h>
diff --git a/testsuites/smptests/smpunsupported01/smpunsupported01.doc b/testsuites/smptests/smpunsupported01/smpunsupported01.doc
new file mode 100644
index 0000000..954bf30
--- /dev/null
+++ b/testsuites/smptests/smpunsupported01/smpunsupported01.doc
@@ -0,0 +1,11 @@
+This file describes the directives and concepts tested by this test set.
+
+test set name: smpunsupported01
+
+directives:
+
+  - rtems_configuration_is_smp_enabled()
+
+concepts:
+
+  - Ensure that functions unsupported on SMP return an error status.
diff --git a/testsuites/smptests/smpunsupported01/smpunsupported01.scn b/testsuites/smptests/smpunsupported01/smpunsupported01.scn
new file mode 100644
index 0000000..a4ced68
--- /dev/null
+++ b/testsuites/smptests/smpunsupported01/smpunsupported01.scn
@@ -0,0 +1,2 @@
+*** TEST SMPUNSUPPORTED 1 ***
+*** END OF TEST SMPUNSUPPORTED 1 ***
-- 
1.7.7




More information about the devel mailing list