Changeset a49bc35 in rtems


Ignore:
Timestamp:
Jan 28, 2014, 10:49:57 AM (5 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, master
Children:
16a41cc
Parents:
a850d04
git-author:
Sebastian Huber <sebastian.huber@…> (01/28/14 10:49:57)
git-committer:
Sebastian Huber <sebastian.huber@…> (02/04/14 09:06:34)
Message:

score: Add _Heap_Size_with_overhead()

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • cpukit/score/include/rtems/score/heap.h

    ra850d04 ra49bc35  
    465465}
    466466
     467/**
     468 * @brief Returns the size with administration and alignment overhead for one
     469 * allocation.
     470 */
     471RTEMS_INLINE_ROUTINE uintptr_t _Heap_Size_with_overhead(
     472  uintptr_t page_size,
     473  uintptr_t size,
     474  uintptr_t alignment
     475)
     476{
     477  if ( page_size != 0 ) {
     478    page_size = _Heap_Align_up( page_size, CPU_ALIGNMENT );
     479  } else {
     480    page_size = CPU_ALIGNMENT;
     481  }
     482
     483  if ( page_size < alignment ) {
     484    page_size = alignment;
     485  }
     486
     487  return HEAP_BLOCK_HEADER_SIZE + page_size - 1 + size;
     488}
     489
    467490/** @} */
    468491
  • testsuites/libtests/malloctest/init.c

    ra850d04 ra49bc35  
    11581158}
    11591159
     1160static void test_heap_size_with_overhead(void)
     1161{
     1162  uintptr_t s;
     1163
     1164  puts( "_Heap_Size_with_overhead" );
     1165
     1166  s = _Heap_Size_with_overhead(0, 0, 0);
     1167  rtems_test_assert(s == HEAP_BLOCK_HEADER_SIZE + CPU_ALIGNMENT - 1);
     1168
     1169  s = _Heap_Size_with_overhead(CPU_ALIGNMENT, 0, 0);
     1170  rtems_test_assert(s == HEAP_BLOCK_HEADER_SIZE + CPU_ALIGNMENT - 1);
     1171
     1172  s = _Heap_Size_with_overhead(CPU_ALIGNMENT, 0, 2 * CPU_ALIGNMENT);
     1173  rtems_test_assert(s == HEAP_BLOCK_HEADER_SIZE + 2 * CPU_ALIGNMENT - 1);
     1174
     1175  s = _Heap_Size_with_overhead(CPU_ALIGNMENT, 123, 0);
     1176  rtems_test_assert(s == HEAP_BLOCK_HEADER_SIZE + CPU_ALIGNMENT - 1 + 123);
     1177}
     1178
    11601179/*
    11611180 *  A simple test of posix_memalign
     
    12691288  test_heap_no_extend();
    12701289  test_heap_info();
     1290  test_heap_size_with_overhead();
    12711291  test_protected_heap_info();
    12721292  test_rtems_heap_allocate_aligned_with_boundary();
  • testsuites/libtests/malloctest/malloctest.scn

    ra850d04 ra49bc35  
    6060malloc_info - check free space drops after malloc
    6161malloc_info - verify free space returns to previous value
     62_Heap_Size_with_overhead
    6263_Protected_heap_Get_information - NULL heap
    6364_Protected_heap_Get_information - NULL info
Note: See TracChangeset for help on using the changeset viewer.