[PATCH 09/12] rtems: Delete Region_Control::number_of_used_blocks

Sebastian Huber sebastian.huber at embedded-brains.de
Fri Apr 8 06:49:24 UTC 2016


Use Heap_Statistics::used_blocks instead.
---
 cpukit/libmisc/monitor/mon-region.c       | 3 ++-
 cpukit/rtems/include/rtems/rtems/region.h | 1 -
 cpukit/rtems/src/regioncreate.c           | 9 ++++-----
 cpukit/rtems/src/regiondelete.c           | 2 +-
 cpukit/rtems/src/regiongetsegment.c       | 1 -
 cpukit/rtems/src/regionprocessqueue.c     | 1 -
 cpukit/rtems/src/regionreturnsegment.c    | 2 --
 7 files changed, 7 insertions(+), 12 deletions(-)

diff --git a/cpukit/libmisc/monitor/mon-region.c b/cpukit/libmisc/monitor/mon-region.c
index 289a00b..17e6d18 100644
--- a/cpukit/libmisc/monitor/mon-region.c
+++ b/cpukit/libmisc/monitor/mon-region.c
@@ -19,13 +19,14 @@ rtems_monitor_region_canonical(
 )
 {
     const Region_Control *rtems_region = (const Region_Control *) region_void;
+    const Heap_Control *heap = &rtems_region->Memory;
 
     canonical_region->attribute = rtems_region->attribute_set;
     canonical_region->start_addr = rtems_region->starting_address;
     canonical_region->length = rtems_region->length;
     canonical_region->page_size = rtems_region->page_size;
     canonical_region->max_seg_size = rtems_region->maximum_segment_size;
-    canonical_region->used_blocks = rtems_region->number_of_used_blocks;
+    canonical_region->used_blocks = heap->stats.used_blocks;
 }
 
 
diff --git a/cpukit/rtems/include/rtems/rtems/region.h b/cpukit/rtems/include/rtems/rtems/region.h
index 0c28899..8ae52f3 100644
--- a/cpukit/rtems/include/rtems/rtems/region.h
+++ b/cpukit/rtems/include/rtems/rtems/region.h
@@ -65,7 +65,6 @@ typedef struct {
   uintptr_t             page_size;             /* in bytes               */
   uintptr_t             maximum_segment_size;  /* in bytes               */
   rtems_attribute       attribute_set;
-  uint32_t              number_of_used_blocks; /* blocks allocated       */
   Heap_Control          Memory;
 }  Region_Control;
 
diff --git a/cpukit/rtems/src/regioncreate.c b/cpukit/rtems/src/regioncreate.c
index 482c43b..8f1f7c5 100644
--- a/cpukit/rtems/src/regioncreate.c
+++ b/cpukit/rtems/src/regioncreate.c
@@ -87,11 +87,10 @@ rtems_status_code rtems_region_create(
         _Region_Free( the_region );
         return_status = RTEMS_INVALID_SIZE;
       } else {
-        the_region->starting_address      = starting_address;
-        the_region->length                = length;
-        the_region->page_size             = page_size;
-        the_region->attribute_set         = attribute_set;
-        the_region->number_of_used_blocks = 0;
+        the_region->starting_address = starting_address;
+        the_region->length           = length;
+        the_region->page_size        = page_size;
+        the_region->attribute_set    = attribute_set;
 
         _Objects_Open(
           &_Region_Information,
diff --git a/cpukit/rtems/src/regiondelete.c b/cpukit/rtems/src/regiondelete.c
index 7897646..2161335 100644
--- a/cpukit/rtems/src/regiondelete.c
+++ b/cpukit/rtems/src/regiondelete.c
@@ -35,7 +35,7 @@ rtems_status_code rtems_region_delete(
     return RTEMS_INVALID_ID;
   }
 
-  if ( the_region->number_of_used_blocks != 0 ) {
+  if ( the_region->Memory.stats.used_blocks != 0 ) {
     status = RTEMS_RESOURCE_IN_USE;
   } else {
     _Objects_Close( &_Region_Information, &the_region->Object );
diff --git a/cpukit/rtems/src/regiongetsegment.c b/cpukit/rtems/src/regiongetsegment.c
index ecc6378..d59de38 100644
--- a/cpukit/rtems/src/regiongetsegment.c
+++ b/cpukit/rtems/src/regiongetsegment.c
@@ -58,7 +58,6 @@ rtems_status_code rtems_region_get_segment(
     the_segment = _Region_Allocate_segment( the_region, size );
 
     if ( the_segment != NULL ) {
-      the_region->number_of_used_blocks += 1;
       *segment = the_segment;
       status = RTEMS_SUCCESSFUL;
     } else if ( _Options_Is_no_wait( option_set ) ) {
diff --git a/cpukit/rtems/src/regionprocessqueue.c b/cpukit/rtems/src/regionprocessqueue.c
index 1c9d273..db5759a 100644
--- a/cpukit/rtems/src/regionprocessqueue.c
+++ b/cpukit/rtems/src/regionprocessqueue.c
@@ -64,7 +64,6 @@ void _Region_Process_queue(
       break;
 
     *(void **)the_thread->Wait.return_argument = the_segment;
-    the_region->number_of_used_blocks += 1;
     _Thread_queue_Extract( the_thread );
     the_thread->Wait.return_code = RTEMS_SUCCESSFUL;
   }
diff --git a/cpukit/rtems/src/regionreturnsegment.c b/cpukit/rtems/src/regionreturnsegment.c
index 8ec84fb..ff742cf 100644
--- a/cpukit/rtems/src/regionreturnsegment.c
+++ b/cpukit/rtems/src/regionreturnsegment.c
@@ -34,8 +34,6 @@ rtems_status_code rtems_region_return_segment(
   }
 
   if ( _Region_Free_segment( the_region, segment ) ) {
-    the_region->number_of_used_blocks -= 1;
-
     /* Unlocks allocator */
     _Region_Process_queue( the_region );
     return RTEMS_SUCCESSFUL;
-- 
1.8.4.5




More information about the devel mailing list