diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 2008-01-09 21:08:36 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 2008-01-09 21:08:36 +0000 |
commit | 635865aefd842e94e32856b8d32fbcacb52d78ba (patch) | |
tree | 0f72fdb1b2a42b01744451e124b46bac24705281 /cpukit/libcsupport | |
parent | 2008-01-09 Joel Sherrill <joel.sherrill@OARcorp.com> (diff) | |
download | rtems-635865aefd842e94e32856b8d32fbcacb52d78ba.tar.bz2 |
2008-01-09 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_deferred.c,
libcsupport/src/malloc_initialize.c, libcsupport/src/malloc_p.h,
libcsupport/src/malloc_sbrk_helpers.c,
libcsupport/src/posix_memalign.c: Place all deferred free code and
place it in subroutines. Add plugin for dirtying allocated memory to
assist in debugging. Clean up comments and spacing as needed.
* libcsupport/src/malloc_dirtier.c: New file.
Diffstat (limited to 'cpukit/libcsupport')
-rw-r--r-- | cpukit/libcsupport/src/free.c | 2 | ||||
-rw-r--r-- | cpukit/libcsupport/src/malloc.c | 8 | ||||
-rw-r--r-- | cpukit/libcsupport/src/malloc_deferred.c | 11 | ||||
-rw-r--r-- | cpukit/libcsupport/src/malloc_dirtier.c | 30 | ||||
-rw-r--r-- | cpukit/libcsupport/src/malloc_initialize.c | 3 | ||||
-rw-r--r-- | cpukit/libcsupport/src/malloc_p.h | 9 | ||||
-rw-r--r-- | cpukit/libcsupport/src/malloc_sbrk_helpers.c | 3 | ||||
-rw-r--r-- | cpukit/libcsupport/src/posix_memalign.c | 2 |
8 files changed, 48 insertions, 20 deletions
diff --git a/cpukit/libcsupport/src/free.c b/cpukit/libcsupport/src/free.c index be23388888..a4b1917ec2 100644 --- a/cpukit/libcsupport/src/free.c +++ b/cpukit/libcsupport/src/free.c @@ -38,7 +38,7 @@ void free( if ( _System_state_Is_up(_System_state_Get()) && !malloc_is_system_state_OK() ) { - malloc_defer_free(ptr); + malloc_deferred_free(ptr); return; } diff --git a/cpukit/libcsupport/src/malloc.c b/cpukit/libcsupport/src/malloc.c index 954d5f7690..60a8793f8d 100644 --- a/cpukit/libcsupport/src/malloc.c +++ b/cpukit/libcsupport/src/malloc.c @@ -27,14 +27,13 @@ void *malloc( ) { void *return_this; - Chain_Node *to_be_freed; MSBUMP(malloc_calls, 1); /* * If some free's have been deferred, then do them now. */ - malloc_process_deferred_frees(); + malloc_deferred_frees_process(); /* * Validate the parameters @@ -85,9 +84,8 @@ void *malloc( /* * If the user wants us to dirty the allocated memory, then do it. */ - #ifdef MALLOC_DIRTY - (void) memset(return_this, 0xCF, size); - #endif + if ( rtems_malloc_dirty_helper ) + (*rtems_malloc_dirty_helper)( return_this, size ); /* * If configured, update the statistics diff --git a/cpukit/libcsupport/src/malloc_deferred.c b/cpukit/libcsupport/src/malloc_deferred.c index 9e8a259deb..57fd8752c3 100644 --- a/cpukit/libcsupport/src/malloc_deferred.c +++ b/cpukit/libcsupport/src/malloc_deferred.c @@ -22,6 +22,8 @@ #include "malloc_p.h" +Chain_Control RTEMS_Malloc_GC_list; + boolean malloc_is_system_state_OK(void) { if ( _Thread_Dispatch_disable_level > 0 ) @@ -33,7 +35,12 @@ boolean malloc_is_system_state_OK(void) return TRUE; } -void malloc_process_deferred_frees(void) +void malloc_deferred_frees_initialize(void) +{ + Chain_Initialize_empty(&RTEMS_Malloc_GC_list); +} + +void malloc_deferred_frees_process(void) { Chain_Node *to_be_freed; @@ -44,7 +51,7 @@ void malloc_process_deferred_frees(void) free(to_be_freed); } -void malloc_defer_free( +void malloc_deferred_free( void *pointer ) { diff --git a/cpukit/libcsupport/src/malloc_dirtier.c b/cpukit/libcsupport/src/malloc_dirtier.c new file mode 100644 index 0000000000..eb6ae7ccf3 --- /dev/null +++ b/cpukit/libcsupport/src/malloc_dirtier.c @@ -0,0 +1,30 @@ +/* + * RTEMS Malloc Family -- Dirty Memory from Malloc + * + * 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 + +#include <rtems.h> +#include <rtems/malloc.h> +#include "malloc_p.h" + +#include <errno.h> + +void rtems_malloc_dirty_memory( + void *start, + size_t size +) +{ + (void) memset(start, 0xCF, size); +} diff --git a/cpukit/libcsupport/src/malloc_initialize.c b/cpukit/libcsupport/src/malloc_initialize.c index 362d4477e2..3ad7d69765 100644 --- a/cpukit/libcsupport/src/malloc_initialize.c +++ b/cpukit/libcsupport/src/malloc_initialize.c @@ -21,7 +21,6 @@ #include "malloc_p.h" Heap_Control RTEMS_Malloc_Heap; -Chain_Control RTEMS_Malloc_GC_list; rtems_malloc_statistics_t rtems_malloc_statistics; void RTEMS_Malloc_Initialize( @@ -50,7 +49,7 @@ void RTEMS_Malloc_Initialize( /* * Initialize the garbage collection list to start with nothing on it. */ - Chain_Initialize_empty(&RTEMS_Malloc_GC_list); + malloc_deferred_frees_initialize(); starting_address = start; diff --git a/cpukit/libcsupport/src/malloc_p.h b/cpukit/libcsupport/src/malloc_p.h index a505d920a2..10642ba46a 100644 --- a/cpukit/libcsupport/src/malloc_p.h +++ b/cpukit/libcsupport/src/malloc_p.h @@ -38,7 +38,6 @@ * Basic management data */ extern Heap_Control RTEMS_Malloc_Heap; -extern Chain_Control RTEMS_Malloc_GC_list; /* * Malloc Statistics Structure @@ -48,13 +47,9 @@ extern rtems_malloc_statistics_t rtems_malloc_statistics; #define MSBUMP(_f,_n) rtems_malloc_statistics._f += (_n) /* - * Dirty memory plugin - */ -#define MALLOC_DIRTY - -/* * Process deferred free operations */ boolean malloc_is_system_state_OK(void); -void malloc_process_deferred_frees(void); +void malloc_deferred_frees_initialize(void); +void malloc_deferred_frees_process(void); void malloc_defer_free(void *); diff --git a/cpukit/libcsupport/src/malloc_sbrk_helpers.c b/cpukit/libcsupport/src/malloc_sbrk_helpers.c index ac992bba88..bbc6faf519 100644 --- a/cpukit/libcsupport/src/malloc_sbrk_helpers.c +++ b/cpukit/libcsupport/src/malloc_sbrk_helpers.c @@ -1,6 +1,5 @@ /* - * RTEMS Malloc Family Implementation --Initialization - * + * RTEMS Malloc -- SBRK Support Plugin * * COPYRIGHT (c) 1989-2007. * On-Line Applications Research Corporation (OAR). diff --git a/cpukit/libcsupport/src/posix_memalign.c b/cpukit/libcsupport/src/posix_memalign.c index c3dae3449e..34b6b627e6 100644 --- a/cpukit/libcsupport/src/posix_memalign.c +++ b/cpukit/libcsupport/src/posix_memalign.c @@ -59,7 +59,7 @@ int posix_memalign( * * If some free's have been deferred, then do them now. */ - malloc_process_deferred_frees(); + malloc_deferred_frees_process(); #if defined(RTEMS_MALLOC_BOUNDARY_HELPERS) /* |