summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2018-11-22 06:38:42 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2018-12-07 14:22:01 +0100
commit359a3a36ca9bf82054fe6a83bd97868c310e5aae (patch)
tree431e2a12d7950abe39bc63e55d862232c0a3ce4e
parentscore: Rename Objects_Information::size (diff)
downloadrtems-359a3a36ca9bf82054fe6a83bd97868c310e5aae.tar.bz2
score: Rename Objects_Information::allocation_size
Rename Objects_Information::allocation_size in Objects_Information::objects_per_block. Adjust integer types in _Objects_Shrink_information() and _Objects_Free(). Update #3621.
-rw-r--r--cpukit/include/rtems/score/objectimpl.h4
-rw-r--r--cpukit/score/src/objectallocate.c2
-rw-r--r--cpukit/score/src/objectextendinformation.c15
-rw-r--r--cpukit/score/src/objectfree.c24
-rw-r--r--cpukit/score/src/objectinitializeinformation.c2
-rw-r--r--cpukit/score/src/objectshrinkinformation.c35
6 files changed, 47 insertions, 35 deletions
diff --git a/cpukit/include/rtems/score/objectimpl.h b/cpukit/include/rtems/score/objectimpl.h
index 3a64573f6b..c3597c33ff 100644
--- a/cpukit/include/rtems/score/objectimpl.h
+++ b/cpukit/include/rtems/score/objectimpl.h
@@ -131,7 +131,7 @@ typedef struct {
/** This is the number of objects on the Inactive list. */
Objects_Maximum inactive;
/** This is the number of objects in a block. */
- Objects_Maximum allocation_size;
+ Objects_Maximum objects_per_block;
/** This is the size in bytes of each object instance. */
uint16_t object_size;
/**
@@ -750,7 +750,7 @@ RTEMS_INLINE_ROUTINE Objects_Maximum _Objects_Extend_size(
const Objects_Information *information
)
{
- return information->auto_extend ? information->allocation_size : 0;
+ return information->auto_extend ? information->objects_per_block : 0;
}
/**
diff --git a/cpukit/score/src/objectallocate.c b/cpukit/score/src/objectallocate.c
index 97ced4bdf5..81e322757c 100644
--- a/cpukit/score/src/objectallocate.c
+++ b/cpukit/score/src/objectallocate.c
@@ -72,7 +72,7 @@ Objects_Control *_Objects_Allocate_unprotected(
block = (uint32_t) _Objects_Get_index( the_object->id ) -
_Objects_Get_index( information->minimum_id );
- block /= information->allocation_size;
+ block /= information->objects_per_block;
information->inactive_per_block[ block ]--;
information->inactive--;
diff --git a/cpukit/score/src/objectextendinformation.c b/cpukit/score/src/objectextendinformation.c
index 3fc9cdd464..b8e72f93b6 100644
--- a/cpukit/score/src/objectextendinformation.c
+++ b/cpukit/score/src/objectextendinformation.c
@@ -73,19 +73,19 @@ void _Objects_Extend_information(
if ( information->object_blocks == NULL )
block_count = 0;
else {
- block_count = information->maximum / information->allocation_size;
+ block_count = information->maximum / information->objects_per_block;
for ( ; block < block_count; block++ ) {
if ( information->object_blocks[ block ] == NULL ) {
do_extend = false;
break;
} else
- index_base += information->allocation_size;
+ index_base += information->objects_per_block;
}
}
- index_end = index_base + information->allocation_size;
+ index_end = index_base + information->objects_per_block;
- maximum = (uint32_t) information->maximum + information->allocation_size;
+ maximum = (uint32_t) information->maximum + information->objects_per_block;
/*
* We need to limit the number of objects to the maximum number
@@ -100,7 +100,8 @@ void _Objects_Extend_information(
* Allocate the name table, and the objects and if it fails either return or
* generate a fatal error depending on auto-extending being active.
*/
- object_block_size = information->allocation_size * information->object_size;
+ object_block_size = information->objects_per_block
+ * information->object_size;
if ( information->auto_extend ) {
new_object_block = _Workspace_Allocate( object_block_size );
if ( !new_object_block )
@@ -243,8 +244,8 @@ void _Objects_Extend_information(
* Assign the new object block to the object block table.
*/
information->object_blocks[ block ] = new_object_block;
- information->inactive_per_block[ block ] = information->allocation_size;
- information->inactive += information->allocation_size;
+ information->inactive_per_block[ block ] = information->objects_per_block;
+ information->inactive += information->objects_per_block;
/*
* Append to inactive chain.
diff --git a/cpukit/score/src/objectfree.c b/cpukit/score/src/objectfree.c
index 30ea1e36e5..3e7c8e409c 100644
--- a/cpukit/score/src/objectfree.c
+++ b/cpukit/score/src/objectfree.c
@@ -27,28 +27,32 @@ void _Objects_Free(
Objects_Control *the_object
)
{
- uint32_t allocation_size = information->allocation_size;
-
_Assert( _Objects_Allocator_is_owner() );
_Chain_Append_unprotected( &information->Inactive, &the_object->Node );
if ( information->auto_extend ) {
- uint32_t block;
+ Objects_Maximum objects_per_block;
+ Objects_Maximum block;
+ Objects_Maximum inactive;
+
+ objects_per_block = information->objects_per_block;
+ block = _Objects_Get_index( the_object->id );
+ block -= _Objects_Get_index( information->minimum_id );
+ block /= objects_per_block;
- block = (uint32_t) (_Objects_Get_index( the_object->id ) -
- _Objects_Get_index( information->minimum_id ));
- block /= information->allocation_size;
+ ++information->inactive_per_block[ block ];
- information->inactive_per_block[ block ]++;
- information->inactive++;
+ inactive = information->inactive;
+ ++inactive;
+ information->inactive = inactive;
/*
* Check if the threshold level has been met of
- * 1.5 x allocation_size are free.
+ * 1.5 x objects_per_block are free.
*/
- if ( information->inactive > ( allocation_size + ( allocation_size >> 1 ) ) ) {
+ if ( inactive > ( objects_per_block + ( objects_per_block >> 1 ) ) ) {
_Objects_Shrink_information( information );
}
}
diff --git a/cpukit/score/src/objectinitializeinformation.c b/cpukit/score/src/objectinitializeinformation.c
index 90f50d544c..a341dc1a5d 100644
--- a/cpukit/score/src/objectinitializeinformation.c
+++ b/cpukit/score/src/objectinitializeinformation.c
@@ -76,7 +76,7 @@ void _Objects_Do_initialize_information(
/*
* The allocation unit is the maximum value
*/
- information->allocation_size = maximum_per_allocation;
+ information->objects_per_block = maximum_per_allocation;
/*
* Provide a null local table entry for the case of any empty table.
diff --git a/cpukit/score/src/objectshrinkinformation.c b/cpukit/score/src/objectshrinkinformation.c
index db085e1042..cf3618f8fa 100644
--- a/cpukit/score/src/objectshrinkinformation.c
+++ b/cpukit/score/src/objectshrinkinformation.c
@@ -27,9 +27,10 @@ void _Objects_Shrink_information(
Objects_Information *information
)
{
- uint32_t block_count;
- uint32_t block;
- uint32_t index_base;
+ Objects_Maximum objects_per_block;
+ Objects_Maximum index_base;
+ Objects_Maximum block_count;
+ Objects_Maximum block;
_Assert( _Objects_Allocator_is_owner() );
@@ -37,20 +38,26 @@ void _Objects_Shrink_information(
* Search the list to find block or chunk with all objects inactive.
*/
+ objects_per_block = information->objects_per_block;
index_base = _Objects_Get_index( information->minimum_id );
- block_count = (information->maximum - index_base) /
- information->allocation_size;
+ block_count = ( information->maximum - index_base ) / objects_per_block;
for ( block = 0; block < block_count; block++ ) {
- if ( information->inactive_per_block[ block ] ==
- information->allocation_size ) {
- Chain_Node *node = _Chain_First( &information->Inactive );
- const Chain_Node *tail = _Chain_Immutable_tail( &information->Inactive );
- uint32_t index_end = index_base + information->allocation_size;
+ if ( information->inactive_per_block[ block ] == objects_per_block ) {
+ Chain_Node *node;
+ const Chain_Node *tail;
+ uint32_t index_end;
+
+ node = _Chain_First( &information->Inactive );
+ tail = _Chain_Immutable_tail( &information->Inactive );
+ index_end = index_base + objects_per_block;
while ( node != tail ) {
- Objects_Control *object = (Objects_Control *) node;
- uint32_t index = _Objects_Get_index( object->id );
+ Objects_Control *object;
+ uint32_t index;
+
+ object = (Objects_Control *) node;
+ index = _Objects_Get_index( object->id );
/*
* Get the next node before the node is extracted
@@ -70,11 +77,11 @@ void _Objects_Shrink_information(
information->object_blocks[ block ] = NULL;
information->inactive_per_block[ block ] = 0;
- information->inactive -= information->allocation_size;
+ information->inactive -= objects_per_block;
return;
}
- index_base += information->allocation_size;
+ index_base += objects_per_block;
}
}