Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit a654ff0

Browse files
GrabYourPitchforksjkotas
authored andcommitted
Add Unsafe.IsAddressGreaterThan / IsAddressLessThan (dotnet/coreclr#15988)
Signed-off-by: dotnet-bot-corefx-mirror <dotnet-bot@microsoft.com>
1 parent 3f03814 commit a654ff0

File tree

1 file changed

+40
-0
lines changed
  • src/Common/src/CoreLib/Internal/Runtime/CompilerServices

1 file changed

+40
-0
lines changed

src/Common/src/CoreLib/Internal/Runtime/CompilerServices/Unsafe.cs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,46 @@ public static bool AreSame<T>(ref T left, ref T right)
168168
// ret
169169
}
170170

171+
/// <summary>
172+
/// Determines whether the memory address referenced by <paramref name="left"/> is greater than
173+
/// the memory address referenced by <paramref name="right"/>.
174+
/// </summary>
175+
/// <remarks>
176+
/// This check is conceptually similar to "(void*)(&amp;left) &gt; (void*)(&amp;right)".
177+
/// </remarks>
178+
[Intrinsic]
179+
[NonVersionable]
180+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
181+
public static bool IsAddressGreaterThan<T>(ref T left, ref T right)
182+
{
183+
throw new PlatformNotSupportedException();
184+
185+
// ldarg.0
186+
// ldarg.1
187+
// cgt.un
188+
// ret
189+
}
190+
191+
/// <summary>
192+
/// Determines whether the memory address referenced by <paramref name="left"/> is less than
193+
/// the memory address referenced by <paramref name="right"/>.
194+
/// </summary>
195+
/// <remarks>
196+
/// This check is conceptually similar to "(void*)(&amp;left) &lt; (void*)(&amp;right)".
197+
/// </remarks>
198+
[Intrinsic]
199+
[NonVersionable]
200+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
201+
public static bool IsAddressLessThan<T>(ref T left, ref T right)
202+
{
203+
throw new PlatformNotSupportedException();
204+
205+
// ldarg.0
206+
// ldarg.1
207+
// clt.un
208+
// ret
209+
}
210+
171211
/// <summary>
172212
/// Initializes a block of memory at the given location with a given initial value
173213
/// without assuming architecture dependent alignment of the address.

0 commit comments

Comments
 (0)