Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf tools: Move term functions out of util.c

The term functions are needed by help.c which is going to be moved into
a separate library. Move them out of util.c and into their own file.

Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/9a39c854dd156b55ebda57e427594c9a59dcb40f.1449548395.git.jpoimboe@redhat.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Josh Poimboeuf and committed by
Arnaldo Carvalho de Melo
1fe143c5 de7cf7ca

+47 -37
+1
tools/perf/util/Build
··· 86 86 libperf-$(CONFIG_AUXTRACE) += intel-bts.o 87 87 libperf-y += parse-branch-options.o 88 88 libperf-y += parse-regs-options.o 89 + libperf-y += term.o 89 90 90 91 libperf-$(CONFIG_LIBBPF) += bpf-loader.o 91 92 libperf-$(CONFIG_BPF_PROLOGUE) += bpf-prologue.o
+35
tools/perf/util/term.c
··· 1 + #include "util.h" 2 + 3 + void get_term_dimensions(struct winsize *ws) 4 + { 5 + char *s = getenv("LINES"); 6 + 7 + if (s != NULL) { 8 + ws->ws_row = atoi(s); 9 + s = getenv("COLUMNS"); 10 + if (s != NULL) { 11 + ws->ws_col = atoi(s); 12 + if (ws->ws_row && ws->ws_col) 13 + return; 14 + } 15 + } 16 + #ifdef TIOCGWINSZ 17 + if (ioctl(1, TIOCGWINSZ, ws) == 0 && 18 + ws->ws_row && ws->ws_col) 19 + return; 20 + #endif 21 + ws->ws_row = 25; 22 + ws->ws_col = 80; 23 + } 24 + 25 + void set_term_quiet_input(struct termios *old) 26 + { 27 + struct termios tc; 28 + 29 + tcgetattr(0, old); 30 + tc = *old; 31 + tc.c_lflag &= ~(ICANON | ECHO); 32 + tc.c_cc[VMIN] = 0; 33 + tc.c_cc[VTIME] = 0; 34 + tcsetattr(0, TCSANOW, &tc); 35 + }
+10
tools/perf/util/term.h
··· 1 + #ifndef __PERF_TERM_H 2 + #define __PERF_TERM_H 3 + 4 + struct termios; 5 + struct winsize; 6 + 7 + void get_term_dimensions(struct winsize *ws); 8 + void set_term_quiet_input(struct termios *old); 9 + 10 + #endif /* __PERF_TERM_H */
-34
tools/perf/util/util.c
··· 355 355 exit(sig); 356 356 } 357 357 358 - void get_term_dimensions(struct winsize *ws) 359 - { 360 - char *s = getenv("LINES"); 361 - 362 - if (s != NULL) { 363 - ws->ws_row = atoi(s); 364 - s = getenv("COLUMNS"); 365 - if (s != NULL) { 366 - ws->ws_col = atoi(s); 367 - if (ws->ws_row && ws->ws_col) 368 - return; 369 - } 370 - } 371 - #ifdef TIOCGWINSZ 372 - if (ioctl(1, TIOCGWINSZ, ws) == 0 && 373 - ws->ws_row && ws->ws_col) 374 - return; 375 - #endif 376 - ws->ws_row = 25; 377 - ws->ws_col = 80; 378 - } 379 - 380 - void set_term_quiet_input(struct termios *old) 381 - { 382 - struct termios tc; 383 - 384 - tcgetattr(0, old); 385 - tc = *old; 386 - tc.c_lflag &= ~(ICANON | ECHO); 387 - tc.c_cc[VMIN] = 0; 388 - tc.c_cc[VTIME] = 0; 389 - tcsetattr(0, TCSANOW, &tc); 390 - } 391 - 392 358 int parse_nsec_time(const char *str, u64 *ptime) 393 359 { 394 360 u64 time_sec, time_nsec;
+1 -3
tools/perf/util/util.h
··· 53 53 #include <stdlib.h> 54 54 #include <stdarg.h> 55 55 #include <string.h> 56 + #include <term.h> 56 57 #include <errno.h> 57 58 #include <limits.h> 58 59 #include <sys/param.h> ··· 282 281 283 282 extern unsigned int page_size; 284 283 extern int cacheline_size; 285 - 286 - void get_term_dimensions(struct winsize *ws); 287 - void set_term_quiet_input(struct termios *old); 288 284 289 285 struct parse_tag { 290 286 char tag;