diff options
author | Simon Glass <sjg@chromium.org> | 2023-01-15 14:15:45 -0700 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2023-02-11 12:22:34 -0500 |
commit | 90ad4e28e8d299395922364409c37bd7afc293e4 (patch) | |
tree | 8e403d1a0a68676a46af8c9ada2f5f98d06b668f /lib/abuf.c | |
parent | c33425c6f960944ba88104f281217de5a89a5562 (diff) | |
download | u-boot-90ad4e28e8d299395922364409c37bd7afc293e4.tar.gz u-boot-90ad4e28e8d299395922364409c37bd7afc293e4.tar.bz2 u-boot-90ad4e28e8d299395922364409c37bd7afc293e4.zip |
abuf: Support use from tools
Update the code slightly so that abuf can be used in U-Boot tools. It will
soon be needed for proftool.
Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'lib/abuf.c')
-rw-r--r-- | lib/abuf.c | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/lib/abuf.c b/lib/abuf.c index 1635d58682..bd270467dd 100644 --- a/lib/abuf.c +++ b/lib/abuf.c @@ -6,11 +6,14 @@ * Written by Simon Glass <sjg@chromium.org> */ +#ifndef USE_HOSTCC #include <common.h> -#include <abuf.h> #include <malloc.h> #include <mapmem.h> #include <string.h> +#endif + +#include <abuf.h> void abuf_set(struct abuf *abuf, void *data, size_t size) { @@ -19,10 +22,26 @@ void abuf_set(struct abuf *abuf, void *data, size_t size) abuf->size = size; } +#ifndef USE_HOSTCC void abuf_map_sysmem(struct abuf *abuf, ulong addr, size_t size) { abuf_set(abuf, map_sysmem(addr, size), size); } +#else +/* copied from lib/string.c for convenience */ +static char *memdup(const void *src, size_t len) +{ + char *p; + + p = malloc(len); + if (!p) + return NULL; + + memcpy(p, src, len); + + return p; +} +#endif bool abuf_realloc(struct abuf *abuf, size_t new_size) { |