Changeset d434b8d6 in rtems


Ignore:
Timestamp:
Sep 19, 1995, 9:43:45 PM (25 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 4.8, 4.9, 5, master
Children:
2122a0b
Parents:
91a3554d
Message:

Modifications from Tony Bennett accepted to return aligned block.

Thread_Close fixed to avoid returning FP context area when one was not
allocated at initialization time.

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • c/src/exec/score/src/heap.c

    r91a3554d rd434b8d6  
    1515
    1616#include <rtems/system.h>
     17#include <rtems/sysstate.h>
    1718#include <rtems/core/heap.h>
    18 #include <rtems/sysstate.h>
    1919
    2020/*PAGE
     
    3131 *
    3232 *  Output parameters:
    33  *    returns - maximum memory available if successfully initialized
     33 *    returns - maximum memory available if RTEMS_SUCCESSFUL
    3434 *    0       - otherwise
    3535 *
     
    117117{
    118118  Heap_Block        *the_block;
     119  unsigned32        *p;
    119120 
    120121  /*
     
    174175  /*
    175176   *  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 
    180185  return HEAP_EXTEND_SUCCESSFUL;
    181186}
     
    206211  Heap_Block *next_block;
    207212  Heap_Block *temporary_block;
    208 
     213  void       *ptr;
     214  unsigned32  offset;
     215 
    209216  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 
    212219  if ( excess )
    213220    the_size += the_heap->page_size - excess;
     
    235242    next_block->front_flag     = _Heap_Build_flag( the_size,
    236243                                    HEAP_BLOCK_USED );
    237     return( _Heap_Start_of_user_area( next_block ) );
     244    ptr = _Heap_Start_of_user_area( next_block );
    238245  } else {
    239246    next_block                = _Heap_Next_block( the_block );
     
    243250    the_block->next->previous = the_block->previous;
    244251    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;
    247274}
    248275
     
    275302  unsigned32         the_size;
    276303
    277   the_block = _Heap_Block_at( starting_address, - (sizeof( void * ) * 2) );
    278 
     304  the_block = _Heap_User_Block_at( starting_address );
     305 
    279306  if ( !_Heap_Is_block_in( the_heap, the_block ) ||
    280307        _Heap_Is_block_free( the_block ) )
     
    320347  unsigned32         the_size;
    321348
    322   the_block = _Heap_Block_at( starting_address, - (sizeof( void * ) * 2) );
     349  the_block = _Heap_User_Block_at( starting_address );
    323350
    324351  if ( !_Heap_Is_block_in( the_heap, the_block ) ||
  • c/src/exec/score/src/thread.c

    r91a3554d rd434b8d6  
    465465  the_thread->fp_context = NULL;
    466466
     467  if ( the_thread->Start.fp_context )
    467468  (void) _Workspace_Free( the_thread->Start.fp_context );
    468469
  • cpukit/score/src/heap.c

    r91a3554d rd434b8d6  
    1515
    1616#include <rtems/system.h>
     17#include <rtems/sysstate.h>
    1718#include <rtems/core/heap.h>
    18 #include <rtems/sysstate.h>
    1919
    2020/*PAGE
     
    3131 *
    3232 *  Output parameters:
    33  *    returns - maximum memory available if successfully initialized
     33 *    returns - maximum memory available if RTEMS_SUCCESSFUL
    3434 *    0       - otherwise
    3535 *
     
    117117{
    118118  Heap_Block        *the_block;
     119  unsigned32        *p;
    119120 
    120121  /*
     
    174175  /*
    175176   *  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 
    180185  return HEAP_EXTEND_SUCCESSFUL;
    181186}
     
    206211  Heap_Block *next_block;
    207212  Heap_Block *temporary_block;
    208 
     213  void       *ptr;
     214  unsigned32  offset;
     215 
    209216  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 
    212219  if ( excess )
    213220    the_size += the_heap->page_size - excess;
     
    235242    next_block->front_flag     = _Heap_Build_flag( the_size,
    236243                                    HEAP_BLOCK_USED );
    237     return( _Heap_Start_of_user_area( next_block ) );
     244    ptr = _Heap_Start_of_user_area( next_block );
    238245  } else {
    239246    next_block                = _Heap_Next_block( the_block );
     
    243250    the_block->next->previous = the_block->previous;
    244251    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;
    247274}
    248275
     
    275302  unsigned32         the_size;
    276303
    277   the_block = _Heap_Block_at( starting_address, - (sizeof( void * ) * 2) );
    278 
     304  the_block = _Heap_User_Block_at( starting_address );
     305 
    279306  if ( !_Heap_Is_block_in( the_heap, the_block ) ||
    280307        _Heap_Is_block_free( the_block ) )
     
    320347  unsigned32         the_size;
    321348
    322   the_block = _Heap_Block_at( starting_address, - (sizeof( void * ) * 2) );
     349  the_block = _Heap_User_Block_at( starting_address );
    323350
    324351  if ( !_Heap_Is_block_in( the_heap, the_block ) ||
  • cpukit/score/src/thread.c

    r91a3554d rd434b8d6  
    465465  the_thread->fp_context = NULL;
    466466
     467  if ( the_thread->Start.fp_context )
    467468  (void) _Workspace_Free( the_thread->Start.fp_context );
    468469
Note: See TracChangeset for help on using the changeset viewer.