X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=include%2Fmalloc.h;h=1fbaf3755c7aa2b1f4bd1b3804ae06d3d3ff047a;hb=0f9595b9fa68ed1634adddf989fd037909eec433;hp=5df634873f147f93fb444b9621abf07e1e6e21e1;hpb=1fc4e6f486cc1e9d2dcf0ba86e6021c3d83dce51;p=platform%2Fkernel%2Fu-boot.git diff --git a/include/malloc.h b/include/malloc.h index 5df6348..1fbaf37 100644 --- a/include/malloc.h +++ b/include/malloc.h @@ -1,12 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ /* - A version of malloc/free/realloc written by Doug Lea and released to the - public domain. Send questions/comments/complaints/performance data - to dl@cs.oswego.edu + This code is based on a version of malloc/free/realloc written by Doug Lea and + released to the public domain. Send questions/comments/complaints/performance + data to dl@cs.oswego.edu * VERSION 2.6.6 Sun Mar 5 19:10:03 2000 Doug Lea (dl at gee) Note: There may be an updated version of this malloc obtainable at - ftp://g.oswego.edu/pub/misc/malloc.c + http://g.oswego.edu/pub/misc/malloc.c Check before installing! * Why use this malloc? @@ -361,8 +362,11 @@ extern "C" { #if (__STD_C || defined(HAVE_MEMCPY)) #if __STD_C +/* U-Boot defines memset() and memcpy in /include/linux/string.h void* memset(void*, int, size_t); void* memcpy(void*, const void*, size_t); +*/ +#include #else #ifdef WIN32 /* On Win32 platforms, 'memset()' and 'memcpy()' are already declared in */ @@ -788,8 +792,13 @@ struct mallinfo { */ -/* #define USE_DL_PREFIX */ - +/* + * Rename the U-Boot alloc functions so that sandbox can still use the system + * ones + */ +#ifdef CONFIG_SANDBOX +#define USE_DL_PREFIX +#endif /* @@ -872,13 +881,14 @@ extern Void_t* sbrk(); #else -#ifdef CONFIG_SYS_MALLOC_SIMPLE +void malloc_simple_info(void); + +#if CONFIG_IS_ENABLED(SYS_MALLOC_SIMPLE) #define malloc malloc_simple #define realloc realloc_simple #define memalign memalign_simple static inline void free(void *ptr) {} void *calloc(size_t nmemb, size_t size); -void *memalign_simple(size_t alignment, size_t bytes); void *realloc_simple(void *ptr, size_t size); #else @@ -892,6 +902,21 @@ void *realloc_simple(void *ptr, size_t size); # define pvALLOc dlpvalloc # define mALLINFo dlmallinfo # define mALLOPt dlmallopt + +/* Ensure that U-Boot actually uses these too */ +#define calloc dlcalloc +#define free(ptr) dlfree(ptr) +#define malloc(x) dlmalloc(x) +#define memalign dlmemalign +#define realloc dlrealloc +#define valloc dlvalloc +#define pvalloc dlpvalloc +#define mallinfo() dlmallinfo() +#define mallopt dlmallopt +#define malloc_trim dlmalloc_trim +#define malloc_usable_size dlmalloc_usable_size +#define malloc_stats dlmalloc_stats + # else /* USE_DL_PREFIX */ # define cALLOc calloc # define fREe free @@ -906,11 +931,16 @@ void *realloc_simple(void *ptr, size_t size); #endif +/* Set up pre-relocation malloc() ready for use */ +int initf_malloc(void); + /* Public routines */ /* Simple versions which can be used when space is tight */ void *malloc_simple(size_t size); +void *memalign_simple(size_t alignment, size_t bytes); +#pragma GCC visibility push(hidden) # if __STD_C Void_t* mALLOc(size_t); @@ -942,6 +972,7 @@ int mALLOPt(); struct mallinfo mALLINFo(); # endif #endif +#pragma GCC visibility pop /* * Begin and End of memory area for malloc(), and current "brk"