diff --git a/libcpuid/asm-bits.c b/libcpuid/asm-bits.c index b8e3228..c1fa39d 100644 --- a/libcpuid/asm-bits.c +++ b/libcpuid/asm-bits.c @@ -32,7 +32,7 @@ int cpuid_exists_by_eflags(void) #if defined(PLATFORM_X64) return 1; /* CPUID is always present on the x86_64 */ #elif defined(PLATFORM_X86) -# if defined(COMPILER_GCC) +# if defined(COMPILER_GCC) || defined(COMPILER_CLANG) int result; __asm __volatile( " pushfl\n" @@ -70,6 +70,8 @@ int cpuid_exists_by_eflags(void) # else return 0; # endif /* COMPILER_MICROSOFT */ +#elif defined(PLATFORM_ARM) + return 0; #else return 0; #endif /* PLATFORM_X86 */ @@ -82,7 +84,7 @@ int cpuid_exists_by_eflags(void) */ void exec_cpuid(uint32_t *regs) { -#ifdef COMPILER_GCC +#if defined(COMPILER_GCC) || defined(COMPILER_CLANG) # ifdef PLATFORM_X64 __asm __volatile( " mov %0, %%rdi\n" @@ -109,7 +111,7 @@ void exec_cpuid(uint32_t *regs) :"m"(regs) :"memory", "eax", "rdi" ); -# else +# elif defined(PLATFORM_X86) __asm __volatile( " mov %0, %%edi\n" @@ -135,6 +137,7 @@ void exec_cpuid(uint32_t *regs) :"m"(regs) :"memory", "eax", "edi" ); +# elif defined(PLATFORM_ARM) # endif /* COMPILER_GCC */ #else # ifdef COMPILER_MICROSOFT @@ -173,13 +176,18 @@ void exec_cpuid(uint32_t *regs) void cpu_rdtsc(uint64_t* result) { uint32_t low_part, hi_part; -#ifdef COMPILER_GCC +#if defined(COMPILER_GCC) || defined(COMPILER_CLANG) +#ifdef PLATFORM_ARM + low_part = 0; + hi_part = 0; +#else __asm __volatile ( " rdtsc\n" " mov %%eax, %0\n" " mov %%edx, %1\n" :"=m"(low_part), "=m"(hi_part)::"memory", "eax", "edx" ); +#endif #else # ifdef COMPILER_MICROSOFT __asm { @@ -198,12 +206,14 @@ void cpu_rdtsc(uint64_t* result) #ifdef INLINE_ASM_SUPPORTED void busy_sse_loop(int cycles) { -#ifdef COMPILER_GCC +#if defined(COMPILER_GCC) || defined(COMPILER_CLANG) #ifndef __APPLE__ # define XALIGN ".balign 16\n" #else # define XALIGN ".align 4\n" #endif +#ifdef PLATFORM_ARM +#else __asm __volatile ( " xorps %%xmm0, %%xmm0\n" " xorps %%xmm1, %%xmm1\n" diff --git a/libcpuid/asm-bits.h b/libcpuid/asm-bits.h index 3a03e11..cc47342 100644 --- a/libcpuid/asm-bits.h +++ b/libcpuid/asm-bits.h @@ -32,6 +32,8 @@ # define COMPILER_MICROSOFT #elif defined(__GNUC__) # define COMPILER_GCC +#elif defined(__clang__) +# define COMPILER_CLANG #endif /* Determine Platform */ @@ -39,10 +41,12 @@ # define PLATFORM_X64 #elif defined(__i386__) || defined(_M_IX86) # define PLATFORM_X86 +#elif defined(__ARMEL__) +# define PLATFORM_ARM #endif /* Under Windows/AMD64 with MSVC, inline assembly isn't supported */ -#if (defined(COMPILER_GCC) && defined(PLATFORM_X64)) || defined(PLATFORM_X86) +#if ((defined(COMPILER_GCC) || defined(COMPILER_CLANG))) && defined(PLATFORM_X64)) || defined(PLATFORM_X86) || defined(PLATFORM_ARM) # define INLINE_ASM_SUPPORTED #endif diff --git a/libcpuid/libcpuid.h b/libcpuid/libcpuid.h index 2bf445f..053b014 100644 --- a/libcpuid/libcpuid.h +++ b/libcpuid/libcpuid.h @@ -1141,7 +1141,7 @@ int msr_serialize_raw_data(struct msr_driver_t* handle, const char* filename); int cpu_msr_driver_close(struct msr_driver_t* handle); #ifdef __cplusplus -}; /* extern "C" */ +} /* extern "C" */ #endif