Pr/30 (#32)
* 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:
+15
-16
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user