source: rtems/c/src/lib/libcpu/shared/src/cache_aligned_malloc.c @ 1a505aa

4.104.114.84.95
Last change on this file since 1a505aa was 1a505aa, checked in by Joel Sherrill <joel.sherrill@…>, on Dec 6, 2000 at 3:47:02 PM

2000-12-06 Joel Sherrill <joel@…>

  • shared/src/cache_aligned_malloc.c: Added include of <stdlib.h> to eliminate warnings.
  • Property mode set to 100644
File size: 935 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.OARcorp.com/rtems/license.html.
11 *
12 *  $Id$
13 */
14
15#include <rtems.h>
16#include <cache_.h>
17#include <stdlib.h>
18
19/*
20 *  rtems_cache_aligned_malloc
21 *
22 *  DESCRIPTION:
23 *
24 *  This function is used to allocate storage that spans an
25 *  integral number of cache blocks.
26 */
27
28void *rtems_cache_aligned_malloc (
29  size_t nbytes
30)
31{
32  /*
33   * Arrange to have the user storage start on the first cache
34   * block beyond the header.
35   */
36#if defined(CPU_DATA_CACHE_ALIGNMENT)
37  return (void *) ((((unsigned long)
38     malloc( nbytes + CPU_DATA_CACHE_ALIGNMENT - 1 ))
39        + CPU_DATA_CACHE_ALIGNMENT - 1 ) &(~(CPU_DATA_CACHE_ALIGNMENT - 1)) );
40#else
41  return malloc( nbytes );
42#endif
43}
44
Note: See TracBrowser for help on using the repository browser.