aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKoan-Sin Tan <freedom.tan@linaro.org>2015-01-21 14:43:50 +0800
committerTuukka Tikkanen <tuukka.tikkanen@linaro.org>2015-01-22 03:48:19 +0200
commit31ecd910c4f9b8692bc08947db5a90e73b0515fa (patch)
treea6db0f324776fcd022c54c880ca33e192f9ef35c
parent4fed8af2a0c606381c6116e2da9a860dc76b3b8d (diff)
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 <libgen.h> 4. Android doesn't have old <values.h>, use <floats.h> instead Signed-off-by: Koan-Sin Tan <freedom.tan@linaro.org> Reviewed-by: Tuukka Tikkanen <tuukka.tikkanen@linaro.org>
-rw-r--r--Android.mk16
-rw-r--r--energy_model.c14
-rw-r--r--idlestat.c9
-rw-r--r--topology.c2
-rw-r--r--tracefile_ftrace.c1
-rw-r--r--tracefile_idlestat.c2
-rw-r--r--tracefile_tracecmd.c1
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 <sys/wait.h>
#include <assert.h>
#include <ctype.h>
+#ifdef ANDROID
+#include <libgen.h>
+#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 <ctype.h>
#include <sys/stat.h>
#include <assert.h>
-#include <values.h>
+#include <float.h>
#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 <string.h>
#include <malloc.h>
#include <assert.h>
-#include <values.h>
#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 <string.h>
#include <malloc.h>
#include <assert.h>
-#include <values.h>
+#include <float.h>
#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 <string.h>
#include <malloc.h>
#include <assert.h>
-#include <values.h>
#define TRACE_CMD_REPORT_FORMAT "%*[^]]] %lf:%*[^=]=%u%*[^=]=%d"