source: rtems/cpukit/libcsupport/src/malloc_initialize.c @ 1c6926c1

5
Last change on this file since 1c6926c1 was 3a659b04, checked in by Sebastian Huber <sebastian.huber@…>, on 12/09/16 at 06:19:22

score: Introduce _Internal_error()

  • Property mode set to 100644
File size: 1.4 KB
Line 
1/**
2 * @file
3 *
4 * @brief RTEMS_Malloc_Initialize() implementation.
5 */
6
7/*
8 *  COPYRIGHT (c) 1989-2012.
9 *  On-Line Applications Research Corporation (OAR).
10 *
11 *  The license and distribution terms for this file may be
12 *  found in the file LICENSE in this distribution or at
13 *  http://www.rtems.org/license/LICENSE.
14 */
15
16#if HAVE_CONFIG_H
17  #include "config.h"
18#endif
19
20#include <rtems/malloc.h>
21
22#include "malloc_p.h"
23
24#ifdef RTEMS_NEWLIB
25void RTEMS_Malloc_Initialize(
26  const Heap_Area *areas,
27  size_t area_count,
28  Heap_Initialization_or_extend_handler extend
29)
30{
31  Heap_Control *heap = RTEMS_Malloc_Heap;
32
33  if ( !rtems_configuration_get_unified_work_area() ) {
34    Heap_Initialization_or_extend_handler init_or_extend = _Heap_Initialize;
35    uintptr_t page_size = CPU_HEAP_ALIGNMENT;
36    size_t i;
37
38    for (i = 0; i < area_count; ++i) {
39      const Heap_Area *area = &areas [i];
40      uintptr_t space_available = (*init_or_extend)(
41        heap,
42        area->begin,
43        area->size,
44        page_size
45      );
46
47      if ( space_available > 0 ) {
48        init_or_extend = extend;
49      }
50    }
51
52    if ( init_or_extend == _Heap_Initialize ) {
53      _Internal_error( INTERNAL_ERROR_NO_MEMORY_FOR_HEAP );
54    }
55  }
56}
57#else
58void RTEMS_Malloc_Initialize(
59  Heap_Area *areas,
60  size_t area_count,
61  Heap_Initialization_or_extend_handler extend
62)
63{
64  /* FIXME: Dummy function */
65}
66#endif
Note: See TracBrowser for help on using the repository browser.