[PATCH 07/12] score: Simplify _Objects_Get_no_protection()
Sebastian Huber
sebastian.huber at embedded-brains.de
Fri Apr 8 06:49:22 UTC 2016
This functions supports only local objects. Thus, drop the location
parameter which was unused by all callers.
Remove superfluous includes from Classic Region implementation.
---
cpukit/posix/include/rtems/posix/keyimpl.h | 9 +-
cpukit/rtems/include/rtems/rtems/regionimpl.h | 16 +---
cpukit/rtems/src/regiondelete.c | 45 +++-------
cpukit/rtems/src/regionextend.c | 73 ++++++----------
cpukit/rtems/src/regiongetfreeinfo.c | 48 ++++------
cpukit/rtems/src/regiongetinfo.c | 39 +++------
cpukit/rtems/src/regiongetsegment.c | 121 ++++++++++++--------------
cpukit/rtems/src/regiongetsegmentsize.c | 41 ++++-----
cpukit/rtems/src/regionprocessqueue.c | 12 +--
cpukit/rtems/src/regionresizesegment.c | 71 ++++++---------
cpukit/rtems/src/regionreturnsegment.c | 51 ++++-------
cpukit/score/include/rtems/score/objectimpl.h | 6 +-
cpukit/score/src/objectgetnext.c | 9 +-
cpukit/score/src/objectgetnoprotection.c | 7 +-
14 files changed, 207 insertions(+), 341 deletions(-)
diff --git a/cpukit/posix/include/rtems/posix/keyimpl.h b/cpukit/posix/include/rtems/posix/keyimpl.h
index 0f255ba..1f87470 100644
--- a/cpukit/posix/include/rtems/posix/keyimpl.h
+++ b/cpukit/posix/include/rtems/posix/keyimpl.h
@@ -76,13 +76,8 @@ RTEMS_INLINE_ROUTINE void _POSIX_Keys_Free(
RTEMS_INLINE_ROUTINE POSIX_Keys_Control *_POSIX_Keys_Get( pthread_key_t key )
{
- Objects_Locations location;
-
- return (POSIX_Keys_Control *) _Objects_Get_no_protection(
- &_POSIX_Keys_Information,
- (Objects_Id) key,
- &location
- );
+ return (POSIX_Keys_Control *)
+ _Objects_Get_no_protection( &_POSIX_Keys_Information, (Objects_Id) key );
}
RTEMS_INLINE_ROUTINE void _POSIX_Keys_Key_value_acquire(
diff --git a/cpukit/rtems/include/rtems/rtems/regionimpl.h b/cpukit/rtems/include/rtems/rtems/regionimpl.h
index 4598351..60cf50c 100644
--- a/cpukit/rtems/include/rtems/rtems/regionimpl.h
+++ b/cpukit/rtems/include/rtems/rtems/regionimpl.h
@@ -67,23 +67,11 @@ RTEMS_INLINE_ROUTINE void _Region_Free (
_Objects_Free( &_Region_Information, &the_region->Object );
}
-/**
- * @brief Region_Get
- *
- * This function maps region IDs to region control blocks.
- * If ID corresponds to a local region, then it returns
- * the_region control pointer which maps to ID and location
- * is set to OBJECTS_LOCAL. Otherwise, location is set
- * to OBJECTS_ERROR and the_region is undefined.
- */
-RTEMS_INLINE_ROUTINE Region_Control *_Region_Get (
- Objects_Id id,
- Objects_Locations *location
-)
+RTEMS_INLINE_ROUTINE Region_Control *_Region_Get( Objects_Id id )
{
_Assert( _RTEMS_Allocator_is_owner() );
return (Region_Control *)
- _Objects_Get_no_protection( &_Region_Information, id, location );
+ _Objects_Get_no_protection( &_Region_Information, id );
}
/**
diff --git a/cpukit/rtems/src/regiondelete.c b/cpukit/rtems/src/regiondelete.c
index f256423..3927a54 100644
--- a/cpukit/rtems/src/regiondelete.c
+++ b/cpukit/rtems/src/regiondelete.c
@@ -18,50 +18,33 @@
#include "config.h"
#endif
-#include <rtems/system.h>
-#include <rtems/rtems/status.h>
-#include <rtems/rtems/support.h>
-#include <rtems/rtems/options.h>
#include <rtems/rtems/regionimpl.h>
-#include <rtems/score/thread.h>
-#include <rtems/score/apimutex.h>
rtems_status_code rtems_region_delete(
rtems_id id
)
{
- Objects_Locations location;
- rtems_status_code return_status;
- Region_Control *the_region;
+ rtems_status_code status;
+ Region_Control *the_region;
_Objects_Allocator_lock();
_RTEMS_Lock_allocator();
- the_region = _Region_Get( id, &location );
- switch ( location ) {
+ the_region = _Region_Get( id );
- case OBJECTS_LOCAL:
- if ( the_region->number_of_used_blocks != 0 )
- return_status = RTEMS_RESOURCE_IN_USE;
- else {
- _Objects_Close( &_Region_Information, &the_region->Object );
- _Region_Free( the_region );
- return_status = RTEMS_SUCCESSFUL;
- }
- break;
-
-#if defined(RTEMS_MULTIPROCESSING)
- case OBJECTS_REMOTE: /* this error cannot be returned */
-#endif
-
- case OBJECTS_ERROR:
- default:
- return_status = RTEMS_INVALID_ID;
- break;
+ if ( the_region != NULL ) {
+ if ( the_region->number_of_used_blocks != 0 ) {
+ status = RTEMS_RESOURCE_IN_USE;
+ } else {
+ _Objects_Close( &_Region_Information, &the_region->Object );
+ _Region_Free( the_region );
+ status = RTEMS_SUCCESSFUL;
}
+ } else {
+ status = RTEMS_INVALID_ID;
+ }
_RTEMS_Unlock_allocator();
_Objects_Allocator_unlock();
-
- return return_status;
+ return status;
}
diff --git a/cpukit/rtems/src/regionextend.c b/cpukit/rtems/src/regionextend.c
index 2ee2b99..b1df066 100644
--- a/cpukit/rtems/src/regionextend.c
+++ b/cpukit/rtems/src/regionextend.c
@@ -18,13 +18,7 @@
#include "config.h"
#endif
-#include <rtems/system.h>
-#include <rtems/rtems/status.h>
-#include <rtems/rtems/support.h>
-#include <rtems/rtems/options.h>
#include <rtems/rtems/regionimpl.h>
-#include <rtems/score/thread.h>
-#include <rtems/score/apimutex.h>
rtems_status_code rtems_region_extend(
rtems_id id,
@@ -32,48 +26,37 @@ rtems_status_code rtems_region_extend(
uintptr_t length
)
{
- uintptr_t amount_extended;
- Objects_Locations location;
- rtems_status_code return_status;
- Region_Control *the_region;
+ rtems_status_code status;
+ Region_Control *the_region;
+ uintptr_t amount_extended;
- if ( !starting_address )
+ if ( starting_address == NULL ) {
return RTEMS_INVALID_ADDRESS;
-
- _RTEMS_Lock_allocator(); /* to prevent deletion */
-
- the_region = _Region_Get( id, &location );
- switch ( location ) {
-
- case OBJECTS_LOCAL:
-
- amount_extended = _Heap_Extend(
- &the_region->Memory,
- starting_address,
- length,
- 0
- );
-
- if ( amount_extended > 0 ) {
- the_region->length += amount_extended;
- the_region->maximum_segment_size += amount_extended;
- return_status = RTEMS_SUCCESSFUL;
- } else {
- return_status = RTEMS_INVALID_ADDRESS;
- }
- break;
-
-#if defined(RTEMS_MULTIPROCESSING)
- case OBJECTS_REMOTE: /* this error cannot be returned */
-#endif
-
- case OBJECTS_ERROR:
- default:
- return_status = RTEMS_INVALID_ID;
- break;
+ }
+
+ _RTEMS_Lock_allocator();
+
+ the_region = _Region_Get( id );
+
+ if ( the_region != NULL ) {
+ amount_extended = _Heap_Extend(
+ &the_region->Memory,
+ starting_address,
+ length,
+ 0
+ );
+
+ if ( amount_extended > 0 ) {
+ the_region->length += amount_extended;
+ the_region->maximum_segment_size += amount_extended;
+ status = RTEMS_SUCCESSFUL;
+ } else {
+ status = RTEMS_INVALID_ADDRESS;
}
+ } else {
+ status = RTEMS_INVALID_ID;
+ }
_RTEMS_Unlock_allocator();
-
- return return_status;
+ return status;
}
diff --git a/cpukit/rtems/src/regiongetfreeinfo.c b/cpukit/rtems/src/regiongetfreeinfo.c
index 6ebd1ab..7924c0f 100644
--- a/cpukit/rtems/src/regiongetfreeinfo.c
+++ b/cpukit/rtems/src/regiongetfreeinfo.c
@@ -18,52 +18,34 @@
#include "config.h"
#endif
-#include <rtems/system.h>
-#include <rtems/rtems/status.h>
-#include <rtems/rtems/support.h>
-#include <rtems/rtems/options.h>
#include <rtems/rtems/regionimpl.h>
-#include <rtems/score/apimutex.h>
-#include <rtems/score/thread.h>
+
+#include <string.h>
rtems_status_code rtems_region_get_free_information(
rtems_id id,
Heap_Information_block *the_info
)
{
- Objects_Locations location;
- rtems_status_code return_status;
- Region_Control *the_region;
+ rtems_status_code status;
+ Region_Control *the_region;
- if ( !the_info )
+ if ( the_info == NULL ) {
return RTEMS_INVALID_ADDRESS;
+ }
_RTEMS_Lock_allocator();
- the_region = _Region_Get( id, &location );
- switch ( location ) {
-
- case OBJECTS_LOCAL:
-
- the_info->Used.number = 0;
- the_info->Used.total = 0;
- the_info->Used.largest = 0;
-
- _Heap_Get_free_information( &the_region->Memory, &the_info->Free );
-
- return_status = RTEMS_SUCCESSFUL;
- break;
-
-#if defined(RTEMS_MULTIPROCESSING)
- case OBJECTS_REMOTE: /* this error cannot be returned */
-#endif
+ the_region = _Region_Get( id );
- case OBJECTS_ERROR:
- default:
- return_status = RTEMS_INVALID_ID;
- break;
- }
+ if ( the_region != NULL ) {
+ memset( &the_info->Used, 0, sizeof( the_info->Used ) );
+ _Heap_Get_free_information( &the_region->Memory, &the_info->Free );
+ status = RTEMS_SUCCESSFUL;
+ } else {
+ status = RTEMS_INVALID_ID;
+ }
_RTEMS_Unlock_allocator();
- return return_status;
+ return status;
}
diff --git a/cpukit/rtems/src/regiongetinfo.c b/cpukit/rtems/src/regiongetinfo.c
index d5eee72..2ab3d40 100644
--- a/cpukit/rtems/src/regiongetinfo.c
+++ b/cpukit/rtems/src/regiongetinfo.c
@@ -18,46 +18,31 @@
#include "config.h"
#endif
-#include <rtems/system.h>
-#include <rtems/rtems/status.h>
-#include <rtems/rtems/support.h>
-#include <rtems/rtems/options.h>
#include <rtems/rtems/regionimpl.h>
-#include <rtems/score/apimutex.h>
-#include <rtems/score/thread.h>
rtems_status_code rtems_region_get_information(
rtems_id id,
Heap_Information_block *the_info
)
{
- Objects_Locations location;
- rtems_status_code return_status;
- Region_Control *the_region;
+ rtems_status_code status;
+ Region_Control *the_region;
- if ( !the_info )
+ if ( the_info == NULL ) {
return RTEMS_INVALID_ADDRESS;
+ }
_RTEMS_Lock_allocator();
- the_region = _Region_Get( id, &location );
- switch ( location ) {
+ the_region = _Region_Get( id );
- case OBJECTS_LOCAL:
- _Heap_Get_information( &the_region->Memory, the_info );
- return_status = RTEMS_SUCCESSFUL;
- break;
-
-#if defined(RTEMS_MULTIPROCESSING)
- case OBJECTS_REMOTE: /* this error cannot be returned */
-#endif
-
- case OBJECTS_ERROR:
- default:
- return_status = RTEMS_INVALID_ID;
- break;
- }
+ if ( the_region != NULL ) {
+ _Heap_Get_information( &the_region->Memory, the_info );
+ status = RTEMS_SUCCESSFUL;
+ } else {
+ status = RTEMS_INVALID_ID;
+ }
_RTEMS_Unlock_allocator();
- return return_status;
+ return status;
}
diff --git a/cpukit/rtems/src/regiongetsegment.c b/cpukit/rtems/src/regiongetsegment.c
index 0d1ac57..5a98e85 100644
--- a/cpukit/rtems/src/regiongetsegment.c
+++ b/cpukit/rtems/src/regiongetsegment.c
@@ -20,7 +20,6 @@
#include <rtems/rtems/regionimpl.h>
#include <rtems/rtems/optionsimpl.h>
-#include <rtems/score/apimutex.h>
#include <rtems/score/threadqimpl.h>
#include <rtems/score/statesimpl.h>
@@ -32,79 +31,73 @@ rtems_status_code rtems_region_get_segment(
void **segment
)
{
- Thread_Control *executing;
- Objects_Locations location;
- rtems_status_code return_status;
- Region_Control *the_region;
- void *the_segment;
+ rtems_status_code status;
+ Region_Control *the_region;
- if ( !segment )
+ if ( segment == NULL ) {
return RTEMS_INVALID_ADDRESS;
+ }
*segment = NULL;
- if ( size == 0 )
+ if ( size == 0 ) {
return RTEMS_INVALID_SIZE;
+ }
_RTEMS_Lock_allocator();
- executing = _Thread_Get_executing();
- the_region = _Region_Get( id, &location );
- switch ( location ) {
-
- case OBJECTS_LOCAL:
- if ( size > the_region->maximum_segment_size )
- return_status = RTEMS_INVALID_SIZE;
-
- else {
- the_segment = _Region_Allocate_segment( the_region, size );
-
- if ( the_segment ) {
- the_region->number_of_used_blocks += 1;
- *segment = the_segment;
- return_status = RTEMS_SUCCESSFUL;
- } else if ( _Options_Is_no_wait( option_set ) ) {
- return_status = RTEMS_UNSATISFIED;
- } else {
- /*
- * Switch from using the memory allocation mutex to using a
- * dispatching disabled critical section. We have to do this
- * because this thread is going to block.
- */
- /* FIXME: Lock order reversal */
- _Thread_Disable_dispatch();
- _RTEMS_Unlock_allocator();
-
- executing->Wait.count = size;
- executing->Wait.return_argument = segment;
-
- _Thread_queue_Enqueue(
- &the_region->Wait_queue,
- the_region->wait_operations,
- executing,
- STATES_WAITING_FOR_SEGMENT,
- timeout,
- RTEMS_TIMEOUT
- );
-
- _Objects_Put( &the_region->Object );
-
- return (rtems_status_code) executing->Wait.return_code;
- }
- }
- break;
-
-#if defined(RTEMS_MULTIPROCESSING)
- case OBJECTS_REMOTE: /* this error cannot be returned */
-#endif
-
- case OBJECTS_ERROR:
- default:
- return_status = RTEMS_INVALID_ID;
- break;
+ the_region = _Region_Get( id );
+
+ if ( the_region != NULL ) {
+ if ( size > the_region->maximum_segment_size ) {
+ status = RTEMS_INVALID_SIZE;
+ } else {
+ void *the_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 ) ) {
+ status = RTEMS_UNSATISFIED;
+ } else {
+ Per_CPU_Control *cpu_self;
+ Thread_Control *executing;
+
+ /*
+ * Switch from using the memory allocation mutex to using a
+ * dispatching disabled critical section. We have to do this
+ * because this thread is going to block.
+ */
+ /* FIXME: This is a home grown condition variable */
+ cpu_self = _Thread_Dispatch_disable();
+ _RTEMS_Unlock_allocator();
+
+ executing = _Per_CPU_Get_executing( cpu_self );
+
+ executing->Wait.count = size;
+ executing->Wait.return_argument = segment;
+
+ _Thread_queue_Enqueue(
+ &the_region->Wait_queue,
+ the_region->wait_operations,
+ executing,
+ STATES_WAITING_FOR_SEGMENT,
+ timeout,
+ RTEMS_TIMEOUT
+ );
+
+ _Thread_Dispatch_enable( cpu_self );
+
+ return (rtems_status_code) executing->Wait.return_code;
+ }
}
+ } else {
+ status = RTEMS_INVALID_ID;
+ }
_RTEMS_Unlock_allocator();
-
- return return_status;
+ return status;
}
diff --git a/cpukit/rtems/src/regiongetsegmentsize.c b/cpukit/rtems/src/regiongetsegmentsize.c
index ab07a56..21a2bb4 100644
--- a/cpukit/rtems/src/regiongetsegmentsize.c
+++ b/cpukit/rtems/src/regiongetsegmentsize.c
@@ -18,12 +18,7 @@
#include "config.h"
#endif
-#include <rtems/system.h>
-#include <rtems/rtems/status.h>
-#include <rtems/rtems/support.h>
-#include <rtems/rtems/options.h>
#include <rtems/rtems/regionimpl.h>
-#include <rtems/score/apimutex.h>
rtems_status_code rtems_region_get_segment_size(
rtems_id id,
@@ -31,35 +26,31 @@ rtems_status_code rtems_region_get_segment_size(
uintptr_t *size
)
{
- Objects_Locations location;
- rtems_status_code return_status = RTEMS_SUCCESSFUL;
- Region_Control *the_region;
+ rtems_status_code status;
+ Region_Control *the_region;
- if ( !segment )
+ if ( segment == NULL ) {
return RTEMS_INVALID_ADDRESS;
+ }
- if ( !size )
+ if ( size == NULL ) {
return RTEMS_INVALID_ADDRESS;
+ }
_RTEMS_Lock_allocator();
- the_region = _Region_Get( id, &location );
- switch ( location ) {
+ the_region = _Region_Get( id );
- case OBJECTS_LOCAL:
- if ( !_Heap_Size_of_alloc_area( &the_region->Memory, segment, size ) )
- return_status = RTEMS_INVALID_ADDRESS;
- break;
-
-#if defined(RTEMS_MULTIPROCESSING)
- case OBJECTS_REMOTE: /* this error cannot be returned */
-#endif
-
- case OBJECTS_ERROR:
- return_status = RTEMS_INVALID_ID;
- break;
+ if ( the_region != NULL ) {
+ if ( _Heap_Size_of_alloc_area( &the_region->Memory, segment, size ) ) {
+ status = RTEMS_SUCCESSFUL;
+ } else {
+ status = RTEMS_INVALID_ADDRESS;
}
+ } else {
+ status = RTEMS_INVALID_ID;
+ }
_RTEMS_Unlock_allocator();
- return return_status;
+ return status;
}
diff --git a/cpukit/rtems/src/regionprocessqueue.c b/cpukit/rtems/src/regionprocessqueue.c
index a1f2601..a28d68c 100644
--- a/cpukit/rtems/src/regionprocessqueue.c
+++ b/cpukit/rtems/src/regionprocessqueue.c
@@ -19,15 +19,16 @@
#endif
#include <rtems/rtems/regionimpl.h>
-#include <rtems/score/apimutex.h>
#include <rtems/score/threadqimpl.h>
void _Region_Process_queue(
Region_Control *the_region
)
{
- Thread_Control *the_thread;
- void *the_segment;
+ Per_CPU_Control *cpu_self;
+ Thread_Control *the_thread;
+ void *the_segment;
+
/*
* Switch from using the memory allocation mutex to using a
* dispatching disabled critical section. We have to do this
@@ -38,7 +39,7 @@ void _Region_Process_queue(
* since we do not want to open a window where a context
* switch could occur.
*/
- _Thread_Disable_dispatch();
+ cpu_self = _Thread_Dispatch_disable();
_RTEMS_Unlock_allocator();
/*
@@ -67,5 +68,6 @@ void _Region_Process_queue(
_Thread_queue_Extract( the_thread );
the_thread->Wait.return_code = RTEMS_SUCCESSFUL;
}
- _Thread_Enable_dispatch();
+
+ _Thread_Dispatch_enable( cpu_self );
}
diff --git a/cpukit/rtems/src/regionresizesegment.c b/cpukit/rtems/src/regionresizesegment.c
index 86d8a77..a21d1b9 100644
--- a/cpukit/rtems/src/regionresizesegment.c
+++ b/cpukit/rtems/src/regionresizesegment.c
@@ -18,13 +18,7 @@
#include "config.h"
#endif
-#include <rtems/system.h>
-#include <rtems/rtems/status.h>
-#include <rtems/rtems/support.h>
-#include <rtems/rtems/options.h>
#include <rtems/rtems/regionimpl.h>
-#include <rtems/score/thread.h>
-#include <rtems/score/apimutex.h>
rtems_status_code rtems_region_resize_segment(
rtems_id id,
@@ -33,55 +27,48 @@ rtems_status_code rtems_region_resize_segment(
uintptr_t *old_size
)
{
- uintptr_t avail_size;
- Objects_Locations location;
- uintptr_t osize;
- rtems_status_code return_status;
- Heap_Resize_status status;
- Region_Control *the_region;
+ uintptr_t avail_size;
+ uintptr_t osize;
+ rtems_status_code status;
+ Heap_Resize_status resize_status;
+ Region_Control *the_region;
- if ( !old_size )
+ if ( old_size == NULL ) {
return RTEMS_INVALID_ADDRESS;
+ }
_RTEMS_Lock_allocator();
- the_region = _Region_Get( id, &location );
- switch ( location ) {
+ the_region = _Region_Get( id );
- case OBJECTS_LOCAL:
- status = _Heap_Resize_block(
- &the_region->Memory,
- segment,
- (uint32_t) size,
- &osize,
- &avail_size
- );
- *old_size = (uint32_t) osize;
+ if ( the_region != NULL ) {
+ resize_status = _Heap_Resize_block(
+ &the_region->Memory,
+ segment,
+ (uint32_t) size,
+ &osize,
+ &avail_size
+ );
+ *old_size = (uint32_t) osize;
- if ( status == HEAP_RESIZE_SUCCESSFUL )
- /* unlocks allocator */
- _Region_Process_queue( the_region );
- else
- _RTEMS_Unlock_allocator();
+ switch ( resize_status ) {
+ case HEAP_RESIZE_SUCCESSFUL:
+ /* Unlocks allocator */
+ _Region_Process_queue( the_region );
+ return RTEMS_SUCCESSFUL;
-
- if (status == HEAP_RESIZE_SUCCESSFUL)
- return RTEMS_SUCCESSFUL;
- if (status == HEAP_RESIZE_UNSATISFIED)
- return RTEMS_UNSATISFIED;
- return RTEMS_INVALID_ADDRESS;
+ case HEAP_RESIZE_UNSATISFIED:
+ status = RTEMS_UNSATISFIED;
break;
-#if defined(RTEMS_MULTIPROCESSING)
- case OBJECTS_REMOTE: /* this error cannot be returned */
-#endif
-
- case OBJECTS_ERROR:
default:
- return_status = RTEMS_INVALID_ID;
+ status = RTEMS_INVALID_ADDRESS;
break;
}
+ } else {
+ status = RTEMS_INVALID_ID;
+ }
_RTEMS_Unlock_allocator();
- return return_status;
+ return status;
}
diff --git a/cpukit/rtems/src/regionreturnsegment.c b/cpukit/rtems/src/regionreturnsegment.c
index aeff1df..c7147bb 100644
--- a/cpukit/rtems/src/regionreturnsegment.c
+++ b/cpukit/rtems/src/regionreturnsegment.c
@@ -18,53 +18,34 @@
#include "config.h"
#endif
-#include <rtems/system.h>
-#include <rtems/rtems/status.h>
-#include <rtems/rtems/support.h>
-#include <rtems/rtems/options.h>
#include <rtems/rtems/regionimpl.h>
-#include <rtems/score/thread.h>
-#include <rtems/score/apimutex.h>
rtems_status_code rtems_region_return_segment(
rtems_id id,
void *segment
)
{
- Objects_Locations location;
- rtems_status_code return_status;
- int status;
- Region_Control *the_region;
+ rtems_status_code status;
+ Region_Control *the_region;
_RTEMS_Lock_allocator();
- the_region = _Region_Get( id, &location );
- switch ( location ) {
+ the_region = _Region_Get( id );
- case OBJECTS_LOCAL:
- status = _Region_Free_segment( the_region, segment );
+ if ( the_region != NULL ) {
+ if ( _Region_Free_segment( the_region, segment ) ) {
+ the_region->number_of_used_blocks -= 1;
- if ( !status )
- return_status = RTEMS_INVALID_ADDRESS;
- else {
- the_region->number_of_used_blocks -= 1;
-
- _Region_Process_queue(the_region); /* unlocks allocator */
-
- return RTEMS_SUCCESSFUL;
- }
- break;
-
-#if defined(RTEMS_MULTIPROCESSING)
- case OBJECTS_REMOTE: /* this error cannot be returned */
-#endif
-
- case OBJECTS_ERROR:
- default:
- return_status = RTEMS_INVALID_ID;
- break;
- }
+ /* Unlocks allocator */
+ _Region_Process_queue( the_region );
+ return RTEMS_SUCCESSFUL;
+ } else {
+ status = RTEMS_INVALID_ADDRESS;
+ }
+ } else {
+ status = RTEMS_INVALID_ID;
+ }
_RTEMS_Unlock_allocator();
- return return_status;
+ return status;
}
diff --git a/cpukit/score/include/rtems/score/objectimpl.h b/cpukit/score/include/rtems/score/objectimpl.h
index aed7faf..ee9da93 100644
--- a/cpukit/score/include/rtems/score/objectimpl.h
+++ b/cpukit/score/include/rtems/score/objectimpl.h
@@ -614,7 +614,6 @@ Objects_Control *_Objects_Get_local(
*
* @param[in] information points to an object class information block.
* @param[in] id is the Id of the object whose name we are locating.
- * @param[in] location will contain an indication of success or failure.
*
* @retval This method returns one of the values from the
* @ref Objects_Name_or_id_lookup_errors enumeration to indicate
@@ -627,9 +626,8 @@ Objects_Control *_Objects_Get_local(
* objects.
*/
Objects_Control *_Objects_Get_no_protection(
- Objects_Information *information,
- Objects_Id id,
- Objects_Locations *location
+ const Objects_Information *information,
+ Objects_Id id
);
/**
diff --git a/cpukit/score/src/objectgetnext.c b/cpukit/score/src/objectgetnext.c
index 544ded7..c0ebbbe 100644
--- a/cpukit/score/src/objectgetnext.c
+++ b/cpukit/score/src/objectgetnext.c
@@ -28,7 +28,7 @@ _Objects_Get_next(
Objects_Id *next_id_p
)
{
- Objects_Control *object;
+ Objects_Control *the_object;
Objects_Id next_id;
if ( !information )
@@ -58,12 +58,13 @@ _Objects_Get_next(
}
/* try to grab one */
- object = _Objects_Get_no_protection(information, next_id, location_p);
+ the_object = _Objects_Get_no_protection( information, next_id );
next_id++;
- } while (*location_p != OBJECTS_LOCAL);
+ } while ( the_object == NULL );
+ *location_p = OBJECTS_LOCAL;
*next_id_p = next_id;
- return object;
+ return the_object;
}
diff --git a/cpukit/score/src/objectgetnoprotection.c b/cpukit/score/src/objectgetnoprotection.c
index aebe6c7..eaa172c 100644
--- a/cpukit/score/src/objectgetnoprotection.c
+++ b/cpukit/score/src/objectgetnoprotection.c
@@ -21,9 +21,8 @@
#include <rtems/score/objectimpl.h>
Objects_Control *_Objects_Get_no_protection(
- Objects_Information *information,
- Objects_Id id,
- Objects_Locations *location
+ const Objects_Information *information,
+ Objects_Id id
)
{
Objects_Control *the_object;
@@ -37,7 +36,6 @@ Objects_Control *_Objects_Get_no_protection(
if ( information->maximum >= index ) {
if ( (the_object = information->local_table[ index ]) != NULL ) {
- *location = OBJECTS_LOCAL;
return the_object;
}
}
@@ -46,6 +44,5 @@ Objects_Control *_Objects_Get_no_protection(
* This isn't supported or required yet for Global objects so
* if it isn't local, we don't find it.
*/
- *location = OBJECTS_ERROR;
return NULL;
}
--
1.8.4.5
More information about the devel
mailing list