From c543451f67d8b47b45053a1bc5b786f59c53e4ee Mon Sep 17 00:00:00 2001 From: lordmulder Date: Mon, 15 Nov 2010 14:02:58 +0100 Subject: [PATCH] Also detect number of CPU cores and x64 support --- src/Config.h | 2 +- src/Global.cpp | 16 ++++++++++++++++ src/Global.h | 3 +++ src/Main.cpp | 3 ++- 4 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/Config.h b/src/Config.h index 367596f6..84d7094c 100644 --- a/src/Config.h +++ b/src/Config.h @@ -25,7 +25,7 @@ #define VER_LAMEXP_MAJOR 4 #define VER_LAMEXP_MINOR_HI 0 #define VER_LAMEXP_MINOR_LO 0 -#define VER_LAMEXP_BUILD 20 +#define VER_LAMEXP_BUILD 21 #define VER_LAMEXP_SUFFIX TechPreview /* diff --git a/src/Global.cpp b/src/Global.cpp index 5ba9d28e..754199e4 100644 --- a/src/Global.cpp +++ b/src/Global.cpp @@ -246,6 +246,22 @@ lamexp_cpu_t lamexp_detect_cpu_features(void) } strcpy_s(features.brand, 0x40, CPUBrandString); + +#if defined(_M_X64 ) || defined(_M_IA64) + features.x64 = true; +#else + BOOL x64 = FALSE; + if(IsWow64Process(GetCurrentProcess(), &x64)) + { + features.x64 = x64; + } +#endif + + SYSTEM_INFO systemInfo; + memset(&systemInfo, 0, sizeof(SYSTEM_INFO)); + GetNativeSystemInfo(&systemInfo); + features.count = systemInfo.dwNumberOfProcessors; + return features; } diff --git a/src/Global.h b/src/Global.h index f5de491e..964c05db 100644 --- a/src/Global.h +++ b/src/Global.h @@ -42,6 +42,8 @@ typedef struct int family; int model; int stepping; + int count; + bool x64; bool mmx; bool sse; bool sse2; @@ -85,6 +87,7 @@ SIZE_T lamexp_dbg_private_bytes(void); #define LAMEXP_CLOSE(HANDLE) if(HANDLE != NULL && HANDLE != INVALID_HANDLE_VALUE) { CloseHandle(HANDLE); HANDLE = NULL; } #define QWCHAR(STR) reinterpret_cast(STR.utf16()) #define LAMEXP_DYNCAST(OUT,CLASS,SRC) try { OUT = dynamic_cast(SRC); } catch(std::bad_cast) { OUT = NULL; } +#define LAMEXP_BOOL(X) (X ? "1" : "0") //Check for debug build #if defined(_DEBUG) || defined(QT_DEBUG) || !defined(NDEBUG) || !defined(QT_NODEBUG) diff --git a/src/Main.cpp b/src/Main.cpp index 2feb0df0..d79ce17b 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -60,7 +60,8 @@ int lamexp_main(int argc, char* argv[]) lamexp_cpu_t cpuFeatures = lamexp_detect_cpu_features(); qDebug("CPU brand string: %s", cpuFeatures.brand); qDebug("CPU signature: Family: %d, Model: %d, Stepping: %d", cpuFeatures.family, cpuFeatures.model, cpuFeatures.stepping); - qDebug("CPU capabilities: MMX: %s, SSE: %s, SSE2: %s, SSE3: %s, SSSE3: %s\n", (cpuFeatures.mmx ? "Yes" : "No"), (cpuFeatures.sse ? "Yes" : "No"), (cpuFeatures.sse2 ? "Yes" : "No"), (cpuFeatures.sse3 ? "Yes" : "No"), (cpuFeatures.ssse3 ? "Yes" : "No")); + qDebug("CPU capabilities: MMX: %s, SSE: %s, SSE2: %s, SSE3: %s, SSSE3: %s, x64: %s", LAMEXP_BOOL(cpuFeatures.mmx), LAMEXP_BOOL(cpuFeatures.sse), LAMEXP_BOOL(cpuFeatures.sse2), LAMEXP_BOOL(cpuFeatures.sse3), LAMEXP_BOOL(cpuFeatures.ssse3), LAMEXP_BOOL(cpuFeatures.x64)); + qDebug("CPU no. of cores: %d\n", cpuFeatures.count); //Initialize Qt lamexp_init_qt(argc, argv);