mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2026-08-29 11:59:27 +08:00
2009-11-11 Sebastian Huber <sebastian.huber@embedded-brains.de>
* libcsupport/Makefile.am, libcsupport/include/rtems/malloc.h, libcsupport/src/rtems_malloc.c: New function rtems_malloc().
This commit is contained in:
@@ -1,3 +1,8 @@
|
||||
2009-11-11 Sebastian Huber <sebastian.huber@embedded-brains.de>
|
||||
|
||||
* libcsupport/Makefile.am, libcsupport/include/rtems/malloc.h,
|
||||
libcsupport/src/rtems_malloc.c: New function rtems_malloc().
|
||||
|
||||
2009-11-11 Jennifer Averett <jennifer.averett@OARcorp.com>
|
||||
|
||||
PR 1471/cpukit
|
||||
|
||||
@@ -90,7 +90,8 @@ MALLOC_C_FILES = src/malloc_initialize.c src/calloc.c src/malloc.c \
|
||||
src/malloc_report_statistics.c src/malloc_report_statistics_plugin.c \
|
||||
src/malloc_statistics_helpers.c src/malloc_boundary.c \
|
||||
src/posix_memalign.c src/rtems_memalign.c src/malloc_deferred.c \
|
||||
src/malloc_sbrk_helpers.c src/malloc_dirtier.c src/malloc_p.h
|
||||
src/malloc_sbrk_helpers.c src/malloc_dirtier.c src/malloc_p.h \
|
||||
src/rtems_malloc.c
|
||||
|
||||
PASSWORD_GROUP_C_FILES = src/getpwent.c
|
||||
|
||||
|
||||
@@ -149,6 +149,28 @@ int rtems_memalign(
|
||||
size_t size
|
||||
);
|
||||
|
||||
/**
|
||||
* @brief Allocates a memory area of size @a size bytes from the heap.
|
||||
*
|
||||
* If the alignment parameter @a alignment is not equal to zero, the allocated
|
||||
* memory area will begin at an address aligned by this value.
|
||||
*
|
||||
* If the boundary parameter @a boundary is not equal to zero, the allocated
|
||||
* memory area will fulfill a boundary constraint. The boundary value
|
||||
* specifies the set of addresses which are aligned by the boundary value. The
|
||||
* interior of the allocated memory area will not contain an element of this
|
||||
* set. The begin or end address of the area may be a member of the set.
|
||||
*
|
||||
* A size value of zero will return a unique address which may be freed with
|
||||
* free().
|
||||
*
|
||||
* The memory allocated by this function can be released with a call to free().
|
||||
*
|
||||
* @return A pointer to the begin of the allocated memory area, or @c NULL if
|
||||
* no memory is available or the parameters are inconsistent.
|
||||
*/
|
||||
void *rtems_malloc(size_t size, uintptr_t alignment, uintptr_t boundary);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,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
|
||||
Reference in New Issue
Block a user