source: rtems/c/src/lib/libcpu/shared/src/cache_aligned_malloc.c @ 0c0181d

4.115
Last change on this file since 0c0181d was de5868fe, checked in by Ralf Corsepius <ralf.corsepius@…>, on 12/10/11 at 04:03:50

2011-12-10 Ralf Corsépius <ralf.corsepius@…>

PR 1986/libcpu

  • shared/src/cache_aligned_malloc.c: Include <rtems/rtems/cache.h>.
  • Property mode set to 100644
File size: 961 bytes
Line 
1/*
2 *  RTEMS Cache Aligned Malloc
3 *
4 *
5 *  COPYRIGHT (c) 1989-1999.
6 *  On-Line Applications Research Corporation (OAR).
7 *
8 *  The license and distribution terms for this file may be
9 *  found in the file LICENSE in this distribution or at
10 *  http://www.rtems.com/license/LICENSE.
11 *
12 *  $Id$
13 */
14
15#include <stdlib.h>
16
17#include <rtems.h>
18#include <cache_.h>
19#include <rtems/rtems/cache.h>
20
21/*
22 *  rtems_cache_aligned_malloc
23 *
24 *  DESCRIPTION:
25 *
26 *  This function is used to allocate storage that spans an
27 *  integral number of cache blocks.
28 */
29
30void *rtems_cache_aligned_malloc (
31  size_t nbytes
32)
33{
34  /*
35   * Arrange to have the user storage start on the first cache
36   * block beyond the header.
37   */
38#if defined(CPU_DATA_CACHE_ALIGNMENT)
39  return (void *) ((((unsigned long)
40     malloc( nbytes + CPU_DATA_CACHE_ALIGNMENT - 1 ))
41        + CPU_DATA_CACHE_ALIGNMENT - 1 ) &(~(CPU_DATA_CACHE_ALIGNMENT - 1)) );
42#else
43  return malloc( nbytes );
44#endif
45}
Note: See TracBrowser for help on using the repository browser.