diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 2007-12-19 16:03:54 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 2007-12-19 16:03:54 +0000 |
commit | 8e30a269a21cd61ca1387e666e458e52c0b153ab (patch) | |
tree | 4d1cc760d319a170b335b9e90ea9d26162ffc687 /cpukit/libcsupport/src/malloc_deferred.c | |
parent | 2007-12-18 Joel Sherrill <joel.sherrill@oarcorp.com> (diff) | |
download | rtems-8e30a269a21cd61ca1387e666e458e52c0b153ab.tar.bz2 |
2007-12-19 Joel Sherrill <joel.sherrill@OARcorp.com>
* libcsupport/Makefile.am, libcsupport/include/rtems/malloc.h,
libcsupport/src/free.c, libcsupport/src/malloc.c,
libcsupport/src/malloc_p.h,
libcsupport/src/malloc_report_statistics_plugin.c,
libmisc/shell/shell.c, libmisc/shell/shell.h,
score/src/objectinitializeinformation.c: Add posix_memalign. Split
out management of deferred frees to subroutines.
* libcsupport/src/malloc_deferred.c, libcsupport/src/posix_memalign.c: New files.
Diffstat (limited to '')
-rw-r--r-- | cpukit/libcsupport/src/malloc_deferred.c | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/cpukit/libcsupport/src/malloc_deferred.c b/cpukit/libcsupport/src/malloc_deferred.c new file mode 100644 index 0000000000..9e8a259deb --- /dev/null +++ b/cpukit/libcsupport/src/malloc_deferred.c @@ -0,0 +1,53 @@ +/* + * Process free requests deferred because they were from ISR + * or other critical section. + * + * COPYRIGHT (c) 1989-2007. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.com/license/LICENSE. + * + * $Id$ + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#ifdef RTEMS_NEWLIB +#include <stdlib.h> +#include <errno.h> + +#include "malloc_p.h" + +boolean malloc_is_system_state_OK(void) +{ + if ( _Thread_Dispatch_disable_level > 0 ) + return FALSE; + + if ( _ISR_Nest_level > 0 ) + return FALSE; + + return TRUE; +} + +void malloc_process_deferred_frees(void) +{ + Chain_Node *to_be_freed; + + /* + * If some free's have been deferred, then do them now. + */ + while ((to_be_freed = Chain_Get(&RTEMS_Malloc_GC_list)) != NULL) + free(to_be_freed); +} + +void malloc_defer_free( + void *pointer +) +{ + Chain_Append(&RTEMS_Malloc_GC_list, (Chain_Node *)pointer); +} +#endif |