source: rtems/cpukit/score/macros/rtems/score/heap.inl @ a85d8ec

4.104.114.84.95
Last change on this file since a85d8ec was 08311cc3, checked in by Joel Sherrill <joel.sherrill@…>, on 11/17/99 at 17:51:34

Updated copyright notice.

  • Property mode set to 100644
File size: 2.6 KB
Line 
1/*  heap.inl
2 *
3 *  This file contains the macro implementation of the inlined
4 *  routines from the heap handler.
5 *
6 *  COPYRIGHT (c) 1989-1999.
7 *  On-Line Applications Research Corporation (OAR).
8 *
9 *  The license and distribution terms for this file may be
10 *  found in the file LICENSE in this distribution or at
11 *  http://www.OARcorp.com/rtems/license.html.
12 *
13 *  $Id$
14 */
15
16#ifndef __HEAP_inl
17#define __HEAP_inl
18
19#include <rtems/score/address.h>
20
21/*PAGE
22 *
23 *  _Heap_Head
24 */
25
26#define _Heap_Head( _the_heap ) \
27  ((Heap_Block *)&(_the_heap)->start)
28
29/*PAGE
30 *
31 *  _Heap_Tail
32 */
33
34#define _Heap_Tail( _the_heap ) \
35  ((Heap_Block *)&(_the_heap)->final)
36
37/*PAGE
38 *
39 *  _Heap_Previous_block
40 */
41
42#define _Heap_Previous_block( _the_block ) \
43  ( (Heap_Block *) _Addresses_Subtract_offset( \
44      (void *)(_the_block), \
45      (_the_block)->back_flag & ~ HEAP_BLOCK_USED \
46    ) \
47  )
48
49/*PAGE
50 *
51 *  _Heap_Next_block
52 */
53
54#define _Heap_Next_block( _the_block ) \
55  ( (Heap_Block *) _Addresses_Add_offset( \
56      (void *)(_the_block), \
57      (_the_block)->front_flag & ~ HEAP_BLOCK_USED \
58    ) \
59  )
60
61/*PAGE
62 *
63 *  _Heap_Block_at
64 */
65
66#define _Heap_Block_at( _base, _offset ) \
67  ( (Heap_Block *) \
68     _Addresses_Add_offset( (void *)(_base), (_offset) ) )
69
70/*PAGE
71 *
72 *  _Heap_User_block_at
73 *
74 */
75 
76#define _Heap_User_block_at( _base ) \
77  _Heap_Block_at( \
78    (_base), \
79    -*(((unsigned32 *) (_base)) - 1) + -HEAP_BLOCK_USED_OVERHEAD \
80  )
81
82/*PAGE
83 *
84 *  _Heap_Is_previous_block_free
85 */
86
87#define _Heap_Is_previous_block_free( _the_block ) \
88  ( !((_the_block)->back_flag & HEAP_BLOCK_USED) )
89
90/*PAGE
91 *
92 *  _Heap_Is_block_free
93 */
94
95#define _Heap_Is_block_free( _the_block ) \
96  ( !((_the_block)->front_flag & HEAP_BLOCK_USED) )
97
98/*PAGE
99 *
100 *  _Heap_Is_block_used
101 */
102
103#define _Heap_Is_block_used( _the_block ) \
104  ((_the_block)->front_flag & HEAP_BLOCK_USED)
105
106/*PAGE
107 *
108 *  _Heap_Block_size
109 */
110
111#define _Heap_Block_size( _the_block )    \
112  ((_the_block)->front_flag & ~HEAP_BLOCK_USED)
113
114/*PAGE
115 *
116 *  _Heap_Start_of_user_area
117 */
118
119#define _Heap_Start_of_user_area( _the_block ) \
120  ((void *) &(_the_block)->next)
121
122/*PAGE
123 *
124 *  _Heap_Is_block_in
125 */
126
127#define _Heap_Is_block_in( _the_heap, _the_block ) \
128  ( ((_the_block) >= (_the_heap)->start) && \
129    ((_the_block) <= (_the_heap)->final) )
130
131/*PAGE
132 *
133 *  _Heap_Is_page_size_valid
134 */
135
136#define _Heap_Is_page_size_valid( _page_size ) \
137  ( ((_page_size) != 0) && \
138    (((_page_size) % CPU_HEAP_ALIGNMENT) == 0) )
139
140/*PAGE
141 *
142 *  _Heap_Build_flag
143 */
144
145#define _Heap_Build_flag( _size, _in_use_flag ) \
146  ( (_size) | (_in_use_flag))
147
148#endif
149/* end of include file */
Note: See TracBrowser for help on using the repository browser.