summaryrefslogtreecommitdiffstats
path: root/cpukit/libcsupport/src/malloc_initialize.c
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2008-01-08 22:59:14 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2008-01-08 22:59:14 +0000
commitcfcc4e202d928690c46a083ce594aa0d505bf302 (patch)
treeae22c4fd873aacb37662b661760f4d4ce021acc6 /cpukit/libcsupport/src/malloc_initialize.c
parent2008-01-08 Joel Sherrill <joel.sherrill@OARcorp.com> (diff)
downloadrtems-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_initialize.c')
-rw-r--r--cpukit/libcsupport/src/malloc_initialize.c39
1 files changed, 9 insertions, 30 deletions
diff --git a/cpukit/libcsupport/src/malloc_initialize.c b/cpukit/libcsupport/src/malloc_initialize.c
index 08fc351f7f..362d4477e2 100644
--- a/cpukit/libcsupport/src/malloc_initialize.c
+++ b/cpukit/libcsupport/src/malloc_initialize.c
@@ -22,7 +22,6 @@
Heap_Control RTEMS_Malloc_Heap;
Chain_Control RTEMS_Malloc_GC_list;
-size_t RTEMS_Malloc_Sbrk_amount;
rtems_malloc_statistics_t rtems_malloc_statistics;
void RTEMS_Malloc_Initialize(
@@ -33,8 +32,6 @@ void RTEMS_Malloc_Initialize(
{
uint32_t status;
void *starting_address;
- uintptr_t old_address;
- uintptr_t uaddress;
#if defined(RTEMS_MALLOC_BOUNDARY_HELPERS)
/*
@@ -55,36 +52,18 @@ void RTEMS_Malloc_Initialize(
*/
Chain_Initialize_empty(&RTEMS_Malloc_GC_list);
- /*
- * If the starting address is 0 then we are to attempt to
- * get length worth of memory using sbrk. Make sure we
- * align the address that we get back.
- */
-
starting_address = start;
- RTEMS_Malloc_Sbrk_amount = sbrk_amount;
-
- if (!starting_address) {
- uaddress = (uintptr_t)sbrk(length);
-
- if (uaddress == (uintptr_t) -1) {
- rtems_fatal_error_occurred( RTEMS_NO_MEMORY );
- /* DOES NOT RETURN!!! */
- }
- if (uaddress & (CPU_HEAP_ALIGNMENT-1)) {
- old_address = uaddress;
- uaddress = (uaddress + CPU_HEAP_ALIGNMENT) & ~(CPU_HEAP_ALIGNMENT-1);
-
- /*
- * adjust the length by whatever we aligned by
- */
- length -= uaddress - old_address;
- }
-
- starting_address = (void *)uaddress;
+ /*
+ * Initialize the optional sbrk support for extending the heap
+ */
+ if (rtems_malloc_sbrk_helpers) {
+ starting_address = (*rtems_malloc_sbrk_helpers->initialize)(
+ start,
+ sbrk_amount
+ );
}
-
+
/*
* If the BSP is not clearing out the workspace, then it is most likely
* not clearing out the initial memory for the heap. There is no