summaryrefslogtreecommitdiffstats
path: root/cpukit/score/include/rtems/score/heap.h
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2014-01-28 11:49:57 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2014-02-04 10:06:34 +0100
commita49bc354a77f7710fcfa7995e18107170d32eb70 (patch)
tree55660903659862a0d481ee6db136154437c02c6f /cpukit/score/include/rtems/score/heap.h
parentscore: Add _Workspace_Allocate_aligned() (diff)
downloadrtems-a49bc354a77f7710fcfa7995e18107170d32eb70.tar.bz2
score: Add _Heap_Size_with_overhead()
Diffstat (limited to 'cpukit/score/include/rtems/score/heap.h')
-rw-r--r--cpukit/score/include/rtems/score/heap.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/cpukit/score/include/rtems/score/heap.h b/cpukit/score/include/rtems/score/heap.h
index 80a041ca7c..53b569af82 100644
--- a/cpukit/score/include/rtems/score/heap.h
+++ b/cpukit/score/include/rtems/score/heap.h
@@ -464,6 +464,29 @@ RTEMS_INLINE_ROUTINE uintptr_t _Heap_Area_overhead(
return 2 * (page_size - 1) + HEAP_BLOCK_HEADER_SIZE;
}
+/**
+ * @brief Returns the size with administration and alignment overhead for one
+ * allocation.
+ */
+RTEMS_INLINE_ROUTINE uintptr_t _Heap_Size_with_overhead(
+ uintptr_t page_size,
+ uintptr_t size,
+ uintptr_t alignment
+)
+{
+ if ( page_size != 0 ) {
+ page_size = _Heap_Align_up( page_size, CPU_ALIGNMENT );
+ } else {
+ page_size = CPU_ALIGNMENT;
+ }
+
+ if ( page_size < alignment ) {
+ page_size = alignment;
+ }
+
+ return HEAP_BLOCK_HEADER_SIZE + page_size - 1 + size;
+}
+
/** @} */
#ifdef __cplusplus