source: rtems/cpukit/score/inline/rtems/score/heap.inl @ 8bd41178

4.104.114.84.95
Last change on this file since 8bd41178 was dd687d97, checked in by Joel Sherrill <joel.sherrill@…>, on 09/04/03 at 18:56:05

2003-09-04 Joel Sherrill <joel@…>

  • include/rtems/debug.h, include/rtems/seterr.h, include/rtems/system.h, include/rtems/score/address.h, include/rtems/score/apiext.h, include/rtems/score/apimutex.h, include/rtems/score/bitfield.h, include/rtems/score/chain.h, include/rtems/score/context.h, include/rtems/score/copyrt.h, include/rtems/score/coremsg.h, include/rtems/score/coremutex.h, include/rtems/score/coresem.h, include/rtems/score/heap.h, include/rtems/score/interr.h, include/rtems/score/isr.h, include/rtems/score/mpci.h, include/rtems/score/mppkt.h, include/rtems/score/object.h, include/rtems/score/objectmp.h, include/rtems/score/priority.h, include/rtems/score/stack.h, include/rtems/score/states.h, include/rtems/score/sysstate.h, include/rtems/score/thread.h, include/rtems/score/threadmp.h, include/rtems/score/threadq.h, include/rtems/score/tod.h, include/rtems/score/tqdata.h, include/rtems/score/userext.h, include/rtems/score/watchdog.h, include/rtems/score/wkspace.h, inline/rtems/score/address.inl, inline/rtems/score/chain.inl, inline/rtems/score/coremsg.inl, inline/rtems/score/coremutex.inl, inline/rtems/score/coresem.inl, inline/rtems/score/heap.inl, inline/rtems/score/isr.inl, inline/rtems/score/mppkt.inl, inline/rtems/score/object.inl, inline/rtems/score/objectmp.inl, inline/rtems/score/priority.inl, inline/rtems/score/stack.inl, inline/rtems/score/states.inl, inline/rtems/score/sysstate.inl, inline/rtems/score/thread.inl, inline/rtems/score/threadmp.inl, inline/rtems/score/tod.inl, inline/rtems/score/tqdata.inl, inline/rtems/score/userext.inl, inline/rtems/score/watchdog.inl, inline/rtems/score/wkspace.inl, macros/rtems/score/address.inl, macros/rtems/score/chain.inl, macros/rtems/score/coremsg.inl, macros/rtems/score/coremutex.inl, macros/rtems/score/coresem.inl, macros/rtems/score/heap.inl, macros/rtems/score/isr.inl, macros/rtems/score/mppkt.inl, macros/rtems/score/object.inl, macros/rtems/score/objectmp.inl, macros/rtems/score/priority.inl, macros/rtems/score/stack.inl, macros/rtems/score/states.inl, macros/rtems/score/sysstate.inl, macros/rtems/score/thread.inl, macros/rtems/score/threadmp.inl, macros/rtems/score/tod.inl, macros/rtems/score/tqdata.inl, macros/rtems/score/userext.inl, macros/rtems/score/watchdog.inl, macros/rtems/score/wkspace.inl, src/apiext.c, src/chain.c, src/coremsg.c, src/coremsgbroadcast.c, src/coremsgclose.c, src/coremsgflush.c, src/coremsgflushsupp.c, src/coremsgflushwait.c, src/coremsginsert.c, src/coremsgseize.c, src/coremsgsubmit.c, src/coremutex.c, src/coremutexflush.c, src/coremutexseize.c, src/coremutexsurrender.c, src/coresem.c, src/coresemflush.c, src/coresemseize.c, src/coresemsurrender.c, src/coretod.c, src/coretodset.c, src/coretodtickle.c, src/coretodtoseconds.c, src/coretodvalidate.c, src/heap.c, src/heapallocate.c, src/heapextend.c, src/heapfree.c, src/heapgetinfo.c, src/heapsizeofuserarea.c, src/heapwalk.c, src/interr.c, src/isr.c, src/iterateoverthreads.c, src/mpci.c, src/object.c, src/objectallocate.c, src/objectallocatebyindex.c, src/objectclearname.c, src/objectcomparenameraw.c, src/objectcomparenamestring.c, src/objectcopynameraw.c, src/objectcopynamestring.c, src/objectextendinformation.c, src/objectfree.c, src/objectget.c, src/objectgetbyindex.c, src/objectgetisr.c, src/objectgetnext.c, src/objectgetnoprotection.c, src/objectidtoname.c, src/objectinitializeinformation.c, src/objectmp.c, src/objectnametoid.c, src/objectshrinkinformation.c, src/thread.c, src/threadchangepriority.c, src/threadclearstate.c, src/threadclose.c, src/threadcreateidle.c, src/threaddelayended.c, src/threaddispatch.c, src/threadevaluatemode.c, src/threadget.c, src/threadhandler.c, src/threadidlebody.c, src/threadinitialize.c, src/threadloadenv.c, src/threadmp.c, src/threadq.c, src/threadqdequeue.c, src/threadqdequeuefifo.c, src/threadqdequeuepriority.c, src/threadqenqueue.c, src/threadqenqueuefifo.c, src/threadqenqueuepriority.c, src/threadqextract.c, src/threadqextractfifo.c, src/threadqextractpriority.c, src/threadqextractwithproxy.c, src/threadqfirst.c, src/threadqfirstfifo.c, src/threadqfirstpriority.c, src/threadqflush.c, src/threadqtimeout.c, src/threadready.c, src/threadreset.c, src/threadresettimeslice.c, src/threadrestart.c, src/threadresume.c, src/threadrotatequeue.c, src/threadsetpriority.c, src/threadsetstate.c, src/threadsettransient.c, src/threadstackallocate.c, src/threadstackfree.c, src/threadstart.c, src/threadstartmultitasking.c, src/threadsuspend.c, src/threadtickletimeslice.c, src/threadyieldprocessor.c, src/userext.c, src/watchdog.c, src/watchdogadjust.c, src/watchdoginsert.c, src/watchdogremove.c, src/watchdogtickle.c, src/wkspace.c: URL for license changed.
  • Property mode set to 100644
File size: 5.0 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-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.rtems.com/license/LICENSE.
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 *  DESCRIPTION:
26 *
27 *  This function returns the head of the specified heap.
28 */
29
30RTEMS_INLINE_ROUTINE Heap_Block *_Heap_Head (
31  Heap_Control *the_heap
32)
33{
34  return (Heap_Block *)&the_heap->start;
35}
36
37/*PAGE
38 *
39 *  _Heap_Tail
40 *
41 *  DESCRIPTION:
42 *
43 *  This function returns the tail of the specified heap.
44 */
45
46RTEMS_INLINE_ROUTINE Heap_Block *_Heap_Tail (
47  Heap_Control *the_heap
48)
49{
50  return (Heap_Block *)&the_heap->final;
51}
52
53/*PAGE
54 *
55 *  _Heap_Previous_block
56 *
57 *  DESCRIPTION:
58 *
59 *  This function returns the address of the block which physically
60 *  precedes the_block in memory.
61 */
62
63RTEMS_INLINE_ROUTINE Heap_Block *_Heap_Previous_block (
64  Heap_Block *the_block
65)
66{
67  return (Heap_Block *) _Addresses_Subtract_offset(
68                          (void *)the_block,
69                          the_block->back_flag & ~ HEAP_BLOCK_USED
70                        );
71}
72
73/*PAGE
74 *
75 *  _Heap_Next_block
76 *
77 *  DESCRIPTION:
78 *
79 *  This function returns the address of the block which physically
80 *  follows the_block in memory.
81 *
82 *  NOTE: Next_block assumes that the block is free.
83 */
84
85RTEMS_INLINE_ROUTINE Heap_Block *_Heap_Next_block (
86  Heap_Block *the_block
87)
88{
89  return (Heap_Block *) _Addresses_Add_offset(
90                          (void *)the_block,
91                          the_block->front_flag & ~ HEAP_BLOCK_USED
92                        );
93}
94
95/*PAGE
96 *
97 *  _Heap_Block_at
98 *
99 *  DESCRIPTION:
100 *
101 *  This function calculates and returns a block's location (address)
102 *  in the heap based upon a base address and an offset.
103 */
104
105RTEMS_INLINE_ROUTINE Heap_Block *_Heap_Block_at(
106  void       *base,
107  unsigned32  offset
108)
109{
110  return (Heap_Block *) _Addresses_Add_offset( (void *)base, offset );
111}
112
113/*PAGE
114 *
115 *  _Heap_User_block_at
116 *
117 *  DESCRIPTION:
118 *
119 *  XXX
120 */
121 
122RTEMS_INLINE_ROUTINE Heap_Block *_Heap_User_block_at(
123  void       *base
124)
125{
126  unsigned32         offset;
127 
128  offset = *(((unsigned32 *) base) - 1);
129  return _Heap_Block_at( base, -offset + -HEAP_BLOCK_USED_OVERHEAD);
130}
131
132/*PAGE
133 *
134 *  _Heap_Is_previous_block_free
135 *
136 *  DESCRIPTION:
137 *
138 *  This function returns TRUE if the previous block of the_block
139 *  is free, and FALSE otherwise.
140 */
141
142RTEMS_INLINE_ROUTINE boolean _Heap_Is_previous_block_free (
143  Heap_Block *the_block
144)
145{
146  return !(the_block->back_flag & HEAP_BLOCK_USED);
147}
148
149/*PAGE
150 *
151 *  _Heap_Is_block_free
152 *
153 *  DESCRIPTION:
154 *
155 *  This function returns TRUE if the block is free, and FALSE otherwise.
156 */
157
158RTEMS_INLINE_ROUTINE boolean _Heap_Is_block_free (
159  Heap_Block *the_block
160)
161{
162  return !(the_block->front_flag & HEAP_BLOCK_USED);
163}
164
165/*PAGE
166 *
167 *  _Heap_Is_block_used
168 *
169 *  DESCRIPTION:
170 *
171 *  This function returns TRUE if the block is currently allocated,
172 *  and FALSE otherwise.
173 */
174
175RTEMS_INLINE_ROUTINE boolean _Heap_Is_block_used (
176  Heap_Block *the_block
177)
178{
179  return (the_block->front_flag & HEAP_BLOCK_USED);
180}
181
182/*PAGE
183 *
184 *  _Heap_Block_size
185 *
186 *  DESCRIPTION:
187 *
188 *  This function returns the size of the_block in bytes.
189 */
190
191RTEMS_INLINE_ROUTINE unsigned32 _Heap_Block_size (
192  Heap_Block *the_block
193)
194{
195  return (the_block->front_flag & ~HEAP_BLOCK_USED);
196}
197
198/*PAGE
199 *
200 *  _Heap_Start_of_user_area
201 *
202 *  DESCRIPTION:
203 *
204 *  This function returns the starting address of the portion of the block
205 *  which the user may access.
206 */
207
208RTEMS_INLINE_ROUTINE void *_Heap_Start_of_user_area (
209  Heap_Block *the_block
210)
211{
212  return (void *) &the_block->next;
213}
214
215/*PAGE
216 *
217 *  _Heap_Is_block_in
218 *
219 *  DESCRIPTION:
220 *
221 *  This function returns TRUE if the_block is within the memory area
222 *  managed by the_heap, and FALSE otherwise.
223 */
224
225RTEMS_INLINE_ROUTINE boolean _Heap_Is_block_in (
226  Heap_Control *the_heap,
227  Heap_Block   *the_block
228)
229{
230  return _Addresses_Is_in_range( the_block, the_heap->start, the_heap->final );
231}
232
233/*PAGE
234 *
235 *  _Heap_Is_page_size_valid
236 *
237 *  DESCRIPTION:
238 *
239 *  This function validates a specified heap page size.  If the page size
240 *  is 0 or if lies outside a page size alignment boundary it is invalid
241 *  and FALSE is returned.  Otherwise, the page size is valid and TRUE is
242 *  returned.
243 */
244
245RTEMS_INLINE_ROUTINE boolean _Heap_Is_page_size_valid(
246  unsigned32 page_size
247)
248{
249  return ((page_size != 0) &&
250         ((page_size % CPU_HEAP_ALIGNMENT) == 0));
251}
252
253/*PAGE
254 *
255 *  _Heap_Build_flag
256 *
257 *  DESCRIPTION:
258 *
259 *  This function returns the block flag composed of size and in_use_flag.
260 *  The flag returned is suitable for use as a back or front flag in a
261 *  heap block.
262 */
263
264RTEMS_INLINE_ROUTINE unsigned32 _Heap_Build_flag (
265  unsigned32 size,
266  unsigned32 in_use_flag
267)
268{
269  return  size | in_use_flag;
270}
271
272#endif
273/* end of include file */
Note: See TracBrowser for help on using the repository browser.