From: David Ahern Date: Mon, 14 Jan 2013 17:48:01 +0000 (-0700) Subject: perf tools: Move get_term_dimensions from top to util.c X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=2c803e52;p=linux-beck.git perf tools: Move get_term_dimensions from top to util.c It is used by util/help.c so it should be a lib function and included in libperf.a. Code move only. Signed-off-by: David Ahern Link: http://lkml.kernel.org/r/1358185681-90926-1-git-send-email-dsahern@gmail.com Signed-off-by: Arnaldo Carvalho de Melo --- diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index bc788126397b..e05ba817f8ce 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c @@ -68,28 +68,6 @@ #include #include -void get_term_dimensions(struct winsize *ws) -{ - char *s = getenv("LINES"); - - if (s != NULL) { - ws->ws_row = atoi(s); - s = getenv("COLUMNS"); - if (s != NULL) { - ws->ws_col = atoi(s); - if (ws->ws_row && ws->ws_col) - return; - } - } -#ifdef TIOCGWINSZ - if (ioctl(1, TIOCGWINSZ, ws) == 0 && - ws->ws_row && ws->ws_col) - return; -#endif - ws->ws_row = 25; - ws->ws_col = 80; -} - static void perf_top__update_print_entries(struct perf_top *top) { if (top->print_entries > 9) diff --git a/tools/perf/perf.h b/tools/perf/perf.h index 7622f15bcfb7..8f3bf388e414 100644 --- a/tools/perf/perf.h +++ b/tools/perf/perf.h @@ -1,10 +1,6 @@ #ifndef _PERF_PERF_H #define _PERF_PERF_H -struct winsize; - -void get_term_dimensions(struct winsize *ws); - #include #if defined(__i386__) diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c index 252b889ac8c2..805d1f52c5b4 100644 --- a/tools/perf/util/util.c +++ b/tools/perf/util/util.c @@ -220,3 +220,25 @@ void dump_stack(void) #else void dump_stack(void) {} #endif + +void get_term_dimensions(struct winsize *ws) +{ + char *s = getenv("LINES"); + + if (s != NULL) { + ws->ws_row = atoi(s); + s = getenv("COLUMNS"); + if (s != NULL) { + ws->ws_col = atoi(s); + if (ws->ws_row && ws->ws_col) + return; + } + } +#ifdef TIOCGWINSZ + if (ioctl(1, TIOCGWINSZ, ws) == 0 && + ws->ws_row && ws->ws_col) + return; +#endif + ws->ws_row = 25; + ws->ws_col = 80; +} diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h index c2330918110c..ec5de5e3330c 100644 --- a/tools/perf/util/util.h +++ b/tools/perf/util/util.h @@ -271,4 +271,7 @@ void dump_stack(void); extern unsigned int page_size; +struct winsize; +void get_term_dimensions(struct winsize *ws); + #endif