summaryrefslogtreecommitdiffstats
path: root/cpukit
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2016-04-07 16:48:30 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2016-04-12 07:36:18 +0200
commit572cb6242969f96a5bf74dc107e3f845894b6b2b (patch)
treebe87de631165d9314f36ad6d48e15b8ca8fb9d7b /cpukit
parentrtems: Ensure lock ownership for _Region_Get() (diff)
downloadrtems-572cb6242969f96a5bf74dc107e3f845894b6b2b.tar.bz2
score: Simplify _Objects_Get_no_protection()
This functions supports only local objects. Thus, drop the location parameter which was unused by all callers. Remove superfluous includes from Classic Region implementation.
Diffstat (limited to 'cpukit')
-rw-r--r--cpukit/posix/include/rtems/posix/keyimpl.h9
-rw-r--r--cpukit/rtems/include/rtems/rtems/regionimpl.h16
-rw-r--r--cpukit/rtems/src/regiondelete.c45
-rw-r--r--cpukit/rtems/src/regionextend.c73
-rw-r--r--cpukit/rtems/src/regiongetfreeinfo.c48
-rw-r--r--cpukit/rtems/src/regiongetinfo.c39
-rw-r--r--cpukit/rtems/src/regiongetsegment.c121
-rw-r--r--cpukit/rtems/src/regiongetsegmentsize.c41
-rw-r--r--cpukit/rtems/src/regionprocessqueue.c12
-rw-r--r--cpukit/rtems/src/regionresizesegment.c71
-rw-r--r--cpukit/rtems/src/regionreturnsegment.c51
-rw-r--r--cpukit/score/include/rtems/score/objectimpl.h6
-rw-r--r--cpukit/score/src/objectgetnext.c9
-rw-r--r--cpukit/score/src/objectgetnoprotection.c7
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 0f255ba880..1f8747052d 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 4598351a20..60cf50c2fd 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 f25642354b..3927a545d6 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 2ee2b992e4..b1df066f25 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 6ebd1abbd2..7924c0f90e 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 d5eee727d3..2ab3d40e30 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 0d1ac574dd..5a98e85ba4 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 ab07a56e9c..21a2bb4bde 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 a1f2601c77..a28d68c03e 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 86d8a7775e..a21d1b9d44 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 aeff1df16c..c7147bbe19 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 aed7fafad2..ee9da931ae 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 544ded7000..c0ebbbed98 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 aebe6c798a..eaa172c83b 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;
}