Changeset d7205f0 in rtems


Ignore:
Timestamp:
Apr 8, 2020, 3:14:41 PM (22 months ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
0d83bed2
Parents:
3d0620b
git-author:
Sebastian Huber <sebastian.huber@…> (04/08/20 15:14:41)
git-committer:
Sebastian Huber <sebastian.huber@…> (11/30/21 07:33:12)
Message:

libc: Optimize malloc() initialization

The BSPs provide memory for the separate C Program Heap initialization
via _Memory_Get(). Most BSPs provide exactly one memory area. Only two
BSPs provide more than one memory area (arm/altera-cyclone-v and
bsps/powerpc/mpc55xxevb). Only if more than one memory area is
provided, there is a need to use _Heap_Extend(). Provide two
implementations to initialize the separate C Program Heap and let the
BSP select one of the implementations based on the number of provided
memory areas. This gets rid of a dependency on _Heap_Extend(). It
also avoids dead code sections for most BSPs.

Change licence to BSD-2-Clause according to file history.

Update #3053.

Files:
4 added
1 deleted
14 edited

Legend:

Unmodified
Added
Removed
  • cpukit/include/rtems/malloc.h

    r3d0620b rd7205f0  
    2020#include <rtems/bspIo.h>
    2121#include <rtems/libcsupport.h> /* for malloc_walk() */
    22 #include <rtems/score/memory.h>
    2322
    2423#include <stdint.h>
     
    4443extern Heap_Control *RTEMS_Malloc_Heap;
    4544
    46 Heap_Control *RTEMS_Malloc_Initialize(
    47   const Memory_Information              *mem,
    48   Heap_Initialization_or_extend_handler  extend
    49 );
     45void _Malloc_Initialize( void );
    5046
    5147void rtems_heap_set_sbrk_amount( ptrdiff_t sbrk_amount );
  • cpukit/libcsupport/src/mallocheap.c

    r3d0620b rd7205f0  
    4545Heap_Control *RTEMS_Malloc_Heap;
    4646
    47 static void _Malloc_Initialize( void )
     47void _Malloc_Initialize( void )
    4848{
    4949  RTEMS_Malloc_Heap = ( *_Workspace_Malloc_initializer )();
  • spec/build/bsps/arm/altera-cyclone-v/bspalteracyclonev.yml

    r3d0620b rd7205f0  
    140140- bsps/shared/start/bsp-fdt.c
    141141- bsps/shared/start/gettargethash-default.c
     142- bsps/shared/start/mallocinitmulti.c
    142143- bsps/shared/start/sbrk.c
    143144- bsps/shared/start/stackalloc.c
  • spec/build/bsps/arm/imx/bspimx.yml

    r3d0620b rd7205f0  
    107107- bsps/shared/start/bspfatal-default.c
    108108- bsps/shared/start/gettargethash-default.c
     109- bsps/shared/start/mallocinitone.c
    109110- bsps/shared/start/sbrk.c
    110111- bsps/shared/start/stackalloc.c
  • spec/build/bsps/arm/raspberrypi/obj.yml

    r3d0620b rd7205f0  
    5757- bsps/shared/start/bspfatal-default.c
    5858- bsps/shared/start/gettargethash-default.c
     59- bsps/shared/start/mallocinitone.c
    5960- bsps/shared/start/sbrk.c
    6061- bsps/shared/start/stackalloc.c
  • spec/build/bsps/i386/pc386/obj.yml

    r3d0620b rd7205f0  
    8181- bsps/shared/start/bspfatal-default.c
    8282- bsps/shared/start/gettargethash-default.c
     83- bsps/shared/start/mallocinitone.c
    8384- bsps/shared/start/sbrk.c
    8485- bsps/shared/start/wkspaceinitone.c
  • spec/build/bsps/objmem.yml

    r3d0620b rd7205f0  
    1212source:
    1313- bsps/shared/start/bspgetworkarea-default.c
     14- bsps/shared/start/mallocinitone.c
    1415- bsps/shared/start/wkspaceinitone.c
    1516type: build
  • spec/build/bsps/powerpc/mpc55xxevb/obj.yml

    r3d0620b rd7205f0  
    9595- bsps/shared/start/bspfatal-default.c
    9696- bsps/shared/start/gettargethash-default.c
     97- bsps/shared/start/mallocinitmulti.c
    9798- bsps/shared/start/stackalloc.c
    9899- bsps/shared/start/wkspaceinitmulti.c
  • spec/build/bsps/powerpc/objmem.yml

    r3d0620b rd7205f0  
    1212source:
    1313- bsps/powerpc/shared/start/bspgetworkarea.c
     14- bsps/shared/start/mallocinitone.c
    1415- bsps/shared/start/wkspaceinitone.c
    1516type: build
  • spec/build/bsps/powerpc/qoriq/obj.yml

    r3d0620b rd7205f0  
    7373- bsps/shared/start/bspfatal-default.c
    7474- bsps/shared/start/gettargethash-default.c
     75- bsps/shared/start/mallocinitone.c
    7576- bsps/shared/start/sbrk.c
    7677- bsps/shared/start/wkspaceinitone.c
  • spec/build/bsps/powerpc/tqm8xx/obj.yml

    r3d0620b rd7205f0  
    4747- bsps/shared/start/bspreset-empty.c
    4848- bsps/shared/start/gettargethash-default.c
     49- bsps/shared/start/mallocinitone.c
    4950- bsps/shared/start/sbrk.c
    5051- bsps/shared/start/wkspaceinitone.c
  • spec/build/bsps/sparc/objmem.yml

    r3d0620b rd7205f0  
    1111links: []
    1212source:
     13- bsps/shared/start/mallocinitone.c
    1314- bsps/shared/start/wkspaceinitone.c
    1415- bsps/sparc/shared/start/bspgetworkarea.c
  • spec/build/cpukit/librtemscpu.yml

    r3d0620b rd7205f0  
    676676- cpukit/libcsupport/src/malloc_deferred.c
    677677- cpukit/libcsupport/src/malloc_dirtier.c
    678 - cpukit/libcsupport/src/malloc_initialize.c
    679678- cpukit/libcsupport/src/malloc_walk.c
    680679- cpukit/libcsupport/src/mallocdirtydefault.c
  • testsuites/libtests/malloc04/init.c

    r3d0620b rd7205f0  
    7979{
    8080  Heap_Control *real_heap;
    81   Memory_Area area;
    82   Memory_Information mem = {
    83     .count = 1,
    84     .areas = &area
    85   };
     81  const Memory_Information *mem;
     82  Memory_Area *area;
     83  size_t i;
    8684
    8785  void *p;
    8886
    8987  TEST_BEGIN();
     88
     89  mem = _Memory_Get();
     90
     91  for ( i = 0; i < _Memory_Get_count( mem ); ++i ) {
     92    area = _Memory_Get_area( mem, i );
     93    _Memory_Initialize( area, NULL, NULL );
     94  }
     95
     96  area = _Memory_Get_area( mem, 0 );
    9097
    9198  /* Safe information on real heap */
     
    99106  sbrk_count = 0;
    100107  offset     = 256;
    101   _Memory_Initialize_by_size( &area, &Malloc_Heap[ 0 ], offset );
    102   RTEMS_Malloc_Initialize( &mem, NULL );
     108  _Memory_Initialize_by_size( area, &Malloc_Heap[ 0 ], offset );
     109  _Malloc_Initialize();
    103110
    104111  errno = 0;
     
    114121  sbrk_count = 0;
    115122  offset     = 256;
    116   _Memory_Initialize_by_size( &area, &Malloc_Heap[ 0 ], offset );
    117   RTEMS_Malloc_Initialize( &mem, NULL );
     123  _Memory_Initialize_by_size( area, &Malloc_Heap[ 0 ], offset );
     124  _Malloc_Initialize();
    118125
    119126  p = malloc(1);
     
    129136  sbrk_count = 0;
    130137  offset     = 256;
    131   _Memory_Initialize_by_size( &area, &Malloc_Heap[ 0 ], offset );
    132   RTEMS_Malloc_Initialize( &mem, NULL );
     138  _Memory_Initialize_by_size( area, &Malloc_Heap[ 0 ], offset );
     139  _Malloc_Initialize();
    133140
    134141  errno = 0;
     
    142149  sbrk_count = 0;
    143150  offset     = 256;
    144   _Memory_Initialize_by_size( &area, &Malloc_Heap[ 0 ], offset );
    145   RTEMS_Malloc_Initialize( &mem, NULL );
     151  _Memory_Initialize_by_size( area, &Malloc_Heap[ 0 ], offset );
     152  _Malloc_Initialize();
    146153
    147154  p = malloc( 128 );
     
    157164  sbrk_count = -1;
    158165  offset     = 256;
    159   _Memory_Initialize_by_size( &area, &Malloc_Heap[ 0 ], offset );
    160   RTEMS_Malloc_Initialize( &mem, NULL );
     166  _Memory_Initialize_by_size( area, &Malloc_Heap[ 0 ], offset );
     167  _Malloc_Initialize();
    161168
    162169  errno = 0;
Note: See TracChangeset for help on using the changeset viewer.