diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2014-11-25 14:58:13 +0100 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2014-11-25 16:08:16 +0100 |
commit | 7e5c9b895e52c76376386e54a0008c3a9e4a1698 (patch) | |
tree | bb8f7db25258fc1438c58a60aa950d782d0d77ab /testsuites/sptests/spcache01/init.c | |
parent | sptest/spcache01: New test cases (diff) | |
download | rtems-7e5c9b895e52c76376386e54a0008c3a9e4a1698.tar.bz2 |
rtems: Move rtems_cache_aligned_malloc()
Make sure also the size is cache aligned since otherwise we may have
some overlap with the next allocation block. A cache invalidate on this
area would be fatal.
Diffstat (limited to '')
-rw-r--r-- | testsuites/sptests/spcache01/init.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/testsuites/sptests/spcache01/init.c b/testsuites/sptests/spcache01/init.c index e303436224..95777e1a28 100644 --- a/testsuites/sptests/spcache01/init.c +++ b/testsuites/sptests/spcache01/init.c @@ -17,6 +17,7 @@ #endif #include <stdio.h> +#include <stdlib.h> #include <inttypes.h> #include <rtems.h> @@ -379,12 +380,42 @@ static void test_timing(void) rtems_interrupt_lock_destroy(&lock); } +static void test_cache_aligned_alloc(void) +{ + void *p0; + void *p1; + size_t cls; + + printf("test rtems_cache_aligned_malloc()\n"); + + p0 = rtems_cache_aligned_malloc(1); + p1 = rtems_cache_aligned_malloc(1); + + rtems_test_assert(p0 != NULL); + rtems_test_assert(p1 != NULL); + + cls = rtems_cache_get_data_line_size(); + if (cls > 0) { + size_t m = cls - 1; + uintptr_t a0 = (uintptr_t) p0; + uintptr_t a1 = (uintptr_t) p1; + + rtems_test_assert(a1 - a0 > cls); + rtems_test_assert((a0 & m) == 0); + rtems_test_assert((a1 & m) == 0); + } + + free(p0); + free(p1); +} + static void Init(rtems_task_argument arg) { TEST_BEGIN(); test_data_flush_and_invalidate(); test_timing(); + test_cache_aligned_alloc(); TEST_END(); |