[PATCH 5/5] igt-gpu-tools: Changes to compile for Android
Jeevaka Prabu Badrappan
jeevaka.badrappan at intel.com
Tue Apr 29 20:39:19 UTC 2025
Changes done to compile for android:
- __noreturn and PAGE_SIZE are already defined in Android,
undef and then define it.
- define strchrnul for Android
- Replace index with strchr
Signed-off-by: Jeevaka Prabu Badrappan <jeevaka.badrappan at intel.com>
---
lib/igt_core.c | 4 ++++
lib/igt_core.h | 1 +
lib/igt_kmod.c | 10 ++++++++++
tests/intel/xe_create.c | 1 +
tools/intel_gpu_top.c | 2 +-
5 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/lib/igt_core.c b/lib/igt_core.c
index e1061a2ed..519600dfa 100644
--- a/lib/igt_core.c
+++ b/lib/igt_core.c
@@ -373,6 +373,9 @@ static bool stderr_needs_sentinel = false;
static int _igt_dynamic_tests_executed = -1;
+#ifdef ANDROID
+static void print_backtrace(void) {}
+#else
static void print_backtrace(void)
{
unw_cursor_t cursor;
@@ -433,6 +436,7 @@ static void print_backtrace(void)
if (dwfl)
dwfl_end(dwfl);
}
+#endif // ANDROID
__attribute__((format(printf, 2, 3)))
static void internal_assert(bool cond, const char *format, ...)
diff --git a/lib/igt_core.h b/lib/igt_core.h
index 45170e215..7add65938 100644
--- a/lib/igt_core.h
+++ b/lib/igt_core.h
@@ -86,6 +86,7 @@
#define igt_assume(e) BUILD_BUG_ON_INVALID(e)
#endif
+#undef __noreturn
#define __noreturn __attribute__((noreturn))
#define __maybe_unused __attribute__((unused))
diff --git a/lib/igt_kmod.c b/lib/igt_kmod.c
index 14b6b957a..d0a7372b8 100644
--- a/lib/igt_kmod.c
+++ b/lib/igt_kmod.c
@@ -765,6 +765,16 @@ igt_amdgpu_driver_unload(void)
return IGT_EXIT_SUCCESS;
}
+#ifdef ANDROID
+char *strchrnul(const char *s, int c)
+{
+ while (*s && *s != (char)c) {
+ s++;
+ }
+ return (char *)s;
+}
+#endif
+
static void kmsg_dump(int fd)
{
char record[4096 + 1];
diff --git a/tests/intel/xe_create.c b/tests/intel/xe_create.c
index b22084c84..264b2ae37 100644
--- a/tests/intel/xe_create.c
+++ b/tests/intel/xe_create.c
@@ -18,6 +18,7 @@
#include "xe/xe_ioctl.h"
#include "xe/xe_query.h"
+#undef PAGE_SIZE
#define PAGE_SIZE 0x1000
static struct param {
diff --git a/tools/intel_gpu_top.c b/tools/intel_gpu_top.c
index 68d27089b..54e71e559 100644
--- a/tools/intel_gpu_top.c
+++ b/tools/intel_gpu_top.c
@@ -290,7 +290,7 @@ get_pmu_config(int dirfd, const char *name, const char *counter)
if (ret <= 0)
return -1;
- p = index(buf, '0');
+ p = strchr(buf, '0');
if (!p)
return -1;
--
2.49.0
More information about the igt-dev
mailing list