source:
rtems/cpukit/libcsupport/src/malloc_deferred.c
@
9b4422a2
Last change on this file since 9b4422a2 was 9b4422a2, checked in by Joel Sherrill <joel.sherrill@…>, on 05/03/12 at 15:09:24 | |
---|---|
|
|
File size: 1.1 KB |
Rev | Line | |
---|---|---|
[8e30a269] | 1 | /* |
2 | * Process free requests deferred because they were from ISR | |
3 | * or other critical section. | |
4 | * | |
5 | * COPYRIGHT (c) 1989-2007. | |
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.com/license/LICENSE. | |
11 | */ | |
12 | ||
13 | #if HAVE_CONFIG_H | |
14 | #include "config.h" | |
15 | #endif | |
16 | ||
17 | #ifdef RTEMS_NEWLIB | |
18 | #include <stdlib.h> | |
19 | #include <errno.h> | |
20 | ||
21 | #include "malloc_p.h" | |
22 | ||
[72d2ec4d] | 23 | rtems_chain_control RTEMS_Malloc_GC_list; |
[635865ae] | 24 | |
[4088d01d] | 25 | bool malloc_is_system_state_OK(void) |
[8e30a269] | 26 | { |
[d7c3883] | 27 | if ( _Thread_Dispatch_in_critical_section() ) |
[4088d01d] | 28 | return false; |
[8e30a269] | 29 | |
30 | if ( _ISR_Nest_level > 0 ) | |
[4088d01d] | 31 | return false; |
[8e30a269] | 32 | |
[4088d01d] | 33 | return true; |
[8e30a269] | 34 | } |
35 | ||
[635865ae] | 36 | void malloc_deferred_frees_initialize(void) |
37 | { | |
[72d2ec4d] | 38 | rtems_chain_initialize_empty(&RTEMS_Malloc_GC_list); |
[635865ae] | 39 | } |
40 | ||
41 | void malloc_deferred_frees_process(void) | |
[8e30a269] | 42 | { |
[72d2ec4d] | 43 | rtems_chain_node *to_be_freed; |
[8e30a269] | 44 | |
45 | /* | |
46 | * If some free's have been deferred, then do them now. | |
47 | */ | |
[72d2ec4d] | 48 | while ((to_be_freed = rtems_chain_get(&RTEMS_Malloc_GC_list)) != NULL) |
[8e30a269] | 49 | free(to_be_freed); |
50 | } | |
51 | ||
[635865ae] | 52 | void malloc_deferred_free( |
[8e30a269] | 53 | void *pointer |
54 | ) | |
55 | { | |
[72d2ec4d] | 56 | rtems_chain_append(&RTEMS_Malloc_GC_list, (rtems_chain_node *)pointer); |
[8e30a269] | 57 | } |
58 | #endif |
Note: See TracBrowser
for help on using the repository browser.