Add wxGetCpuArchitectureName() for finding out CPU architecture
The returned value is OS-dependent and can be something like: "x86_64", "x86", "arm64". Closes https://github.com/wxWidgets/wxWidgets/pull/2121
This commit is contained in:
committed by
Vadim Zeitlin
parent
4bd0cd40f4
commit
493cc3571e
@@ -153,6 +153,9 @@ WXDLLIMPEXP_BASE bool wxIsPlatformLittleEndian();
|
|||||||
// Get platform architecture
|
// Get platform architecture
|
||||||
WXDLLIMPEXP_BASE bool wxIsPlatform64Bit();
|
WXDLLIMPEXP_BASE bool wxIsPlatform64Bit();
|
||||||
|
|
||||||
|
// Get machine CPU architecture
|
||||||
|
WXDLLIMPEXP_BASE wxString wxGetCpuArchitectureName();
|
||||||
|
|
||||||
#ifdef __LINUX__
|
#ifdef __LINUX__
|
||||||
// Get linux-distro information
|
// Get linux-distro information
|
||||||
WXDLLIMPEXP_BASE wxLinuxDistributionInfo wxGetLinuxDistributionInfo();
|
WXDLLIMPEXP_BASE wxLinuxDistributionInfo wxGetLinuxDistributionInfo();
|
||||||
|
@@ -991,6 +991,15 @@ bool wxIsPlatform64Bit();
|
|||||||
*/
|
*/
|
||||||
bool wxIsPlatformLittleEndian();
|
bool wxIsPlatformLittleEndian();
|
||||||
|
|
||||||
|
/**
|
||||||
|
Returns the CPU architecture name. This can be, for example, "x86_64",
|
||||||
|
"arm64", or "i86pc". The name for the same CPU running on the same
|
||||||
|
hardware can vary across operating systems.
|
||||||
|
|
||||||
|
@since 3.1.5
|
||||||
|
*/
|
||||||
|
wxString wxGetCpuArchitectureName();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Returns a structure containing information about the currently running
|
Returns a structure containing information about the currently running
|
||||||
Linux distribution.
|
Linux distribution.
|
||||||
|
@@ -86,6 +86,10 @@
|
|||||||
#include <shellapi.h>
|
#include <shellapi.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef PROCESSOR_ARCHITECTURE_ARM64
|
||||||
|
#define PROCESSOR_ARCHITECTURE_ARM64 12
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
// For wxKillAllChildren
|
// For wxKillAllChildren
|
||||||
@@ -1269,6 +1273,34 @@ wxWinVersion wxGetWinVersion()
|
|||||||
return wxWinVersion_Unknown;
|
return wxWinVersion_Unknown;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wxString wxGetCpuArchitectureName()
|
||||||
|
{
|
||||||
|
SYSTEM_INFO si;
|
||||||
|
GetNativeSystemInfo(&si);
|
||||||
|
|
||||||
|
switch (si.wProcessorArchitecture)
|
||||||
|
{
|
||||||
|
case PROCESSOR_ARCHITECTURE_AMD64:
|
||||||
|
return "x64";
|
||||||
|
|
||||||
|
case PROCESSOR_ARCHITECTURE_ARM:
|
||||||
|
return "ARM";
|
||||||
|
|
||||||
|
case PROCESSOR_ARCHITECTURE_ARM64:
|
||||||
|
return "ARM64";
|
||||||
|
|
||||||
|
case PROCESSOR_ARCHITECTURE_IA64:
|
||||||
|
return "Itanium";
|
||||||
|
|
||||||
|
case PROCESSOR_ARCHITECTURE_INTEL:
|
||||||
|
return "x86";
|
||||||
|
|
||||||
|
case PROCESSOR_ARCHITECTURE_UNKNOWN:
|
||||||
|
default:
|
||||||
|
return "Unknown";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// sleep functions
|
// sleep functions
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
@@ -1079,7 +1079,7 @@ bool wxIsPlatform64Bit()
|
|||||||
(void)wxGetCommandOutput;
|
(void)wxGetCommandOutput;
|
||||||
return true; // 64-bit programs run only on 64-bit platforms
|
return true; // 64-bit programs run only on 64-bit platforms
|
||||||
#else
|
#else
|
||||||
const wxString machine = wxGetCommandOutput(wxT("uname -m"));
|
const wxString machine = wxGetCpuArchitectureName();
|
||||||
|
|
||||||
// the test for "64" is obviously not 100% reliable but seems to work fine
|
// the test for "64" is obviously not 100% reliable but seems to work fine
|
||||||
// in practice
|
// in practice
|
||||||
@@ -1088,6 +1088,11 @@ bool wxIsPlatform64Bit()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wxString wxGetCpuArchitectureName()
|
||||||
|
{
|
||||||
|
return wxGetCommandOutput(wxT("uname -m"));
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef __LINUX__
|
#ifdef __LINUX__
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
|
Reference in New Issue
Block a user