aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf
diff options
context:
space:
mode:
authorDavid Ahern <dsahern@gmail.com>2013-01-14 12:48:01 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2013-01-24 14:40:34 -0500
commit2c803e5248d038988ec7c52e8fd7c83130dd3c13 (patch)
tree7be870a45610585b34258b6a5da0551f5613e301 /tools/perf
parentb7c14a0b6a4e3add92e1527a31cb1826f4799248 (diff)
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 <dsahern@gmail.com> Link: http://lkml.kernel.org/r/1358185681-90926-1-git-send-email-dsahern@gmail.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf')
-rw-r--r--tools/perf/builtin-top.c22
-rw-r--r--tools/perf/perf.h4
-rw-r--r--tools/perf/util/util.c22
-rw-r--r--tools/perf/util/util.h3
4 files changed, 25 insertions, 26 deletions
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 @@
68#include <linux/unistd.h> 68#include <linux/unistd.h>
69#include <linux/types.h> 69#include <linux/types.h>
70 70
71void get_term_dimensions(struct winsize *ws)
72{
73 char *s = getenv("LINES");
74
75 if (s != NULL) {
76 ws->ws_row = atoi(s);
77 s = getenv("COLUMNS");
78 if (s != NULL) {
79 ws->ws_col = atoi(s);
80 if (ws->ws_row && ws->ws_col)
81 return;
82 }
83 }
84#ifdef TIOCGWINSZ
85 if (ioctl(1, TIOCGWINSZ, ws) == 0 &&
86 ws->ws_row && ws->ws_col)
87 return;
88#endif
89 ws->ws_row = 25;
90 ws->ws_col = 80;
91}
92
93static void perf_top__update_print_entries(struct perf_top *top) 71static void perf_top__update_print_entries(struct perf_top *top)
94{ 72{
95 if (top->print_entries > 9) 73 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 @@
1#ifndef _PERF_PERF_H 1#ifndef _PERF_PERF_H
2#define _PERF_PERF_H 2#define _PERF_PERF_H
3 3
4struct winsize;
5
6void get_term_dimensions(struct winsize *ws);
7
8#include <asm/unistd.h> 4#include <asm/unistd.h>
9 5
10#if defined(__i386__) 6#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)
220#else 220#else
221void dump_stack(void) {} 221void dump_stack(void) {}
222#endif 222#endif
223
224void get_term_dimensions(struct winsize *ws)
225{
226 char *s = getenv("LINES");
227
228 if (s != NULL) {
229 ws->ws_row = atoi(s);
230 s = getenv("COLUMNS");
231 if (s != NULL) {
232 ws->ws_col = atoi(s);
233 if (ws->ws_row && ws->ws_col)
234 return;
235 }
236 }
237#ifdef TIOCGWINSZ
238 if (ioctl(1, TIOCGWINSZ, ws) == 0 &&
239 ws->ws_row && ws->ws_col)
240 return;
241#endif
242 ws->ws_row = 25;
243 ws->ws_col = 80;
244}
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);
271 271
272extern unsigned int page_size; 272extern unsigned int page_size;
273 273
274struct winsize;
275void get_term_dimensions(struct winsize *ws);
276
274#endif 277#endif