source: rtems/cpukit/score/src/heapgetinfo.c @ 749d64a

4.104.115
Last change on this file since 749d64a was dea3eccb, checked in by Joel Sherrill <joel.sherrill@…>, on 09/06/09 at 15:24:08

2009-09-06 Sebastian Huber <Sebastian.Huber@…>

  • libcsupport/src/free.c, libmisc/stackchk/check.c, rtems/include/rtems/rtems/region.h, rtems/src/regioncreate.c, rtems/src/regionextend.c, rtems/src/regiongetinfo.c, rtems/src/regiongetsegment.c, rtems/src/regiongetsegmentsize.c, rtems/src/regionresizesegment.c, score/src/pheapallocate.c, score/src/pheapallocatealigned.c, score/src/pheapextend.c, score/src/pheapfree.c, score/src/pheapgetblocksize.c, score/src/pheapgetfreeinfo.c, score/src/pheapgetinfo.c, score/src/pheapgetsize.c, score/src/pheapinit.c, score/src/pheapresizeblock.c, score/src/pheapwalk.c: Update for heap API changes.
  • score/include/rtems/score/apimutex.h, score/include/rtems/score/object.h: Documentation.
  • score/include/rtems/score/heap.h, score/include/rtems/score/protectedheap.h, score/inline/rtems/score/heap.inl, score/src/heap.c, score/src/heapallocate.c, score/src/heapallocatealigned.c, score/src/heapextend.c, score/src/heapfree.c, score/src/heapgetfreeinfo.c, score/src/heapgetinfo.c, score/src/heapresizeblock.c, score/src/heapsizeofuserarea.c, score/src/heapwalk.c: Overall cleanup. Added boundary constraint to allocation function. More changes follow.
  • Property mode set to 100644
File size: 1.6 KB
Line 
1/**
2 * @file
3 *
4 * @ingroup ScoreHeap
5 *
6 * @brief Heap Handler implementation.
7 */
8
9/*
10 *  COPYRIGHT (c) 1989-2009.
11 *  On-Line Applications Research Corporation (OAR).
12 *
13 *  The license and distribution terms for this file may be
14 *  found in the file LICENSE in this distribution or at
15 *  http://www.rtems.com/license/LICENSE.
16 *
17 *  $Id$
18 */
19
20#if HAVE_CONFIG_H
21#include "config.h"
22#endif
23
24#include <rtems/system.h>
25#include <rtems/score/sysstate.h>
26#include <rtems/score/heap.h>
27
28void _Heap_Get_information(
29  Heap_Control            *the_heap,
30  Heap_Information_block  *the_info
31)
32{
33  Heap_Block *the_block = the_heap->first_block;
34  Heap_Block *const end = the_heap->last_block;
35
36  _HAssert(the_block->prev_size == the_heap->page_size);
37  _HAssert(_Heap_Is_prev_used(the_block));
38
39  the_info->Free.number  = 0;
40  the_info->Free.total   = 0;
41  the_info->Free.largest = 0;
42  the_info->Used.number  = 0;
43  the_info->Used.total   = 0;
44  the_info->Used.largest = 0;
45
46  while ( the_block != end ) {
47    uintptr_t const     the_size = _Heap_Block_size(the_block);
48    Heap_Block *const  next_block = _Heap_Block_at(the_block, the_size);
49    Heap_Information  *info;
50
51    if ( _Heap_Is_prev_used(next_block) )
52      info = &the_info->Used;
53    else
54      info = &the_info->Free;
55
56    info->number++;
57    info->total += the_size;
58    if ( info->largest < the_size )
59      info->largest = the_size;
60
61    the_block = next_block;
62  }
63
64  /*
65   *  Handle the last dummy block. Don't consider this block to be
66   *  "used" as client never allocated it. Make 'Used.total' contain this
67   *  blocks' overhead though.
68   */
69  the_info->Used.total += HEAP_BLOCK_HEADER_SIZE;
70}
Note: See TracBrowser for help on using the repository browser.