summaryrefslogtreecommitdiffstats
path: root/cpukit
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
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')
-rw-r--r--cpukit/ChangeLog11
-rw-r--r--cpukit/libcsupport/include/rtems/malloc.h6
-rw-r--r--cpukit/libcsupport/src/rtems_malloc.c38
-rw-r--r--cpukit/score/Makefile.am2
-rw-r--r--cpukit/score/include/rtems/score/protectedheap.h28
-rw-r--r--cpukit/score/src/pheapallocate.c17
-rw-r--r--cpukit/score/src/pheapallocatealigned.c40
7 files changed, 74 insertions, 68 deletions
diff --git a/cpukit/ChangeLog b/cpukit/ChangeLog
index 12a0868031..181d2c523c 100644
--- a/cpukit/ChangeLog
+++ b/cpukit/ChangeLog
@@ -1,5 +1,16 @@
2009-11-30 Sebastian Huber <sebastian.huber@embedded-brains.de>
+ * score/include/rtems/score/protectedheap.h,
+ score/src/pheapallocate.c: Changed base implementation of protected
+ heap allocations to use _Heap_Allocate_aligned_with_boundary().
+ * libcsupport/include/rtems/malloc.h, libcsupport/src/rtems_malloc.c:
+ Check system state. Process deferred frees. Renamed rtems_malloc() in
+ rtems_heap_allocate_aligned_with_boundary().
+ * score/src/pheapallocatealigned.c: Removed file.
+ * score/Makefile.am: Update for removed file.
+
+2009-11-30 Sebastian Huber <sebastian.huber@embedded-brains.de>
+
* libblock/include/rtems/bdbuf.h: Documentation.
* libblock/include/rtems/blkdev.h: Avoid designated initializers for
C++ compatibility.
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
diff --git a/cpukit/score/Makefile.am b/cpukit/score/Makefile.am
index 8cf2eff059..a86f2a323e 100644
--- a/cpukit/score/Makefile.am
+++ b/cpukit/score/Makefile.am
@@ -138,7 +138,7 @@ libscore_a_SOURCES += src/objectallocatebyindex.c src/objectgetbyindex.c
endif
## PROTECTED_HEAP_C_FILES
-libscore_a_SOURCES += src/pheapallocatealigned.c src/pheapallocate.c \
+libscore_a_SOURCES += src/pheapallocate.c \
src/pheapextend.c src/pheapfree.c src/pheapgetsize.c \
src/pheapgetblocksize.c src/pheapgetfreeinfo.c src/pheapgetinfo.c \
src/pheapinit.c src/pheapresizeblock.c src/pheapwalk.c
diff --git a/cpukit/score/include/rtems/score/protectedheap.h b/cpukit/score/include/rtems/score/protectedheap.h
index c9d6a62d8d..01c736d6ae 100644
--- a/cpukit/score/include/rtems/score/protectedheap.h
+++ b/cpukit/score/include/rtems/score/protectedheap.h
@@ -66,19 +66,37 @@ bool _Protected_heap_Extend(
/**
* @brief See _Heap_Allocate_aligned_with_boundary().
*/
-void *_Protected_heap_Allocate(
+void *_Protected_heap_Allocate_aligned_with_boundary(
Heap_Control *heap,
- uintptr_t size
+ uintptr_t size,
+ uintptr_t alignment,
+ uintptr_t boundary
);
/**
- * @brief See _Heap_Allocate_aligned_with_boundary().
+ * @brief See _Heap_Allocate_aligned_with_boundary() with boundary equals zero.
*/
-void *_Protected_heap_Allocate_aligned(
+RTEMS_INLINE_ROUTINE void *_Protected_heap_Allocate_aligned(
Heap_Control *heap,
uintptr_t size,
uintptr_t alignment
-);
+)
+{
+ return
+ _Protected_heap_Allocate_aligned_with_boundary( heap, size, alignment, 0 );
+}
+
+/**
+ * @brief See _Heap_Allocate_aligned_with_boundary() with alignment and
+ * boundary equals zero.
+ */
+RTEMS_INLINE_ROUTINE void *_Protected_heap_Allocate(
+ Heap_Control *heap,
+ uintptr_t size
+)
+{
+ return _Protected_heap_Allocate_aligned_with_boundary( heap, size, 0, 0 );
+}
/**
* @brief See _Heap_Size_of_alloc_area().
diff --git a/cpukit/score/src/pheapallocate.c b/cpukit/score/src/pheapallocate.c
index 50d560f3a7..b4888dc8ea 100644
--- a/cpukit/score/src/pheapallocate.c
+++ b/cpukit/score/src/pheapallocate.c
@@ -24,16 +24,23 @@
#include <rtems/system.h>
#include <rtems/score/protectedheap.h>
-void *_Protected_heap_Allocate(
- Heap_Control *the_heap,
- uintptr_t size
+void *_Protected_heap_Allocate_aligned_with_boundary(
+ Heap_Control *heap,
+ uintptr_t size,
+ uintptr_t alignment,
+ uintptr_t boundary
)
{
void *p;
_RTEMS_Lock_allocator();
- p = _Heap_Allocate( the_heap, size );
+ p = _Heap_Allocate_aligned_with_boundary(
+ heap,
+ size,
+ alignment,
+ boundary
+ );
_RTEMS_Unlock_allocator();
+
return p;
}
-
diff --git a/cpukit/score/src/pheapallocatealigned.c b/cpukit/score/src/pheapallocatealigned.c
deleted file mode 100644
index 756d8a8aa2..0000000000
--- a/cpukit/score/src/pheapallocatealigned.c
+++ /dev/null
@@ -1,40 +0,0 @@
-/**
- * @file
- *
- * @ingroup ScoreProtHeap
- *
- * @brief Protected Heap Handler implementation.
- */
-
-/*
- * 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/system.h>
-#include <rtems/score/protectedheap.h>
-
-void *_Protected_heap_Allocate_aligned(
- Heap_Control *the_heap,
- uintptr_t size,
- uintptr_t alignment
-)
-{
- void *p;
-
- _RTEMS_Lock_allocator();
- p = _Heap_Allocate_aligned( the_heap, size, alignment );
- _RTEMS_Unlock_allocator();
- return p;
-}
-