From 9ee68a0b85f13147af86cb1218bb8311e36031d6 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 23 Apr 2024 13:55:57 +0000 Subject: [PATCH 1/2] Fix big endian issue in Interlocked test cases Fix big indian issue wiht BitConverted as part of intercloked test cases. --- .../src/System/Threading/Interlocked.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/Interlocked.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/Interlocked.cs index 45ebce76f7b0e..f981629e526a0 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/Interlocked.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/Interlocked.cs @@ -126,7 +126,7 @@ public static unsafe ushort Exchange(ref ushort location1, ushort value) nuint offset = Unsafe.OpportunisticMisalignment(ref location1, sizeof(uint)); ref uint alignedRef = ref Unsafe.As(ref Unsafe.SubtractByteOffset(ref location1, offset)); int bitOffset = - (int)((BitConverter.IsLittleEndian ? offset : sizeof(uint) - offset - sizeof(byte)) * 8); // to bit offset + (int)((BitConverter.IsLittleEndian ? offset : sizeof(uint) - offset - sizeof(short)) * 8); // to bit offset Debug.Assert(bitOffset is 0 or 16); uint mask = ~((uint)ushort.MaxValue << bitOffset); uint shiftedValue = (uint)value << bitOffset; @@ -308,7 +308,7 @@ public static unsafe ushort CompareExchange(ref ushort location1, ushort value, nuint offset = Unsafe.OpportunisticMisalignment(ref location1, sizeof(uint)); ref uint alignedRef = ref Unsafe.As(ref Unsafe.SubtractByteOffset(ref location1, offset)); int bitOffset = - (int)((BitConverter.IsLittleEndian ? offset : sizeof(uint) - offset - sizeof(byte)) * 8); // to bit offset + (int)((BitConverter.IsLittleEndian ? offset : sizeof(uint) - offset - sizeof(short)) * 8); // to bit offset Debug.Assert(bitOffset is 0 or 16); uint mask = ~((uint)ushort.MaxValue << bitOffset); uint shiftedValue = (uint)value << bitOffset; From a552af5c19524a7ee599249851e7a73413959a98 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 23 Apr 2024 15:51:42 +0000 Subject: [PATCH 2/2] Fix big endian issue in Interlocked test cases Fix big indian issue wiht BitConverted as part of intercloked test cases. These were causing failures in runtime_community pipeline --- .../src/System/Threading/Interlocked.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/Interlocked.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/Interlocked.cs index f981629e526a0..6e33ce716fd6a 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/Interlocked.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/Interlocked.cs @@ -126,7 +126,7 @@ public static unsafe ushort Exchange(ref ushort location1, ushort value) nuint offset = Unsafe.OpportunisticMisalignment(ref location1, sizeof(uint)); ref uint alignedRef = ref Unsafe.As(ref Unsafe.SubtractByteOffset(ref location1, offset)); int bitOffset = - (int)((BitConverter.IsLittleEndian ? offset : sizeof(uint) - offset - sizeof(short)) * 8); // to bit offset + (int)((BitConverter.IsLittleEndian ? offset : sizeof(uint) - offset - sizeof(ushort)) * 8); // to bit offset Debug.Assert(bitOffset is 0 or 16); uint mask = ~((uint)ushort.MaxValue << bitOffset); uint shiftedValue = (uint)value << bitOffset; @@ -308,7 +308,7 @@ public static unsafe ushort CompareExchange(ref ushort location1, ushort value, nuint offset = Unsafe.OpportunisticMisalignment(ref location1, sizeof(uint)); ref uint alignedRef = ref Unsafe.As(ref Unsafe.SubtractByteOffset(ref location1, offset)); int bitOffset = - (int)((BitConverter.IsLittleEndian ? offset : sizeof(uint) - offset - sizeof(short)) * 8); // to bit offset + (int)((BitConverter.IsLittleEndian ? offset : sizeof(uint) - offset - sizeof(ushort)) * 8); // to bit offset Debug.Assert(bitOffset is 0 or 16); uint mask = ~((uint)ushort.MaxValue << bitOffset); uint shiftedValue = (uint)value << bitOffset;