source: rtems/cpukit/score/inline/rtems/score/heap.inl @ ac7d5ef0

4.104.114.84.95
Last change on this file since ac7d5ef0 was ac7d5ef0, checked in by Joel Sherrill <joel.sherrill@…>, on 05/11/95 at 17:39:37

Initial revision

  • Property mode set to 100644
File size: 3.2 KB
Line 
1/*  heap.inl
2 *
3 *  This file contains the static inline 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/address.h>
21
22/*PAGE
23 *
24 *  _Heap_Head
25 *
26 */
27
28STATIC INLINE Heap_Block *_Heap_Head (
29  Heap_Control *the_heap
30)
31{
32  return (Heap_Block *)&the_heap->start;
33}
34
35/*PAGE
36 *
37 *  _Heap_Tail
38 *
39 */
40
41STATIC INLINE Heap_Block *_Heap_Tail (
42  Heap_Control *the_heap
43)
44{
45  return (Heap_Block *)&the_heap->final;
46}
47
48/*PAGE
49 *
50 *  _Heap_Previous_block
51 *
52 */
53
54STATIC INLINE Heap_Block *_Heap_Previous_block (
55  Heap_Block *the_block
56)
57{
58  return (Heap_Block *) _Addresses_Subtract_offset(
59                          (void *)the_block,
60                          the_block->back_flag & ~ HEAP_BLOCK_USED
61                        );
62}
63
64/*PAGE
65 *
66 *  _Heap_Next_block
67 *
68 *  NOTE: Next_block assumes that the block is free.
69 */
70
71STATIC INLINE Heap_Block *_Heap_Next_block (
72  Heap_Block *the_block
73)
74{
75  return (Heap_Block *) _Addresses_Add_offset(
76                          (void *)the_block,
77                          the_block->front_flag & ~ HEAP_BLOCK_USED
78                        );
79}
80
81/*PAGE
82 *
83 *  _Heap_Block_at
84 *
85 */
86
87STATIC INLINE Heap_Block *_Heap_Block_at(
88  void       *base,
89  unsigned32  offset
90)
91{
92  return (Heap_Block *) _Addresses_Add_offset( (void *)base, offset );
93}
94
95/*PAGE
96 *
97 *  _Heap_Is_previous_block_free
98 *
99 */
100
101STATIC INLINE boolean _Heap_Is_previous_block_free (
102  Heap_Block *the_block
103)
104{
105  return !(the_block->back_flag & HEAP_BLOCK_USED);
106}
107
108/*PAGE
109 *
110 *  _Heap_Is_block_free
111 *
112 */
113
114STATIC INLINE boolean _Heap_Is_block_free (
115  Heap_Block *the_block
116)
117{
118  return !(the_block->front_flag & HEAP_BLOCK_USED);
119}
120
121/*PAGE
122 *
123 *  _Heap_Is_block_used
124 *
125 */
126
127STATIC INLINE boolean _Heap_Is_block_used (
128  Heap_Block *the_block
129)
130{
131  return (the_block->front_flag & HEAP_BLOCK_USED);
132}
133
134/*PAGE
135 *
136 *  _Heap_Block_size
137 *
138 */
139
140STATIC INLINE unsigned32 _Heap_Block_size (
141  Heap_Block *the_block
142)
143{
144  return (the_block->front_flag & ~HEAP_BLOCK_USED);
145}
146
147/*PAGE
148 *
149 *  _Heap_Start_of_user_area
150 *
151 */
152
153STATIC INLINE void *_Heap_Start_of_user_area (
154  Heap_Block *the_block
155)
156{
157  return (void *) &the_block->next;
158}
159
160/*PAGE
161 *
162 *  _Heap_Is_block_in
163 *
164 */
165
166STATIC INLINE boolean _Heap_Is_block_in (
167  Heap_Control *the_heap,
168  Heap_Block   *the_block
169)
170{
171  return _Addresses_Is_in_range( the_block, the_heap->start, the_heap->final );
172}
173
174/*PAGE
175 *
176 *  _Heap_Is_page_size_valid
177 *
178 */
179
180STATIC INLINE boolean _Heap_Is_page_size_valid(
181  unsigned32 page_size
182)
183{
184  return ((page_size != 0) &&
185         ((page_size % CPU_HEAP_ALIGNMENT) == 0));
186}
187
188/*PAGE
189 *
190 *  _Heap_Build_flag
191 *
192 */
193
194STATIC INLINE unsigned32 _Heap_Build_flag (
195  unsigned32 size,
196  unsigned32 in_use_flag
197)
198{
199  return  size | in_use_flag;
200}
201
202#endif
203/* end of include file */
Note: See TracBrowser for help on using the repository browser.