summaryrefslogtreecommitdiffstats
path: root/c/src/exec/score/macros/heap.inl
diff options
context:
space:
mode:
Diffstat (limited to 'c/src/exec/score/macros/heap.inl')
-rw-r--r--c/src/exec/score/macros/heap.inl136
1 files changed, 136 insertions, 0 deletions
diff --git a/c/src/exec/score/macros/heap.inl b/c/src/exec/score/macros/heap.inl
new file mode 100644
index 0000000000..6f06478207
--- /dev/null
+++ b/c/src/exec/score/macros/heap.inl
@@ -0,0 +1,136 @@
+/* heap.inl
+ *
+ * This file contains the macro implementation of the inlined
+ * routines from the heap handler.
+ *
+ * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
+ * On-Line Applications Research Corporation (OAR).
+ * All rights assigned to U.S. Government, 1994.
+ *
+ * This material may be reproduced by or for the U.S. Government pursuant
+ * to the copyright license under the clause at DFARS 252.227-7013. This
+ * notice must appear in all copies of this file and its derivatives.
+ *
+ * $Id$
+ */
+
+#ifndef __HEAP_inl
+#define __HEAP_inl
+
+#include <rtems/address.h>
+
+/*PAGE
+ *
+ * _Heap_Head
+ */
+
+#define _Heap_Head( _the_heap ) \
+ ((Heap_Block *)&(_the_heap)->start)
+
+/*PAGE
+ *
+ * _Heap_Tail
+ */
+
+#define _Heap_Tail( _the_heap ) \
+ ((Heap_Block *)&(_the_heap)->final)
+
+/*PAGE
+ *
+ * _Heap_Previous_block
+ */
+
+#define _Heap_Previous_block( _the_block ) \
+ ( (Heap_Block *) _Addresses_Subtract_offset( \
+ (void *)(_the_block), \
+ (_the_block)->back_flag & ~ HEAP_BLOCK_USED \
+ )
+
+/*PAGE
+ *
+ * _Heap_Next_block
+ */
+
+#define _Heap_Next_block( _the_block ) \
+ ( (Heap_Block *) _Addresses_Add_offset( \
+ (void *)(_the_block), \
+ (_the_block)->front_flag & ~ HEAP_BLOCK_USED \
+ )
+
+/*PAGE
+ *
+ * _Heap_Block_at
+ */
+
+#define _Heap_Block_at( _base, _offset ) \
+ ( (Heap_Block *) \
+ _Addresses_Add_offset( (void *)(_base), (_offset) ) )
+
+/*PAGE
+ *
+ * _Heap_Is_previous_block_free
+ */
+
+#define _Heap_Is_previous_block_free( _the_block ) \
+ ( !((_the_block)->back_flag & HEAP_BLOCK_USED) )
+
+/*PAGE
+ *
+ * _Heap_Is_block_free
+ */
+
+#define _Heap_Is_block_free( _the_block ) \
+ ( !((_the_block)->front_flag & HEAP_BLOCK_USED) )
+
+/*PAGE
+ *
+ * _Heap_Is_block_used
+ */
+
+#define _Heap_Is_block_used( _the_block ) \
+ ((_the_block)->front_flag & HEAP_BLOCK_USED)
+
+/*PAGE
+ *
+ * _Heap_Block_size
+ */
+
+#define _Heap_Block_size( _the_block ) \
+ ((_the_block)->front_flag & ~HEAP_BLOCK_USED)
+
+/*PAGE
+ *
+ * _Heap_Start_of_user_area
+ */
+
+#define _Heap_Start_of_user_area( _the_block ) \
+ ((void *) &(_the_block)->next)
+
+/*PAGE
+ *
+ * _Heap_Is_block_in
+ */
+
+#define _Heap_Is_block_in( _the_heap, _the_block ) \
+ ( ((_the_block) >= (_the_heap)->start) && \
+ ((_the_block) <= (_the_heap)->final) )
+
+/*PAGE
+ *
+ * _Heap_Is_page_size_valid
+ */
+
+#define _Heap_Is_page_size_valid( _page_size ) \
+ ( ((_page_size) != 0) && \
+ (((_page_size) % CPU_HEAP_ALIGNMENT) == 0) )
+
+/*PAGE
+ *
+ * _Heap_Build_flag
+ */
+
+#define _Heap_Build_flag( _size, _in_use_flag ) \
+ ( (_size) | (_in_use_flag))
+
+#endif
+/* end of include file */