···1515#include <string.h>
1616#include <stdarg.h>
1717#include <stdio.h>
1818+#include <inttypes.h>
181919202021/*
···262263 case XRT_SPACE_REFERENCE_TYPE_INVALID: DG("XRT_SPACE_REFERENCE_TYPE_INVALID"); return;
263264 default: u_pp(dg, "XRT_SPACE_REFERENCE_TYPE_0x%08x", type); return;
264265 }
266266+}
267267+268268+void
269269+u_pp_padded_pretty_ms(u_pp_delegate_t dg, uint64_t value_ns)
270270+{
271271+ uint64_t in_us = value_ns / 1000;
272272+ uint64_t in_ms = in_us / 1000;
273273+ uint64_t in_1_000_ms = in_ms / 1000;
274274+ uint64_t in_1_000_000_ms = in_1_000_ms / 1000;
275275+276276+ // Prints " M'TTT'###.FFFms"
277277+278278+ // " M'"
279279+ if (in_1_000_000_ms >= 1) {
280280+ u_pp(dg, " %" PRIu64 "'", in_1_000_000_ms);
281281+ } else {
282282+ // " M'"
283283+ u_pp(dg, " ");
284284+ }
285285+286286+ // "TTT'"
287287+ if (in_1_000_ms >= 1000) {
288288+ // Need to pad with zeros
289289+ u_pp(dg, "%03" PRIu64 "'", in_1_000_ms % 1000);
290290+ } else if (in_1_000_ms >= 1) {
291291+ // Pad with spaces, we need to write a number.
292292+ u_pp(dg, "%3" PRIu64 "'", in_1_000_ms);
293293+ } else {
294294+ // "TTT'"
295295+ u_pp(dg, " ");
296296+ }
297297+298298+ // "###"
299299+ if (in_ms >= 1000) {
300300+ // Need to pad with zeros
301301+ u_pp(dg, "%03" PRIu64, in_ms % 1000);
302302+ } else {
303303+ // Pad with spaces, always need a numbere here.
304304+ u_pp(dg, "%3" PRIu64, in_ms % 1000);
305305+ }
306306+307307+ // ".FFFms"
308308+ u_pp(dg, ".%03" PRIu64 "ms", in_us % 1000);
265309}
266310267311
+15
src/xrt/auxiliary/util/u_pretty_print.h
···11// Copyright 2022, Collabora, Ltd.
22+// Copyright 2024-2025, NVIDIA CORPORATION.
23// SPDX-License-Identifier: BSL-1.0
34/*!
45 * @file
···100101 */
101102void
102103u_pp_xrt_reference_space_type(struct u_pp_delegate dg, enum xrt_reference_space_type type);
104104+105105+106106+/*!
107107+ * Pretty prints a milliseconds padded to be at least 16 characters, the
108108+ * formatting is meant to be human readable, does not use locale.
109109+ *
110110+ * Formatted as: " M'TTT'###.FFFms"
111111+ * Zero: " 0.000ms"
112112+ *
113113+ * If the value is 10 seconds or larger (MM) then it will be longer then 16
114114+ * characters.
115115+ */
116116+void
117117+u_pp_padded_pretty_ms(u_pp_delegate_t dg, uint64_t value_ns);
103118104119105120/*