summaryrefslogtreecommitdiffstats
path: root/cpukit/libcsupport
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2011-02-17 14:17:09 +0000
committerSebastian Huber <sebastian.huber@embedded-brains.de>2011-02-17 14:17:09 +0000
commitddb29e37c9bbb6809809c643b62ab3ad8b151632 (patch)
treee54947cbe31114bedb8223339bdb2e68b773c0ed /cpukit/libcsupport
parent2011-02-17 Till Straumann <strauman@slac.stanford.edu> (diff)
downloadrtems-ddb29e37c9bbb6809809c643b62ab3ad8b151632.tar.bz2
2011-02-17 Sebastian Huber <sebastian.huber@embedded-brains.de>
* libcsupport/src/rtems_heap_extend.c: New file. * libcsupport/Makefile.am: Reflect change from above. * libcsupport/include/rtems/malloc.h: Declare rtems_heap_extend(). * score/include/rtems/score/heap.h: Documentation.
Diffstat (limited to 'cpukit/libcsupport')
-rw-r--r--cpukit/libcsupport/Makefile.am3
-rw-r--r--cpukit/libcsupport/include/rtems/malloc.h18
-rw-r--r--cpukit/libcsupport/src/rtems_heap_extend.c45
3 files changed, 65 insertions, 1 deletions
diff --git a/cpukit/libcsupport/Makefile.am b/cpukit/libcsupport/Makefile.am
index 73dc5209b6..39a32f4cde 100644
--- a/cpukit/libcsupport/Makefile.am
+++ b/cpukit/libcsupport/Makefile.am
@@ -98,7 +98,8 @@ MALLOC_C_FILES = src/malloc_initialize.c src/calloc.c src/malloc.c \
src/malloc_report_statistics.c src/malloc_report_statistics_plugin.c \
src/malloc_statistics_helpers.c src/posix_memalign.c \
src/rtems_memalign.c src/malloc_deferred.c src/malloc_sbrk_helpers.c \
- src/malloc_dirtier.c src/malloc_p.h src/rtems_malloc.c
+ src/malloc_dirtier.c src/malloc_p.h src/rtems_malloc.c \
+ src/rtems_heap_extend.c
PASSWORD_GROUP_C_FILES = src/getpwent.c
diff --git a/cpukit/libcsupport/include/rtems/malloc.h b/cpukit/libcsupport/include/rtems/malloc.h
index adc32c2a58..af092982f7 100644
--- a/cpukit/libcsupport/include/rtems/malloc.h
+++ b/cpukit/libcsupport/include/rtems/malloc.h
@@ -161,6 +161,24 @@ void *rtems_heap_allocate_aligned_with_boundary(
uintptr_t boundary
);
+/**
+ * @brief Extends the memory available for the heap using the memory area
+ * starting at @a area_begin of size @a area_size bytes.
+ *
+ * There are no alignment requirements. The memory area must be big enough to
+ * contain some maintainance blocks. It must not overlap parts of the current
+ * heap areas. Disconnected subordinate heap areas will lead to used blocks
+ * which cover the gaps. Extending with an inappropriate memory area will
+ * corrupt the heap.
+ *
+ * @retval RTEMS_SUCCESSFUL Successful operation.
+ * @retval RTEMS_INVALID_ADDRESS Invalid memory area.
+ */
+rtems_status_code rtems_heap_extend(
+ void *area_begin,
+ uintptr_t area_size
+);
+
#ifdef __cplusplus
}
#endif
diff --git a/cpukit/libcsupport/src/rtems_heap_extend.c b/cpukit/libcsupport/src/rtems_heap_extend.c
new file mode 100644
index 0000000000..5916852278
--- /dev/null
+++ b/cpukit/libcsupport/src/rtems_heap_extend.c
@@ -0,0 +1,45 @@
+/**
+ * @file
+ *
+ * @ingroup libcsupport
+ *
+ * @brief rtems_heap_extend() implementation.
+ */
+
+/*
+ * Copyright (c) 2011 embedded brains GmbH. All rights reserved.
+ *
+ * embedded brains GmbH
+ * Obere Lagerstr. 30
+ * 82178 Puchheim
+ * Germany
+ * <rtems@embedded-brains.de>
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ *
+ * $Id$
+ */
+
+#if HAVE_CONFIG_H
+ #include "config.h"
+#endif
+
+#ifdef RTEMS_NEWLIB
+#include "malloc_p.h"
+
+rtems_status_code rtems_heap_extend(
+ void *area_begin,
+ uintptr_t area_size
+)
+{
+ bool ok = _Protected_heap_Extend(RTEMS_Malloc_Heap, area_begin, area_size);
+
+ if (ok) {
+ return RTEMS_SUCCESSFUL;
+ } else {
+ return RTEMS_INVALID_ADDRESS;
+ }
+}
+#endif /* RTEMS_NEWLIB */