From 734150717a7bec55d0e4d5a23e5433ed67849e19 Mon Sep 17 00:00:00 2001 From: Jiebin Sun Date: Mon, 17 Aug 2026 17:46:15 +0800 Subject: perf c2c: extract shared data structures into util/c2c.h The function browser belongs in libperf-ui.a, but that archive is also linked into python/perf.so, where builtin command objects are unavailable. The browser therefore cannot depend on types or callbacks owned by builtin-c2c.c. Move c2c_hists, compute_stats, c2c_hist_entry, and the shared column formatting definitions from builtin-c2c.c to a new util/c2c.h. Move c2c_fmt_free() and c2c_fmt_equal() to a new util/c2c.c. Keep struct perf_c2c, the command instance, and perf_c2c__browse_cacheline() private to builtin-c2c.c. No functional change. Signed-off-by: Jiebin Sun Reviewed-by: Tianyou Li Reviewed-by: Wangyang Guo Reviewed-by: Ian Rogers Cc: Dapeng Mi Cc: James Clark Cc: Thomas Falcon Signed-off-by: Namhyung Kim --- tools/perf/util/c2c.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 tools/perf/util/c2c.c (limited to 'tools/perf/util/c2c.c') diff --git a/tools/perf/util/c2c.c b/tools/perf/util/c2c.c new file mode 100644 index 000000000000..58c7342dff46 --- /dev/null +++ b/tools/perf/util/c2c.c @@ -0,0 +1,21 @@ +// SPDX-License-Identifier: GPL-2.0 +#include +#include +#include "hist.h" +#include "c2c.h" + +void c2c_fmt_free(struct perf_hpp_fmt *fmt) +{ + struct c2c_fmt *c2c_fmt; + + c2c_fmt = container_of(fmt, struct c2c_fmt, fmt); + free(c2c_fmt); +} + +bool c2c_fmt_equal(struct perf_hpp_fmt *a, struct perf_hpp_fmt *b) +{ + struct c2c_fmt *c2c_a = container_of(a, struct c2c_fmt, fmt); + struct c2c_fmt *c2c_b = container_of(b, struct c2c_fmt, fmt); + + return c2c_a->dim == c2c_b->dim; +} -- cgit v1.2.3