Changeset d434b8d6 in rtems
- Timestamp:
- 09/19/95 21:43:45 (28 years ago)
- Branches:
- 4.10, 4.11, 4.8, 4.9, 5, master
- Children:
- 2122a0b
- Parents:
- 91a3554d
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
c/src/exec/score/src/heap.c
r91a3554d rd434b8d6 15 15 16 16 #include <rtems/system.h> 17 #include <rtems/sysstate.h> 17 18 #include <rtems/core/heap.h> 18 #include <rtems/sysstate.h>19 19 20 20 /*PAGE … … 31 31 * 32 32 * Output parameters: 33 * returns - maximum memory available if successfully initialized33 * returns - maximum memory available if RTEMS_SUCCESSFUL 34 34 * 0 - otherwise 35 35 * … … 117 117 { 118 118 Heap_Block *the_block; 119 unsigned32 *p; 119 120 120 121 /* … … 174 175 /* 175 176 * Must pass in address of "user" area 176 */ 177 178 _Heap_Free( the_heap, &old_final->next ); 179 177 * So add in the offset field. 178 */ 179 180 p = (unsigned32 *) &old_final->next; 181 *p = sizeof(unsigned32); 182 p++; 183 _Heap_Free( the_heap, p ); 184 180 185 return HEAP_EXTEND_SUCCESSFUL; 181 186 } … … 206 211 Heap_Block *next_block; 207 212 Heap_Block *temporary_block; 208 213 void *ptr; 214 unsigned32 offset; 215 209 216 excess = size % the_heap->page_size; 210 the_size = size + HEAP_BLOCK_USED_OVERHEAD;211 217 the_size = size + the_heap->page_size + HEAP_BLOCK_USED_OVERHEAD; 218 212 219 if ( excess ) 213 220 the_size += the_heap->page_size - excess; … … 235 242 next_block->front_flag = _Heap_Build_flag( the_size, 236 243 HEAP_BLOCK_USED ); 237 return( _Heap_Start_of_user_area( next_block ));244 ptr = _Heap_Start_of_user_area( next_block ); 238 245 } else { 239 246 next_block = _Heap_Next_block( the_block ); … … 243 250 the_block->next->previous = the_block->previous; 244 251 the_block->previous->next = the_block->next; 245 return( _Heap_Start_of_user_area( the_block ) ); 246 } 252 ptr = _Heap_Start_of_user_area( the_block ); 253 } 254 255 /* 256 * round ptr up to a multiple of page size 257 * Have to save the bump amount in the buffer so that free can figure it out 258 */ 259 260 offset = the_heap->page_size - (((unsigned32) ptr) & (the_heap->page_size - 1)); 261 ptr += offset; 262 *(((unsigned32 *) ptr) - 1) = offset; 263 264 #ifdef RTEMS_DEBUG 265 { 266 unsigned32 ptr_u32; 267 ptr_u32 = (unsigned32) ptr; 268 if (ptr_u32 & (the_heap->page_size - 1)) 269 abort(); 270 } 271 #endif 272 273 return ptr; 247 274 } 248 275 … … 275 302 unsigned32 the_size; 276 303 277 the_block = _Heap_ Block_at( starting_address, - (sizeof( void * ) * 2));278 304 the_block = _Heap_User_Block_at( starting_address ); 305 279 306 if ( !_Heap_Is_block_in( the_heap, the_block ) || 280 307 _Heap_Is_block_free( the_block ) ) … … 320 347 unsigned32 the_size; 321 348 322 the_block = _Heap_ Block_at( starting_address, - (sizeof( void * ) * 2));349 the_block = _Heap_User_Block_at( starting_address ); 323 350 324 351 if ( !_Heap_Is_block_in( the_heap, the_block ) || -
c/src/exec/score/src/thread.c
r91a3554d rd434b8d6 465 465 the_thread->fp_context = NULL; 466 466 467 if ( the_thread->Start.fp_context ) 467 468 (void) _Workspace_Free( the_thread->Start.fp_context ); 468 469 -
cpukit/score/src/heap.c
r91a3554d rd434b8d6 15 15 16 16 #include <rtems/system.h> 17 #include <rtems/sysstate.h> 17 18 #include <rtems/core/heap.h> 18 #include <rtems/sysstate.h>19 19 20 20 /*PAGE … … 31 31 * 32 32 * Output parameters: 33 * returns - maximum memory available if successfully initialized33 * returns - maximum memory available if RTEMS_SUCCESSFUL 34 34 * 0 - otherwise 35 35 * … … 117 117 { 118 118 Heap_Block *the_block; 119 unsigned32 *p; 119 120 120 121 /* … … 174 175 /* 175 176 * Must pass in address of "user" area 176 */ 177 178 _Heap_Free( the_heap, &old_final->next ); 179 177 * So add in the offset field. 178 */ 179 180 p = (unsigned32 *) &old_final->next; 181 *p = sizeof(unsigned32); 182 p++; 183 _Heap_Free( the_heap, p ); 184 180 185 return HEAP_EXTEND_SUCCESSFUL; 181 186 } … … 206 211 Heap_Block *next_block; 207 212 Heap_Block *temporary_block; 208 213 void *ptr; 214 unsigned32 offset; 215 209 216 excess = size % the_heap->page_size; 210 the_size = size + HEAP_BLOCK_USED_OVERHEAD;211 217 the_size = size + the_heap->page_size + HEAP_BLOCK_USED_OVERHEAD; 218 212 219 if ( excess ) 213 220 the_size += the_heap->page_size - excess; … … 235 242 next_block->front_flag = _Heap_Build_flag( the_size, 236 243 HEAP_BLOCK_USED ); 237 return( _Heap_Start_of_user_area( next_block ));244 ptr = _Heap_Start_of_user_area( next_block ); 238 245 } else { 239 246 next_block = _Heap_Next_block( the_block ); … … 243 250 the_block->next->previous = the_block->previous; 244 251 the_block->previous->next = the_block->next; 245 return( _Heap_Start_of_user_area( the_block ) ); 246 } 252 ptr = _Heap_Start_of_user_area( the_block ); 253 } 254 255 /* 256 * round ptr up to a multiple of page size 257 * Have to save the bump amount in the buffer so that free can figure it out 258 */ 259 260 offset = the_heap->page_size - (((unsigned32) ptr) & (the_heap->page_size - 1)); 261 ptr += offset; 262 *(((unsigned32 *) ptr) - 1) = offset; 263 264 #ifdef RTEMS_DEBUG 265 { 266 unsigned32 ptr_u32; 267 ptr_u32 = (unsigned32) ptr; 268 if (ptr_u32 & (the_heap->page_size - 1)) 269 abort(); 270 } 271 #endif 272 273 return ptr; 247 274 } 248 275 … … 275 302 unsigned32 the_size; 276 303 277 the_block = _Heap_ Block_at( starting_address, - (sizeof( void * ) * 2));278 304 the_block = _Heap_User_Block_at( starting_address ); 305 279 306 if ( !_Heap_Is_block_in( the_heap, the_block ) || 280 307 _Heap_Is_block_free( the_block ) ) … … 320 347 unsigned32 the_size; 321 348 322 the_block = _Heap_ Block_at( starting_address, - (sizeof( void * ) * 2));349 the_block = _Heap_User_Block_at( starting_address ); 323 350 324 351 if ( !_Heap_Is_block_in( the_heap, the_block ) || -
cpukit/score/src/thread.c
r91a3554d rd434b8d6 465 465 the_thread->fp_context = NULL; 466 466 467 if ( the_thread->Start.fp_context ) 467 468 (void) _Workspace_Free( the_thread->Start.fp_context ); 468 469
Note: See TracChangeset
for help on using the changeset viewer.