Line | |
---|
1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @ingroup libcsupport |
---|
5 | */ |
---|
6 | |
---|
7 | /* |
---|
8 | * COPYRIGHT (c) 1989-2008. |
---|
9 | * On-Line Applications Research Corporation (OAR). |
---|
10 | * |
---|
11 | * The license and distribution terms for this file may be |
---|
12 | * found in the file LICENSE in this distribution or at |
---|
13 | * http://www.rtems.org/license/LICENSE. |
---|
14 | */ |
---|
15 | |
---|
16 | #ifdef HAVE_CONFIG_H |
---|
17 | #include "config.h" |
---|
18 | #endif |
---|
19 | |
---|
20 | #ifdef RTEMS_NEWLIB |
---|
21 | #include "malloc_p.h" |
---|
22 | |
---|
23 | #include <stdlib.h> |
---|
24 | #include <errno.h> |
---|
25 | |
---|
26 | int posix_memalign( |
---|
27 | void **memptr, |
---|
28 | size_t alignment, |
---|
29 | size_t size |
---|
30 | ) |
---|
31 | { |
---|
32 | RTEMS_OBFUSCATE_VARIABLE( memptr ); |
---|
33 | |
---|
34 | if ( memptr == NULL ) { |
---|
35 | return EINVAL; |
---|
36 | } |
---|
37 | |
---|
38 | *memptr = NULL; |
---|
39 | |
---|
40 | if ( size == 0 ) { |
---|
41 | return 0; |
---|
42 | } |
---|
43 | |
---|
44 | if ( alignment < sizeof( void * ) ) { |
---|
45 | return EINVAL; |
---|
46 | } |
---|
47 | |
---|
48 | if ( ( ( alignment - 1 ) & alignment ) != 0 ) { |
---|
49 | return EINVAL; |
---|
50 | } |
---|
51 | |
---|
52 | *memptr = rtems_heap_allocate_aligned_with_boundary( size, alignment, 0 ); |
---|
53 | |
---|
54 | if ( *memptr == NULL ) { |
---|
55 | return ENOMEM; |
---|
56 | } |
---|
57 | |
---|
58 | return 0; |
---|
59 | } |
---|
60 | #endif |
---|
Note: See
TracBrowser
for help on using the repository browser.