The following set of patches add changes in powertop needed for arm android platforms. These patches depends on the below mentioned patches. http://www.mail-archive.com/power@bughost.org/msg02078.html
Amit Daniel Kachhap (3): powertop: Disable pci bus measurement for arm platforms perf-event: Add defination of __NR_perf_event_open for arm platforms ncurses: Enable ncurses for android and miscellaneous changes
Android.mk | 30 +++++++++++++++++++++++++----- devices/runtime_pm.cpp | 3 ++- display.cpp | 5 ++++- display.h | 3 ++- lib.cpp | 13 ++++++++----- main.cpp | 11 +++++++++++ perf/perf_event.h | 3 +++ process/do_process.cpp | 4 ++++ tuning/runtime.cpp | 2 ++ 9 files changed, 61 insertions(+), 13 deletions(-)
This patch disables pci related measurement which is not needed for ARM platforms and also library libpci is not needed.
Signed-off-by: Amit Daniel Kachhap amit.kachhap@linaro.org --- Android.mk | 7 ++++++- devices/runtime_pm.cpp | 3 ++- lib.cpp | 7 ++++--- main.cpp | 6 ++++++ tuning/runtime.cpp | 2 ++ 5 files changed, 20 insertions(+), 5 deletions(-)
diff --git a/Android.mk b/Android.mk index 146f57a..6948011 100644 --- a/Android.mk +++ b/Android.mk @@ -4,7 +4,6 @@ include $(CLEAR_VARS) LOCAL_MODULE_TAGS := debug LOCAL_SHARED_LIBRARIES := libstlport \ libnl \ - libpci \
LOCAL_MODULE := powertop
@@ -14,6 +13,12 @@ LOCAL_CPPFLAGS += -DDISABLE_NCURSES -DDISABLE_I18N -DDISABLE_TRYCATCH
LOCAL_C_INCLUDES += external/stlport/stlport/ external/stlport/stlport/stl external/stlport/stlport/using/h/ bionic external/libnl/include/
+ifneq ($(TARGET_ARCH),arm) +LOCAL_SHARED_LIBRARIES += libpci +else #TARGET_ARCH != arm +LOCAL_CPPFLAGS += -DDISABLE_PCI +endif #TARGET_ARCH == arm + LOCAL_SRC_FILES += \ parameters/parameters.cpp \ parameters/persistent.cpp \ diff --git a/devices/runtime_pm.cpp b/devices/runtime_pm.cpp index 368d995..5a55426 100644 --- a/devices/runtime_pm.cpp +++ b/devices/runtime_pm.cpp @@ -200,7 +200,7 @@ static void do_bus(const char *bus) continue;
dev = new class runtime_pmdevice(entry->d_name, filename); - +#ifndef DISABLE_PCI if (strcmp(bus, "pci") == 0) { uint16_t vendor = 0, device = 0;
@@ -226,6 +226,7 @@ static void do_bus(const char *bus) dev->set_human_name(devname); } } +#endif//DISABLE_PCI all_devices.push_back(dev); } closedir(dir); diff --git a/lib.cpp b/lib.cpp index e6684b0..d058e4f 100644 --- a/lib.cpp +++ b/lib.cpp @@ -35,10 +35,11 @@ #include <stdbool.h> #include <math.h> #include <stdlib.h> - +#ifndef DISABLE_PCI extern "C" { #include <pci/pci.h> } +#endif
#include "lib.h"
@@ -243,7 +244,7 @@ void format_watts(double W, char *buffer, unsigned int len) #endif }
- +#ifndef DISABLE_PCI static struct pci_access *pci_access;
char *pci_id_to_name(uint16_t vendor, uint16_t device, char *buffer, int len) @@ -267,7 +268,7 @@ void end_pci_access(void) if (pci_access) pci_free_name_list(pci_access); } - +#endif //DISABLE_PCI int utf_ok = -1;
diff --git a/main.cpp b/main.cpp index 4241d44..3ee0a7e 100644 --- a/main.cpp +++ b/main.cpp @@ -261,7 +261,9 @@ void html_report(int time, bool file) learn_parameters(50, 0); save_all_results("saved_results.powertop"); save_parameters("saved_parameters.powertop"); +#ifndef DISABLE_PCI end_pci_access(); +#endif exit(0); }
@@ -370,7 +372,9 @@ int main(int argc, char **argv) if (debug_learning) { learn_parameters(1000, 1); dump_parameter_bundle(); +#ifndef DISABLE_PCI end_pci_access(); +#endif exit(0); }
@@ -404,7 +408,9 @@ int main(int argc, char **argv) save_parameters("saved_parameters.powertop"); learn_parameters(500, 0); save_parameters("saved_parameters.powertop"); +#ifndef DISABLE_PCI end_pci_access(); +#endif reset_display();
return 0; diff --git a/tuning/runtime.cpp b/tuning/runtime.cpp index 03cfa0b..a543b41 100644 --- a/tuning/runtime.cpp +++ b/tuning/runtime.cpp @@ -48,6 +48,7 @@ runtime_tunable::runtime_tunable(const char *path, const char *bus, const char * if (!device_has_runtime_pm(path)) sprintf(desc, _("%s device %s has no runtime power management"), bus, dev);
+#ifndef DISABLE_PCI if (strcmp(bus, "pci") == 0) { char filename[4096]; uint16_t vendor = 0, device = 0; @@ -77,6 +78,7 @@ runtime_tunable::runtime_tunable(const char *path, const char *bus, const char *
} +#endif//DISABLE_PCI }
int runtime_tunable::good_bad(void)
On Thu, Jul 14, 2011 at 11:35 PM, Amit Daniel Kachhap amit.kachhap@linaro.org wrote:
This patch disables pci related measurement which is not needed for ARM platforms and also library libpci is not needed.
Signed-off-by: Amit Daniel Kachhap amit.kachhap@linaro.org
Android.mk | 7 ++++++- devices/runtime_pm.cpp | 3 ++- lib.cpp | 7 ++++--- main.cpp | 6 ++++++ tuning/runtime.cpp | 2 ++ 5 files changed, 20 insertions(+), 5 deletions(-)
diff --git a/Android.mk b/Android.mk index 146f57a..6948011 100644 --- a/Android.mk +++ b/Android.mk @@ -4,7 +4,6 @@ include $(CLEAR_VARS) LOCAL_MODULE_TAGS := debug LOCAL_SHARED_LIBRARIES := libstlport \ libnl \
- libpci \
LOCAL_MODULE := powertop
@@ -14,6 +13,12 @@ LOCAL_CPPFLAGS += -DDISABLE_NCURSES -DDISABLE_I18N -DDISABLE_TRYCATCH
LOCAL_C_INCLUDES += external/stlport/stlport/ external/stlport/stlport/stl external/stlport/stlport/using/h/ bionic external/libnl/include/
+ifneq ($(TARGET_ARCH),arm) +LOCAL_SHARED_LIBRARIES += libpci +else #TARGET_ARCH != arm +LOCAL_CPPFLAGS += -DDISABLE_PCI +endif #TARGET_ARCH == arm
should probably not use #ifdef ARM but something like #ifdef HAVE_LIBPCI instead.. there will be other architectures that don't have libpci as well.
LOCAL_SRC_FILES += \ parameters/parameters.cpp \ parameters/persistent.cpp \ diff --git a/devices/runtime_pm.cpp b/devices/runtime_pm.cpp index 368d995..5a55426 100644 --- a/devices/runtime_pm.cpp +++ b/devices/runtime_pm.cpp @@ -200,7 +200,7 @@ static void do_bus(const char *bus) continue;
dev = new class runtime_pmdevice(entry->d_name, filename);
+#ifndef DISABLE_PCI
I'd prefer a nice HAVE_LIBPCI here instead as well for the rest of these...
On 15 July 2011 22:56, Kok, Auke-jan H auke-jan.h.kok@intel.com wrote:
On Thu, Jul 14, 2011 at 11:35 PM, Amit Daniel Kachhap amit.kachhap@linaro.org wrote:
This patch disables pci related measurement which is not needed for ARM platforms and also library libpci is not needed.
Signed-off-by: Amit Daniel Kachhap amit.kachhap@linaro.org
Android.mk | 7 ++++++- devices/runtime_pm.cpp | 3 ++- lib.cpp | 7 ++++--- main.cpp | 6 ++++++ tuning/runtime.cpp | 2 ++ 5 files changed, 20 insertions(+), 5 deletions(-)
diff --git a/Android.mk b/Android.mk index 146f57a..6948011 100644 --- a/Android.mk +++ b/Android.mk @@ -4,7 +4,6 @@ include $(CLEAR_VARS) LOCAL_MODULE_TAGS := debug LOCAL_SHARED_LIBRARIES := libstlport \ libnl \
- libpci \
LOCAL_MODULE := powertop
@@ -14,6 +13,12 @@ LOCAL_CPPFLAGS += -DDISABLE_NCURSES -DDISABLE_I18N -DDISABLE_TRYCATCH
LOCAL_C_INCLUDES += external/stlport/stlport/ external/stlport/stlport/stl external/stlport/stlport/using/h/ bionic external/libnl/include/
+ifneq ($(TARGET_ARCH),arm) +LOCAL_SHARED_LIBRARIES += libpci +else #TARGET_ARCH != arm +LOCAL_CPPFLAGS += -DDISABLE_PCI +endif #TARGET_ARCH == arm
should probably not use #ifdef ARM but something like #ifdef HAVE_LIBPCI instead.. there will be other architectures that don't have libpci as well.
Thanks for your comments. i will use this macro in the next patches.
LOCAL_SRC_FILES += \ parameters/parameters.cpp \ parameters/persistent.cpp \ diff --git a/devices/runtime_pm.cpp b/devices/runtime_pm.cpp index 368d995..5a55426 100644 --- a/devices/runtime_pm.cpp +++ b/devices/runtime_pm.cpp @@ -200,7 +200,7 @@ static void do_bus(const char *bus) continue;
dev = new class runtime_pmdevice(entry->d_name, filename);
+#ifndef DISABLE_PCI
I'd prefer a nice HAVE_LIBPCI here instead as well for the rest of these...
This patch adds defination for __NR_perf_event_open if not present for arm platforms.
Signed-off-by: Amit Daniel Kachhap amit.kachhap@linaro.org --- perf/perf_event.h | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/perf/perf_event.h b/perf/perf_event.h index 563ffc7..eac4a73 100644 --- a/perf/perf_event.h +++ b/perf/perf_event.h @@ -51,6 +51,9 @@ #if __x86_64__ #define __NR_perf_event_open 298 #endif +#if __arm__ +#define __NR_perf_event_open 364 +#endif #endif
This patch enables ncurses for android. NCURSES_NOMACRO flag is enabled as there is some conflict with stl libraries.
Signed-off-by: Amit Daniel Kachhap amit.kachhap@linaro.org --- Android.mk | 23 +++++++++++++++++++---- display.cpp | 5 ++++- display.h | 3 ++- lib.cpp | 6 ++++-- main.cpp | 5 +++++ process/do_process.cpp | 4 ++++ 6 files changed, 38 insertions(+), 8 deletions(-)
diff --git a/Android.mk b/Android.mk index 6948011..e6e73b1 100644 --- a/Android.mk +++ b/Android.mk @@ -1,17 +1,32 @@ LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS)
-LOCAL_MODULE_TAGS := debug +LOCAL_MODULE_TAGS := optional LOCAL_SHARED_LIBRARIES := libstlport \ - libnl \ + libnl + +LOCAL_STATIC_LIBRARIES := libncurses
LOCAL_MODULE := powertop
#LOCAL_CFLAGS += -Wall -O2 -g -fno-omit-frame-pointer -fstack-protector -Wshadow -Wformat -D_FORTIFY_SOURCE=2 #LOCAL_CPPFLAGS += -Wall -O2 -g -fno-omit-frame-pointer -LOCAL_CPPFLAGS += -DDISABLE_NCURSES -DDISABLE_I18N -DDISABLE_TRYCATCH +LOCAL_CPPFLAGS += \ + -DDISABLE_I18N \ + -DDISABLE_TRYCATCH \ + -DNCURSES_NOMACROS \ + -DDISABLE_WSTRING \ + -DDEFAULT_TERM="xterm" \
-LOCAL_C_INCLUDES += external/stlport/stlport/ external/stlport/stlport/stl external/stlport/stlport/using/h/ bionic external/libnl/include/ +LOCAL_C_INCLUDES += external/stlport/stlport/ \ + external/stlport/stlport/stl \ + external/stlport/stlport/using/h/ \ + bionic \ + external/libnl/include/ \ + external/ncurses \ + external/ncurses/lib \ + external/ncurses/include \ + external/ncurses/include/ncurses
ifneq ($(TARGET_ARCH),arm) LOCAL_SHARED_LIBRARIES += libpci diff --git a/display.cpp b/display.cpp index f486050..283743c 100644 --- a/display.cpp +++ b/display.cpp @@ -84,8 +84,11 @@ void reset_display(void) keypad(stdscr, FALSE); echo(); nocbreak(); - +#ifndef NCURSES_NOMACROS resetterm(); +#else + reset_shell_mode(); +#endif }
diff --git a/display.h b/display.h index 3b24914..023f68d 100644 --- a/display.h +++ b/display.h @@ -49,7 +49,8 @@ public: int cursor_pos; int cursor_max; WINDOW *win; - + + virtual ~tab_window() {}; virtual void cursor_down(void) { if (cursor_pos < cursor_max ) cursor_pos++; repaint(); } ; virtual void cursor_up(void) { if (cursor_pos > 0) cursor_pos--; repaint(); };
diff --git a/lib.cpp b/lib.cpp index d058e4f..86fcf96 100644 --- a/lib.cpp +++ b/lib.cpp @@ -238,10 +238,12 @@ void format_watts(double W, char *buffer, unsigned int len) if (W < 0.0001) sprintf(buffer, _(" 0 mW")); -#ifndef DISABLE_NCURSES +#ifndef DISABLE_NCURSES +#ifndef DISABLE_WSTRING while (mbstowcs(NULL,buffer,0) < len) strcat(buffer, " "); -#endif +#endif //DISABLE_WSTRING +#endif //DISABLE_NCURSES }
#ifndef DISABLE_PCI diff --git a/main.cpp b/main.cpp index 3ee0a7e..fc4b0cf 100644 --- a/main.cpp +++ b/main.cpp @@ -280,6 +280,11 @@ int main(int argc, char **argv) bindtextdomain ("powertop", "/usr/share/locale"); textdomain ("powertop"); #endif + +#ifdef DEFAULT_TERM + if (!getenv("TERM")) + setenv("TERM", DEFAULT_TERM, 1); +#endif uid = getuid();
if (uid != 0) { diff --git a/process/do_process.cpp b/process/do_process.cpp index 5c382f1..7e39321 100644 --- a/process/do_process.cpp +++ b/process/do_process.cpp @@ -720,7 +720,9 @@ void process_update_display(void) if (!show_power) strcpy(power, " "); sprintf(name, "%s", all_power[i]->type()); +#ifndef DISABLE_WSTRING while (mbstowcs(NULL,name,0) < 14) strcat(name, " "); +#endif
if (all_power[i]->events() == 0 && all_power[i]->usage() == 0 && all_power[i]->Witts() == 0) @@ -733,7 +735,9 @@ void process_update_display(void) else sprintf(usage, "%5i%s", (int)all_power[i]->usage(), all_power[i]->usage_units()); } +#ifndef DISABLE_WSTRING while (mbstowcs(NULL,usage,0) < 14) strcat(usage, " "); +#endif sprintf(events, "%5.1f", all_power[i]->events()); if (!all_power[i]->show_events()) events[0] = 0;
On Thu, Jul 14, 2011 at 11:35 PM, Amit Daniel Kachhap amit.kachhap@linaro.org wrote:
This patch enables ncurses for android. NCURSES_NOMACRO flag is enabled as there is some conflict with stl libraries.
Signed-off-by: Amit Daniel Kachhap amit.kachhap@linaro.org
Android.mk | 23 +++++++++++++++++++---- display.cpp | 5 ++++- display.h | 3 ++- lib.cpp | 6 ++++-- main.cpp | 5 +++++ process/do_process.cpp | 4 ++++ 6 files changed, 38 insertions(+), 8 deletions(-)
diff --git a/Android.mk b/Android.mk index 6948011..e6e73b1 100644 --- a/Android.mk +++ b/Android.mk @@ -1,17 +1,32 @@ LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS)
-LOCAL_MODULE_TAGS := debug +LOCAL_MODULE_TAGS := optional LOCAL_SHARED_LIBRARIES := libstlport \
- libnl \
- libnl
+LOCAL_STATIC_LIBRARIES := libncurses
LOCAL_MODULE := powertop
#LOCAL_CFLAGS += -Wall -O2 -g -fno-omit-frame-pointer -fstack-protector -Wshadow -Wformat -D_FORTIFY_SOURCE=2 #LOCAL_CPPFLAGS += -Wall -O2 -g -fno-omit-frame-pointer -LOCAL_CPPFLAGS += -DDISABLE_NCURSES -DDISABLE_I18N -DDISABLE_TRYCATCH +LOCAL_CPPFLAGS += \
- -DDISABLE_I18N \
- -DDISABLE_TRYCATCH \
- -DNCURSES_NOMACROS \
- -DDISABLE_WSTRING \
- -DDEFAULT_TERM="xterm" \
-LOCAL_C_INCLUDES += external/stlport/stlport/ external/stlport/stlport/stl external/stlport/stlport/using/h/ bionic external/libnl/include/ +LOCAL_C_INCLUDES += external/stlport/stlport/ \
- external/stlport/stlport/stl \
- external/stlport/stlport/using/h/ \
- bionic \
- external/libnl/include/ \
- external/ncurses \
- external/ncurses/lib \
- external/ncurses/include \
- external/ncurses/include/ncurses
ifneq ($(TARGET_ARCH),arm) LOCAL_SHARED_LIBRARIES += libpci diff --git a/display.cpp b/display.cpp index f486050..283743c 100644 --- a/display.cpp +++ b/display.cpp @@ -84,8 +84,11 @@ void reset_display(void) keypad(stdscr, FALSE); echo(); nocbreak();
+#ifndef NCURSES_NOMACROS resetterm(); +#else
- reset_shell_mode();
+#endif }
diff --git a/display.h b/display.h index 3b24914..023f68d 100644 --- a/display.h +++ b/display.h @@ -49,7 +49,8 @@ public: int cursor_pos; int cursor_max; WINDOW *win;
- virtual ~tab_window() {};
virtual void cursor_down(void) { if (cursor_pos < cursor_max ) cursor_pos++; repaint(); } ; virtual void cursor_up(void) { if (cursor_pos > 0) cursor_pos--; repaint(); };
diff --git a/lib.cpp b/lib.cpp index d058e4f..86fcf96 100644 --- a/lib.cpp +++ b/lib.cpp @@ -238,10 +238,12 @@ void format_watts(double W, char *buffer, unsigned int len) if (W < 0.0001) sprintf(buffer, _(" 0 mW"));
-#ifndef DISABLE_NCURSES +#ifndef DISABLE_NCURSES +#ifndef DISABLE_WSTRING while (mbstowcs(NULL,buffer,0) < len) strcat(buffer, " "); -#endif +#endif //DISABLE_WSTRING +#endif //DISABLE_NCURSES }
#ifndef DISABLE_PCI diff --git a/main.cpp b/main.cpp index 3ee0a7e..fc4b0cf 100644 --- a/main.cpp +++ b/main.cpp @@ -280,6 +280,11 @@ int main(int argc, char **argv) bindtextdomain ("powertop", "/usr/share/locale"); textdomain ("powertop"); #endif
+#ifdef DEFAULT_TERM
- if (!getenv("TERM"))
- setenv("TERM", DEFAULT_TERM, 1);
+#endif uid = getuid();
if (uid != 0) { diff --git a/process/do_process.cpp b/process/do_process.cpp index 5c382f1..7e39321 100644 --- a/process/do_process.cpp +++ b/process/do_process.cpp @@ -720,7 +720,9 @@ void process_update_display(void) if (!show_power) strcpy(power, " "); sprintf(name, "%s", all_power[i]->type()); +#ifndef DISABLE_WSTRING while (mbstowcs(NULL,name,0) < 14) strcat(name, " "); +#endif
if (all_power[i]->events() == 0 && all_power[i]->usage() == 0 && all_power[i]->Witts() == 0) @@ -733,7 +735,9 @@ void process_update_display(void) else sprintf(usage, "%5i%s", (int)all_power[i]->usage(), all_power[i]->usage_units()); } +#ifndef DISABLE_WSTRING while (mbstowcs(NULL,usage,0) < 14) strcat(usage, " "); +#endif sprintf(events, "%5.1f", all_power[i]->events()); if (!all_power[i]->show_events()) events[0] = 0;
most of the code in this patch read "autotoolize this" to me...
You can redefine stuff that needs stubbing out easily, get rid of most of the #ifdefs as well.
Auke
On 15 July 2011 23:05, Kok, Auke-jan H auke-jan.h.kok@intel.com wrote:
On Thu, Jul 14, 2011 at 11:35 PM, Amit Daniel Kachhap amit.kachhap@linaro.org wrote:
This patch enables ncurses for android. NCURSES_NOMACRO flag is enabled as there is some conflict with stl libraries.
Signed-off-by: Amit Daniel Kachhap amit.kachhap@linaro.org
Android.mk | 23 +++++++++++++++++++---- display.cpp | 5 ++++- display.h | 3 ++- lib.cpp | 6 ++++-- main.cpp | 5 +++++ process/do_process.cpp | 4 ++++ 6 files changed, 38 insertions(+), 8 deletions(-)
diff --git a/Android.mk b/Android.mk index 6948011..e6e73b1 100644 --- a/Android.mk +++ b/Android.mk @@ -1,17 +1,32 @@ LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS)
-LOCAL_MODULE_TAGS := debug +LOCAL_MODULE_TAGS := optional LOCAL_SHARED_LIBRARIES := libstlport \
- libnl \
- libnl
+LOCAL_STATIC_LIBRARIES := libncurses
LOCAL_MODULE := powertop
#LOCAL_CFLAGS += -Wall -O2 -g -fno-omit-frame-pointer -fstack-protector -Wshadow -Wformat -D_FORTIFY_SOURCE=2 #LOCAL_CPPFLAGS += -Wall -O2 -g -fno-omit-frame-pointer -LOCAL_CPPFLAGS += -DDISABLE_NCURSES -DDISABLE_I18N -DDISABLE_TRYCATCH +LOCAL_CPPFLAGS += \
- -DDISABLE_I18N \
- -DDISABLE_TRYCATCH \
- -DNCURSES_NOMACROS \
- -DDISABLE_WSTRING \
- -DDEFAULT_TERM="xterm" \
-LOCAL_C_INCLUDES += external/stlport/stlport/ external/stlport/stlport/stl external/stlport/stlport/using/h/ bionic external/libnl/include/ +LOCAL_C_INCLUDES += external/stlport/stlport/ \
- external/stlport/stlport/stl \
- external/stlport/stlport/using/h/ \
- bionic \
- external/libnl/include/ \
- external/ncurses \
- external/ncurses/lib \
- external/ncurses/include \
- external/ncurses/include/ncurses
ifneq ($(TARGET_ARCH),arm) LOCAL_SHARED_LIBRARIES += libpci diff --git a/display.cpp b/display.cpp index f486050..283743c 100644 --- a/display.cpp +++ b/display.cpp @@ -84,8 +84,11 @@ void reset_display(void) keypad(stdscr, FALSE); echo(); nocbreak();
+#ifndef NCURSES_NOMACROS resetterm(); +#else
- reset_shell_mode();
+#endif }
diff --git a/display.h b/display.h index 3b24914..023f68d 100644 --- a/display.h +++ b/display.h @@ -49,7 +49,8 @@ public: int cursor_pos; int cursor_max; WINDOW *win;
- virtual ~tab_window() {};
virtual void cursor_down(void) { if (cursor_pos < cursor_max ) cursor_pos++; repaint(); } ; virtual void cursor_up(void) { if (cursor_pos > 0) cursor_pos--; repaint(); };
diff --git a/lib.cpp b/lib.cpp index d058e4f..86fcf96 100644 --- a/lib.cpp +++ b/lib.cpp @@ -238,10 +238,12 @@ void format_watts(double W, char *buffer, unsigned int len) if (W < 0.0001) sprintf(buffer, _(" 0 mW"));
-#ifndef DISABLE_NCURSES +#ifndef DISABLE_NCURSES +#ifndef DISABLE_WSTRING while (mbstowcs(NULL,buffer,0) < len) strcat(buffer, " "); -#endif +#endif //DISABLE_WSTRING +#endif //DISABLE_NCURSES }
#ifndef DISABLE_PCI diff --git a/main.cpp b/main.cpp index 3ee0a7e..fc4b0cf 100644 --- a/main.cpp +++ b/main.cpp @@ -280,6 +280,11 @@ int main(int argc, char **argv) bindtextdomain ("powertop", "/usr/share/locale"); textdomain ("powertop"); #endif
+#ifdef DEFAULT_TERM
- if (!getenv("TERM"))
- setenv("TERM", DEFAULT_TERM, 1);
+#endif uid = getuid();
if (uid != 0) { diff --git a/process/do_process.cpp b/process/do_process.cpp index 5c382f1..7e39321 100644 --- a/process/do_process.cpp +++ b/process/do_process.cpp @@ -720,7 +720,9 @@ void process_update_display(void) if (!show_power) strcpy(power, " "); sprintf(name, "%s", all_power[i]->type()); +#ifndef DISABLE_WSTRING while (mbstowcs(NULL,name,0) < 14) strcat(name, " "); +#endif
if (all_power[i]->events() == 0 && all_power[i]->usage() == 0 && all_power[i]->Witts() == 0) @@ -733,7 +735,9 @@ void process_update_display(void) else sprintf(usage, "%5i%s", (int)all_power[i]->usage(), all_power[i]->usage_units()); } +#ifndef DISABLE_WSTRING while (mbstowcs(NULL,usage,0) < 14) strcat(usage, " "); +#endif sprintf(events, "%5.1f", all_power[i]->events()); if (!all_power[i]->show_events()) events[0] = 0;
most of the code in this patch read "autotoolize this" to me...
You can redefine stuff that needs stubbing out easily, get rid of most of the #ifdefs as well.
Agreed. I will redefine mbstowcs implementation in next version.
Auke
On Thu, Jul 14, 2011 at 11:35 PM, Amit Daniel Kachhap amit.kachhap@linaro.org wrote:
The following set of patches add changes in powertop needed for arm android platforms. These patches depends on the below mentioned patches. http://www.mail-archive.com/power@bughost.org/msg02078.html
Amit Daniel Kachhap (3): powertop: Disable pci bus measurement for arm platforms perf-event: Add defination of __NR_perf_event_open for arm platforms ncurses: Enable ncurses for android and miscellaneous changes
I hate to say this, but with stuff like this being posted, it's time to autotoolize powertop properly. These patches do more harm to building sanely than anything, and I don't think they're the right solution to making the code portable at all.
Adding an Android.mk should have never happened in the first place.
Auke