mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2025-11-16 12:34:45 +00:00
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.
This commit is contained in:
@@ -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 ','.
|
||||
|
||||
@@ -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 );
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user