From 378a0424d350911b569ff3ab0263bb1c1e5fa5ba Mon Sep 17 00:00:00 2001 From: Jan Kotas Date: Wed, 27 Mar 2019 22:37:22 -0700 Subject: [PATCH] Move QueryPerformanceCounter PInvokes to shared (dotnet/corefx#36409) Signed-off-by: dotnet-bot --- .../Kernel32/Interop.QueryPerformanceCounter.cs | 22 ++++++++++++++++++++++ .../Kernel32/Interop.QueryPerformanceFrequency.cs | 22 ++++++++++++++++++++++ .../shared/System.Private.CoreLib.Shared.projitems | 2 ++ 3 files changed, 46 insertions(+) create mode 100644 src/System.Private.CoreLib/shared/Interop/Windows/Kernel32/Interop.QueryPerformanceCounter.cs create mode 100644 src/System.Private.CoreLib/shared/Interop/Windows/Kernel32/Interop.QueryPerformanceFrequency.cs diff --git a/src/System.Private.CoreLib/shared/Interop/Windows/Kernel32/Interop.QueryPerformanceCounter.cs b/src/System.Private.CoreLib/shared/Interop/Windows/Kernel32/Interop.QueryPerformanceCounter.cs new file mode 100644 index 0000000..ddc9797 --- /dev/null +++ b/src/System.Private.CoreLib/shared/Interop/Windows/Kernel32/Interop.QueryPerformanceCounter.cs @@ -0,0 +1,22 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Runtime.InteropServices; + +internal partial class Interop +{ + internal partial class Kernel32 + { + // The actual native signature is: + // BOOL WINAPI QueryPerformanceCounter( + // _Out_ LARGE_INTEGER* lpPerformanceCount + // ); + // + // We take a long* (rather than a out long) to avoid the pinning overhead. + // We don't set last error since we don't need the extended error info. + + [DllImport(Libraries.Kernel32, ExactSpelling = true)] + internal static extern unsafe BOOL QueryPerformanceCounter(long* lpPerformanceCount); + } +} diff --git a/src/System.Private.CoreLib/shared/Interop/Windows/Kernel32/Interop.QueryPerformanceFrequency.cs b/src/System.Private.CoreLib/shared/Interop/Windows/Kernel32/Interop.QueryPerformanceFrequency.cs new file mode 100644 index 0000000..72a48ba --- /dev/null +++ b/src/System.Private.CoreLib/shared/Interop/Windows/Kernel32/Interop.QueryPerformanceFrequency.cs @@ -0,0 +1,22 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Runtime.InteropServices; + +internal partial class Interop +{ + internal partial class Kernel32 + { + // The actual native signature is: + // BOOL WINAPI QueryPerformanceFrequency( + // _Out_ LARGE_INTEGER* lpFrequency + // ); + // + // We take a long* (rather than a out long) to avoid the pinning overhead. + // We don't set last error since we don't need the extended error info. + + [DllImport(Libraries.Kernel32, ExactSpelling = true)] + internal static extern unsafe BOOL QueryPerformanceFrequency(long* lpFrequency); + } +} diff --git a/src/System.Private.CoreLib/shared/System.Private.CoreLib.Shared.projitems b/src/System.Private.CoreLib/shared/System.Private.CoreLib.Shared.projitems index 3cd36e0..3b56c77 100644 --- a/src/System.Private.CoreLib/shared/System.Private.CoreLib.Shared.projitems +++ b/src/System.Private.CoreLib/shared/System.Private.CoreLib.Shared.projitems @@ -1027,6 +1027,8 @@ + + -- 2.7.4