vlib: add format_vlib_thread_name

Type: improvement
Change-Id: I2231f8e32964868ff6ef154b8ef431d99643c6a5
Signed-off-by: Damjan Marion <damarion@cisco.com>
This commit is contained in:
Damjan Marion
2020-11-23 16:50:24 +01:00
parent d1bd5d26cc
commit 2cdb301678
2 changed files with 27 additions and 0 deletions

View File

@ -210,6 +210,27 @@ unformat_vlib_tmpfile (unformat_input_t * input, va_list * args)
return 1;
}
u8 *
format_vlib_thread_name (u8 * s, va_list * args)
{
u32 thread_index = va_arg (*args, u32);
if (thread_index == 0)
return format (s, "main");
if (thread_index < vec_len (vlib_worker_threads))
return format (s, "%s", vlib_worker_threads[thread_index].name);
return s;
}
u8 *
format_vlib_thread_name_and_index (u8 * s, va_list * args)
{
u32 thread_index = va_arg (*args, u32);
return format (s, "%U (%u)", format_vlib_thread_name, thread_index,
thread_index);
}
/*
* fd.io coding-style-patch-verification: ON