Browse Source

Merge pull request #323 from zrax/cpuid_check

Don't use CPUID call on targets that don't support it
Adam Johnson 12 years ago
parent
commit
81e7e15702
  1. 10
      Sources/Plasma/CoreLib/CMakeLists.txt
  2. 6
      Sources/Plasma/CoreLib/hsCpuID.cpp
  3. 11
      cmake/check_cpuid.cpp

10
Sources/Plasma/CoreLib/CMakeLists.txt

@ -21,6 +21,16 @@ if(NOT WCHAR_BYTES)
endif(NOT WCHAR_BYTES)
add_definitions(-DWCHAR_BYTES=${WCHAR_BYTES})
try_compile(HAVE_CPUID ${PROJECT_BINARY_DIR}
${PROJECT_SOURCE_DIR}/cmake/check_cpuid.cpp
OUTPUT_VARIABLE OUTPUT)
if(HAVE_CPUID)
add_definitions(-DHAVE_CPUID)
message("CPUID header found -- using hardware math acceleration when available")
else()
message("CPUID header not found -- using software math")
endif()
set(CoreLib_SOURCES
HeadSpin.cpp
hsBitVector.cpp

6
Sources/Plasma/CoreLib/hsCpuID.cpp

@ -40,12 +40,18 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
*==LICENSE==*/
#if defined(HAVE_CPUID)
# if defined(_MSC_VER) || ((defined(_WIN32) || defined(_WIN64)) && defined(__INTEL_COMPILER))
# include <intrin.h>
# define MSC_COMPATIBLE
# elif defined(__GNUC__)
# include <cpuid.h>
# define GCC_COMPATIBLE
# else
# define SOFTWARE_ONLY
# endif
#else
# define SOFTWARE_ONLY
#endif
#include "hsCpuID.h"

11
cmake/check_cpuid.cpp

@ -0,0 +1,11 @@
#if defined(_MSC_VER) || ((defined(_WIN32) || defined(_WIN64)) && defined(__INTEL_COMPILER))
# include <intrin.h>
#elif defined(__GNUC__)
# include <cpuid.h>
#endif
/* Just needed to look for the headers -- this just makes the compiler happy. */
int main(int argc, char *argv[])
{
return 0;
}
Loading…
Cancel
Save