summaryrefslogtreecommitdiffstats
path: root/cpukit
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2009-05-13 16:48:08 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2009-05-13 16:48:08 +0000
commit4423e62ac1d7bc7ed4e809ab5ac15540ea61c4c9 (patch)
treec28487317f85b85e38f401a04327f158f11c5776 /cpukit
parent2009-05-11 Joel Sherrill <joel.sherrill@oarcorp.com> (diff)
downloadrtems-4423e62ac1d7bc7ed4e809ab5ac15540ea61c4c9.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.
Diffstat (limited to 'cpukit')
-rw-r--r--cpukit/ChangeLog7
-rw-r--r--cpukit/rtems/src/workspace.c43
-rw-r--r--cpukit/score/include/rtems/score/protectedheap.h6
-rw-r--r--cpukit/score/src/pheapgetfreeinfo.c8
-rw-r--r--cpukit/score/src/pheapgetinfo.c13
5 files changed, 58 insertions, 19 deletions
diff --git a/cpukit/ChangeLog b/cpukit/ChangeLog
index 7c1fa748b6..4894e92744 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-05-10 Joel Sherrill <joel.sherrill@oarcorp.com>
* libmisc/shell/login_prompt.c, libmisc/shell/shell_script.c,
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 f9407b27db..ffe6b8406a 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;
}