From patchwork Mon Sep 17 14:34:09 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: rajagopal.venkat@linaro.org X-Patchwork-Id: 11462 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id D082123EB4 for ; Mon, 17 Sep 2012 14:36:27 +0000 (UTC) Received: from mail-ie0-f180.google.com (mail-ie0-f180.google.com [209.85.223.180]) by fiordland.canonical.com (Postfix) with ESMTP id 1BA983D08933 for ; Mon, 17 Sep 2012 14:36:26 +0000 (UTC) Received: by mail-ie0-f180.google.com with SMTP id k11so9283829iea.11 for ; Mon, 17 Sep 2012 07:36:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=8E16bVc+hkQFeRjE+8Yl7Gr3ZM/2atYfOY7nARC1D6s=; b=OFcwpQ24WhadpUhE5B2DjGR7Fsf/hoqQZVEyWRepPtxx8XskwTGFpyrEupUpRlbqQd x4wu+mFsWVdnpS/BWzw9pkrgUb6F1+OJrlNX3HPktZLQtl+GWpd4bshTM/hu7vlbiCTH 1Ae4Cs8YGre8b6+gPDooaRhNQJ9ISADmcYFLd7tfIhWbg9RAm/7UrmUp8+op0Nm0IV2b UiSpy7lm8PUNKQRMQE8sAIy0hJlWJuKB/IU/JrkpSnnxqhaBiyemVN3W104gH7RpHrlc PBR5s6sVoUm2bUY49mSsfLHQspRQP4sjrXSHPkqe3Xtp7lKUnbX78iEZcgI+A/fe25CO P98Q== Received: by 10.50.184.129 with SMTP id eu1mr1110114igc.0.1347892585832; Mon, 17 Sep 2012 07:36:25 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.50.184.232 with SMTP id ex8csp319228igc; Mon, 17 Sep 2012 07:36:25 -0700 (PDT) Received: by 10.68.241.105 with SMTP id wh9mr23036562pbc.1.1347892584850; Mon, 17 Sep 2012 07:36:24 -0700 (PDT) Received: from mail-pz0-f50.google.com (mail-pz0-f50.google.com [209.85.210.50]) by mx.google.com with ESMTPS id iw4si15807200pbc.321.2012.09.17.07.36.24 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 17 Sep 2012 07:36:24 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.210.50 is neither permitted nor denied by best guess record for domain of rajagopal.venkat@linaro.org) client-ip=209.85.210.50; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.210.50 is neither permitted nor denied by best guess record for domain of rajagopal.venkat@linaro.org) smtp.mail=rajagopal.venkat@linaro.org Received: by dade7 with SMTP id e7so4961379dad.37 for ; Mon, 17 Sep 2012 07:36:24 -0700 (PDT) Received: by 10.68.218.101 with SMTP id pf5mr23020180pbc.60.1347892584451; Mon, 17 Sep 2012 07:36:24 -0700 (PDT) Received: from localhost.localdomain ([101.62.98.60]) by mx.google.com with ESMTPS id ty1sm7025415pbc.76.2012.09.17.07.36.21 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 17 Sep 2012 07:36:23 -0700 (PDT) From: Rajagopal Venkat To: powertop@lists.01.org Cc: patches@linaro.org, linaro-dev@lists.linaro.org, rajagopal.venkat@linaro.org Subject: [Powertop][PATCH 2/2] Add stubs to support Android platform Date: Mon, 17 Sep 2012 20:04:09 +0530 Message-Id: <1347892449-10484-2-git-send-email-rajagopal.venkat@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1347892449-10484-1-git-send-email-rajagopal.venkat@linaro.org> References: <1347892449-10484-1-git-send-email-rajagopal.venkat@linaro.org> X-Gm-Message-State: ALoCoQnZuLpY5fvRx6x6IJsfo2E9tnSw6JlPuKtkrVy9eD6yEQtDr+BI3E2X0Ry61qKjBk6NqA3y This patch adds stubs for features that are not supported by Andriod. An header file which defines all stubs is included only for Android builds. Signed-off-by: Rajagopal Venkat --- Android.mk | 33 +++++++++++++++++++++++++++------ src/android_stubs.h | 47 +++++++++++++++++++++++++++++++++++++++++++++++ src/lib.h | 4 ++++ 3 files changed, 78 insertions(+), 6 deletions(-) create mode 100644 src/android_stubs.h diff --git a/Android.mk b/Android.mk index a52ecfd..081f470 100644 --- a/Android.mk +++ b/Android.mk @@ -1,17 +1,36 @@ LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) +LOCAL_MODULE := powertop + LOCAL_MODULE_TAGS := debug LOCAL_SHARED_LIBRARIES := libstlport \ libnl \ libpci \ - libtraceevnet \ -LOCAL_MODULE := powertop + +LOCAL_STATIC_LIBRARIES := libncurses + +CSSTOH_SOURCE := $(LOCAL_PATH)/src/csstoh.c +POWERTOP_CSS_SOURCE := $(LOCAL_PATH)/src/powertop.css +GEN_CSSTOH := $(LOCAL_PATH)/src/csstoh +GEN_CSS_H := $(LOCAL_PATH)/src/css.h +$(GEN_CSS_H): + $(CC) -o $(GEN_CSSTOH) $(CSSTOH_SOURCE) + ./$(GEN_CSSTOH) $(POWERTOP_CSS_SOURCE) $@ + +LOCAL_GENERATED_SOURCES += $(GEN_CSS_H) #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_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/include \ + external/elfutils/bionic-fixup \ + $(LOCAL_PATH)/src LOCAL_SRC_FILES += \ src/parameters/parameters.cpp \ @@ -21,10 +40,11 @@ LOCAL_SRC_FILES += \ src/process/work.cpp \ src/process/process.cpp \ src/process/timer.cpp \ - src/process/device.cpp \ + src/process/processdevice.cpp \ src/process/interrupt.cpp \ src/process/do_process.cpp \ src/cpu/intel_cpus.cpp \ + src/cpu/intel_gpu.cpp \ src/cpu/cpu.cpp \ src/cpu/cpu_linux.cpp \ src/cpu/cpudevice.cpp \ @@ -33,20 +53,21 @@ LOCAL_SRC_FILES += \ src/cpu/abstract_cpu.cpp \ src/measurement/measurement.cpp \ src/measurement/acpi.cpp \ + src/measurement/sysfs.cpp \ src/measurement/extech.cpp \ src/measurement/power_supply.cpp \ src/display.cpp \ src/report.cpp \ src/main.cpp \ src/tuning/tuning.cpp \ - src/tuning/usb.cpp \ + src/tuning/tuningusb.cpp \ src/tuning/bluetooth.cpp \ src/tuning/ethernet.cpp \ src/tuning/runtime.cpp \ src/tuning/iw.c \ src/tuning/iw.h \ src/tuning/tunable.cpp \ - src/tuning/sysfs.cpp \ + src/tuning/tuningsysfs.cpp \ src/tuning/cpufreq.cpp \ src/tuning/wifi.cpp \ src/perf/perf_bundle.cpp \ diff --git a/src/android_stubs.h b/src/android_stubs.h new file mode 100644 index 0000000..60b1e29 --- /dev/null +++ b/src/android_stubs.h @@ -0,0 +1,47 @@ +#include +#include + +/* Android doesn't provide locale support int its C and C++ + * runtime. Handled at higher level in application stack. + * So define stubs for gettext funtions used. + */ +#define PACKAGE 0 +#define LOCALEDIR 0 +#define bindtextdomain(x, y) +#define textdomain(x) +#define gettext(x) (x) + +/* Android C++ new operator does not throw exception on failure */ +#define set_new_handler(x) + +/* define stubs for C++ exception handling */ +#define try if (true) +#define catch(x) if (false) + +/* Define __NR_perf_event_open if not already defined */ +#if __arm__ +#ifndef __NR_perf_event_open +#define __NR_perf_event_open 364 +#endif +#endif + +/* Implement missing functions */ +static inline void ethtool_cmd_speed_set(struct ethtool_cmd *ep, + __u32 speed) +{ + + ep->speed = (__u16)speed; + ep->speed_hi = (__u16)(speed >> 16); +} + +static inline __u32 ethtool_cmd_speed(struct ethtool_cmd *ep) +{ + return (ep->speed_hi << 16) | ep->speed; +} + +static inline char *strchrnul(const char *s, int c) +{ + while (*s && (*s != c)) + s++; + return (char *)s; +} diff --git a/src/lib.h b/src/lib.h index 8cf4632..6772904 100644 --- a/src/lib.h +++ b/src/lib.h @@ -33,6 +33,10 @@ #include "config.h" #endif +#ifdef __ANDROID__ +#include "android_stubs.h" +#endif + #define _(STRING) gettext(STRING) #define POWERTOP_VERSION "v2.1"