aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJiri Olsa <jolsa@redhat.com>2013-02-04 10:33:19 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2013-07-12 12:54:18 -0400
commitbe0e6d105d31a5818608ae243411aef5c976147a (patch)
tree75fab8aaefdb07c5ff464daa1f966bdd97a96135
parent5f3f8d3b1207cba3664d57a33de43f5ee11c8a06 (diff)
perf tools: Move hist_entry__period_snprintf into stdio code
Moving hist_entry__period_snprintf function into stdio code and making it static, as it's no longer used anywhere else. Signed-off-by: Jiri Olsa <jolsa@redhat.com> Reviewed-by: Namhyung Kim <namhyung@kernel.org> Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Link: http://lkml.kernel.org/n/tip-ah8ms343h8xygt20iqz91kz4@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r--tools/perf/ui/hist.c40
-rw-r--r--tools/perf/ui/stdio/hist.c41
-rw-r--r--tools/perf/util/hist.h2
3 files changed, 41 insertions, 42 deletions
diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c
index dc900d7a190e..0a193281eba8 100644
--- a/tools/perf/ui/hist.c
+++ b/tools/perf/ui/hist.c
@@ -236,46 +236,6 @@ void perf_hpp__column_enable(unsigned col)
236 perf_hpp__column_register(&perf_hpp__format[col]); 236 perf_hpp__column_register(&perf_hpp__format[col]);
237} 237}
238 238
239static inline void advance_hpp(struct perf_hpp *hpp, int inc)
240{
241 hpp->buf += inc;
242 hpp->size -= inc;
243}
244
245int hist_entry__period_snprintf(struct perf_hpp *hpp, struct hist_entry *he,
246 bool color)
247{
248 const char *sep = symbol_conf.field_sep;
249 struct perf_hpp_fmt *fmt;
250 char *start = hpp->buf;
251 int ret;
252 bool first = true;
253
254 if (symbol_conf.exclude_other && !he->parent)
255 return 0;
256
257 perf_hpp__for_each_format(fmt) {
258 /*
259 * If there's no field_sep, we still need
260 * to display initial ' '.
261 */
262 if (!sep || !first) {
263 ret = scnprintf(hpp->buf, hpp->size, "%s", sep ?: " ");
264 advance_hpp(hpp, ret);
265 } else
266 first = false;
267
268 if (color && fmt->color)
269 ret = fmt->color(fmt, hpp, he);
270 else
271 ret = fmt->entry(fmt, hpp, he);
272
273 advance_hpp(hpp, ret);
274 }
275
276 return hpp->buf - start;
277}
278
279int hist_entry__sort_snprintf(struct hist_entry *he, char *s, size_t size, 239int hist_entry__sort_snprintf(struct hist_entry *he, char *s, size_t size,
280 struct hists *hists) 240 struct hists *hists)
281{ 241{
diff --git a/tools/perf/ui/stdio/hist.c b/tools/perf/ui/stdio/hist.c
index ee703720649d..5b4fb330f656 100644
--- a/tools/perf/ui/stdio/hist.c
+++ b/tools/perf/ui/stdio/hist.c
@@ -308,6 +308,47 @@ static size_t hist_entry__callchain_fprintf(struct hist_entry *he,
308 return hist_entry_callchain__fprintf(he, total_period, left_margin, fp); 308 return hist_entry_callchain__fprintf(he, total_period, left_margin, fp);
309} 309}
310 310
311static inline void advance_hpp(struct perf_hpp *hpp, int inc)
312{
313 hpp->buf += inc;
314 hpp->size -= inc;
315}
316
317static int hist_entry__period_snprintf(struct perf_hpp *hpp,
318 struct hist_entry *he,
319 bool color)
320{
321 const char *sep = symbol_conf.field_sep;
322 struct perf_hpp_fmt *fmt;
323 char *start = hpp->buf;
324 int ret;
325 bool first = true;
326
327 if (symbol_conf.exclude_other && !he->parent)
328 return 0;
329
330 perf_hpp__for_each_format(fmt) {
331 /*
332 * If there's no field_sep, we still need
333 * to display initial ' '.
334 */
335 if (!sep || !first) {
336 ret = scnprintf(hpp->buf, hpp->size, "%s", sep ?: " ");
337 advance_hpp(hpp, ret);
338 } else
339 first = false;
340
341 if (color && fmt->color)
342 ret = fmt->color(fmt, hpp, he);
343 else
344 ret = fmt->entry(fmt, hpp, he);
345
346 advance_hpp(hpp, ret);
347 }
348
349 return hpp->buf - start;
350}
351
311static int hist_entry__fprintf(struct hist_entry *he, size_t size, 352static int hist_entry__fprintf(struct hist_entry *he, size_t size,
312 struct hists *hists, FILE *fp) 353 struct hists *hists, FILE *fp)
313{ 354{
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h
index bfcbb11c2648..1329b6b6ffe6 100644
--- a/tools/perf/util/hist.h
+++ b/tools/perf/util/hist.h
@@ -174,8 +174,6 @@ enum {
174void perf_hpp__init(void); 174void perf_hpp__init(void);
175void perf_hpp__column_register(struct perf_hpp_fmt *format); 175void perf_hpp__column_register(struct perf_hpp_fmt *format);
176void perf_hpp__column_enable(unsigned col); 176void perf_hpp__column_enable(unsigned col);
177int hist_entry__period_snprintf(struct perf_hpp *hpp, struct hist_entry *he,
178 bool color);
179 177
180struct perf_evlist; 178struct perf_evlist;
181 179