Commit 2c803e52 authored by David Ahern's avatar David Ahern Committed by Arnaldo Carvalho de Melo

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: default avatarDavid Ahern <dsahern@gmail.com>
Link: http://lkml.kernel.org/r/1358185681-90926-1-git-send-email-dsahern@gmail.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent b7c14a0b
...@@ -68,28 +68,6 @@ ...@@ -68,28 +68,6 @@
#include <linux/unistd.h> #include <linux/unistd.h>
#include <linux/types.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) static void perf_top__update_print_entries(struct perf_top *top)
{ {
if (top->print_entries > 9) if (top->print_entries > 9)
......
#ifndef _PERF_PERF_H #ifndef _PERF_PERF_H
#define _PERF_PERF_H #define _PERF_PERF_H
struct winsize;
void get_term_dimensions(struct winsize *ws);
#include <asm/unistd.h> #include <asm/unistd.h>
#if defined(__i386__) #if defined(__i386__)
......
...@@ -220,3 +220,25 @@ void dump_stack(void) ...@@ -220,3 +220,25 @@ void dump_stack(void)
#else #else
void dump_stack(void) {} void dump_stack(void) {}
#endif #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;
}
...@@ -271,4 +271,7 @@ void dump_stack(void); ...@@ -271,4 +271,7 @@ void dump_stack(void);
extern unsigned int page_size; extern unsigned int page_size;
struct winsize;
void get_term_dimensions(struct winsize *ws);
#endif #endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment