[PATCH 5/5] igt-gpu-tools: Changes to compile for Android
Kamil Konieczny
kamil.konieczny at linux.intel.com
Wed Apr 30 17:26:59 UTC 2025
Hi Jeevaka,
On 2025-04-29 at 20:40:00 +0000, Jeevaka Prabu Badrappan wrote:
> 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
Please split this into patches for lib/igt_core, lib/igt_kmod,
tests/intel/xe_create and tools/intel_gpu_top
+cc Zbigniew
>
> 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) {}
Please print something like "backtrace not implemented\n"
> +#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
Use C-style comments /* 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
Either for ANDROID or use:
#ifndef __noreturn
...
#endif
> #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
Please add to Cc developer which added this. imho this should be:
int page_size = 0x1000;
and used in this test.
Or what about:
#define IGT_PAGE_SIZE 0x1000
or other name like GPU_PAGE_SIZE
There are many places in igt source where PAGE_SIZE is used so why
change is only here? If you will want to change more, please split
big patches to some smaller portions.
> 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');
Good change, index is deprecated.
Regards,
Kamil
> if (!p)
> return -1;
>
> --
> 2.49.0
>
More information about the igt-dev
mailing list