diff options
author | Chris Robinson <[email protected]> | 2014-08-11 13:38:43 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2014-08-11 13:38:43 -0700 |
commit | e3ee534c3961c4a7c9961019a242693e0da402ef (patch) | |
tree | 05c66a83cd52fd29307b60766c680c1c86b703c8 | |
parent | 8ecbeb4945441ed4d797905ee1c609c163dcd51b (diff) |
Check for GCC's __get_cpuid before using it
-rw-r--r-- | Alc/helpers.c | 4 | ||||
-rw-r--r-- | CMakeLists.txt | 9 | ||||
-rw-r--r-- | config.h.in | 3 |
3 files changed, 14 insertions, 2 deletions
diff --git a/Alc/helpers.c b/Alc/helpers.c index dd74ad62..22e99d7e 100644 --- a/Alc/helpers.c +++ b/Alc/helpers.c @@ -107,8 +107,8 @@ void FillCPUCaps(ALuint capfilter) /* FIXME: We really should get this for all available CPUs in case different * CPUs have different caps (is that possible on one machine?). */ -#if defined(HAVE_CPUID_H) && (defined(__i386__) || defined(__x86_64__) || \ - defined(_M_IX86) || defined(_M_X64)) +#if defined(HAVE_GCC_GET_CPUID) && (defined(__i386__) || defined(__x86_64__) || \ + defined(_M_IX86) || defined(_M_X64)) union { unsigned int regs[4]; char str[sizeof(unsigned int[4])]; diff --git a/CMakeLists.txt b/CMakeLists.txt index 1b1fc772..cbb6844b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -360,6 +360,15 @@ IF(NOT HAVE_GUIDDEF_H) CHECK_INCLUDE_FILE(initguid.h HAVE_INITGUID_H) ENDIF() +IF(HAVE_CPUID_H) + CHECK_C_SOURCE_COMPILES("#include <cpuid.h> + int main() + { + unsigned int eax, ebx, ecx, edx; + return __get_cpuid(0, eax, ebx, ecx, edx); + }" HAVE_GCC_GET_CPUID) +ENDIF() + # Some systems need libm for some of the following math functions to work CHECK_LIBRARY_EXISTS(m pow "" HAVE_LIBM) IF(HAVE_LIBM) diff --git a/config.h.in b/config.h.in index 5d71951b..27184824 100644 --- a/config.h.in +++ b/config.h.in @@ -166,6 +166,9 @@ /* Define if we have fenv.h */ #cmakedefine HAVE_FENV_H +/* Define if we have GCC's __get_cpuid() */ +#cmakedefine HAVE_GCC_GET_CPUID + /* Define if we have _controlfp() */ #cmakedefine HAVE__CONTROLFP |