Move aligned_alloc, posix_memalign and valloc from mm/umm to libs/libc/stdlib

since the similar functions(e.g. strdup/strndup) put into libs/libc/string

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: Ifb2c0c51298b09014748e5ee8275db51213d6911
This commit is contained in:
Xiang Xiao 2021-06-30 20:10:10 -07:00 committed by David Sidrane
parent 1d0ade6fa2
commit 187538c0b9
5 changed files with 14 additions and 8 deletions

View File

@ -26,6 +26,7 @@ CSRCS += lib_itoa.c lib_labs.c lib_llabs.c lib_realpath.c lib_bsearch.c
CSRCS += lib_rand.c lib_qsort.c lib_srand.c lib_strtol.c CSRCS += lib_rand.c lib_qsort.c lib_srand.c lib_strtol.c
CSRCS += lib_strtoll.c lib_strtoul.c lib_strtoull.c lib_strtod.c lib_strtof.c CSRCS += lib_strtoll.c lib_strtoul.c lib_strtoull.c lib_strtod.c lib_strtof.c
CSRCS += lib_strtold.c lib_checkbase.c lib_mktemp.c lib_mkstemp.c lib_mkdtemp.c CSRCS += lib_strtold.c lib_checkbase.c lib_mktemp.c lib_mkstemp.c lib_mkdtemp.c
CSRCS += lib_aligned_alloc.c lib_posix_memalign.c lib_valloc.c
ifeq ($(CONFIG_LIBC_WCHAR),y) ifeq ($(CONFIG_LIBC_WCHAR),y)
CSRCS += lib_mblen.c lib_mbtowc.c lib_wctomb.c CSRCS += lib_mblen.c lib_mbtowc.c lib_wctomb.c

View File

@ -1,5 +1,5 @@
/**************************************************************************** /****************************************************************************
* mm/umm_heap/umm_aligned_alloc.c * libs/libc/stdlib/lib_aligned_alloc.c
* *
* Licensed to the Apache Software Foundation (ASF) under one or more * Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with * contributor license agreements. See the NOTICE file distributed with
@ -24,11 +24,13 @@
#include <stdlib.h> #include <stdlib.h>
#include "libc.h"
/**************************************************************************** /****************************************************************************
* Public Functions * Public Functions
****************************************************************************/ ****************************************************************************/
FAR void *aligned_alloc(size_t align, size_t size) FAR void *aligned_alloc(size_t align, size_t size)
{ {
return memalign(align, size); return lib_memalign(align, size);
} }

View File

@ -1,5 +1,5 @@
/**************************************************************************** /****************************************************************************
* mm/umm_heap/umm_posix_memalign.c * libs/libc/stdlib/lib_posix_memalign.c
* *
* Licensed to the Apache Software Foundation (ASF) under one or more * Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with * contributor license agreements. See the NOTICE file distributed with
@ -25,12 +25,14 @@
#include <stdlib.h> #include <stdlib.h>
#include <errno.h> #include <errno.h>
#include "libc.h"
/**************************************************************************** /****************************************************************************
* Public Functions * Public Functions
****************************************************************************/ ****************************************************************************/
int posix_memalign(FAR void **mem, size_t align, size_t size) int posix_memalign(FAR void **mem, size_t align, size_t size)
{ {
*mem = memalign(align, size); *mem = lib_memalign(align, size);
return *mem ? OK : ENOMEM; return *mem ? OK : ENOMEM;
} }

View File

@ -1,5 +1,5 @@
/**************************************************************************** /****************************************************************************
* mm/umm_heap/umm_valloc.c * libs/libc/stdlib/lib_valloc.c
* *
* Licensed to the Apache Software Foundation (ASF) under one or more * Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with * contributor license agreements. See the NOTICE file distributed with
@ -25,6 +25,8 @@
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#include "libc.h"
/**************************************************************************** /****************************************************************************
* Public Functions * Public Functions
****************************************************************************/ ****************************************************************************/
@ -49,5 +51,5 @@
FAR void *valloc(size_t size) FAR void *valloc(size_t size)
{ {
return memalign(sysconf(_SC_PAGESIZE), size); return lib_memalign(sysconf(_SC_PAGESIZE), size);
} }

View File

@ -20,10 +20,9 @@
# User heap allocator # User heap allocator
CSRCS += umm_initialize.c umm_addregion.c CSRCS += umm_globals.c umm_initialize.c umm_addregion.c
CSRCS += umm_brkaddr.c umm_calloc.c umm_extend.c umm_free.c umm_mallinfo.c CSRCS += umm_brkaddr.c umm_calloc.c umm_extend.c umm_free.c umm_mallinfo.c
CSRCS += umm_malloc.c umm_memalign.c umm_realloc.c umm_zalloc.c umm_heapmember.c CSRCS += umm_malloc.c umm_memalign.c umm_realloc.c umm_zalloc.c umm_heapmember.c
CSRCS += umm_globals.c umm_valloc.c umm_aligned_alloc.c umm_posix_memalign.c
ifeq ($(CONFIG_BUILD_KERNEL),y) ifeq ($(CONFIG_BUILD_KERNEL),y)
CSRCS += umm_sbrk.c CSRCS += umm_sbrk.c