diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 2008-01-08 22:59:14 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 2008-01-08 22:59:14 +0000 |
commit | cfcc4e202d928690c46a083ce594aa0d505bf302 (patch) | |
tree | ae22c4fd873aacb37662b661760f4d4ce021acc6 /cpukit/libcsupport/src/malloc.c | |
parent | 2008-01-08 Joel Sherrill <joel.sherrill@OARcorp.com> (diff) | |
download | rtems-cfcc4e202d928690c46a083ce594aa0d505bf302.tar.bz2 |
2008-01-08 Joel Sherrill <joel.sherrill@oarcorp.com>
* libcsupport/Makefile.am: Add malloc_sbrk_helpers.c.
* libcsupport/include/rtems/malloc.h,
libcsupport/src/malloc.c, libcsupport/src/malloc_initialize.c,
libcsupport/src/malloc_p.h,
libcsupport/src/malloc_statistics_helpers.c: Make sbrk()
support pluggable and optional. This eliminates the need for
heap extend and sbrk in the minimum footprint which is ~2.5K on
the SPARC.
* sapi/include/confdefs.h: Add the following configuration points:
+ CONFIGURE_MALLOC_STATISTICS
+ CONFIGURE_MALLOC_BSP_SUPPORTS_SBRK
* libcsupport/src/malloc_sbrk_helpers.c: New file.
Diffstat (limited to 'cpukit/libcsupport/src/malloc.c')
-rw-r--r-- | cpukit/libcsupport/src/malloc.c | 32 |
1 files changed, 2 insertions, 30 deletions
diff --git a/cpukit/libcsupport/src/malloc.c b/cpukit/libcsupport/src/malloc.c index a77444dc2c..954d5f7690 100644 --- a/cpukit/libcsupport/src/malloc.c +++ b/cpukit/libcsupport/src/malloc.c @@ -27,9 +27,6 @@ void *malloc( ) { void *return_this; - void *starting_address; - uint32_t the_size; - uint32_t sbrk_amount; Chain_Node *to_be_freed; MSBUMP(malloc_calls, 1); @@ -77,33 +74,8 @@ void *malloc( return_this = _Protected_heap_Allocate( &RTEMS_Malloc_Heap, size ); if ( !return_this ) { - /* - * Round to the "requested sbrk amount" so hopefully we won't have - * to grow again for a while. This effectively does sbrk() calls - * in "page" amounts. - */ - - sbrk_amount = RTEMS_Malloc_Sbrk_amount; - - if ( sbrk_amount == 0 ) - return (void *) 0; - - the_size = ((size + sbrk_amount) / sbrk_amount * sbrk_amount); - - if ((starting_address = (void *)sbrk(the_size)) - == (void*) -1) - return (void *) 0; - - if ( !_Protected_heap_Extend( - &RTEMS_Malloc_Heap, starting_address, the_size) ) { - sbrk(-the_size); - errno = ENOMEM; - return (void *) 0; - } - - MSBUMP(space_available, the_size); - - return_this = _Protected_heap_Allocate( &RTEMS_Malloc_Heap, size ); + if (rtems_malloc_sbrk_helpers) + return_this = (*rtems_malloc_sbrk_helpers->extend)( size ); if ( !return_this ) { errno = ENOMEM; return (void *) 0; |