Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public static ulong Read(ref ulong location) =>
/// <summary>Bitwise "ands" two 32-bit signed integers and replaces the first integer with the result, as an atomic operation.</summary>
/// <param name="location1">A variable containing the first value to be combined. The result is stored in <paramref name="location1"/>.</param>
/// <param name="value">The value to be combined with the integer at <paramref name="location1"/>.</param>
/// <returns>The new value stored at <paramref name="location1"/>.</returns>
/// <returns>The original value in <paramref name="location1"/>.</returns>
/// <exception cref="NullReferenceException">The address of <paramref name="location1"/> is a null pointer.</exception>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static int And(ref int location1, int value)
Expand All @@ -144,7 +144,7 @@ public static int And(ref int location1, int value)
int oldValue = CompareExchange(ref location1, newValue, current);
if (oldValue == current)
{
return newValue;
return oldValue;
}
current = oldValue;
}
Expand All @@ -153,7 +153,7 @@ public static int And(ref int location1, int value)
/// <summary>Bitwise "ands" two 32-bit unsigned integers and replaces the first integer with the result, as an atomic operation.</summary>
/// <param name="location1">A variable containing the first value to be combined. The result is stored in <paramref name="location1"/>.</param>
/// <param name="value">The value to be combined with the integer at <paramref name="location1"/>.</param>
/// <returns>The new value stored at <paramref name="location1"/>.</returns>
/// <returns>The original value in <paramref name="location1"/>.</returns>
/// <exception cref="NullReferenceException">The address of <paramref name="location1"/> is a null pointer.</exception>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[CLSCompliant(false)]
Expand All @@ -163,7 +163,7 @@ public static uint And(ref uint location1, uint value) =>
/// <summary>Bitwise "ands" two 64-bit signed integers and replaces the first integer with the result, as an atomic operation.</summary>
/// <param name="location1">A variable containing the first value to be combined. The result is stored in <paramref name="location1"/>.</param>
/// <param name="value">The value to be combined with the integer at <paramref name="location1"/>.</param>
/// <returns>The new value stored at <paramref name="location1"/>.</returns>
/// <returns>The original value in <paramref name="location1"/>.</returns>
/// <exception cref="NullReferenceException">The address of <paramref name="location1"/> is a null pointer.</exception>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static long And(ref long location1, long value)
Expand All @@ -175,7 +175,7 @@ public static long And(ref long location1, long value)
long oldValue = CompareExchange(ref location1, newValue, current);
if (oldValue == current)
{
return newValue;
return oldValue;
}
current = oldValue;
}
Expand All @@ -184,7 +184,7 @@ public static long And(ref long location1, long value)
/// <summary>Bitwise "ands" two 64-bit unsigned integers and replaces the first integer with the result, as an atomic operation.</summary>
/// <param name="location1">A variable containing the first value to be combined. The result is stored in <paramref name="location1"/>.</param>
/// <param name="value">The value to be combined with the integer at <paramref name="location1"/>.</param>
/// <returns>The new value stored at <paramref name="location1"/>.</returns>
/// <returns>The original value in <paramref name="location1"/>.</returns>
/// <exception cref="NullReferenceException">The address of <paramref name="location1"/> is a null pointer.</exception>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[CLSCompliant(false)]
Expand All @@ -196,7 +196,7 @@ public static ulong And(ref ulong location1, ulong value) =>
/// <summary>Bitwise "ors" two 32-bit signed integers and replaces the first integer with the result, as an atomic operation.</summary>
/// <param name="location1">A variable containing the first value to be combined. The result is stored in <paramref name="location1"/>.</param>
/// <param name="value">The value to be combined with the integer at <paramref name="location1"/>.</param>
/// <returns>The new value stored at <paramref name="location1"/>.</returns>
/// <returns>The original value in <paramref name="location1"/>.</returns>
/// <exception cref="NullReferenceException">The address of <paramref name="location1"/> is a null pointer.</exception>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static int Or(ref int location1, int value)
Expand All @@ -208,7 +208,7 @@ public static int Or(ref int location1, int value)
int oldValue = CompareExchange(ref location1, newValue, current);
if (oldValue == current)
{
return newValue;
return oldValue;
}
current = oldValue;
}
Expand All @@ -217,7 +217,7 @@ public static int Or(ref int location1, int value)
/// <summary>Bitwise "ors" two 32-bit unsigned integers and replaces the first integer with the result, as an atomic operation.</summary>
/// <param name="location1">A variable containing the first value to be combined. The result is stored in <paramref name="location1"/>.</param>
/// <param name="value">The value to be combined with the integer at <paramref name="location1"/>.</param>
/// <returns>The new value stored at <paramref name="location1"/>.</returns>
/// <returns>The original value in <paramref name="location1"/>.</returns>
/// <exception cref="NullReferenceException">The address of <paramref name="location1"/> is a null pointer.</exception>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[CLSCompliant(false)]
Expand All @@ -227,7 +227,7 @@ public static uint Or(ref uint location1, uint value) =>
/// <summary>Bitwise "ors" two 64-bit signed integers and replaces the first integer with the result, as an atomic operation.</summary>
/// <param name="location1">A variable containing the first value to be combined. The result is stored in <paramref name="location1"/>.</param>
/// <param name="value">The value to be combined with the integer at <paramref name="location1"/>.</param>
/// <returns>The new value stored at <paramref name="location1"/>.</returns>
/// <returns>The original value in <paramref name="location1"/>.</returns>
/// <exception cref="NullReferenceException">The address of <paramref name="location1"/> is a null pointer.</exception>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static long Or(ref long location1, long value)
Expand All @@ -239,7 +239,7 @@ public static long Or(ref long location1, long value)
long oldValue = CompareExchange(ref location1, newValue, current);
if (oldValue == current)
{
return newValue;
return oldValue;
}
current = oldValue;
}
Expand All @@ -248,7 +248,7 @@ public static long Or(ref long location1, long value)
/// <summary>Bitwise "ors" two 64-bit unsigned integers and replaces the first integer with the result, as an atomic operation.</summary>
/// <param name="location1">A variable containing the first value to be combined. The result is stored in <paramref name="location1"/>.</param>
/// <param name="value">The value to be combined with the integer at <paramref name="location1"/>.</param>
/// <returns>The new value stored at <paramref name="location1"/>.</returns>
/// <returns>The original value in <paramref name="location1"/>.</returns>
/// <exception cref="NullReferenceException">The address of <paramref name="location1"/> is a null pointer.</exception>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[CLSCompliant(false)]
Expand Down
16 changes: 8 additions & 8 deletions src/libraries/System.Threading/tests/InterlockedTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -242,63 +242,63 @@ public void InterlockedRead_UInt64()
public void InterlockedAnd_Int32()
{
int value = 0x12345670;
Assert.Equal(0x02244220, Interlocked.And(ref value, 0x7654321));
Assert.Equal(0x12345670, Interlocked.And(ref value, 0x7654321));
Assert.Equal(0x02244220, value);
}

[Fact]
public void InterlockedAnd_UInt32()
{
uint value = 0x12345670u;
Assert.Equal(0x02244220u, Interlocked.And(ref value, 0x7654321));
Assert.Equal(0x12345670u, Interlocked.And(ref value, 0x7654321));
Assert.Equal(0x02244220u, value);
}

[Fact]
public void InterlockedAnd_Int64()
{
long value = 0x12345670;
Assert.Equal(0x02244220, Interlocked.And(ref value, 0x7654321));
Assert.Equal(0x12345670, Interlocked.And(ref value, 0x7654321));
Assert.Equal(0x02244220, value);
}

[Fact]
public void InterlockedAnd_UInt64()
{
ulong value = 0x12345670u;
Assert.Equal(0x02244220u, Interlocked.And(ref value, 0x7654321));
Assert.Equal(0x12345670u, Interlocked.And(ref value, 0x7654321));
Assert.Equal(0x02244220u, value);
}

[Fact]
public void InterlockedOr_Int32()
{
int value = 0x12345670;
Assert.Equal(0x17755771, Interlocked.Or(ref value, 0x7654321));
Assert.Equal(0x12345670, Interlocked.Or(ref value, 0x7654321));
Assert.Equal(0x17755771, value);
}

[Fact]
public void InterlockedOr_UInt32()
{
uint value = 0x12345670u;
Assert.Equal(0x17755771u, Interlocked.Or(ref value, 0x7654321));
Assert.Equal(0x12345670u, Interlocked.Or(ref value, 0x7654321));
Assert.Equal(0x17755771u, value);
}

[Fact]
public void InterlockedOr_Int64()
{
long value = 0x12345670;
Assert.Equal(0x17755771, Interlocked.Or(ref value, 0x7654321));
Assert.Equal(0x12345670, Interlocked.Or(ref value, 0x7654321));
Assert.Equal(0x17755771, value);
}

[Fact]
public void InterlockedOr_UInt64()
{
ulong value = 0x12345670u;
Assert.Equal(0x17755771u, Interlocked.Or(ref value, 0x7654321));
Assert.Equal(0x12345670u, Interlocked.Or(ref value, 0x7654321));
Assert.Equal(0x17755771u, value);
}

Expand Down