summaryrefslogtreecommitdiffstats
path: root/cpukit/rtems
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2013-06-25 12:09:50 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2013-06-25 17:03:22 +0200
commitd0d357edeb8527becced15e2784b92790d2b22c1 (patch)
tree64985dad8d48fe6b888a7d4faaf3b3cc18c6c7d5 /cpukit/rtems
parentheap: Free all delayed blocks during resize (diff)
downloadrtems-d0d357edeb8527becced15e2784b92790d2b22c1.tar.bz2
heap: Add _Heap_Greedy_allocate_all_except_largest
Add rtems_workspace_greedy_allocate_all_except_largest() and rtems_heap_greedy_allocate_all_except_largest().
Diffstat (limited to '')
-rw-r--r--cpukit/rtems/include/rtems/rtems/support.h18
-rw-r--r--cpukit/rtems/src/workspacegreedy.c16
2 files changed, 32 insertions, 2 deletions
diff --git a/cpukit/rtems/include/rtems/rtems/support.h b/cpukit/rtems/include/rtems/rtems/support.h
index 1f3cd3da76..335b8c02fa 100644
--- a/cpukit/rtems/include/rtems/rtems/support.h
+++ b/cpukit/rtems/include/rtems/rtems/support.h
@@ -99,7 +99,7 @@ bool rtems_workspace_free(
/**
* @brief Greedy allocate that empties the workspace.
*
- * Afterward the heap has at most @a block_count allocateable blocks of sizes
+ * Afterwards the heap has at most @a block_count allocatable blocks of sizes
* specified by @a block_sizes. The @a block_sizes must point to an array with
* @a block_count members. All other blocks are used.
*
@@ -111,10 +111,24 @@ void *rtems_workspace_greedy_allocate(
);
/**
+ * @brief Greedy allocate all blocks except the largest free block.
+ *
+ * Afterwards the heap has at most one allocatable block. This block is the
+ * largest free block if it exists. The allocatable size of this block is
+ * stored in @a allocatable_size. All other blocks are used.
+ *
+ * @see rtems_workspace_greedy_free().
+ */
+void *rtems_workspace_greedy_allocate_all_except_largest(
+ uintptr_t *allocatable_size
+);
+
+/**
* @brief Frees space of a greedy allocation.
*
* The @a opaque argument must be the return value of
- * rtems_workspace_greedy_allocate().
+ * rtems_workspace_greedy_allocate() or
+ * rtems_workspace_greedy_allocate_all_except_largest().
*/
void rtems_workspace_greedy_free( void *opaque );
diff --git a/cpukit/rtems/src/workspacegreedy.c b/cpukit/rtems/src/workspacegreedy.c
index 8e43370336..4f46e7d919 100644
--- a/cpukit/rtems/src/workspacegreedy.c
+++ b/cpukit/rtems/src/workspacegreedy.c
@@ -40,6 +40,22 @@ void *rtems_workspace_greedy_allocate(
return opaque;
}
+void *rtems_workspace_greedy_allocate_all_except_largest(
+ uintptr_t *allocatable_size
+)
+{
+ void *opaque;
+
+ _Thread_Disable_dispatch();
+ opaque = _Heap_Greedy_allocate_all_except_largest(
+ &_Workspace_Area,
+ allocatable_size
+ );
+ _Thread_Enable_dispatch();
+
+ return opaque;
+}
+
void rtems_workspace_greedy_free( void *opaque )
{
_Thread_Disable_dispatch();