From 1c089cba038e7b2c4d1026f7f041e9c228a7e5a1 Mon Sep 17 00:00:00 2001 From: Tanner Gooding Date: Thu, 23 Dec 2021 10:34:12 -0800 Subject: [PATCH] Adding some implicit conversion operators for LARGE_INTEGER and ULARGE_INTEGER --- .../Windows/um/winnt/LARGE_INTEGER.Manual.cs | 20 +++++++++++++++++++ .../Windows/um/winnt/ULARGE_INTEGER.Manual.cs | 20 +++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 sources/Interop/Windows/Windows/um/winnt/LARGE_INTEGER.Manual.cs create mode 100644 sources/Interop/Windows/Windows/um/winnt/ULARGE_INTEGER.Manual.cs diff --git a/sources/Interop/Windows/Windows/um/winnt/LARGE_INTEGER.Manual.cs b/sources/Interop/Windows/Windows/um/winnt/LARGE_INTEGER.Manual.cs new file mode 100644 index 0000000000..c24af4e155 --- /dev/null +++ b/sources/Interop/Windows/Windows/um/winnt/LARGE_INTEGER.Manual.cs @@ -0,0 +1,20 @@ +// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information. + +// Ported from um/winnt.h in the Windows SDK for Windows 10.0.20348.0 +// Original source is Copyright © Microsoft. All rights reserved. + +using System.Runtime.CompilerServices; + +namespace TerraFX.Interop.Windows; + +public partial struct LARGE_INTEGER +{ + public static implicit operator long(LARGE_INTEGER value) => value.QuadPart; + + public static implicit operator LARGE_INTEGER(long value) + { + Unsafe.SkipInit(out LARGE_INTEGER result); + result.QuadPart = value; + return result; + } +} diff --git a/sources/Interop/Windows/Windows/um/winnt/ULARGE_INTEGER.Manual.cs b/sources/Interop/Windows/Windows/um/winnt/ULARGE_INTEGER.Manual.cs new file mode 100644 index 0000000000..3a8d3dcbc1 --- /dev/null +++ b/sources/Interop/Windows/Windows/um/winnt/ULARGE_INTEGER.Manual.cs @@ -0,0 +1,20 @@ +// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information. + +// Ported from um/winnt.h in the Windows SDK for Windows 10.0.20348.0 +// Original source is Copyright © Microsoft. All rights reserved. + +using System.Runtime.CompilerServices; + +namespace TerraFX.Interop.Windows; + +public partial struct ULARGE_INTEGER +{ + public static implicit operator ulong(ULARGE_INTEGER value) => value.QuadPart; + + public static implicit operator ULARGE_INTEGER(ulong value) + { + Unsafe.SkipInit(out ULARGE_INTEGER result); + result.QuadPart = value; + return result; + } +}