diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 2009-05-13 16:48:22 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 2009-05-13 16:48:22 +0000 |
commit | f7e4067f3c60e1aae26dceac3f8c1d5f637930d8 (patch) | |
tree | bb161579b2369bb7ab94e03272f6fb8e1312cd47 | |
parent | 2009-05-08 Joel Sherrill <joel.sherrill@oarcorp.com> (diff) | |
download | rtems-f7e4067f3c60e1aae26dceac3f8c1d5f637930d8.tar.bz2 |
2009-05-13 Joel Sherrill <joel.sherrill@OARcorp.com>
PR 1411/cpukit
* rtems/src/workspace.c, score/include/rtems/score/protectedheap.h,
score/src/pheapgetfreeinfo.c, score/src/pheapgetinfo.c: Improve
workspace wrapper methods.
-rw-r--r-- | cpukit/ChangeLog | 7 | ||||
-rw-r--r-- | cpukit/rtems/src/workspace.c | 43 | ||||
-rw-r--r-- | cpukit/score/include/rtems/score/protectedheap.h | 6 | ||||
-rw-r--r-- | cpukit/score/src/pheapgetfreeinfo.c | 8 | ||||
-rw-r--r-- | cpukit/score/src/pheapgetinfo.c | 13 |
5 files changed, 58 insertions, 19 deletions
diff --git a/cpukit/ChangeLog b/cpukit/ChangeLog index ff38efac61..110da00cd5 100644 --- a/cpukit/ChangeLog +++ b/cpukit/ChangeLog @@ -1,3 +1,10 @@ +2009-05-13 Joel Sherrill <joel.sherrill@OARcorp.com> + + PR 1411/cpukit + * rtems/src/workspace.c, score/include/rtems/score/protectedheap.h, + score/src/pheapgetfreeinfo.c, score/src/pheapgetinfo.c: Improve + workspace wrapper methods. + 2009-04-02 Ralf Corsépius <ralfcorsepius@rtems.org> * aclocal/check-rtems-debug.m4: Add missing ','. diff --git a/cpukit/rtems/src/workspace.c b/cpukit/rtems/src/workspace.c index f573440475..e6394aca86 100644 --- a/cpukit/rtems/src/workspace.c +++ b/cpukit/rtems/src/workspace.c @@ -1,7 +1,7 @@ /* * Workspace Handler * - * COPYRIGHT (c) 1989-2007. + * COPYRIGHT (c) 1989-2009. * On-Line Applications Research Corporation (OAR). * * The license and distribution terms for this file may be @@ -17,6 +17,7 @@ #include <rtems/system.h> #include <rtems/score/wkspace.h> +#include <rtems/score/protectedheap.h> #include <rtems/score/interr.h> #include <rtems/config.h> @@ -26,28 +27,40 @@ bool rtems_workspace_get_information( Heap_Information_block *the_info ) { - Heap_Get_information_status status; - - status = _Heap_Get_information( &_Workspace_Area, the_info ); - if ( status == HEAP_GET_INFORMATION_SUCCESSFUL ) - return true; - else + if ( !the_info ) return false; + + return _Protected_heap_Get_information( &_Workspace_Area, the_info ); } /* * _Workspace_Allocate */ bool rtems_workspace_allocate( - size_t bytes, - void **pointer + uintptr_t bytes, + void **pointer ) { - *pointer = _Heap_Allocate( &_Workspace_Area, bytes ); - if (!pointer) - return false; - else - return true; + void *ptr; + + /* + * check the arguments + */ + if ( !pointer ) + return false; + + if ( !bytes ) + return false; + + /* + * Allocate the memory + */ + ptr = _Protected_heap_Allocate( &_Workspace_Area, (intptr_t) bytes ); + if (!ptr) + return false; + + *pointer = ptr; + return true; } /* @@ -57,6 +70,6 @@ bool rtems_workspace_free( void *pointer ) { - return _Heap_Free( &_Workspace_Area, pointer ); + return _Protected_heap_Free( &_Workspace_Area, pointer ); } diff --git a/cpukit/score/include/rtems/score/protectedheap.h b/cpukit/score/include/rtems/score/protectedheap.h index 78c2abc3d2..4840ddd7a7 100644 --- a/cpukit/score/include/rtems/score/protectedheap.h +++ b/cpukit/score/include/rtems/score/protectedheap.h @@ -185,8 +185,10 @@ bool _Protected_heap_Walk( * * @param[in] the_heap pointer to heap header * @param[in] the_info pointer to a status information area + * + * @return true if successfully able to return information */ -void _Protected_heap_Get_information( +bool _Protected_heap_Get_information( Heap_Control *the_heap, Heap_Information_block *the_info ); @@ -200,7 +202,7 @@ void _Protected_heap_Get_information( * * @return free block information filled in. */ -void _Protected_heap_Get_free_information( +bool _Protected_heap_Get_free_information( Heap_Control *the_heap, Heap_Information *info ); diff --git a/cpukit/score/src/pheapgetfreeinfo.c b/cpukit/score/src/pheapgetfreeinfo.c index bba8a90b18..4b211d93dd 100644 --- a/cpukit/score/src/pheapgetfreeinfo.c +++ b/cpukit/score/src/pheapgetfreeinfo.c @@ -16,13 +16,19 @@ #include <rtems/system.h> #include <rtems/score/protectedheap.h> -void _Protected_heap_Get_free_information( +bool _Protected_heap_Get_free_information( Heap_Control *the_heap, Heap_Information *info ) { + /* + * TBD: _Heap_Get_free_information does not error check or return status. + */ + _RTEMS_Lock_allocator(); _Heap_Get_free_information( the_heap, info ); _RTEMS_Unlock_allocator(); + + return true; } diff --git a/cpukit/score/src/pheapgetinfo.c b/cpukit/score/src/pheapgetinfo.c index 26e15d1d5c..1d62fc0673 100644 --- a/cpukit/score/src/pheapgetinfo.c +++ b/cpukit/score/src/pheapgetinfo.c @@ -16,14 +16,25 @@ #include <rtems/system.h> #include <rtems/score/protectedheap.h> -void _Protected_heap_Get_information( +bool _Protected_heap_Get_information( Heap_Control *the_heap, Heap_Information_block *the_info ) { Heap_Get_information_status status; + if ( !the_heap ) + return false; + + if ( !the_info ) + return false; + _RTEMS_Lock_allocator(); status = _Heap_Get_information( the_heap, the_info ); _RTEMS_Unlock_allocator(); + + if ( status == HEAP_GET_INFORMATION_SUCCESSFUL ) + return true; + + return false; } |