///////////////////////////////////////////////////////////////////////////////
// MuldeR's Utilities for Qt
-// Copyright (C) 2004-2016 LoRd_MuldeR <MuldeR2@GMX.de>
+// Copyright (C) 2004-2019 LoRd_MuldeR <MuldeR2@GMX.de>
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
#define WIN32_LEAN_AND_MEAN 1
#include <Windows.h>
+//ASM
+#include <intrin.h>
+
//MUtils
#include <MUtils/CPUFeatures.h>
#include <MUtils/OSSupport.h>
//Initialize variables to zero
memset(&features, 0, sizeof(cpu_info_t));
memset(&systemInfo, 0, sizeof(SYSTEM_INFO));
- memset(cpuInfo, 0, sizeof(cpuInfo));
+ memset(&cpuInfo[0], 0, sizeof(cpuInfo));
//Detect the CPU identifier string
MY_CPUID(&cpuInfo[0], 0);
//Detect extended feature flags
if (max_basic_cap >= 7)
{
- MY_CPUID(&cpuInfo[1], 7);
+ MY_CPUID(&cpuInfo[0], 7);
if (features.features & FLAG_AVX)
{
- features.features |= CHECK_FLAG(cpuInfo[2], 0x00000020, FLAG_AVX2);
+ features.features |= CHECK_FLAG(cpuInfo[1], 0x00000020, FLAG_AVX2);
}
}
}
//Detect 64-Bit processors
-#if (!(defined(_M_X64) || defined(_M_IA64)))
- const IsWow64ProcessFun isWow64ProcessPtr = MUtils::Win32Utils::resolve<IsWow64ProcessFun>(QLatin1String("kernel32"), QLatin1String("IsWow64Process"));
- if(isWow64ProcessPtr)
+ if (OS::os_architecture() == OS::ARCH_X64)
{
- BOOL x64flag = FALSE;
- if(isWow64ProcessPtr(GetCurrentProcess(), &x64flag))
- {
- if (x64flag)
- {
- features.x64 = true;
- features.features |= FLAGS_X64; /*x86_64 implies SSE2*/
- }
- }
+ features.x64 = true;
+ features.features |= FLAGS_X64; /*x86_64 implies SSE2*/
}
-#else
- features.x64 = true;
- features.features |= FLAGS_X64;
-#endif
//Make sure that (at least) the MMX flag has been set!
if (!(features.features & FLAG_MMX))