summaryrefslogtreecommitdiffstats
path: root/src/vppinfra/std-formats.c
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2023-04-04 17:06:26 +0000
committerOle Tr�an <otroan@employees.org>2023-04-06 08:00:08 +0000
commit5294cdc79213a8703f70d9a300b0c5806c788ca4 (patch)
treedcf97886f8331b832a46ca71e9f4bb5a61358373 /src/vppinfra/std-formats.c
parent1315d14d4c022d6fcfe43e6223b8ff557508b31f (diff)
vppinfra: refactor uword bitmaps
Type: improvement Change-Id: I4f05a0435825cd23b8ad8a6f8f1397e60c522319 Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/vppinfra/std-formats.c')
-rw-r--r--src/vppinfra/std-formats.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/vppinfra/std-formats.c b/src/vppinfra/std-formats.c
index bfe9844c832..4605ed5d75c 100644
--- a/src/vppinfra/std-formats.c
+++ b/src/vppinfra/std-formats.c
@@ -456,29 +456,30 @@ format_hexdump (u8 * s, va_list * args)
}
__clib_export u8 *
-format_u64_bitmap (u8 *s, va_list *args)
+format_uword_bitmap (u8 *s, va_list *args)
{
- u64 *bitmap = va_arg (*args, u64 *);
+ uword *bitmap = va_arg (*args, uword *);
int n_uword = va_arg (*args, int);
- u32 indent = format_get_indent (s);
+ uword indent = format_get_indent (s);
s = format (s, "%6s", "");
- for (int i = 60; i >= 0; i -= 4)
+ for (int i = uword_bits - 4; i >= 0; i -= 4)
s = format (s, "%5d", i);
vec_add1 (s, '\n');
for (int j = n_uword - 1; j >= 0; j--)
{
- s = format (s, "%U0x%04x ", format_white_space, indent, j * 8);
- for (int i = 63; i >= 0; i--)
+ s = format (s, "%U0x%04x ", format_white_space, indent,
+ j * uword_bits / 8);
+ for (int i = uword_bits - 1; i >= 0; i--)
{
vec_add1 (s, (1ULL << i) & bitmap[j] ? '1' : '.');
if (i % 4 == 0)
vec_add1 (s, ' ');
}
- s = format (s, "0x%016lx", bitmap[j]);
+ s = format (s, uword_bits == 64 ? "0x%016lx" : "0x%08lx", bitmap[j]);
if (j)
vec_add1 (s, '\n');
}