perf: move get_term_dimensions from top to util.c
PATCH 1/1 perf: 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.
--- tools/perf/builtin-top.c | 22 ---------------------- tools/perf/perf.h | 4 ---- tools/perf/util/util.c | 22 ++++++++++++++++++++++ tools/perf/util/util.h | 3 +++ 4 files changed, 25 insertions(+), 26 deletions(-)
tools/perf/builtin-top.c +0 -22
@@ -68,28 +68,6 @@#include <linux/unistd.h> #include <linux/types.h> -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 )
tools/perf/perf.h +0 -4
@@ -1,10 +1,6 @@#ifndef _PERF_PERF_H#define _PERF_PERF_H -struct winsize ; - -void get_term_dimensions (struct winsize *ws); -#include <asm/unistd.h> #if defined(__i386__)
tools/perf/util/util.c +22 -0
@@ -218,3 +218,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 ; +}
tools/perf/util/util.h +3 -0
@@ -271,4 +271,7 @@ void dump_stack(void);extern unsigned int page_size; +struct winsize ; +void get_term_dimensions (struct winsize *ws); +#endif
Signature · 1 line
1.7.10.1