From ac7d5ef06a6d6e8d84abbd1f0b82162725f98326 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Thu, 11 May 1995 17:39:37 +0000 Subject: Initial revision --- cpukit/score/macros/rtems/score/heap.inl | 136 +++++++++++++++++++++++++++++++ 1 file changed, 136 insertions(+) create mode 100644 cpukit/score/macros/rtems/score/heap.inl (limited to 'cpukit/score/macros/rtems/score/heap.inl') diff --git a/cpukit/score/macros/rtems/score/heap.inl b/cpukit/score/macros/rtems/score/heap.inl new file mode 100644 index 0000000000..6f06478207 --- /dev/null +++ b/cpukit/score/macros/rtems/score/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 + +/*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 */ -- cgit v1.2.3