From 03dff2019f6972f9b202b15d57ab295d706d86cd Mon Sep 17 00:00:00 2001 From: Chris Johns Date: Tue, 9 Feb 2021 12:48:07 +1100 Subject: 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 --- cpukit/rtems/src/workspacegreedy.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'cpukit/rtems') 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 #include +#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(); -- cgit v1.2.3