From patchwork Mon Sep 24 13:28:04 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: 11669 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 AA85A23EFB for ; Mon, 24 Sep 2012 13:31:40 +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 58E80A18060 for ; Mon, 24 Sep 2012 13:31:40 +0000 (UTC) Received: by mail-ie0-f180.google.com with SMTP id e10so9896664iej.11 for ; Mon, 24 Sep 2012 06:31:40 -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=S3OqyrBY5JENaOthTrcglaCIuKksRH4UoeYl9T01vAE=; b=hh5eyv2h1s/YemTBo8xEz5m2L69Lw4ufKPAAcOF4bru6yW0iWu2161ClKkkFt5rMVF Dg13k7IIQZCn9eTd+9vDIOuh5Rx2ohkwLQfc4ejXUZKNdSNannGb8V7aeKhke0YXxUJF 7dOLEOgolQE6mus0byXSarFENLC5z/b0rEFNrvIFjlA5NbMO0Czyd/Vj4ejYMPwEMy9B TckwhLdP6meB0/KT1fmY+ZYyjnQc+hCnzcGo1pR0w1RW5GW8fBtm7iuzVGpZ0SAp3Ku3 2GsTT2zCf14mHS+7zZQ2YXbwTvqRBppgjdRtLheliM5YD0gC8Ee6eHg8PtiNcMoFzDTy 5NGA== Received: by 10.50.154.227 with SMTP id vr3mr5188041igb.43.1348493500066; Mon, 24 Sep 2012 06:31:40 -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 ex8csp243490igc; Mon, 24 Sep 2012 06:31:39 -0700 (PDT) Received: by 10.68.210.207 with SMTP id mw15mr36503804pbc.81.1348493499135; Mon, 24 Sep 2012 06:31:39 -0700 (PDT) Received: from mail-pb0-f50.google.com (mail-pb0-f50.google.com [209.85.160.50]) by mx.google.com with ESMTPS id iv6si19593798pbc.118.2012.09.24.06.31.38 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 24 Sep 2012 06:31:39 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.160.50 is neither permitted nor denied by best guess record for domain of rajagopal.venkat@linaro.org) client-ip=209.85.160.50; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.160.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 mail-pb0-f50.google.com with SMTP id md12so13214747pbc.37 for ; Mon, 24 Sep 2012 06:31:38 -0700 (PDT) Received: by 10.68.229.73 with SMTP id so9mr37298701pbc.66.1348493498701; Mon, 24 Sep 2012 06:31:38 -0700 (PDT) Received: from localhost.localdomain ([115.242.131.216]) by mx.google.com with ESMTPS id i1sm8768345pay.26.2012.09.24.06.31.29 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 24 Sep 2012 06:31:37 -0700 (PDT) From: Rajagopal Venkat To: powertop@lists.01.org Cc: patches@linaro.org, linaro-dev@lists.linaro.org, Rajagopal Venkat Subject: [Powertop][PATCH v2 2/2] Add stubs to support Android platform Date: Mon, 24 Sep 2012 18:58:04 +0530 Message-Id: <1348493284-9375-2-git-send-email-rajagopal.venkat@linaro.org> X-Mailer: git-send-email 1.7.11.3 In-Reply-To: <1348493284-9375-1-git-send-email-rajagopal.venkat@linaro.org> References: <1348493284-9375-1-git-send-email-rajagopal.venkat@linaro.org> X-Gm-Message-State: ALoCoQlsWoI79UNtA8cfdA40djzObp/qoQQ0uS9o7rd9eb/zupCpwlWNfKJ4jNaJBEnByjAS3kl3 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 | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++ src/lib.h | 4 ++++ 3 files changed, 96 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..ed37c0e --- /dev/null +++ b/src/android_stubs.h @@ -0,0 +1,65 @@ +#include +#include +#include +#include + + +/* Android doesn't provide locale support in 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 + +/* + * bionic libc mbstowcs version returns zero when max parameter + * is zero, resulting infinite loops in powertop source. Add + * mbstowcs wrapper to fix it. + */ +namespace pandroid { + extern "C" inline size_t mbstowcs(wchar_t *dst, + const char *src, size_t len) + { + return ::mbstowcs(dst, src, ::strlen(src)); + } +} + +#define mbstowcs(dst, src, len) pandroid::mbstowcs(dst, src, len) + +/* 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"