diff --git a/libcpuid/asm-bits.c b/libcpuid/asm-bits.c index 81d610a..95a1846 100644 --- a/libcpuid/asm-bits.c +++ b/libcpuid/asm-bits.c @@ -29,10 +29,10 @@ int cpuid_exists_by_eflags(void) { -#ifdef PLATFORM_X64 +#if defined(PLATFORM_X64) return 1; /* CPUID is always present on the x86_64 */ -#else -# ifdef COMPILER_GCC +#elif defined(PLATFORM_X86) +# if defined(COMPILER_GCC) int result; __asm __volatile( " pushfl\n" @@ -50,8 +50,7 @@ int cpuid_exists_by_eflags(void) : "=m"(result) : :"eax", "ecx", "memory"); return (result != 0); -# else -# ifdef COMPILER_MICROSOFT +# elif defined(COMPILER_MICROSOFT) int result; __asm { pushfd @@ -68,20 +67,21 @@ int cpuid_exists_by_eflags(void) popfd }; return (result != 0); -# else -# error "Unsupported compiler" -# endif /* COMPILER_MICROSOFT */ -# endif /* COMPILER_GCC */ -#endif /* PLATFORM_X64 */ +# else + return 0; +# endif /* COMPILER_MICROSOFT */ +#else + return 0; +#endif /* PLATFORM_X86 */ } /* * with MSVC/AMD64, the exec_cpuid() and cpu_rdtsc() functions * are implemented in separate .asm files. Otherwise, use inline assembly */ -#ifdef INLINE_ASM_SUPPORTED void exec_cpuid(uint32_t *regs) { +#ifdef INLINE_ASM_SUPPORTED #ifdef COMPILER_GCC # ifdef PLATFORM_X64 __asm __volatile( @@ -166,8 +166,8 @@ void exec_cpuid(uint32_t *regs) # error "Unsupported compiler" # endif /* COMPILER_MICROSOFT */ #endif -} #endif /* INLINE_ASSEMBLY_SUPPORTED */ +} #ifdef INLINE_ASM_SUPPORTED void cpu_rdtsc(uint64_t* result) diff --git a/libcpuid/asm-bits.h b/libcpuid/asm-bits.h index c04a0b0..6d127b7 100644 --- a/libcpuid/asm-bits.h +++ b/libcpuid/asm-bits.h @@ -28,21 +28,21 @@ #include "libcpuid.h" /* Determine Compiler: */ -#ifdef _MSC_VER +#if defined(_MSC_VER) # define COMPILER_MICROSOFT -#else +#elif defined(__GNUC__) # define COMPILER_GCC #endif /* Determine Platform */ #if defined(__x86_64__) || defined(_M_AMD64) # define PLATFORM_X64 -#else +#elif defined(__i386__) || defined(_M_IX86) # define PLATFORM_X86 #endif /* Under Windows/AMD64 with MSVC, inline assembly isn't supported */ -#if defined(COMPILER_GCC) || defined(PLATFORM_X86) +#if (defined(COMPILER_GCC) && defined(PLATFORM_X64)) || defined(PLATFORM_X86) # define INLINE_ASM_SUPPORTED #endif