Core/HardwareInfo: Fix compilation for other arch than x86
This commit is contained in:
@@ -11,7 +11,7 @@ namespace Nz
|
||||
{
|
||||
void HardwareInfoImpl::Cpuid(UInt32 functionId, UInt32 subFunctionId, UInt32 registers[4])
|
||||
{
|
||||
#if (defined(NAZARA_COMPILER_CLANG) || defined(NAZARA_COMPILER_GCC) || defined(NAZARA_COMPILER_INTEL)) && !defined(NAZARA_PLATFORM_WEB)
|
||||
#if defined(NAZARA_COMPILER_CLANG) || defined(NAZARA_COMPILER_GCC) || defined(NAZARA_COMPILER_INTEL) && (defined(NAZARA_ARCH_x86) || defined(NAZARA_ARCH_x86_64))
|
||||
// https://en.wikipedia.org/wiki/CPUID
|
||||
asm volatile(
|
||||
#ifdef NAZARA_ARCH_x86_64
|
||||
@@ -49,12 +49,9 @@ namespace Nz
|
||||
|
||||
bool HardwareInfoImpl::IsCpuidSupported()
|
||||
{
|
||||
#ifdef NAZARA_ARCH_x86_64
|
||||
return true; // cpuid is always supported on x64 arch
|
||||
#elif defined(NAZARA_PLATFORM_WEB)
|
||||
return false;
|
||||
#else
|
||||
#if defined(NAZARA_COMPILER_CLANG) || defined(NAZARA_COMPILER_GCC) || defined(NAZARA_COMPILER_INTEL)
|
||||
#if defined(NAZARA_ARCH_x86_64)
|
||||
return true; // cpuid is always supported on x86_64 arch
|
||||
#elif defined(NAZARA_ARCH_x86) && (defined(NAZARA_COMPILER_CLANG) || defined(NAZARA_COMPILER_GCC) || defined(NAZARA_COMPILER_INTEL))
|
||||
int supported;
|
||||
asm volatile (" pushfl\n"
|
||||
" pop %%eax\n"
|
||||
@@ -76,6 +73,5 @@ namespace Nz
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,12 +16,12 @@ namespace Nz
|
||||
{
|
||||
void HardwareInfoImpl::Cpuid(UInt32 functionId, UInt32 subFunctionId, UInt32 registers[4])
|
||||
{
|
||||
#if defined(NAZARA_COMPILER_MSVC)
|
||||
#if defined(NAZARA_COMPILER_MSVC) && (defined(NAZARA_ARCH_x86) || defined(NAZARA_ARCH_x86_64))
|
||||
static_assert(sizeof(UInt32) == sizeof(int));
|
||||
|
||||
// Use intrinsic function if available
|
||||
__cpuidex(reinterpret_cast<int*>(registers), static_cast<int>(functionId), static_cast<int>(subFunctionId));
|
||||
#elif defined(NAZARA_COMPILER_CLANG) || defined(NAZARA_COMPILER_GCC) || defined(NAZARA_COMPILER_INTEL)
|
||||
#elif defined(NAZARA_COMPILER_CLANG) || defined(NAZARA_COMPILER_GCC) || defined(NAZARA_COMPILER_INTEL) && (defined(NAZARA_ARCH_x86) || defined(NAZARA_ARCH_x86_64))
|
||||
// https://en.wikipedia.org/wiki/CPUID
|
||||
asm volatile(
|
||||
#ifdef NAZARA_ARCH_x86_64
|
||||
@@ -63,9 +63,9 @@ namespace Nz
|
||||
|
||||
bool HardwareInfoImpl::IsCpuidSupported()
|
||||
{
|
||||
#ifdef NAZARA_ARCH_x86_64
|
||||
return true; // cpuid is always supported on x64 arch
|
||||
#else
|
||||
#if defined(NAZARA_ARCH_x86_64)
|
||||
return true; // cpuid is always supported on x86_64 arch
|
||||
#elif defined(NAZARA_ARCH_x86)
|
||||
#if defined(NAZARA_COMPILER_MSVC)
|
||||
int supported;
|
||||
__asm
|
||||
@@ -107,6 +107,8 @@ namespace Nz
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user