summaryrefslogtreecommitdiffstats
path: root/cpukit/rtems
diff options
context:
space:
mode:
authorChris Johns <chrisj@rtems.org>2021-02-09 12:48:07 +1100
committerChris Johns <chrisj@rtems.org>2021-02-10 17:28:32 +1100
commit03dff2019f6972f9b202b15d57ab295d706d86cd (patch)
tree6e05487294aa5950f24ad7a17dc319ec7d19df0c /cpukit/rtems
parentbsp/riscv: Re-license to BSD-2-Clause (diff)
downloadrtems-03dff2019f6972f9b202b15d57ab295d706d86cd.tar.bz2
libcsupport: Add sbrk greedy support to consume all sbrk memory
- Move the heap sbrk code into a separate routnine. - Update heap and workspace greedy allocators to use the common sbrk greedy support. Closes #3982
Diffstat (limited to 'cpukit/rtems')
-rw-r--r--cpukit/rtems/src/workspacegreedy.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/cpukit/rtems/src/workspacegreedy.c b/cpukit/rtems/src/workspacegreedy.c
index 09204c2833..5ddf004787 100644
--- a/cpukit/rtems/src/workspacegreedy.c
+++ b/cpukit/rtems/src/workspacegreedy.c
@@ -33,15 +33,20 @@
#include <rtems/score/threaddispatch.h>
#include <rtems/score/wkspace.h>
+#define SBRK_ALLOC_SIZE (128 * 1024UL * 1024UL)
+
void *rtems_workspace_greedy_allocate(
const uintptr_t *block_sizes,
size_t block_count
)
{
+ Heap_Control *heap = &_Workspace_Area;
void *opaque;
+ rtems_heap_sbrk_greedy_allocate( heap, SBRK_ALLOC_SIZE );
+
_RTEMS_Lock_allocator();
- opaque = _Heap_Greedy_allocate( &_Workspace_Area, block_sizes, block_count );
+ opaque = _Heap_Greedy_allocate( heap, block_sizes, block_count );
_RTEMS_Unlock_allocator();
return opaque;
@@ -51,11 +56,14 @@ void *rtems_workspace_greedy_allocate_all_except_largest(
uintptr_t *allocatable_size
)
{
+ Heap_Control *heap = &_Workspace_Area;
void *opaque;
+ rtems_heap_sbrk_greedy_allocate( heap, SBRK_ALLOC_SIZE );
+
_RTEMS_Lock_allocator();
opaque = _Heap_Greedy_allocate_all_except_largest(
- &_Workspace_Area,
+ heap,
allocatable_size
);
_RTEMS_Unlock_allocator();