* Unified operating system type detection

* Revert "Unified operating system type detection"

This reverts commit 3edf0edfceaca259e041e23b9930d78531366fd5.

* Introduced OperatingSystem.IsLinux instead of constant check on Os version.

* Misc
This commit is contained in:
Phyxion
2018-02-10 14:01:52 +01:00
committed by GitHub
parent 22bd00c806
commit 66e69c4c25
12 changed files with 76 additions and 79 deletions
+15 -16
View File
@@ -19,26 +19,25 @@ namespace OpenHardwareMonitor.Hardware {
if (mask == 0)
return 0;
int p = (int)Environment.OSVersion.Platform;
if ((p == 4) || (p == 128)) { // Unix
ulong result = 0;
if (NativeMethods.sched_getaffinity(0, (IntPtr)Marshal.SizeOf(result),
ref result) != 0)
return 0;
if (NativeMethods.sched_setaffinity(0, (IntPtr)Marshal.SizeOf(mask),
ref mask) != 0)
return 0;
return result;
} else { // Windows
if (Software.OperatingSystem.IsLinux)
{ // Unix
ulong result = 0;
if (NativeMethods.sched_getaffinity(0, (IntPtr)Marshal.SizeOf(result),
ref result) != 0)
return 0;
if (NativeMethods.sched_setaffinity(0, (IntPtr)Marshal.SizeOf(mask),
ref mask) != 0)
return 0;
return result;
} // Windows
UIntPtr uIntPtrMask;
try {
uIntPtrMask = (UIntPtr)mask;
uIntPtrMask = (UIntPtr)mask;
} catch (OverflowException) {
throw new ArgumentOutOfRangeException("mask");
}
throw new ArgumentOutOfRangeException("mask");
}
return (ulong)NativeMethods.SetThreadAffinityMask(
NativeMethods.GetCurrentThread(), uIntPtrMask);
}
NativeMethods.GetCurrentThread(), uIntPtrMask);
}
private static class NativeMethods {