diff options
author | Ayrton Munoz <ayrton@google.com> | 2022-09-23 03:27:23 -0400 |
---|---|---|
committer | Ayrton Munoz <ayrton@google.com> | 2022-09-28 13:56:07 -0400 |
commit | 80dc5addb6cdb1d4c689e9a3e66a19ea248ca8d2 (patch) | |
tree | 927aa73792a76708995cf27c75956e675dbb4f6e /lib | |
parent | 767c4f26bff56e626723092d83224befd2d21025 (diff) | |
download | common-80dc5addb6cdb1d4c689e9a3e66a19ea248ca8d2.tar.gz |
Switch to PRIxPTR format specifier macros
LK defines uintptr_t as `unsigned long` for every arch, but
musl defines it as `unsigned int` for ARM so this switches
%lx to PRIxPTR when printing `uintptr_t`s. It also adds PRI
macros for the paddr_t, vaddr_t and addr_t typedefs and
changes the definition of PRIxPTR_USER when IS_64BIT is
false.
Bug: 230134581
Change-Id: I8bb5adef690a65adf426816f51313db3b1df9c3a
Diffstat (limited to 'lib')
-rw-r--r-- | lib/debug/debug.c | 3 | ||||
-rw-r--r-- | lib/heap/miniheap/miniheap.c | 9 |
2 files changed, 7 insertions, 5 deletions
diff --git a/lib/debug/debug.c b/lib/debug/debug.c index 084b6c2c..a6e609a1 100644 --- a/lib/debug/debug.c +++ b/lib/debug/debug.c @@ -34,6 +34,7 @@ #include <platform/debug.h> #include <kernel/spinlock.h> #include <kernel/thread.h> +#include <inttypes.h> void spin(uint32_t usecs) { @@ -133,7 +134,7 @@ void hexdump(const void *ptr, size_t len) size_t s = round_up(MIN(len - count, 16), 4); size_t i; - printf("0x%08lx: ", address); + printf("0x%08" PRIxADDR ": ", address); for (i = 0; i < s / 4; i++) { u.buf[i] = ((const uint32_t *)address)[i]; printf("%08x ", u.buf[i]); diff --git a/lib/heap/miniheap/miniheap.c b/lib/heap/miniheap/miniheap.c index ac705cf5..51f9412c 100644 --- a/lib/heap/miniheap/miniheap.c +++ b/lib/heap/miniheap/miniheap.c @@ -34,6 +34,7 @@ #include <lib/miniheap.h> #include <lib/heap.h> #include <lib/page_alloc.h> +#include <inttypes.h> #define LOCAL_TRACE 0 @@ -84,7 +85,7 @@ static ssize_t heap_grow(size_t len); static void dump_free_chunk(struct free_heap_chunk *chunk) { - dprintf(INFO, "\t\tbase %p, end 0x%lx, len 0x%zx\n", chunk, (vaddr_t)chunk + chunk->len, chunk->len); + dprintf(INFO, "\t\tbase %p, end 0x%" PRIxVADDR ", len 0x%zx\n", chunk, (vaddr_t)chunk + chunk->len, chunk->len); } void miniheap_dump(void) @@ -402,12 +403,12 @@ void miniheap_trim(void) DEBUG_ASSERT(end_page <= end); DEBUG_ASSERT(start_page >= start); - LTRACEF("start page 0x%lx, end page 0x%lx\n", start_page, end_page); + LTRACEF("start page 0x%" PRIxPTR ", end page 0x%" PRIxPTR "\n", start_page, end_page); retry: // see if the free block encompasses at least one page if (unlikely(end_page > start_page)) { - LTRACEF("could trim: start 0x%lx, end 0x%lx\n", start_page, end_page); + LTRACEF("could trim: start 0x%" PRIxPTR ", end 0x%" PRIxPTR "\n", start_page, end_page); // cases where the start of the block is already page aligned if (start_page == start) { @@ -462,7 +463,7 @@ retry: free_chunk: // return it to the allocator - LTRACEF("returning %p size 0x%lx to the page allocator\n", (void *)start_page, end_page - start_page); + LTRACEF("returning %p size 0x%" PRIxPTR " to the page allocator\n", (void *)start_page, end_page - start_page); page_free((void *)start_page, (end_page - start_page) / PAGE_SIZE); // tweak accounting |