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