1.1 --- a/Hardware/CPU/AMD10CPU.cs Mon Nov 01 20:44:21 2010 +0000
1.2 +++ b/Hardware/CPU/AMD10CPU.cs Wed Nov 03 22:07:46 2010 +0000
1.3 @@ -87,10 +87,8 @@
1.4 ActivateSensor(coreClocks[i]);
1.5 }
1.6
1.7 - // set affinity to the first thread for all frequency estimations
1.8 - IntPtr thread = NativeMethods.GetCurrentThread();
1.9 - UIntPtr mask = NativeMethods.SetThreadAffinityMask(thread,
1.10 - (UIntPtr)(1L << cpuid[0][0].Thread));
1.11 + // set affinity to the first thread for all frequency estimations
1.12 + ulong mask = ThreadAffinity.Set(1UL << cpuid[0][0].Thread);
1.13
1.14 uint ctlEax, ctlEdx;
1.15 Ring0.Rdmsr(PERF_CTL_0, out ctlEax, out ctlEdx);
1.16 @@ -104,7 +102,7 @@
1.17 Ring0.Wrmsr(PERF_CTR_0, ctrEax, ctrEdx);
1.18
1.19 // restore the thread affinity.
1.20 - NativeMethods.SetThreadAffinityMask(thread, mask);
1.21 + ThreadAffinity.Set(mask);
1.22
1.23 Update();
1.24 }
1.25 @@ -208,7 +206,7 @@
1.26
1.27 uint curEax, curEdx;
1.28 if (Ring0.RdmsrTx(COFVID_STATUS, out curEax, out curEdx,
1.29 - (UIntPtr)(1L << cpuid[i][0].Thread)))
1.30 + 1UL << cpuid[i][0].Thread))
1.31 {
1.32 // 8:6 CpuDid: current core divisor ID
1.33 // 5:0 CpuFid: current core frequency ID
1.34 @@ -232,16 +230,5 @@
1.35 }
1.36 }
1.37 }
1.38 -
1.39 - private static class NativeMethods {
1.40 - private const string KERNEL = "kernel32.dll";
1.41 -
1.42 - [DllImport(KERNEL, CallingConvention = CallingConvention.Winapi)]
1.43 - public static extern UIntPtr
1.44 - SetThreadAffinityMask(IntPtr handle, UIntPtr mask);
1.45 -
1.46 - [DllImport(KERNEL, CallingConvention = CallingConvention.Winapi)]
1.47 - public static extern IntPtr GetCurrentThread();
1.48 - }
1.49 }
1.50 }