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

github.com/mono/corefx.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornietras <nietras@users.noreply.github.com>2016-12-15 17:22:32 +0300
committerJan Kotas <jkotas@microsoft.com>2016-12-15 17:22:32 +0300
commit60084eb386db5e894348ac2ec0b890230ee238ab (patch)
tree6c93b21027f92df50bb92c6dc0825278d4363ee3 /src/System.Runtime.CompilerServices.Unsafe
parent199a889686c9d09f1f0b33b4adf2f5ba2e7a0527 (diff)
S.R.CS.Unsafe: Add CopyBlock/CopyBlockUnaligned and InitBlock/InitBlockUnaligned for ref byte (#13848)
* S.R.CS.Unsafe: Add CopyBlock<T>/CopyBlockUnaligned<T> for (ref T destination, ref T source, int elementCount) * S.R.CS.Unsafe: Remove new and existing InitBlock/CopyBlock* overloads taking UIntPtr as byteCount.
Diffstat (limited to 'src/System.Runtime.CompilerServices.Unsafe')
-rw-r--r--src/System.Runtime.CompilerServices.Unsafe/src/System.Runtime.CompilerServices.Unsafe.il8
-rw-r--r--src/System.Runtime.CompilerServices.Unsafe/src/System.Runtime.CompilerServices.Unsafe.xml8
-rw-r--r--src/System.Runtime.CompilerServices.Unsafe/tests/UnsafeTests.cs25
3 files changed, 20 insertions, 21 deletions
diff --git a/src/System.Runtime.CompilerServices.Unsafe/src/System.Runtime.CompilerServices.Unsafe.il b/src/System.Runtime.CompilerServices.Unsafe/src/System.Runtime.CompilerServices.Unsafe.il
index 3251744263..8695372258 100644
--- a/src/System.Runtime.CompilerServices.Unsafe/src/System.Runtime.CompilerServices.Unsafe.il
+++ b/src/System.Runtime.CompilerServices.Unsafe/src/System.Runtime.CompilerServices.Unsafe.il
@@ -130,7 +130,7 @@
ret
} // end of method Unsafe::CopyBlock
- .method public hidebysig static void CopyBlock(void* destination, void* source, native unsigned int byteCount) cil managed aggressiveinlining
+ .method public hidebysig static void CopyBlock(uint8& destination, uint8& source, uint32 byteCount) cil managed aggressiveinlining
{
.custom instance void System.Runtime.Versioning.NonVersionableAttribute::.ctor() = ( 01 00 00 00 )
.maxstack 3
@@ -153,7 +153,7 @@
ret
} // end of method Unsafe::CopyBlockUnaligned
- .method public hidebysig static void CopyBlockUnaligned(void* destination, void* source, native unsigned int byteCount) cil managed aggressiveinlining
+ .method public hidebysig static void CopyBlockUnaligned(uint8& destination, uint8& source, uint32 byteCount) cil managed aggressiveinlining
{
.custom instance void System.Runtime.Versioning.NonVersionableAttribute::.ctor() = ( 01 00 00 00 )
.maxstack 3
@@ -176,7 +176,7 @@
ret
} // end of method Unsafe::InitBlock
- .method public hidebysig static void InitBlock(void* startAddress, uint8 'value', native unsigned int byteCount) cil managed aggressiveinlining
+ .method public hidebysig static void InitBlock(uint8& startAddress, uint8 'value', uint32 byteCount) cil managed aggressiveinlining
{
.custom instance void System.Runtime.Versioning.NonVersionableAttribute::.ctor() = ( 01 00 00 00 )
.maxstack 3
@@ -199,7 +199,7 @@
ret
} // end of method Unsafe::InitBlockUnaligned
- .method public hidebysig static void InitBlockUnaligned(void* startAddress, uint8 'value', native unsigned int byteCount) cil managed aggressiveinlining
+ .method public hidebysig static void InitBlockUnaligned(uint8& startAddress, uint8 'value', uint32 byteCount) cil managed aggressiveinlining
{
.custom instance void System.Runtime.Versioning.NonVersionableAttribute::.ctor() = ( 01 00 00 00 )
.maxstack 3
diff --git a/src/System.Runtime.CompilerServices.Unsafe/src/System.Runtime.CompilerServices.Unsafe.xml b/src/System.Runtime.CompilerServices.Unsafe/src/System.Runtime.CompilerServices.Unsafe.xml
index bd8f42271a..4a7ea0d948 100644
--- a/src/System.Runtime.CompilerServices.Unsafe/src/System.Runtime.CompilerServices.Unsafe.xml
+++ b/src/System.Runtime.CompilerServices.Unsafe/src/System.Runtime.CompilerServices.Unsafe.xml
@@ -160,7 +160,7 @@
<param name="source">The source address to copy from.</param>
<param name="byteCount">The number of bytes to copy.</param>
</member>
- <member name="M:System.Runtime.CompilerServices.Unsafe.CopyBlock(System.Void*,System.Void*,System.UIntPtr)">
+ <member name="M:System.Runtime.CompilerServices.Unsafe.CopyBlock(System.Byte@,System.Byte@,System.UInt32)">
<summary>
Copies bytes from the source address to the destination address.
</summary>
@@ -177,7 +177,7 @@
<param name="source">The source address to copy from.</param>
<param name="byteCount">The number of bytes to copy.</param>
</member>
- <member name="M:System.Runtime.CompilerServices.Unsafe.CopyBlockUnaligned(System.Void*,System.Void*,System.UIntPtr)">
+ <member name="M:System.Runtime.CompilerServices.Unsafe.CopyBlockUnaligned(System.Byte@,System.Byte@,System.UInt32)">
<summary>
Copies bytes from the source address to the destination address
without assuming architecture dependent alignment of the addresses.
@@ -194,7 +194,7 @@
<param name="value">The value to initialize the block to.</param>
<param name="byteCount">The number of bytes to initialize.</param>
</member>
- <member name="M:System.Runtime.CompilerServices.Unsafe.InitBlock(System.Void*,System.Byte,System.UIntPtr)">
+ <member name="M:System.Runtime.CompilerServices.Unsafe.InitBlock(System.Byte@,System.Byte,System.UInt32)">
<summary>
Initializes a block of memory at the given location with a given initial value.
</summary>
@@ -211,7 +211,7 @@
<param name="value">The value to initialize the block to.</param>
<param name="byteCount">The number of bytes to initialize.</param>
</member>
- <member name="M:System.Runtime.CompilerServices.Unsafe.InitBlockUnaligned(System.Void*,System.Byte,System.UIntPtr)">
+ <member name="M:System.Runtime.CompilerServices.Unsafe.InitBlockUnaligned(System.Byte@,System.Byte,System.UInt32)">
<summary>
Initializes a block of memory at the given location with a given initial value
without assuming architecture dependent alignment of the address.
diff --git a/src/System.Runtime.CompilerServices.Unsafe/tests/UnsafeTests.cs b/src/System.Runtime.CompilerServices.Unsafe/tests/UnsafeTests.cs
index 84455780e9..7511966b99 100644
--- a/src/System.Runtime.CompilerServices.Unsafe/tests/UnsafeTests.cs
+++ b/src/System.Runtime.CompilerServices.Unsafe/tests/UnsafeTests.cs
@@ -181,10 +181,10 @@ namespace System.Runtime.CompilerServices
[Theory]
[MemberData(nameof(InitBlockData))]
- public static unsafe void InitBlockUIntPtrStack(int numBytes, byte value)
+ public static unsafe void InitBlockRefStack(int numBytes, byte value)
{
byte* stackPtr = stackalloc byte[numBytes];
- Unsafe.InitBlock(stackPtr, value, (UIntPtr)numBytes);
+ Unsafe.InitBlock(ref *stackPtr, value, (uint)numBytes);
for (int i = 0; i < numBytes; i++)
{
Assert.Equal(stackPtr[i], value);
@@ -193,11 +193,11 @@ namespace System.Runtime.CompilerServices
[Theory]
[MemberData(nameof(InitBlockData))]
- public static unsafe void InitBlockUIntPtrUnmanaged(int numBytes, byte value)
+ public static unsafe void InitBlockRefUnmanaged(int numBytes, byte value)
{
IntPtr allocatedMemory = Marshal.AllocCoTaskMem(numBytes);
byte* bytePtr = (byte*)allocatedMemory.ToPointer();
- Unsafe.InitBlock(bytePtr, value, (UIntPtr)numBytes);
+ Unsafe.InitBlock(ref *bytePtr, value, (uint)numBytes);
for (int i = 0; i < numBytes; i++)
{
Assert.Equal(bytePtr[i], value);
@@ -232,11 +232,11 @@ namespace System.Runtime.CompilerServices
[Theory]
[MemberData(nameof(InitBlockData))]
- public static unsafe void InitBlockUnalignedUIntPtrStack(int numBytes, byte value)
+ public static unsafe void InitBlockUnalignedRefStack(int numBytes, byte value)
{
byte* stackPtr = stackalloc byte[numBytes + 1];
stackPtr += 1; // +1 = make unaligned
- Unsafe.InitBlockUnaligned(stackPtr, value, (UIntPtr)numBytes);
+ Unsafe.InitBlockUnaligned(ref *stackPtr, value, (uint)numBytes);
for (int i = 0; i < numBytes; i++)
{
Assert.Equal(stackPtr[i], value);
@@ -245,11 +245,11 @@ namespace System.Runtime.CompilerServices
[Theory]
[MemberData(nameof(InitBlockData))]
- public static unsafe void InitBlockUnalignedUIntPtrUnmanaged(int numBytes, byte value)
+ public static unsafe void InitBlockUnalignedRefUnmanaged(int numBytes, byte value)
{
IntPtr allocatedMemory = Marshal.AllocCoTaskMem(numBytes + 1);
byte* bytePtr = (byte*)allocatedMemory.ToPointer() + 1; // +1 = make unaligned
- Unsafe.InitBlockUnaligned(bytePtr, value, (UIntPtr)numBytes);
+ Unsafe.InitBlockUnaligned(ref *bytePtr, value, (uint)numBytes);
for (int i = 0; i < numBytes; i++)
{
Assert.Equal(bytePtr[i], value);
@@ -291,7 +291,7 @@ namespace System.Runtime.CompilerServices
[Theory]
[MemberData(nameof(CopyBlockData))]
- public static unsafe void CopyBlockUIntPtr(int numBytes)
+ public static unsafe void CopyBlockRef(int numBytes)
{
byte* source = stackalloc byte[numBytes];
byte* destination = stackalloc byte[numBytes];
@@ -302,7 +302,7 @@ namespace System.Runtime.CompilerServices
source[i] = value;
}
- Unsafe.CopyBlock(destination, source, (UIntPtr)numBytes);
+ Unsafe.CopyBlock(ref destination[0], ref source[0], (uint)numBytes);
for (int i = 0; i < numBytes; i++)
{
@@ -337,10 +337,9 @@ namespace System.Runtime.CompilerServices
}
}
-
[Theory]
[MemberData(nameof(CopyBlockData))]
- public static unsafe void CopyBlockUnalignedUIntPtr(int numBytes)
+ public static unsafe void CopyBlockUnalignedRef(int numBytes)
{
byte* source = stackalloc byte[numBytes + 1];
byte* destination = stackalloc byte[numBytes + 1];
@@ -353,7 +352,7 @@ namespace System.Runtime.CompilerServices
source[i] = value;
}
- Unsafe.CopyBlockUnaligned(destination, source, (UIntPtr)numBytes);
+ Unsafe.CopyBlockUnaligned(ref destination[0], ref source[0], (uint)numBytes);
for (int i = 0; i < numBytes; i++)
{