diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2012-08-09 16:48:00 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2012-10-25 14:54:06 +0200 |
commit | 47a3cd8f73780bad3eff5135f0eb58e8c98af91d (patch) | |
tree | 8acdfc6ebe5d596f9c6b974e6c460dc69e824e3c /testsuites/libtests | |
parent | score: Append to free list in _Heap_Extend() (diff) | |
download | rtems-47a3cd8f73780bad3eff5135f0eb58e8c98af91d.tar.bz2 |
score: Work area initialization API change
The work areas (RTEMS work space and C program heap) will be initialized
now in a separate step and are no longer part of
rtems_initialize_data_structures(). Initialization is performed with
tables of Heap_Area entries. This allows usage of scattered memory
areas present on various small scale micro-controllers.
The sbrk() support API changes also. The bsp_sbrk_init() must now deal
with a minimum size for the first memory chunk to take the configured
work space size into account.
Diffstat (limited to 'testsuites/libtests')
-rw-r--r-- | testsuites/libtests/malloc04/init.c | 43 |
1 files changed, 29 insertions, 14 deletions
diff --git a/testsuites/libtests/malloc04/init.c b/testsuites/libtests/malloc04/init.c index 72a397f6a1..00355dabd4 100644 --- a/testsuites/libtests/malloc04/init.c +++ b/testsuites/libtests/malloc04/init.c @@ -30,14 +30,20 @@ #include <rtems/confdefs.h> /* end of configuration */ +#ifndef CONFIGURE_MALLOC_BSP_SUPPORTS_SBRK +void *rtems_heap_null_extend( + Heap_Control *heap, + size_t alloc_size +) +{ + return rtems_heap_extend_via_sbrk( heap, alloc_size ); +} +#endif + char Malloc_Heap[ 128 ] CPU_STRUCTURE_ALIGNMENT; int sbrk_count; -Heap_Control Heap_Holder; Heap_Control TempHeap; -/* Heap variables we need to peek and poke at */ -extern size_t RTEMS_Malloc_Sbrk_amount; - size_t offset; void * sbrk(ptrdiff_t incr) @@ -66,7 +72,8 @@ rtems_task Init( rtems_task_argument argument ) { - Heap_Control *TempHeap; + Heap_Control *real_heap; + Heap_Area area; sbrk_count = 0; offset = 0; @@ -74,21 +81,26 @@ rtems_task Init( puts( "\n\n*** TEST MALLOC 04 ***" ); /* Safe information on real heap */ - TempHeap = malloc_get_heap_pointer(); - Heap_Holder = *TempHeap; - rtems_malloc_sbrk_helpers = &rtems_malloc_sbrk_helpers_table; + real_heap = malloc_get_heap_pointer(); + malloc_set_heap_pointer( &TempHeap ); + + rtems_heap_set_sbrk_amount( 64 ); puts( "Initialize heap with some memory" ); offset = 64; sbrk_count = 0; - RTEMS_Malloc_Initialize( Malloc_Heap, 64, 64 ); + area.begin = &Malloc_Heap [0]; + area.size = 64; + RTEMS_Malloc_Initialize( &area, 1, NULL ); p1 = malloc(64); p2 = malloc(64); p3 = malloc(48); p4 = malloc(48); puts( "Initialize heap with some memory - return address out of heap" ); - RTEMS_Malloc_Initialize( &Malloc_Heap[1], 64, 64 ); + area.begin = &Malloc_Heap [1]; + area.size = 64; + RTEMS_Malloc_Initialize( &area, 1, NULL ); offset = 64; sbrk_count = -1; p1 = malloc( 127 ); @@ -96,18 +108,21 @@ rtems_task Init( rtems_test_assert( errno == ENOMEM ); - RTEMS_Malloc_Initialize( Malloc_Heap, 64, 64 ); + area.begin = &Malloc_Heap [0]; + area.size = 64; + RTEMS_Malloc_Initialize( &area, 1, NULL ); puts( "Initialize heap with some unaligned memory" ); offset = 65; sbrk_count = 0; - RTEMS_Malloc_Initialize( &Malloc_Heap[1], 64, 64 ); + area.begin = &Malloc_Heap [1]; + area.size = 64; + RTEMS_Malloc_Initialize( &area, 1, NULL ); p1 = malloc(64); p2 = malloc(64); p3 = malloc(48); /* Restore information on real heap */ - malloc_set_heap_pointer( TempHeap ); - rtems_malloc_sbrk_helpers = NULL; + malloc_set_heap_pointer( real_heap ); puts( "*** END OF TEST MALLOC 04 ***" ); |