Changeset 962e894f in rtems for cpukit/score/macros
 Timestamp:
 Jan 20, 2005, 6:22:29 PM (16 years ago)
 Branches:
 4.10, 4.11, 4.8, 4.9, 5, master
 Children:
 3e528b7
 Parents:
 f3b7be3
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

cpukit/score/macros/rtems/score/heap.inl
rf3b7be3 r962e894f 17 17 #define __HEAP_inl 18 18 19 /* 20 * WARNING: this file is only visually checked against 21 * '../../../inline/rtems/score/heap.inl'. Use those file for reference 22 * if encounter problems. 23 */ 24 19 25 #include <rtems/score/address.h> 20 26 … … 24 30 */ 25 31 26 #define _Heap_Head( _the_heap ) \ 27 ((Heap_Block *)&(_the_heap)>start) 32 #define _Heap_Head( _the_heap ) (&(_the_heap)>free_list) 28 33 29 34 /*PAGE … … 32 37 */ 33 38 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 ) 39 #define _Heap_Tail( _the_heap ) (&(_the_heap)>free_list) 40 41 /*PAGE 42 * 43 * _Heap_First 44 */ 45 46 #define _Heap_First( _the_heap ) (_Heap_Head(_the_heap)>next) 47 48 /*PAGE 49 * 50 * _Heap_Last 51 */ 52 53 #define _Heap_Last( _the_heap ) (_Heap_Tail(_the_heap)>prev) 54 55 /*PAGE 56 * 57 * _Heap_Block_remove 58 * 59 */ 60 61 #define _Heap_Block_remove( _the_block ) \ 62 do { \ 63 Heap_Block *block = (_the_block); \ 64 Heap_Block *next = block>next; \ 65 Heap_Block *prev = block>prev; \ 66 prev>next = next; \ 67 next>prev = prev; \ 68 } while(0) 69 70 /*PAGE 71 * 72 * _Heap_Block_replace 73 * 74 */ 75 76 #define _Heap_Block_replace( _old_block, _new_block ) \ 77 do { \ 78 Heap_Block *block = (_old_block); \ 79 Heap_Block *next = block>next; \ 80 Heap_Block *prev = block>prev; \ 81 block = (_new_block); \ 82 block>next = next; \ 83 block>prev = prev; \ 84 next>prev = prev>next = block; \ 85 } while(0) 86 87 /*PAGE 88 * 89 * _Heap_Block_insert_after 90 * 91 */ 92 93 #define _Heap_Block_insert_after( _prev_block, _the_block ) \ 94 do { \ 95 Heap_Block *prev = (_prev_block); \ 96 Heap_Block *block = (_the_block); \ 97 Heap_Block *next = prev>next; \ 98 block>next = next; \ 99 block>prev = prev; \ 100 next>prev = prev>next = block; \ 101 } while(0) 102 103 /*PAGE 104 * 105 * _Heap_Is_aligned 106 */ 107 108 #define _Heap_Is_aligned( _value, _alignment ) \ 109 (((_value) % (_alignment)) == 0) 110 111 /*PAGE 112 * 113 * _Heap_Align_up 114 */ 115 116 #define _Heap_Align_up( _value, _alignment ) \ 117 do { \ 118 unsigned32 v = *(_value); \ 119 unsigned32 a = (_alignment); \ 120 unsigned32 r = v % a; \ 121 *(_value) = r ? v  r + a : v; \ 122 } while(0) 123 124 /*PAGE 125 * 126 * _Heap_Align_down 127 */ 128 129 #define _Heap_Align_down( _value, _alignment ) \ 130 do { \ 131 unsigned32 v = *(_value); \ 132 *(_value) = v  (v % (_alignment)); \ 133 } while(0) 134 135 /*PAGE 136 * 137 * _Heap_Is_aligned_ptr 138 */ 139 140 #define _Heap_Is_aligned_ptr( _ptr, _alignment ) \ 141 ((_H_p2u(_ptr) % (_alignment)) == 0) 142 143 /*PAGE 144 * 145 * _Heap_Align_up_uptr 146 */ 147 148 #define _Heap_Align_up_uptr( _value, _alignment ) \ 149 do { \ 150 _H_uptr_t v = *(_value); \ 151 unsigned32 a = (_alignment); \ 152 _H_uptr_t r = v % a; \ 153 *(_value) = r ? v  r + a : v; \ 154 } while(0) 155 156 /*PAGE 157 * 158 * _Heap_Align_down_uptr 159 */ 160 161 #define _Heap_Align_down_uptr( _value, _alignment ) \ 162 do { \ 163 _H_uptr_t v = *(_value); \ 164 *(_value) = v  (v % (_alignment)); \ 165 } while(0) 60 166 61 167 /*PAGE … … 65 171 66 172 #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 * 173 ( (Heap_Block *) _Addresses_Add_offset( (_base), (_offset) ) ) 174 175 /*PAGE 176 * 177 * _Heap_User_area 178 */ 179 180 #define _Heap_User_area( _the_block ) \ 181 ((void *) _Addresses_Add_offset( (_the_block), HEAP_BLOCK_USER_OFFSET )) 182 183 /*PAGE 184 * 185 * _Heap_Start_of_block 74 186 */ 75 187 76 #define _Heap_User_block_at( _base ) \ 77 _Heap_Block_at( \ 78 (_base), \ 79 *(((uint32_t *) (_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) 188 #define _Heap_Start_of_block( _the_heap, _base, _the_block_ptr ) \ 189 do { \ 190 _H_uptr_t addr = _H_p2u(_base); \ 191 _Heap_Align_down( &addr, (_the_heap)>page_size ); \ 192 *(_the_block_ptr) = (Heap_Block *)(addr  HEAP_BLOCK_USER_OFFSET); \ 193 } while(0) 194 195 /*PAGE 196 * 197 * _Heap_Is_prev_used 198 */ 199 200 #define _Heap_Is_prev_used( _the_block ) \ 201 ((_the_block)>size & HEAP_PREV_USED) 105 202 106 203 /*PAGE … … 110 207 111 208 #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) 209 ((_the_block)>size & ~HEAP_PREV_USED) 121 210 122 211 /*PAGE … … 126 215 127 216 #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)) 217 ( _Addresses_Is_in_range( (_the_block), \ 218 (_the_heap)>start, (_the_heap)>final ) ) 147 219 148 220 #endif
Note: See TracChangeset
for help on using the changeset viewer.