Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
/ corefx Public archive

Commit

Permalink
Add Unsafe.IsAddressGreaterThan / IsAddressLessThan (dotnet/coreclr#1…
Browse files Browse the repository at this point in the history
…5988)

Signed-off-by: dotnet-bot-corefx-mirror <dotnet-bot@microsoft.com>
  • Loading branch information
GrabYourPitchforks authored and jkotas committed Jan 24, 2018
1 parent 3f03814 commit a654ff0
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions src/Common/src/CoreLib/Internal/Runtime/CompilerServices/Unsafe.cs
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,46 @@ public static bool AreSame<T>(ref T left, ref T right)
// ret
}

/// <summary>
/// Determines whether the memory address referenced by <paramref name="left"/> is greater than
/// the memory address referenced by <paramref name="right"/>.
/// </summary>
/// <remarks>
/// This check is conceptually similar to "(void*)(&amp;left) &gt; (void*)(&amp;right)".
/// </remarks>
[Intrinsic]
[NonVersionable]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool IsAddressGreaterThan<T>(ref T left, ref T right)
{
throw new PlatformNotSupportedException();

// ldarg.0
// ldarg.1
// cgt.un
// ret
}

/// <summary>
/// Determines whether the memory address referenced by <paramref name="left"/> is less than
/// the memory address referenced by <paramref name="right"/>.
/// </summary>
/// <remarks>
/// This check is conceptually similar to "(void*)(&amp;left) &lt; (void*)(&amp;right)".
/// </remarks>
[Intrinsic]
[NonVersionable]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool IsAddressLessThan<T>(ref T left, ref T right)
{
throw new PlatformNotSupportedException();

// ldarg.0
// ldarg.1
// clt.un
// ret
}

/// <summary>
/// Initializes a block of memory at the given location with a given initial value
/// without assuming architecture dependent alignment of the address.
Expand Down

0 comments on commit a654ff0

Please sign in to comment.