summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cpukit/ChangeLog5
-rw-r--r--cpukit/libcsupport/Makefile.am3
-rw-r--r--cpukit/libcsupport/include/rtems/malloc.h22
-rw-r--r--cpukit/libcsupport/src/rtems_malloc.c50
4 files changed, 79 insertions, 1 deletions
diff --git a/cpukit/ChangeLog b/cpukit/ChangeLog
index 057729e20c..3ae5a4b90c 100644
--- a/cpukit/ChangeLog
+++ b/cpukit/ChangeLog
@@ -1,3 +1,8 @@
+2009-11-11 Sebastian Huber <sebastian.huber@embedded-brains.de>
+
+ * libcsupport/Makefile.am, libcsupport/include/rtems/malloc.h,
+ libcsupport/src/rtems_malloc.c: New function rtems_malloc().
+
2009-11-11 Jennifer Averett <jennifer.averett@OARcorp.com>
PR 1471/cpukit
diff --git a/cpukit/libcsupport/Makefile.am b/cpukit/libcsupport/Makefile.am
index cb403bb08e..7317e6da62 100644
--- a/cpukit/libcsupport/Makefile.am
+++ b/cpukit/libcsupport/Makefile.am
@@ -90,7 +90,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/malloc_boundary.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/malloc_sbrk_helpers.c src/malloc_dirtier.c src/malloc_p.h \
+ src/rtems_malloc.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 d3018db73c..bd771d254a 100644
--- a/cpukit/libcsupport/include/rtems/malloc.h
+++ b/cpukit/libcsupport/include/rtems/malloc.h
@@ -149,6 +149,28 @@ int rtems_memalign(
size_t size
);
+/**
+ * @brief Allocates a memory area of size @a size bytes from the heap.
+ *
+ * If the alignment parameter @a alignment is not equal to zero, the allocated
+ * memory area will begin at an address aligned by this value.
+ *
+ * If the boundary parameter @a boundary is not equal to zero, the allocated
+ * memory area will fulfill a boundary constraint. The boundary value
+ * specifies the set of addresses which are aligned by the boundary value. The
+ * interior of the allocated memory area will not contain an element of this
+ * set. The begin or end address of the area may be a member of the set.
+ *
+ * A size value of zero will return a unique address which may be freed with
+ * free().
+ *
+ * The memory allocated by this function can be released with a call to free().
+ *
+ * @return A pointer to the begin of the allocated memory area, or @c NULL if
+ * no memory is available or the parameters are inconsistent.
+ */
+void *rtems_malloc(size_t size, uintptr_t alignment, uintptr_t boundary);
+
#ifdef __cplusplus
}
#endif
diff --git a/cpukit/libcsupport/src/rtems_malloc.c b/cpukit/libcsupport/src/rtems_malloc.c
new file mode 100644
index 0000000000..a71d8cbfb3
--- /dev/null
+++ b/cpukit/libcsupport/src/rtems_malloc.c
@@ -0,0 +1,50 @@
+/**
+ * @file
+ *
+ * @ingroup libcsupport
+ *
+ * @brief rtems_malloc() implementation.
+ */
+
+/*
+ * Copyright (c) 2009
+ * embedded brains GmbH
+ * Obere Lagerstr. 30
+ * D-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"
+
+#include <stdlib.h>
+#include <errno.h>
+
+void *rtems_malloc(size_t size, uintptr_t alignment, uintptr_t boundary)
+{
+ void *p = NULL;
+
+ _RTEMS_Lock_allocator();
+ p = _Heap_Allocate_aligned_with_boundary(
+ RTEMS_Malloc_Heap,
+ size,
+ alignment,
+ boundary
+ );
+ _RTEMS_Unlock_allocator();
+
+ return p;
+}
+
+#endif