From 9224a751b12835d21b11760c32a4a89524bb6b3e Mon Sep 17 00:00:00 2001 From: Thomas Doerfler Date: Mon, 30 Nov 2009 13:06:21 +0000 Subject: Changed base implementation of protected heap allocations to use _Heap_Allocate_aligned_with_boundary(). --- cpukit/libcsupport/include/rtems/malloc.h | 6 ++++- cpukit/libcsupport/src/rtems_malloc.c | 38 ++++++++++++++++++------------- 2 files changed, 27 insertions(+), 17 deletions(-) (limited to 'cpukit/libcsupport') diff --git a/cpukit/libcsupport/include/rtems/malloc.h b/cpukit/libcsupport/include/rtems/malloc.h index 6281e55851..b061683b4f 100644 --- a/cpukit/libcsupport/include/rtems/malloc.h +++ b/cpukit/libcsupport/include/rtems/malloc.h @@ -169,7 +169,11 @@ int rtems_memalign( * @return A pointer to the begin of the allocated memory area, or @c NULL if * no memory is available or the parameters are inconsistent. */ -void *rtems_malloc(size_t size, uintptr_t alignment, uintptr_t boundary); +void *rtems_heap_allocate_aligned_with_boundary( + size_t size, + uintptr_t alignment, + uintptr_t boundary +); #ifdef __cplusplus } diff --git a/cpukit/libcsupport/src/rtems_malloc.c b/cpukit/libcsupport/src/rtems_malloc.c index a71d8cbfb3..fcd99438f0 100644 --- a/cpukit/libcsupport/src/rtems_malloc.c +++ b/cpukit/libcsupport/src/rtems_malloc.c @@ -28,23 +28,29 @@ #ifdef RTEMS_NEWLIB #include "malloc_p.h" -#include -#include - -void *rtems_malloc(size_t size, uintptr_t alignment, uintptr_t boundary) +void *rtems_heap_allocate_aligned_with_boundary( + size_t size, + uintptr_t alignment, + uintptr_t boundary +) { - void *p = NULL; - - _RTEMS_Lock_allocator(); - p = _Heap_Allocate_aligned_with_boundary( - RTEMS_Malloc_Heap, - size, - alignment, - boundary - ); - _RTEMS_Unlock_allocator(); - - return p; + if ( + _System_state_Is_up( _System_state_Get() ) + && !malloc_is_system_state_OK() + ) { + return NULL; + } + + malloc_deferred_frees_process(); + + /* FIXME: Statistics, boundary checks */ + + return _Protected_heap_Allocate_aligned_with_boundary( + RTEMS_Malloc_Heap, + size, + alignment, + boundary + ); } #endif -- cgit v1.2.3