Merge branch 'platform-info-cpu-arch'

Improvements related to getting the CPU architecture name.

See https://github.com/wxWidgets/wxWidgets/pull/2141
This commit is contained in:
Vadim Zeitlin
2020-12-13 22:46:39 +01:00
5 changed files with 21 additions and 1 deletions

View File

@@ -260,6 +260,8 @@ public:
{ return GetBitnessName(); } { return GetBitnessName(); }
wxString GetEndiannessName() const wxString GetEndiannessName() const
{ return GetEndiannessName(m_endian); } { return GetEndiannessName(m_endian); }
wxString GetCpuArchitectureName() const
{ return m_cpuArch; }
wxString GetOperatingSystemDescription() const wxString GetOperatingSystemDescription() const
{ return m_osDesc; } { return m_osDesc; }
wxString GetDesktopEnvironment() const wxString GetDesktopEnvironment() const
@@ -301,6 +303,8 @@ public:
{ SetBitness(n); } { SetBitness(n); }
void SetEndianness(wxEndianness n) void SetEndianness(wxEndianness n)
{ m_endian = n; } { m_endian = n; }
void SetCpuArchitectureName(const wxString& cpuArch)
{ m_cpuArch = cpuArch; }
void SetDesktopEnvironment(const wxString& de) void SetDesktopEnvironment(const wxString& de)
{ m_desktopEnv = de; } { m_desktopEnv = de; }
@@ -386,6 +390,9 @@ protected:
// endianness of the machine // endianness of the machine
wxEndianness m_endian; wxEndianness m_endian;
// CPU architecture family name, possibly empty if unknown
wxString m_cpuArch;
}; };

View File

@@ -368,6 +368,15 @@ public:
*/ */
wxEndianness GetEndianness() const; 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 Returns the run-time major version of the OS associated with this
wxPlatformInfo instance. wxPlatformInfo instance.

View File

@@ -995,6 +995,9 @@ bool wxIsPlatformLittleEndian();
"arm64", or "i86pc". The name for the same CPU running on the same "arm64", or "i86pc". The name for the same CPU running on the same
hardware can vary across operating systems. hardware can vary across operating systems.
The returned string may be empty if the CPU architecture couldn't be
recognized.
@since 3.1.5 @since 3.1.5
*/ */
wxString wxGetCpuArchitectureName(); wxString wxGetCpuArchitectureName();

View File

@@ -197,6 +197,7 @@ void wxPlatformInfo::InitForCurrentPlatform()
m_osDesc = wxGetOsDescription(); m_osDesc = wxGetOsDescription();
m_endian = wxIsPlatformLittleEndian() ? wxENDIAN_LITTLE : wxENDIAN_BIG; m_endian = wxIsPlatformLittleEndian() ? wxENDIAN_LITTLE : wxENDIAN_BIG;
m_bitness = wxIsPlatform64Bit() ? wxBITNESS_64 : wxBITNESS_32; m_bitness = wxIsPlatform64Bit() ? wxBITNESS_64 : wxBITNESS_32;
m_cpuArch = wxGetCpuArchitectureName();
#ifdef __LINUX__ #ifdef __LINUX__
m_ldi = wxGetLinuxDistributionInfo(); m_ldi = wxGetLinuxDistributionInfo();

View File

@@ -1297,7 +1297,7 @@ wxString wxGetCpuArchitectureName()
case PROCESSOR_ARCHITECTURE_UNKNOWN: case PROCESSOR_ARCHITECTURE_UNKNOWN:
default: default:
return "Unknown"; return wxString();
} }
} }