From 5c4461a15479255648f2314a3edb5f453dbaa5a4 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 12 Dec 2020 15:18:29 +0100 Subject: [PATCH 1/2] Return "" and not "Unknown" from wxMSW wxGetCpuArchitectureName() This is more consistent with the Unix version, and easier to test for in the application code. --- interface/wx/utils.h | 3 +++ src/msw/utils.cpp | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/interface/wx/utils.h b/interface/wx/utils.h index b241060a96..1d17b6986e 100644 --- a/interface/wx/utils.h +++ b/interface/wx/utils.h @@ -995,6 +995,9 @@ bool wxIsPlatformLittleEndian(); "arm64", or "i86pc". The name for the same CPU running on the same hardware can vary across operating systems. + The returned string may be empty if the CPU architecture couldn't be + recognized. + @since 3.1.5 */ wxString wxGetCpuArchitectureName(); diff --git a/src/msw/utils.cpp b/src/msw/utils.cpp index 053f7e2c54..6090e1351d 100644 --- a/src/msw/utils.cpp +++ b/src/msw/utils.cpp @@ -1297,7 +1297,7 @@ wxString wxGetCpuArchitectureName() case PROCESSOR_ARCHITECTURE_UNKNOWN: default: - return "Unknown"; + return wxString(); } } From 15c3ce6710991a1e7f0ecec4740bc760271fb49d Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 12 Dec 2020 15:23:17 +0100 Subject: [PATCH 2/2] Add wxPlatformInfo::GetCpuArchitectureName() This provides the same information as wxGetCpuArchitectureName(), but is consistent with the other wxPlatformInfo accessors, which also correspond to the existing wxGetXXX() functions, and makes it more convenient to use this information in the application code as now everything is available via wxPlatformInfo instead of having to use different functions for different pieces. --- include/wx/platinfo.h | 7 +++++++ interface/wx/platinfo.h | 9 +++++++++ src/common/platinfo.cpp | 1 + 3 files changed, 17 insertions(+) diff --git a/include/wx/platinfo.h b/include/wx/platinfo.h index 4a119cf10d..863d94f51f 100644 --- a/include/wx/platinfo.h +++ b/include/wx/platinfo.h @@ -260,6 +260,8 @@ public: { return GetBitnessName(); } wxString GetEndiannessName() const { return GetEndiannessName(m_endian); } + wxString GetCpuArchitectureName() const + { return m_cpuArch; } wxString GetOperatingSystemDescription() const { return m_osDesc; } wxString GetDesktopEnvironment() const @@ -301,6 +303,8 @@ public: { SetBitness(n); } void SetEndianness(wxEndianness n) { m_endian = n; } + void SetCpuArchitectureName(const wxString& cpuArch) + { m_cpuArch = cpuArch; } void SetDesktopEnvironment(const wxString& de) { m_desktopEnv = de; } @@ -386,6 +390,9 @@ protected: // endianness of the machine wxEndianness m_endian; + + // CPU architecture family name, possibly empty if unknown + wxString m_cpuArch; }; diff --git a/interface/wx/platinfo.h b/interface/wx/platinfo.h index 2346d67015..67cd046f97 100644 --- a/interface/wx/platinfo.h +++ b/interface/wx/platinfo.h @@ -368,6 +368,15 @@ public: */ wxEndianness GetEndianness() const; + /** + Returns the CPU architecture name, if available. + + @see wxGetCpuArchitectureName() + + @since 3.1.5 + */ + wxString GetCpuArchitectureName() const; + /** Returns the run-time major version of the OS associated with this wxPlatformInfo instance. diff --git a/src/common/platinfo.cpp b/src/common/platinfo.cpp index 6bfd18c890..f06e0706e7 100644 --- a/src/common/platinfo.cpp +++ b/src/common/platinfo.cpp @@ -197,6 +197,7 @@ void wxPlatformInfo::InitForCurrentPlatform() m_osDesc = wxGetOsDescription(); m_endian = wxIsPlatformLittleEndian() ? wxENDIAN_LITTLE : wxENDIAN_BIG; m_bitness = wxIsPlatform64Bit() ? wxBITNESS_64 : wxBITNESS_32; + m_cpuArch = wxGetCpuArchitectureName(); #ifdef __LINUX__ m_ldi = wxGetLinuxDistributionInfo();