summaryrefslogtreecommitdiffstats
path: root/cpukit
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--cpukit/libcsupport/Makefile.am1
-rw-r--r--cpukit/libcsupport/src/cachealignedalloc.c28
2 files changed, 29 insertions, 0 deletions
diff --git a/cpukit/libcsupport/Makefile.am b/cpukit/libcsupport/Makefile.am
index bd3f90a648..95c85c4ede 100644
--- a/cpukit/libcsupport/Makefile.am
+++ b/cpukit/libcsupport/Makefile.am
@@ -108,6 +108,7 @@ MALLOC_C_FILES = src/malloc_initialize.c src/calloc.c src/malloc.c \
src/rtems_heap_null_extend.c \
src/rtems_heap_extend.c \
src/rtems_heap_greedy.c
+MALLOC_C_FILES += src/cachealignedalloc.c
PASSWORD_GROUP_C_FILES = src/pwdgrp.c
PASSWORD_GROUP_C_FILES += src/getgrent.c
diff --git a/cpukit/libcsupport/src/cachealignedalloc.c b/cpukit/libcsupport/src/cachealignedalloc.c
new file mode 100644
index 0000000000..a704859dbe
--- /dev/null
+++ b/cpukit/libcsupport/src/cachealignedalloc.c
@@ -0,0 +1,28 @@
+/*
+ * RTEMS Cache Aligned Malloc
+ *
+ *
+ * COPYRIGHT (c) 1989-1999.
+ * On-Line Applications Research Corporation (OAR).
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.org/license/LICENSE.
+ */
+
+#include <rtems.h>
+#include <rtems/malloc.h>
+
+void *rtems_cache_aligned_malloc( size_t nbytes )
+{
+ size_t line_size = rtems_cache_get_data_line_size();
+
+ if ( line_size > 0 ) {
+ /* Assume that the cache line size is a power of two */
+ size_t m = line_size - 1;
+
+ nbytes = (nbytes + m) & ~m;
+ }
+
+ return rtems_heap_allocate_aligned_with_boundary( nbytes, line_size, 0 );
+}