tools/x86: Support clang compilation for Android
PATCH 1/1 tools/x86: Support clang compilation for Android
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(-)
tools/arch/x86/kcpuid/kcpuid.c +4 -1
@@ -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;
tools/include/linux/compiler_types.h +1 -1
@@ -33,7 +33,7 @@/* Compiler specific macros. */ #ifdef __GNUC__ -#include <linux/compiler-gcc.h> +#include <linux/compiler.h> #endif #ifndef asm_goto_output
Signature · 1 line
2.34.1