summaryrefslogtreecommitdiffstats
path: root/cpukit/libcsupport
diff options
context:
space:
mode:
authorThomas Doerfler <Thomas.Doerfler@embedded-brains.de>2009-11-30 13:06:21 +0000
committerThomas Doerfler <Thomas.Doerfler@embedded-brains.de>2009-11-30 13:06:21 +0000
commit9224a751b12835d21b11760c32a4a89524bb6b3e (patch)
treeee87034914f92f7388a421bf4e7a1c3ea40ce5b1 /cpukit/libcsupport
parentfixed some typos (diff)
downloadrtems-9224a751b12835d21b11760c32a4a89524bb6b3e.tar.bz2
Changed base implementation of protected heap allocations to use _Heap_Allocate_aligned_with_boundary().
Diffstat (limited to 'cpukit/libcsupport')
-rw-r--r--cpukit/libcsupport/include/rtems/malloc.h6
-rw-r--r--cpukit/libcsupport/src/rtems_malloc.c38
2 files changed, 27 insertions, 17 deletions
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 <stdlib.h>
-#include <errno.h>
-
-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