From 8e30a269a21cd61ca1387e666e458e52c0b153ab Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Wed, 19 Dec 2007 16:03:54 +0000 Subject: 2007-12-19 Joel Sherrill * 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. --- cpukit/libcsupport/src/malloc_deferred.c | 53 ++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 cpukit/libcsupport/src/malloc_deferred.c (limited to 'cpukit/libcsupport/src/malloc_deferred.c') 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 +#include + +#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 -- cgit v1.2.3