From 31ecd910c4f9b8692bc08947db5a90e73b0515fa Mon Sep 17 00:00:00 2001 From: Koan-Sin Tan Date: Wed, 21 Jan 2015 14:43:50 +0800 Subject: re-enable compile and run on Android platform Make it possible to compile with either AOSP and NDK without warnings. For AOSP, putting the idlestat to AOSP_ROOT/external works fine. For NDK, the following command works fine. ndk-build NDK_PROJECT_PATH=`pwd` \ APP_BUILD_SCRIPT=`pwd`/Android.mk \ APP_PLATFORM=19 APP_ABI=armeabi-v7a 1. Most code modifications to eliminate warnings 2. Both AOSP and NDK use -Wl,--gc-sections, which will remove code compiled from tracefile_*.c and *_report.c, so we need -Wl,--no-gc-sections 3. Android basename() is declared in 4. Android doesn't have old , use instead Signed-off-by: Koan-Sin Tan Reviewed-by: Tuukka Tikkanen --- Android.mk | 16 +++++++++++++--- energy_model.c | 14 +++++++------- idlestat.c | 9 ++++++--- topology.c | 2 +- tracefile_ftrace.c | 1 - tracefile_idlestat.c | 2 +- tracefile_tracecmd.c | 1 - 7 files changed, 28 insertions(+), 17 deletions(-) diff --git a/Android.mk b/Android.mk index 3735d41..922a4b7 100644 --- a/Android.mk +++ b/Android.mk @@ -25,16 +25,26 @@ LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE_TAGS := optional -LOCAL_SHARED_LIBRARIES := libstlport - LOCAL_MODULE := idlestat +LOCAL_CFLAGS := +LOCAL_LDFLAGS := -Wl,--no-gc-sections + +TRACE_SRC_FILES = tracefile_idlestat.c tracefile_ftrace.c \ + tracefile_tracecmd.c -LOCAL_C_INCLUDES += bionic \ +REPORT_SRC_FILES = default_report.c csv_report.c comparison_report.c LOCAL_SRC_FILES += \ idlestat.c \ topology.c \ trace.c \ utils.c \ + energy_model.c \ + reports.c \ + ops_head.c \ + $(TRACE_SRC_FILES) \ + $(REPORT_SRC_FILES) \ + ops_tail.c \ + include $(BUILD_EXECUTABLE) diff --git a/energy_model.c b/energy_model.c index 2515de8..6931ea4 100644 --- a/energy_model.c +++ b/energy_model.c @@ -75,7 +75,7 @@ static int make_energy_model_template(struct program_options *options) list_for_each_entry(s_phy, &cpu_topo->physical_head, list_physical) { unsigned int num_cap_states = 0; unsigned int num_c_states = 0; - unsigned int i; + int i; s_core = list_entry((&s_phy->core_head)->prev, struct cpu_core, list_core); s_cpu = list_entry((&s_core->cpu_head)->prev, struct cpu_cpu, list_cpu); @@ -118,11 +118,11 @@ int parse_energy_model(struct program_options *options) { FILE *f; char tmp; - struct cluster_energy_info *clustp; + struct cluster_energy_info *clustp = NULL; unsigned int number_cap_states, number_c_states; int current_cluster = -1; - unsigned int current_pstate; - unsigned int current_cstate; + unsigned int current_pstate = 0; + unsigned int current_cstate = 0; unsigned int clust_p, core_p; char buffer[BUFSIZE]; char *path = options->energy_model_filename; @@ -170,7 +170,7 @@ int parse_energy_model(struct program_options *options) sscanf(buffer, "cluster%c: %d cap states %d C states", &tmp, &number_cap_states, &number_c_states); current_cluster = tmp - 'A'; - if (current_cluster >= clusters_in_energy_file) { + if (current_cluster >= (int) clusters_in_energy_file) { fprintf(stderr, "%s: cluster%c out of range in %s\n", __func__, tmp, path); fclose(f); @@ -304,7 +304,7 @@ static struct cstate_energy_info *find_cstate_energy_info(const unsigned int clu { struct cluster_energy_info *clustp; struct cstate_energy_info *cp; - int i; + unsigned int i; clustp = cluster_energy_table + cluster; cp = &clustp->c_energy[0]; @@ -318,7 +318,7 @@ static struct pstate_energy_info *find_pstate_energy_info(const unsigned int clu { struct cluster_energy_info *clustp; struct pstate_energy_info *pp; - int i; + unsigned int i; clustp = cluster_energy_table + cluster; pp = &clustp->p_energy[0]; diff --git a/idlestat.c b/idlestat.c index ddfbfe2..f52bd0b 100644 --- a/idlestat.c +++ b/idlestat.c @@ -38,6 +38,9 @@ #include #include #include +#ifdef ANDROID +#include +#endif #include "idlestat.h" #include "utils.h" @@ -293,7 +296,7 @@ int cpuidle_get_target_residency(int cpu, int state) ret = fscanf(snf, "%u", &tr); fclose(snf); - return (ret == 1) ? tr : -1; + return (ret == 1) ? (int)tr : -1; } /** @@ -622,8 +625,8 @@ int check_pstate_composite(struct cpuidle_datas *datas, int cpu, double time) int cpu_change_pstate(struct cpuidle_datas *datas, int cpu, unsigned int freq, double time) { - struct cpufreq_pstates *ps; - struct cpufreq_pstate *p; + struct cpufreq_pstates *ps = NULL; + struct cpufreq_pstate *p = NULL; int cur, next; cur = get_current_pstate(datas, cpu, &ps, &p); diff --git a/topology.c b/topology.c index 6e70773..ff0b6fb 100644 --- a/topology.c +++ b/topology.c @@ -36,7 +36,7 @@ #include #include #include -#include +#include #include "list.h" #include "utils.h" diff --git a/tracefile_ftrace.c b/tracefile_ftrace.c index f4f9706..a5a04b5 100644 --- a/tracefile_ftrace.c +++ b/tracefile_ftrace.c @@ -31,7 +31,6 @@ #include #include #include -#include #define TRACE_FORMAT "%*[^]]] %*s %lf:%*[^=]=%u%*[^=]=%d" diff --git a/tracefile_idlestat.c b/tracefile_idlestat.c index 45b3b93..cb6f5bc 100644 --- a/tracefile_idlestat.c +++ b/tracefile_idlestat.c @@ -33,7 +33,7 @@ #include #include #include -#include +#include #define TRACE_FORMAT "%*[^]]] %*s %lf:%*[^=]=%u%*[^=]=%d" diff --git a/tracefile_tracecmd.c b/tracefile_tracecmd.c index 8938f23..586d3c5 100644 --- a/tracefile_tracecmd.c +++ b/tracefile_tracecmd.c @@ -33,7 +33,6 @@ #include #include #include -#include #define TRACE_CMD_REPORT_FORMAT "%*[^]]] %lf:%*[^=]=%u%*[^=]=%d" -- cgit v1.2.3