4.115
Last change
on this file since 7e5c9b89 was
7e5c9b89,
checked in by Sebastian Huber <sebastian.huber@…>, on 11/25/14 at 13:58:13
|
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.
|
-
Property mode set to
100644
|
File size:
674 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.org/license/LICENSE. |
---|
11 | */ |
---|
12 | |
---|
13 | #include <rtems.h> |
---|
14 | #include <rtems/malloc.h> |
---|
15 | |
---|
16 | void *rtems_cache_aligned_malloc( size_t nbytes ) |
---|
17 | { |
---|
18 | size_t line_size = rtems_cache_get_data_line_size(); |
---|
19 | |
---|
20 | if ( line_size > 0 ) { |
---|
21 | /* Assume that the cache line size is a power of two */ |
---|
22 | size_t m = line_size - 1; |
---|
23 | |
---|
24 | nbytes = (nbytes + m) & ~m; |
---|
25 | } |
---|
26 | |
---|
27 | return rtems_heap_allocate_aligned_with_boundary( nbytes, line_size, 0 ); |
---|
28 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.