5
Last change
on this file since 9d1f3943 was
9d1f3943,
checked in by Sebastian Huber <sebastian.huber@…>, on 02/25/16 at 08:02:43
|
malloc: Add _Malloc_System_state()
Replace malloc_is_system_state_OK() with _Malloc_System_state() to allow
early allocations, e.g. in bsp_start(). Here the _Thread_Executing is
NULL, thus an _API_Mutex_Lock() would lead to a NULL pointer access.
Move malloc() support code to general case
rtems_heap_allocate_aligned_with_boundary(). Use
rtems_heap_allocate_aligned_with_boundary() to avoid duplicated code.
|
-
Property mode set to
100644
|
File size:
916 bytes
|
Line | |
---|
1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @brief RTEMS Variation on Aligned Memory Allocation |
---|
5 | * @ingroup MallocSupport |
---|
6 | */ |
---|
7 | |
---|
8 | /* |
---|
9 | * COPYRIGHT (c) 1989-2008. |
---|
10 | * On-Line Applications Research Corporation (OAR). |
---|
11 | * |
---|
12 | * The license and distribution terms for this file may be |
---|
13 | * found in the file LICENSE in this distribution or at |
---|
14 | * http://www.rtems.org/license/LICENSE. |
---|
15 | */ |
---|
16 | |
---|
17 | #if HAVE_CONFIG_H |
---|
18 | #include "config.h" |
---|
19 | #endif |
---|
20 | |
---|
21 | #ifdef RTEMS_NEWLIB |
---|
22 | #include "malloc_p.h" |
---|
23 | |
---|
24 | #include <stdlib.h> |
---|
25 | #include <errno.h> |
---|
26 | |
---|
27 | int rtems_memalign( |
---|
28 | void **pointer, |
---|
29 | size_t alignment, |
---|
30 | size_t size |
---|
31 | ) |
---|
32 | { |
---|
33 | void *return_this; |
---|
34 | |
---|
35 | /* |
---|
36 | * Parameter error checks |
---|
37 | */ |
---|
38 | if ( !pointer ) |
---|
39 | return EINVAL; |
---|
40 | |
---|
41 | *pointer = NULL; |
---|
42 | |
---|
43 | /* |
---|
44 | * Perform the aligned allocation requested |
---|
45 | */ |
---|
46 | return_this = rtems_heap_allocate_aligned_with_boundary( size, alignment, 0 ); |
---|
47 | if ( !return_this ) |
---|
48 | return ENOMEM; |
---|
49 | |
---|
50 | *pointer = return_this; |
---|
51 | return 0; |
---|
52 | } |
---|
53 | #endif |
---|
Note: See
TracBrowser
for help on using the repository browser.