Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/corert.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Kotas <jkotas@microsoft.com>2017-06-30 05:28:37 +0300
committerJan Kotas <jkotas@microsoft.com>2017-06-30 05:28:37 +0300
commit2111d212f005bd6dadde255ce870fc8c3a1f163a (patch)
treebe1bdc8e4bc82bf3d1d82345b39ade5e3ca204d1 /src/System.Private.Interop
parenta3837f7fc60a1b7db872cfef6463f74fb1ffeafb (diff)
Cleanup MightBeBlittable implementation
- Cleaned up comments around MightBeBlittable and simplified the implementation - Moved a few more Marshal methods to PInvokeMarshal from InteropExtensions and removed redundant wrappers - Fixed potential integer truncation in UnsafeAddrOfPinnedArrayElement on 64-bit platforms [tfs-changeset: 1663953]
Diffstat (limited to 'src/System.Private.Interop')
-rw-r--r--src/System.Private.Interop/src/Shared/McgHelpers.cs2
-rw-r--r--src/System.Private.Interop/src/System/Runtime/InteropServices/ArrayWithOffset.cs2
-rw-r--r--src/System.Private.Interop/src/System/Runtime/InteropServices/Marshal.cs53
3 files changed, 20 insertions, 37 deletions
diff --git a/src/System.Private.Interop/src/Shared/McgHelpers.cs b/src/System.Private.Interop/src/Shared/McgHelpers.cs
index ddabcc53d..370f4d409 100644
--- a/src/System.Private.Interop/src/Shared/McgHelpers.cs
+++ b/src/System.Private.Interop/src/Shared/McgHelpers.cs
@@ -1700,7 +1700,7 @@ namespace System.Runtime.InteropServices
*((uint*)pCount) = (uint)count;
- InteropExtensions.CopyToNative(data, 0, pDest, count);
+ PInvokeMarshal.CopyToNative(data, 0, pDest, count);
}
catch (System.Exception hrExcep)
{
diff --git a/src/System.Private.Interop/src/System/Runtime/InteropServices/ArrayWithOffset.cs b/src/System.Private.Interop/src/System/Runtime/InteropServices/ArrayWithOffset.cs
index 96997db75..5ee563ca6 100644
--- a/src/System.Private.Interop/src/System/Runtime/InteropServices/ArrayWithOffset.cs
+++ b/src/System.Private.Interop/src/System/Runtime/InteropServices/ArrayWithOffset.cs
@@ -83,7 +83,7 @@ namespace System.Runtime.InteropServices
throw new ArgumentException(SR.Arg_NotIsomorphic);
}
- if (!arrayObj.IsElementTypeBlittable())
+ if (!arrayObj.IsBlittable())
{
throw new ArgumentException(SR.Arg_NotIsomorphic);
}
diff --git a/src/System.Private.Interop/src/System/Runtime/InteropServices/Marshal.cs b/src/System.Private.Interop/src/System/Runtime/InteropServices/Marshal.cs
index 6f0cdfa09..28a956b6d 100644
--- a/src/System.Private.Interop/src/System/Runtime/InteropServices/Marshal.cs
+++ b/src/System.Private.Interop/src/System/Runtime/InteropServices/Marshal.cs
@@ -227,47 +227,42 @@ namespace System.Runtime.InteropServices
//====================================================================
public static void Copy(int[] source, int startIndex, IntPtr destination, int length)
{
- CopyToNative(source, startIndex, destination, length);
+ PInvokeMarshal.CopyToNative(source, startIndex, destination, length);
}
public static void Copy(char[] source, int startIndex, IntPtr destination, int length)
{
- CopyToNative(source, startIndex, destination, length);
+ PInvokeMarshal.CopyToNative(source, startIndex, destination, length);
}
public static void Copy(short[] source, int startIndex, IntPtr destination, int length)
{
- CopyToNative(source, startIndex, destination, length);
+ PInvokeMarshal.CopyToNative(source, startIndex, destination, length);
}
public static void Copy(long[] source, int startIndex, IntPtr destination, int length)
{
- CopyToNative(source, startIndex, destination, length);
+ PInvokeMarshal.CopyToNative(source, startIndex, destination, length);
}
public static void Copy(float[] source, int startIndex, IntPtr destination, int length)
{
- CopyToNative(source, startIndex, destination, length);
+ PInvokeMarshal.CopyToNative(source, startIndex, destination, length);
}
public static void Copy(double[] source, int startIndex, IntPtr destination, int length)
{
- CopyToNative(source, startIndex, destination, length);
+ PInvokeMarshal.CopyToNative(source, startIndex, destination, length);
}
public static void Copy(byte[] source, int startIndex, IntPtr destination, int length)
{
- CopyToNative(source, startIndex, destination, length);
+ PInvokeMarshal.CopyToNative(source, startIndex, destination, length);
}
public static void Copy(IntPtr[] source, int startIndex, IntPtr destination, int length)
{
- CopyToNative(source, startIndex, destination, length);
- }
-
- private static void CopyToNative(Array source, int startIndex, IntPtr destination, int length)
- {
- InteropExtensions.CopyToNative(source, startIndex, destination, length);
+ PInvokeMarshal.CopyToNative(source, startIndex, destination, length);
}
//====================================================================
@@ -275,50 +270,44 @@ namespace System.Runtime.InteropServices
//====================================================================
public static void Copy(IntPtr source, int[] destination, int startIndex, int length)
{
- CopyToManaged(source, destination, startIndex, length);
+ PInvokeMarshal.CopyToManaged(source, destination, startIndex, length);
}
public static void Copy(IntPtr source, char[] destination, int startIndex, int length)
{
- CopyToManaged(source, destination, startIndex, length);
+ PInvokeMarshal.CopyToManaged(source, destination, startIndex, length);
}
public static void Copy(IntPtr source, short[] destination, int startIndex, int length)
{
- CopyToManaged(source, destination, startIndex, length);
+ PInvokeMarshal.CopyToManaged(source, destination, startIndex, length);
}
public static void Copy(IntPtr source, long[] destination, int startIndex, int length)
{
- CopyToManaged(source, destination, startIndex, length);
+ PInvokeMarshal.CopyToManaged(source, destination, startIndex, length);
}
public static void Copy(IntPtr source, float[] destination, int startIndex, int length)
{
- CopyToManaged(source, destination, startIndex, length);
+ PInvokeMarshal.CopyToManaged(source, destination, startIndex, length);
}
public static void Copy(IntPtr source, double[] destination, int startIndex, int length)
{
- CopyToManaged(source, destination, startIndex, length);
+ PInvokeMarshal.CopyToManaged(source, destination, startIndex, length);
}
public static void Copy(IntPtr source, byte[] destination, int startIndex, int length)
{
- CopyToManaged(source, destination, startIndex, length);
+ PInvokeMarshal.CopyToManaged(source, destination, startIndex, length);
}
public static void Copy(IntPtr source, IntPtr[] destination, int startIndex, int length)
{
- CopyToManaged(source, destination, startIndex, length);
+ PInvokeMarshal.CopyToManaged(source, destination, startIndex, length);
}
- private static void CopyToManaged(IntPtr source, Array destination, int startIndex, int length)
- {
- InteropExtensions.CopyToManaged(source, destination, startIndex, length);
- }
-
-
//====================================================================
// Read from memory
//====================================================================
@@ -1420,18 +1409,12 @@ namespace System.Runtime.InteropServices
//====================================================================
public static IntPtr UnsafeAddrOfPinnedArrayElement(Array arr, int index)
{
- if (arr == null)
- throw new ArgumentNullException(nameof(arr));
-
- Contract.EndContractBlock();
- int offset = checked(index * arr.GetElementSize());
-
- return arr.GetAddrOfPinnedArrayFromEETypeField() + offset;
+ return PInvokeMarshal.UnsafeAddrOfPinnedArrayElement(arr, index);
}
public static IntPtr UnsafeAddrOfPinnedArrayElement<T>(T[] arr, int index)
{
- return UnsafeAddrOfPinnedArrayElement((Array)arr, index);
+ return PInvokeMarshal.UnsafeAddrOfPinnedArrayElement(arr, index);
}
//====================================================================