4.115
Last change
on this file since de5868fe 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
|
Rev | Line | |
---|
[cf1f72e] | 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 |
---|
[7c4a626] | 10 | * http://www.rtems.com/license/LICENSE. |
---|
[cf1f72e] | 11 | * |
---|
| 12 | * $Id$ |
---|
| 13 | */ |
---|
| 14 | |
---|
[de5868fe] | 15 | #include <stdlib.h> |
---|
| 16 | |
---|
[cf1f72e] | 17 | #include <rtems.h> |
---|
| 18 | #include <cache_.h> |
---|
[de5868fe] | 19 | #include <rtems/rtems/cache.h> |
---|
[cf1f72e] | 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 | |
---|
| 30 | void *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 | */ |
---|
[5e77d129] | 38 | #if defined(CPU_DATA_CACHE_ALIGNMENT) |
---|
[cf1f72e] | 39 | return (void *) ((((unsigned long) |
---|
[5e77d129] | 40 | malloc( nbytes + CPU_DATA_CACHE_ALIGNMENT - 1 )) |
---|
| 41 | + CPU_DATA_CACHE_ALIGNMENT - 1 ) &(~(CPU_DATA_CACHE_ALIGNMENT - 1)) ); |
---|
[cf1f72e] | 42 | #else |
---|
| 43 | return malloc( nbytes ); |
---|
| 44 | #endif |
---|
| 45 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.