aboutsummaryrefslogtreecommitdiff
path: root/src/android_stubs.h
diff options
context:
space:
mode:
authorRajagopal Venkat <rajagopal.venkat@linaro.org>2012-09-17 15:55:48 +0530
committerRajagopal Venkat <rajagopal.venkat@linaro.org>2012-12-07 20:02:29 +0530
commit94e4b9b718496286c37f4910d75148a9f64c6d13 (patch)
treeb544f2a0b793541e2a0c53cf6f51644086eb8e39 /src/android_stubs.h
parent49ada948defeeb33d035e343377ed5447e87ee3e (diff)
downloadpowertop-2.0-v2-94e4b9b718496286c37f4910d75148a9f64c6d13.tar.gz
Add stubs to support Android platform
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 <rajagopal.venkat@linaro.org>
Diffstat (limited to 'src/android_stubs.h')
-rw-r--r--src/android_stubs.h47
1 files changed, 47 insertions, 0 deletions
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 <linux/ethtool.h>
+#include <sys/socket.h>
+
+/* 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;
+}