]> git.tdb.fi Git - builder.git/commitdiff
Detect CPU architecture on Windows
authorMikko Rasa <tdb@tdb.fi>
Sat, 28 Aug 2021 13:01:52 +0000 (16:01 +0300)
committerMikko Rasa <tdb@tdb.fi>
Sat, 28 Aug 2021 13:06:45 +0000 (16:06 +0300)
source/sysutils.cpp

index 6e1828cde1a388e3db28e209764e7511c861bf6e..8fa3d4894924333581810cb9d19a015c26573057 100644 (file)
@@ -1,17 +1,30 @@
-#ifndef _WIN32
+#define WIN32_LEAN_AND_MEAN
+#ifdef _WIN32
+#include <windows.h>
+#else
 #include <sys/utsname.h>
 #endif
 #include <msp/strings/format.h>
 #include <msp/strings/utils.h>
 #include "sysutils.h"
 
+#if defined(_WIN32) && !defined(PROCESSOR_ARCHITECTURE_ARM64)
+#define PROCESSOR_ARCHITECTURE_ARM64 12
+#endif
+
 using namespace std;
 using namespace Msp;
 
 string get_system_type()
 {
 #ifdef _WIN32
-       return "windows";
+       SYSTEM_INFO sysinfo;
+       GetSystemInfo(&sysinfo);
+       WORD machine = sysinfo.wProcessorArchitecture;
+       if(machine==PROCESSOR_ARCHITECTURE_AMD64 || machine==PROCESSOR_ARCHITECTURE_INTEL)
+               return "x86-windows";
+       else if(machine==PROCESSOR_ARCHITECTURE_ARM || machine==PROCESSOR_ARCHITECTURE_ARM64)
+               return "arm-windows";
 #else
        utsname un;
        if(uname(&un)==0)