summaryrefslogtreecommitdiffstats
path: root/cpukit/rtems/src/regionresizesegment.c
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/rtems/src/regionresizesegment.c
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/rtems/src/regionresizesegment.c')
-rw-r--r--cpukit/rtems/src/regionresizesegment.c71
1 files changed, 29 insertions, 42 deletions
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;
}