summaryrefslogtreecommitdiffstats
path: root/cpukit/include/rtems/score/heapimpl.h
diff options
context:
space:
mode:
Diffstat (limited to 'cpukit/include/rtems/score/heapimpl.h')
-rw-r--r--cpukit/include/rtems/score/heapimpl.h89
1 files changed, 50 insertions, 39 deletions
diff --git a/cpukit/include/rtems/score/heapimpl.h b/cpukit/include/rtems/score/heapimpl.h
index 4403f186c7..91326c6577 100644
--- a/cpukit/include/rtems/score/heapimpl.h
+++ b/cpukit/include/rtems/score/heapimpl.h
@@ -1,3 +1,5 @@
+/* SPDX-License-Identifier: BSD-2-Clause */
+
/**
* @file
*
@@ -11,9 +13,26 @@
* COPYRIGHT (c) 1989-2008.
* 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.org/license/LICENSE.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _RTEMS_SCORE_HEAPIMPL_H
@@ -137,7 +156,7 @@ void *_Heap_Allocate_aligned_with_boundary(
* @retval pointer The starting address of the allocated memory area.
* @retval NULL No memory is available of the parameters are inconsistent.
*/
-RTEMS_INLINE_ROUTINE void *_Heap_Allocate_aligned(
+static inline void *_Heap_Allocate_aligned(
Heap_Control *heap,
uintptr_t size,
uintptr_t alignment
@@ -158,7 +177,7 @@ RTEMS_INLINE_ROUTINE void *_Heap_Allocate_aligned(
* @retval pointer The starting address of the allocated memory area.
* @retval NULL No memory is available of the parameters are inconsistent.
*/
-RTEMS_INLINE_ROUTINE void *_Heap_Allocate( Heap_Control *heap, uintptr_t size )
+static inline void *_Heap_Allocate( Heap_Control *heap, uintptr_t size )
{
return _Heap_Allocate_aligned_with_boundary( heap, size, 0, 0 );
}
@@ -408,15 +427,7 @@ Heap_Block *_Heap_Block_allocate(
(*heap->Protection.block_error)( heap, block, reason );
}
- static inline void _Heap_Protection_free_all_delayed_blocks( Heap_Control *heap )
- {
- uintptr_t large = 0
- - (uintptr_t) HEAP_BLOCK_HEADER_SIZE
- - (uintptr_t) HEAP_ALLOC_BONUS
- - (uintptr_t) 1;
- void *p = _Heap_Allocate( heap, large );
- _Heap_Free( heap, p );
- }
+ void _Heap_Protection_free_all_delayed_blocks( Heap_Control *heap );
#endif
/**
@@ -429,7 +440,7 @@ Heap_Block *_Heap_Block_allocate(
* @param[in, out] heap The heap control.
* @param fraction The fraction is one divided by this fraction value.
*/
-RTEMS_INLINE_ROUTINE void _Heap_Protection_set_delayed_free_fraction(
+static inline void _Heap_Protection_set_delayed_free_fraction(
Heap_Control *heap,
uintptr_t fraction
)
@@ -449,7 +460,7 @@ RTEMS_INLINE_ROUTINE void _Heap_Protection_set_delayed_free_fraction(
*
* @return The head of the free list.
*/
-RTEMS_INLINE_ROUTINE Heap_Block *_Heap_Free_list_head( Heap_Control *heap )
+static inline Heap_Block *_Heap_Free_list_head( Heap_Control *heap )
{
return &heap->free_list;
}
@@ -461,7 +472,7 @@ RTEMS_INLINE_ROUTINE Heap_Block *_Heap_Free_list_head( Heap_Control *heap )
*
* @return The tail of the free list.
*/
-RTEMS_INLINE_ROUTINE Heap_Block *_Heap_Free_list_tail( Heap_Control *heap )
+static inline Heap_Block *_Heap_Free_list_tail( Heap_Control *heap )
{
return &heap->free_list;
}
@@ -473,7 +484,7 @@ RTEMS_INLINE_ROUTINE Heap_Block *_Heap_Free_list_tail( Heap_Control *heap )
*
* @return The first block of the free list.
*/
-RTEMS_INLINE_ROUTINE Heap_Block *_Heap_Free_list_first( Heap_Control *heap )
+static inline Heap_Block *_Heap_Free_list_first( Heap_Control *heap )
{
return _Heap_Free_list_head(heap)->next;
}
@@ -485,7 +496,7 @@ RTEMS_INLINE_ROUTINE Heap_Block *_Heap_Free_list_first( Heap_Control *heap )
*
* @return The last block of the free list.
*/
-RTEMS_INLINE_ROUTINE Heap_Block *_Heap_Free_list_last( Heap_Control *heap )
+static inline Heap_Block *_Heap_Free_list_last( Heap_Control *heap )
{
return _Heap_Free_list_tail(heap)->prev;
}
@@ -495,7 +506,7 @@ RTEMS_INLINE_ROUTINE Heap_Block *_Heap_Free_list_last( Heap_Control *heap )
*
* @param block The block to be removed.
*/
-RTEMS_INLINE_ROUTINE void _Heap_Free_list_remove( Heap_Block *block )
+static inline void _Heap_Free_list_remove( Heap_Block *block )
{
Heap_Block *next = block->next;
Heap_Block *prev = block->prev;
@@ -510,7 +521,7 @@ RTEMS_INLINE_ROUTINE void _Heap_Free_list_remove( Heap_Block *block )
* @param old_block The block in the free list to replace.
* @param new_block The block that should replace @a old_block.
*/
-RTEMS_INLINE_ROUTINE void _Heap_Free_list_replace(
+static inline void _Heap_Free_list_replace(
Heap_Block *old_block,
Heap_Block *new_block
)
@@ -531,7 +542,7 @@ RTEMS_INLINE_ROUTINE void _Heap_Free_list_replace(
* @param block_before The block that is already in the free list.
* @param new_block The block to be inserted after @a block_before.
*/
-RTEMS_INLINE_ROUTINE void _Heap_Free_list_insert_after(
+static inline void _Heap_Free_list_insert_after(
Heap_Block *block_before,
Heap_Block *new_block
)
@@ -550,7 +561,7 @@ RTEMS_INLINE_ROUTINE void _Heap_Free_list_insert_after(
* @param block_before The block that is already in the free list.
* @param new_block The block to be inserted before @a block_before.
*/
-RTEMS_INLINE_ROUTINE void _Heap_Free_list_insert_before(
+static inline void _Heap_Free_list_insert_before(
Heap_Block *block_next,
Heap_Block *new_block
)
@@ -572,7 +583,7 @@ RTEMS_INLINE_ROUTINE void _Heap_Free_list_insert_before(
* @retval true The value is aligned to the given alignment.
* @retval false The value is not aligned to the given alignment.
*/
-RTEMS_INLINE_ROUTINE bool _Heap_Is_aligned(
+static inline bool _Heap_Is_aligned(
uintptr_t value,
uintptr_t alignment
)
@@ -588,7 +599,7 @@ RTEMS_INLINE_ROUTINE bool _Heap_Is_aligned(
*
* @return The aligned value, truncated.
*/
-RTEMS_INLINE_ROUTINE uintptr_t _Heap_Align_down(
+static inline uintptr_t _Heap_Align_down(
uintptr_t value,
uintptr_t alignment
)
@@ -604,7 +615,7 @@ RTEMS_INLINE_ROUTINE uintptr_t _Heap_Align_down(
*
* @return The address of the block which is @a offset away from @a block.
*/
-RTEMS_INLINE_ROUTINE Heap_Block *_Heap_Block_at(
+static inline Heap_Block *_Heap_Block_at(
const Heap_Block *block,
uintptr_t offset
)
@@ -619,7 +630,7 @@ RTEMS_INLINE_ROUTINE Heap_Block *_Heap_Block_at(
*
* @return The address of the previous block.
*/
-RTEMS_INLINE_ROUTINE Heap_Block *_Heap_Prev_block(
+static inline Heap_Block *_Heap_Prev_block(
const Heap_Block *block
)
{
@@ -633,7 +644,7 @@ RTEMS_INLINE_ROUTINE Heap_Block *_Heap_Prev_block(
*
* @return The first address after the heap header.
*/
-RTEMS_INLINE_ROUTINE uintptr_t _Heap_Alloc_area_of_block(
+static inline uintptr_t _Heap_Alloc_area_of_block(
const Heap_Block *block
)
{
@@ -648,7 +659,7 @@ RTEMS_INLINE_ROUTINE uintptr_t _Heap_Alloc_area_of_block(
*
* @return The Starting address of the corresponding block of the allocatable area.
*/
-RTEMS_INLINE_ROUTINE Heap_Block *_Heap_Block_of_alloc_area(
+static inline Heap_Block *_Heap_Block_of_alloc_area(
uintptr_t alloc_begin,
uintptr_t page_size
)
@@ -664,7 +675,7 @@ RTEMS_INLINE_ROUTINE Heap_Block *_Heap_Block_of_alloc_area(
*
* @return The block size.
*/
-RTEMS_INLINE_ROUTINE uintptr_t _Heap_Block_size( const Heap_Block *block )
+static inline uintptr_t _Heap_Block_size( const Heap_Block *block )
{
return block->size_and_flag & ~HEAP_PREV_BLOCK_USED;
}
@@ -675,7 +686,7 @@ RTEMS_INLINE_ROUTINE uintptr_t _Heap_Block_size( const Heap_Block *block )
* @param[in, out] block The block of which the size shall be set.
* @param size The new size of the block.
*/
-RTEMS_INLINE_ROUTINE void _Heap_Block_set_size(
+static inline void _Heap_Block_set_size(
Heap_Block *block,
uintptr_t size
)
@@ -694,7 +705,7 @@ RTEMS_INLINE_ROUTINE void _Heap_Block_set_size(
* @retval true The previous block is used.
* @retval false The previous block is not used.
*/
-RTEMS_INLINE_ROUTINE bool _Heap_Is_prev_used( const Heap_Block *block )
+static inline bool _Heap_Is_prev_used( const Heap_Block *block )
{
return block->size_and_flag & HEAP_PREV_BLOCK_USED;
}
@@ -707,7 +718,7 @@ RTEMS_INLINE_ROUTINE bool _Heap_Is_prev_used( const Heap_Block *block )
* @retval true The block is used.
* @retval false The block is not used.
*/
-RTEMS_INLINE_ROUTINE bool _Heap_Is_used(
+static inline bool _Heap_Is_used(
const Heap_Block *block
)
{
@@ -725,7 +736,7 @@ RTEMS_INLINE_ROUTINE bool _Heap_Is_used(
* @retval true The block is free.
* @retval false The block is not free.
*/
-RTEMS_INLINE_ROUTINE bool _Heap_Is_free(
+static inline bool _Heap_Is_free(
const Heap_Block *block
)
{
@@ -741,7 +752,7 @@ RTEMS_INLINE_ROUTINE bool _Heap_Is_free(
* @retval true The block is part of the heap.
* @retval false The block is not part of the heap.
*/
-RTEMS_INLINE_ROUTINE bool _Heap_Is_block_in_heap(
+static inline bool _Heap_Is_block_in_heap(
const Heap_Control *heap,
const Heap_Block *block
)
@@ -763,7 +774,7 @@ RTEMS_INLINE_ROUTINE bool _Heap_Is_block_in_heap(
*
* @param[in, out] heap The heap to set the last block size of.
*/
-RTEMS_INLINE_ROUTINE void _Heap_Set_last_block_size( Heap_Control *heap )
+static inline void _Heap_Set_last_block_size( Heap_Control *heap )
{
_Heap_Block_set_size(
heap->last_block,
@@ -780,7 +791,7 @@ RTEMS_INLINE_ROUTINE void _Heap_Set_last_block_size( Heap_Control *heap )
*
* @return The size of the allocatable area in @a heap in bytes.
*/
-RTEMS_INLINE_ROUTINE uintptr_t _Heap_Get_size( const Heap_Control *heap )
+static inline uintptr_t _Heap_Get_size( const Heap_Control *heap )
{
return heap->stats.size;
}
@@ -794,7 +805,7 @@ RTEMS_INLINE_ROUTINE uintptr_t _Heap_Get_size( const Heap_Control *heap )
* @retval a If a > b.
* @retval b If b >= a
*/
-RTEMS_INLINE_ROUTINE uintptr_t _Heap_Max( uintptr_t a, uintptr_t b )
+static inline uintptr_t _Heap_Max( uintptr_t a, uintptr_t b )
{
return a > b ? a : b;
}
@@ -808,7 +819,7 @@ RTEMS_INLINE_ROUTINE uintptr_t _Heap_Max( uintptr_t a, uintptr_t b )
* @retval a If a < b.
* @retval b If b <= a
*/
-RTEMS_INLINE_ROUTINE uintptr_t _Heap_Min( uintptr_t a, uintptr_t b )
+static inline uintptr_t _Heap_Min( uintptr_t a, uintptr_t b )
{
return a < b ? a : b;
}