diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2017-01-11 16:27:12 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2017-01-11 16:27:12 +0100 |
commit | 6c1f348fa792a33d5a98e68c139df65c2d4c1628 (patch) | |
tree | e0918eb74a6b01baa3cd44e28d7999c970e66ed9 /procps/powertop.c | |
parent | 01ccdd1d3c5221789f1ac62ced12b7984d910705 (diff) | |
download | busybox-w32-6c1f348fa792a33d5a98e68c139df65c2d4c1628.tar.gz busybox-w32-6c1f348fa792a33d5a98e68c139df65c2d4c1628.tar.bz2 busybox-w32-6c1f348fa792a33d5a98e68c139df65c2d4c1628.zip |
Move FEATURE_USE_TERMIOS config option to two applets which use it
No code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'procps/powertop.c')
-rw-r--r-- | procps/powertop.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/procps/powertop.c b/procps/powertop.c index ee806161f..413806836 100644 --- a/procps/powertop.c +++ b/procps/powertop.c | |||
@@ -18,6 +18,14 @@ | |||
18 | //config: default y | 18 | //config: default y |
19 | //config: help | 19 | //config: help |
20 | //config: Analyze power consumption on Intel-based laptops | 20 | //config: Analyze power consumption on Intel-based laptops |
21 | //config: | ||
22 | //config:config FEATURE_POWERTOP_INTERACTIVE | ||
23 | //config: bool "Accept keyboard commands" | ||
24 | //config: default y | ||
25 | //config: depends on POWERTOP | ||
26 | //config: help | ||
27 | //config: Without this, powertop will only refresh display every 10 seconds. | ||
28 | //config: No keyboard commands will work, only ^C to terminate. | ||
21 | 29 | ||
22 | // XXX This should be configurable | 30 | // XXX This should be configurable |
23 | #define ENABLE_FEATURE_POWERTOP_PROCIRQ 1 | 31 | #define ENABLE_FEATURE_POWERTOP_PROCIRQ 1 |
@@ -82,7 +90,7 @@ struct globals { | |||
82 | ullong last_usage[MAX_CSTATE_COUNT]; | 90 | ullong last_usage[MAX_CSTATE_COUNT]; |
83 | ullong start_duration[MAX_CSTATE_COUNT]; | 91 | ullong start_duration[MAX_CSTATE_COUNT]; |
84 | ullong last_duration[MAX_CSTATE_COUNT]; | 92 | ullong last_duration[MAX_CSTATE_COUNT]; |
85 | #if ENABLE_FEATURE_USE_TERMIOS | 93 | #if ENABLE_FEATURE_POWERTOP_INTERACTIVE |
86 | struct termios init_settings; | 94 | struct termios init_settings; |
87 | #endif | 95 | #endif |
88 | }; | 96 | }; |
@@ -91,7 +99,7 @@ struct globals { | |||
91 | SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \ | 99 | SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \ |
92 | } while (0) | 100 | } while (0) |
93 | 101 | ||
94 | #if ENABLE_FEATURE_USE_TERMIOS | 102 | #if ENABLE_FEATURE_POWERTOP_INTERACTIVE |
95 | static void reset_term(void) | 103 | static void reset_term(void) |
96 | { | 104 | { |
97 | tcsetattr_stdin_TCSANOW(&G.init_settings); | 105 | tcsetattr_stdin_TCSANOW(&G.init_settings); |
@@ -682,7 +690,7 @@ int powertop_main(int UNUSED_PARAM argc, char UNUSED_PARAM **argv) | |||
682 | ullong cur_usage[MAX_CSTATE_COUNT]; | 690 | ullong cur_usage[MAX_CSTATE_COUNT]; |
683 | ullong cur_duration[MAX_CSTATE_COUNT]; | 691 | ullong cur_duration[MAX_CSTATE_COUNT]; |
684 | char cstate_lines[MAX_CSTATE_COUNT + 2][64]; | 692 | char cstate_lines[MAX_CSTATE_COUNT + 2][64]; |
685 | #if ENABLE_FEATURE_USE_TERMIOS | 693 | #if ENABLE_FEATURE_POWERTOP_INTERACTIVE |
686 | struct pollfd pfd[1]; | 694 | struct pollfd pfd[1]; |
687 | 695 | ||
688 | pfd[0].fd = 0; | 696 | pfd[0].fd = 0; |
@@ -705,7 +713,7 @@ int powertop_main(int UNUSED_PARAM argc, char UNUSED_PARAM **argv) | |||
705 | 713 | ||
706 | puts("Collecting data for "DEFAULT_SLEEP_STR" seconds"); | 714 | puts("Collecting data for "DEFAULT_SLEEP_STR" seconds"); |
707 | 715 | ||
708 | #if ENABLE_FEATURE_USE_TERMIOS | 716 | #if ENABLE_FEATURE_POWERTOP_INTERACTIVE |
709 | /* Turn on unbuffered input; turn off echoing, ^C ^Z etc */ | 717 | /* Turn on unbuffered input; turn off echoing, ^C ^Z etc */ |
710 | set_termios_to_raw(STDIN_FILENO, &G.init_settings, TERMIOS_CLEAR_ISIG); | 718 | set_termios_to_raw(STDIN_FILENO, &G.init_settings, TERMIOS_CLEAR_ISIG); |
711 | bb_signals(BB_FATAL_SIGS, sig_handler); | 719 | bb_signals(BB_FATAL_SIGS, sig_handler); |
@@ -735,7 +743,7 @@ int powertop_main(int UNUSED_PARAM argc, char UNUSED_PARAM **argv) | |||
735 | int i; | 743 | int i; |
736 | 744 | ||
737 | G.cant_enable_timer_stats |= start_timer(); /* 1 on error */ | 745 | G.cant_enable_timer_stats |= start_timer(); /* 1 on error */ |
738 | #if !ENABLE_FEATURE_USE_TERMIOS | 746 | #if !ENABLE_FEATURE_POWERTOP_INTERACTIVE |
739 | sleep(DEFAULT_SLEEP); | 747 | sleep(DEFAULT_SLEEP); |
740 | #else | 748 | #else |
741 | if (safe_poll(pfd, 1, DEFAULT_SLEEP * 1000) > 0) { | 749 | if (safe_poll(pfd, 1, DEFAULT_SLEEP * 1000) > 0) { |