Ignore:
Timestamp:
Nov 25, 2014, 1:58:13 PM (5 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, master
Children:
e681762
Parents:
7981a88
git-author:
Sebastian Huber <sebastian.huber@…> (11/25/14 13:58:13)
git-committer:
Sebastian Huber <sebastian.huber@…> (11/25/14 15:08:16)
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • testsuites/sptests/spcache01/init.c

    r7981a88 r7e5c9b89  
    1818
    1919#include <stdio.h>
     20#include <stdlib.h>
    2021#include <inttypes.h>
    2122
     
    380381}
    381382
     383static void test_cache_aligned_alloc(void)
     384{
     385  void *p0;
     386  void *p1;
     387  size_t cls;
     388
     389  printf("test rtems_cache_aligned_malloc()\n");
     390
     391  p0 = rtems_cache_aligned_malloc(1);
     392  p1 = rtems_cache_aligned_malloc(1);
     393
     394  rtems_test_assert(p0 != NULL);
     395  rtems_test_assert(p1 != NULL);
     396
     397  cls = rtems_cache_get_data_line_size();
     398  if (cls > 0) {
     399    size_t m = cls - 1;
     400    uintptr_t a0 = (uintptr_t) p0;
     401    uintptr_t a1 = (uintptr_t) p1;
     402
     403    rtems_test_assert(a1 - a0 > cls);
     404    rtems_test_assert((a0 & m) == 0);
     405    rtems_test_assert((a1 & m) == 0);
     406  }
     407
     408  free(p0);
     409  free(p1);
     410}
     411
    382412static void Init(rtems_task_argument arg)
    383413{
     
    386416  test_data_flush_and_invalidate();
    387417  test_timing();
     418  test_cache_aligned_alloc();
    388419
    389420  TEST_END();
Note: See TracChangeset for help on using the changeset viewer.