[PATCH] tools/x86: Support clang compilation for Android
Kaushlendra Kumar <[email protected]> Fri, 7 Nov 2025 12:44:24 +0530
| Newsgroups | dev.linux.lists.x86-cpuid |
|---|---|
| Message-ID | <[email protected]> |
Add missing stdint.h include and replace compiler-gcc.h with compiler.h to fix clang compilation errors on Android builds. Change u64 typedef to use standard uint64_t with header guards to maintain backward compatibility with existing Linux builds. This resolves clang build failures where uint64_t is undefined and ensures the tool compiles on both Android NDK and Linux toolchains. Signed-off-by: Kaushlendra Kumar <[email protected]> --- tools/arch/x86/kcpuid/kcpuid.c | 5 ++++- tools/include/linux/compiler_types.h | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/tools/arch/x86/kcpuid/kcpuid.c b/tools/arch/x86/kcpuid/kcpuid.c index 7dc6b9235d02..5243b49556be 100644 --- a/tools/arch/x86/kcpuid/kcpuid.c +++ b/tools/arch/x86/kcpuid/kcpuid.c @@ -7,6 +7,7 @@ #include <stdbool.h> #include <stdio.h> #include <stdlib.h> +#include <stdint.h> #include <string.h> #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) @@ -14,7 +15,9 @@ #define __noreturn __attribute__((__noreturn__)) typedef unsigned int u32; -typedef unsigned long long u64; +#ifndef u64 +#define u64 uint64_t +#endif char *def_csv = "/usr/share/misc/cpuid.csv"; char *user_csv; diff --git a/tools/include/linux/compiler_types.h b/tools/include/linux/compiler_types.h index d09f9dc172a4..0333c234fe3d 100644 --- a/tools/include/linux/compiler_types.h +++ b/tools/include/linux/compiler_types.h @@ -33,7 +33,7 @@ /* Compiler specific macros. */ #ifdef __GNUC__ -#include <linux/compiler-gcc.h> +#include <linux/compiler.h> #endif #ifndef asm_goto_output -- 2.34.1