source: rtems/c/src/exec/score/macros/heap.inl @ eb5a7e07

4.104.114.84.95
Last change on this file since eb5a7e07 was 11290355, checked in by Joel Sherrill <joel.sherrill@…>, on 09/29/95 at 17:19:16

all targets compile .. tony's patches in place

  • Property mode set to 100644
File size: 2.7 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, 1990, 1991, 1992, 1993, 1994.
7 *  On-Line Applications Research Corporation (OAR).
8 *  All rights assigned to U.S. Government, 1994.
9 *
10 *  This material may be reproduced by or for the U.S. Government pursuant
11 *  to the copyright license under the clause at DFARS 252.227-7013.  This
12 *  notice must appear in all copies of this file and its derivatives.
13 *
14 *  $Id$
15 */
16
17#ifndef __HEAP_inl
18#define __HEAP_inl
19
20#include <rtems/score/address.h>
21
22/*PAGE
23 *
24 *  _Heap_Head
25 */
26
27#define _Heap_Head( _the_heap ) \
28  ((Heap_Block *)&(_the_heap)->start)
29
30/*PAGE
31 *
32 *  _Heap_Tail
33 */
34
35#define _Heap_Tail( _the_heap ) \
36  ((Heap_Block *)&(_the_heap)->final)
37
38/*PAGE
39 *
40 *  _Heap_Previous_block
41 */
42
43#define _Heap_Previous_block( _the_block ) \
44  ( (Heap_Block *) _Addresses_Subtract_offset( \
45      (void *)(_the_block), \
46      (_the_block)->back_flag & ~ HEAP_BLOCK_USED \
47    ) \
48  )
49
50/*PAGE
51 *
52 *  _Heap_Next_block
53 */
54
55#define _Heap_Next_block( _the_block ) \
56  ( (Heap_Block *) _Addresses_Add_offset( \
57      (void *)(_the_block), \
58      (_the_block)->front_flag & ~ HEAP_BLOCK_USED \
59    ) \
60  )
61
62/*PAGE
63 *
64 *  _Heap_Block_at
65 */
66
67#define _Heap_Block_at( _base, _offset ) \
68  ( (Heap_Block *) \
69     _Addresses_Add_offset( (void *)(_base), (_offset) ) )
70
71/*PAGE
72 *
73 *  _Heap_User_block_at
74 *
75 */
76 
77#define _Heap_User_block_at( _base ) \
78  _Heap_Block_at( \
79    (_base), \
80    -*(((unsigned32 *) (_base)) - 1) + -HEAP_BLOCK_USED_OVERHEAD \
81  )
82
83/*PAGE
84 *
85 *  _Heap_Is_previous_block_free
86 */
87
88#define _Heap_Is_previous_block_free( _the_block ) \
89  ( !((_the_block)->back_flag & HEAP_BLOCK_USED) )
90
91/*PAGE
92 *
93 *  _Heap_Is_block_free
94 */
95
96#define _Heap_Is_block_free( _the_block ) \
97  ( !((_the_block)->front_flag & HEAP_BLOCK_USED) )
98
99/*PAGE
100 *
101 *  _Heap_Is_block_used
102 */
103
104#define _Heap_Is_block_used( _the_block ) \
105  ((_the_block)->front_flag & HEAP_BLOCK_USED)
106
107/*PAGE
108 *
109 *  _Heap_Block_size
110 */
111
112#define _Heap_Block_size( _the_block )    \
113  ((_the_block)->front_flag & ~HEAP_BLOCK_USED)
114
115/*PAGE
116 *
117 *  _Heap_Start_of_user_area
118 */
119
120#define _Heap_Start_of_user_area( _the_block ) \
121  ((void *) &(_the_block)->next)
122
123/*PAGE
124 *
125 *  _Heap_Is_block_in
126 */
127
128#define _Heap_Is_block_in( _the_heap, _the_block ) \
129  ( ((_the_block) >= (_the_heap)->start) && \
130    ((_the_block) <= (_the_heap)->final) )
131
132/*PAGE
133 *
134 *  _Heap_Is_page_size_valid
135 */
136
137#define _Heap_Is_page_size_valid( _page_size ) \
138  ( ((_page_size) != 0) && \
139    (((_page_size) % CPU_HEAP_ALIGNMENT) == 0) )
140
141/*PAGE
142 *
143 *  _Heap_Build_flag
144 */
145
146#define _Heap_Build_flag( _size, _in_use_flag ) \
147  ( (_size) | (_in_use_flag))
148
149#endif
150/* end of include file */
Note: See TracBrowser for help on using the repository browser.