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

4.104.114.84.95
Last change on this file since 6b45e470 was 6b45e470, checked in by Joel Sherrill <joel.sherrill@…>, on 08/22/95 at 16:44:49

Merged PowerPC port as submitted by Andy Bray of I-CUBED, Ltd
(andy@…). This initial submission is known
to work on the IBM 403. It is thought to work on the Motorola
601, 603, and 604 although this remains to be tested.

Another user -- Doug Currie (e@…) -- is interested in
this work and will be testing it on the 604 using the Metrowerks
C compiler and a different format assembly language.

  • Property mode set to 100644
File size: 2.5 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/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_Is_previous_block_free
74 */
75
76#define _Heap_Is_previous_block_free( _the_block ) \
77  ( !((_the_block)->back_flag & HEAP_BLOCK_USED) )
78
79/*PAGE
80 *
81 *  _Heap_Is_block_free
82 */
83
84#define _Heap_Is_block_free( _the_block ) \
85  ( !((_the_block)->front_flag & HEAP_BLOCK_USED) )
86
87/*PAGE
88 *
89 *  _Heap_Is_block_used
90 */
91
92#define _Heap_Is_block_used( _the_block ) \
93  ((_the_block)->front_flag & HEAP_BLOCK_USED)
94
95/*PAGE
96 *
97 *  _Heap_Block_size
98 */
99
100#define _Heap_Block_size( _the_block )    \
101  ((_the_block)->front_flag & ~HEAP_BLOCK_USED)
102
103/*PAGE
104 *
105 *  _Heap_Start_of_user_area
106 */
107
108#define _Heap_Start_of_user_area( _the_block ) \
109  ((void *) &(_the_block)->next)
110
111/*PAGE
112 *
113 *  _Heap_Is_block_in
114 */
115
116#define _Heap_Is_block_in( _the_heap, _the_block ) \
117  ( ((_the_block) >= (_the_heap)->start) && \
118    ((_the_block) <= (_the_heap)->final) )
119
120/*PAGE
121 *
122 *  _Heap_Is_page_size_valid
123 */
124
125#define _Heap_Is_page_size_valid( _page_size ) \
126  ( ((_page_size) != 0) && \
127    (((_page_size) % CPU_HEAP_ALIGNMENT) == 0) )
128
129/*PAGE
130 *
131 *  _Heap_Build_flag
132 */
133
134#define _Heap_Build_flag( _size, _in_use_flag ) \
135  ( (_size) | (_in_use_flag))
136
137#endif
138/* end of include file */
Note: See TracBrowser for help on using the repository browser.