aboutsummaryrefslogtreecommitdiff
path: root/include/malloc.h
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2020-02-03 07:35:58 -0700
committerSimon Glass <sjg@chromium.org>2020-02-05 19:33:46 -0700
commitcfda60f99ae237494e9341aad9676152d3bac3c9 (patch)
tree86f56de564e820f72b80c76c04b655ea9193ad6f /include/malloc.h
parentcf23c7c1dd11ca8f47bb7146c72729efc81eafd0 (diff)
downloadu-boot-cfda60f99ae237494e9341aad9676152d3bac3c9.zip
u-boot-cfda60f99ae237494e9341aad9676152d3bac3c9.tar.gz
u-boot-cfda60f99ae237494e9341aad9676152d3bac3c9.tar.bz2
sandbox: Use a prefix for all allocation functions
In order to allow use of both U-Boot's malloc() and the C library's version, set a prefix for the allocation functions so that they can co-exist. This is only done for sandbox. For other archs everything remains the same. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'include/malloc.h')
-rw-r--r--include/malloc.h24
1 files changed, 22 insertions, 2 deletions
diff --git a/include/malloc.h b/include/malloc.h
index 5efa692..f66c2e8 100644
--- a/include/malloc.h
+++ b/include/malloc.h
@@ -788,8 +788,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
/*
@@ -892,6 +897,21 @@ void malloc_simple_info(void);
# 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