diff options
| author | mageven <62494521+mageven@users.noreply.github.com> | 2021-03-01 09:52:00 +0530 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-03-01 15:22:00 +1100 |
| commit | 06a2b03cc91b38e3798d8cc1c57c186778c7e666 (patch) | |
| tree | 1dd1cc0af8a79649053fe053c4246db8548f9230 /Ryujinx.Common/SystemInfo/MacOSSystemInfo.cs | |
| parent | d02eeed9c1ba8a8e4d18f18c24588f2953ad7ed6 (diff) | |
Revise SystemInfo (#2047)
* Revise SystemInfo
Cleans up and adds a bit more info (logical core count and available mem at launch) to logs.
- Extract CPU name from CPUID when supported.
- Linux: Robust parsing of procfs files
- Windows: Prefer native calls to WMI
- Remove unnecessary virtual specifiers
* Address gdkchan's comments
* Address AcK's comments
* Address formatting nits
Diffstat (limited to 'Ryujinx.Common/SystemInfo/MacOSSystemInfo.cs')
| -rw-r--r-- | Ryujinx.Common/SystemInfo/MacOSSystemInfo.cs | 60 |
1 files changed, 25 insertions, 35 deletions
diff --git a/Ryujinx.Common/SystemInfo/MacOSSystemInfo.cs b/Ryujinx.Common/SystemInfo/MacOSSystemInfo.cs index ec069ca4..92b54902 100644 --- a/Ryujinx.Common/SystemInfo/MacOSSystemInfo.cs +++ b/Ryujinx.Common/SystemInfo/MacOSSystemInfo.cs @@ -8,10 +8,27 @@ using Ryujinx.Common.Logging; namespace Ryujinx.Common.SystemInfo { [SupportedOSPlatform("macos")] - internal class MacOSSystemInfo : SystemInfo + class MacOSSystemInfo : SystemInfo { - public override string CpuName { get; } - public override ulong RamSize { get; } + internal MacOSSystemInfo() + { + string cpuName = GetCpuidCpuName(); + + if (cpuName == null && sysctlbyname("machdep.cpu.brand_string", out cpuName) != 0) + { + cpuName = "Unknown"; + } + + ulong totalRAM = 0; + + if (sysctlbyname("hw.memsize", ref totalRAM) != 0) // Bytes + { + totalRAM = 0; + }; + + CpuName = $"{cpuName} ; {LogicalCoreCount} logical"; + RamTotal = totalRAM; + } [DllImport("libSystem.dylib", CharSet = CharSet.Ansi, SetLastError = true)] private static extern int sysctlbyname(string name, IntPtr oldValue, ref ulong oldSize, IntPtr newValue, ulong newValueSize); @@ -20,7 +37,11 @@ namespace Ryujinx.Common.SystemInfo { if (sysctlbyname(name, oldValue, ref oldSize, IntPtr.Zero, 0) == -1) { - return Marshal.GetLastWin32Error(); + int err = Marshal.GetLastWin32Error(); + + Logger.Error?.Print(LogClass.Application, $"Cannot retrieve '{name}'. Error Code {err}"); + + return err; } return 0; @@ -64,36 +85,5 @@ namespace Ryujinx.Common.SystemInfo return res; } - - public MacOSSystemInfo() - { - ulong ramSize = 0; - - int res = sysctlbyname("hw.memsize", ref ramSize); - - if (res == 0) - { - RamSize = ramSize; - } - else - { - Logger.Error?.Print(LogClass.Application, $"Cannot get memory size, sysctlbyname error: {res}"); - - RamSize = 0; - } - - res = sysctlbyname("machdep.cpu.brand_string", out string cpuName); - - if (res == 0) - { - CpuName = cpuName; - } - else - { - Logger.Error?.Print(LogClass.Application, $"Cannot get CPU name, sysctlbyname error: {res}"); - - CpuName = "Unknown"; - } - } } }
\ No newline at end of file |
