Fix a StackOverflowException in some polyfills

These APIs were never actually called by any code paths reachable by ComputeSharp (they're mostly there just to make porting polyfills easier), but still good to fix
このコミットが含まれているのは:
Sergio Pedri committed 2022-08-08 15:45:23 +02:00
1 親 8cc1e42fe9
コミット ef4834be94
1ファイル変更
+14 -4
+14 -4
ファイルの表示
@@ -9,15 +9,25 @@ internal static class IntPtrExtensions
{
/// <inheritdoc cref="IComparable{T}.CompareTo(T)"/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static int CompareTo(this nint left, nint right)
public static unsafe int CompareTo(this nint left, nint right)
{
return left.CompareTo(right);
if (sizeof(nint) == sizeof(int))
{
return ((int)left).CompareTo((int)right);
}
return ((long)left).CompareTo(right);
}
/// <inheritdoc cref="IComparable{T}.CompareTo(T)"/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static int CompareTo(this nuint left, nuint right)
public static unsafe int CompareTo(this nuint left, nuint right)
{
return left.CompareTo(right);
if (sizeof(nuint) == sizeof(uint))
{
return ((uint)left).CompareTo((uint)right);
}
return ((ulong)left).CompareTo(right);
}
}