[rtems commit] score: Add _Objects_Active_count()

Sebastian Huber sebh at rtems.org
Fri Dec 21 15:07:42 UTC 2012


Module:    rtems
Branch:    master
Commit:    fe1dc221b668d6046c0c7b1b09f64d817c764300
Changeset: http://git.rtems.org/rtems/commit/?id=fe1dc221b668d6046c0c7b1b09f64d817c764300

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Fri Dec 21 10:17:34 2012 +0100

score: Add _Objects_Active_count()

---

 cpukit/score/Makefile.am                         |    3 +-
 cpukit/score/include/rtems/score/object.h        |   11 ++++++++
 cpukit/score/src/objectactivecount.c             |   29 ++++++++++++++++++++++
 testsuites/sptests/spobjgetnext/init.c           |    5 ++++
 testsuites/sptests/spobjgetnext/spobjgetnext.doc |    5 +++-
 testsuites/sptests/spobjgetnext/spobjgetnext.scn |    1 +
 6 files changed, 52 insertions(+), 2 deletions(-)

diff --git a/cpukit/score/Makefile.am b/cpukit/score/Makefile.am
index cc0cbd5..d9471c3 100644
--- a/cpukit/score/Makefile.am
+++ b/cpukit/score/Makefile.am
@@ -190,7 +190,8 @@ libscore_a_SOURCES += src/objectallocate.c src/objectclose.c \
     src/objectshrinkinformation.c src/objectgetnoprotection.c \
     src/objectidtoname.c src/objectgetnameasstring.c src/objectsetname.c \
     src/objectgetinfo.c src/objectgetinfoid.c src/objectapimaximumclass.c \
-    src/objectnamespaceremove.c
+    src/objectnamespaceremove.c \
+    src/objectactivecount.c
 
 ## SCHEDULER_C_FILES
 libscore_a_SOURCES += src/scheduler.c
diff --git a/cpukit/score/include/rtems/score/object.h b/cpukit/score/include/rtems/score/object.h
index f2f4469..91173c3 100644
--- a/cpukit/score/include/rtems/score/object.h
+++ b/cpukit/score/include/rtems/score/object.h
@@ -862,6 +862,17 @@ void _Objects_Close(
   Objects_Control      *the_object
 );
 
+/**
+ * @brief Returns the count of active objects.
+ *
+ * @param[in] information The object information table.
+ *
+ * @return The count of active objects.
+ */
+Objects_Maximum _Objects_Active_count(
+  const Objects_Information *information
+);
+
 /*
  *  Pieces of object.inl are promoted out to the user
  */
diff --git a/cpukit/score/src/objectactivecount.c b/cpukit/score/src/objectactivecount.c
new file mode 100644
index 0000000..3b14823
--- /dev/null
+++ b/cpukit/score/src/objectactivecount.c
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2012 embedded brains GmbH.  All rights reserved.
+ *
+ *  embedded brains GmbH
+ *  Obere Lagerstr. 30
+ *  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.
+ */
+
+#if HAVE_CONFIG_H
+  #include "config.h"
+#endif
+
+#include <rtems/score/object.h>
+
+Objects_Maximum _Objects_Active_count(
+  const Objects_Information *information
+)
+{
+  size_t inactive = _Chain_Node_count_unprotected( &information->Inactive );
+  size_t maximum  = information->maximum;
+
+  return (Objects_Maximum) ( maximum - inactive );
+}
diff --git a/testsuites/sptests/spobjgetnext/init.c b/testsuites/sptests/spobjgetnext/init.c
index 0408610..037a833 100644
--- a/testsuites/sptests/spobjgetnext/init.c
+++ b/testsuites/sptests/spobjgetnext/init.c
@@ -68,6 +68,7 @@ rtems_task Init(
   Objects_Locations     location;
   Objects_Id            id;
   Objects_Information  *info;
+  Objects_Maximum       active_count;
 
   puts( "\n\n*** TEST OBJECT GET NEXT ***" );
 
@@ -103,6 +104,10 @@ rtems_task Init(
 
   /* XXX try with a manager with no objects created */
 
+  puts( "Init - _Objects_Active_count" );
+  active_count = _Objects_Active_count( info );
+  rtems_test_assert( active_count == 1 );
+
   puts( "*** END OF TEST OBJECT GET NEXT ***" );
   rtems_test_exit( 0 );
 }
diff --git a/testsuites/sptests/spobjgetnext/spobjgetnext.doc b/testsuites/sptests/spobjgetnext/spobjgetnext.doc
index 2fec4f3..2278dac 100644
--- a/testsuites/sptests/spobjgetnext/spobjgetnext.doc
+++ b/testsuites/sptests/spobjgetnext/spobjgetnext.doc
@@ -12,10 +12,13 @@ test set name:  spobjgetnext
 
 directives:
 
-  SCORE _Objects_Get_next
+  _Objects_Get_next
+  _Objects_Active_count
 
 concepts:
 
 + Ensure that _Objects_Get_next handles error conditions properly.
 
 + Ensure the _Objects_Get_next behaves as expected.
+
++ Ensure the _Objects_Active_count behaves as expected.
diff --git a/testsuites/sptests/spobjgetnext/spobjgetnext.scn b/testsuites/sptests/spobjgetnext/spobjgetnext.scn
index b5e7b11..edf2d5e 100644
--- a/testsuites/sptests/spobjgetnext/spobjgetnext.scn
+++ b/testsuites/sptests/spobjgetnext/spobjgetnext.scn
@@ -4,4 +4,5 @@ Init - _Objects_Get_next - NULL location
 Init - _Objects_Get_next - NULL id
 1 RTEMS Task
 1 RTEMS Task
+Init - _Objects_Active_count
 *** END OF TEST OBJECT GET NEXT ***




More information about the vc mailing list