summaryrefslogtreecommitdiffstats
path: root/cpukit/libcsupport/src/rtems_malloc.c
blob: a71d8cbfb3e383ba9c8037bee28ad58e7178b505 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/**
 * @file
 *
 * @ingroup libcsupport
 *
 * @brief rtems_malloc() implementation.
 */

/*
 * Copyright (c) 2009
 * embedded brains GmbH
 * Obere Lagerstr. 30
 * D-82178 Puchheim
 * Germany
 * <rtems@embedded-brains.de>
 *
 * The license and distribution terms for this file may be
 * found in the file LICENSE in this distribution or at
 * http://www.rtems.com/license/LICENSE.
 *
 * $Id$
 */

#if HAVE_CONFIG_H
#include "config.h"
#endif

#ifdef RTEMS_NEWLIB
#include "malloc_p.h"

#include <stdlib.h>
#include <errno.h>

void *rtems_malloc(size_t size, uintptr_t alignment, uintptr_t boundary)
{
  void *p = NULL;

  _RTEMS_Lock_allocator();
   p = _Heap_Allocate_aligned_with_boundary(
     RTEMS_Malloc_Heap,
     size,
     alignment,
     boundary
   );
  _RTEMS_Unlock_allocator();

  return p;
}

#endif