]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: testsuite: Fix missing handling of little endian.
authorArthur Cohen <arthur.cohen@embecosm.com>
Thu, 18 Jan 2024 16:24:01 +0000 (17:24 +0100)
committerArthur Cohen <arthur.cohen@embecosm.com>
Fri, 21 Mar 2025 11:56:56 +0000 (12:56 +0100)
Some failures occur in the testsuite because we
did not account for the little-endian case.

gcc/testsuite/ChangeLog:

* rust/compile/issue-1446.rs: Add swap_bytes function.
* rust/compile/iterators1.rs: Remove unused {to, from}_le functions.

gcc/testsuite/rust/compile/issue-1446.rs
gcc/testsuite/rust/compile/iterators1.rs

index 8bfa42b9dace8d7b511e5d7cb2c74f0b4bfaf23a..969ad380ee69be1c81c5d66c9b5e99a2d0a78d5a 100644 (file)
@@ -1,3 +1,11 @@
+// fake function
+pub fn swap_bytes(this: u32) -> u32 {
+    (((this) & 0xff000000) >> 24)
+        | (((this) & 0x00ff0000) >> 8)
+        | (((this) & 0x0000ff00) << 8)
+        | (((this) & 0x000000ff) << 24)
+}
+
 pub fn to_le(this: u32) -> u32 {
     #[cfg(target_endian = "little")]
     {
@@ -5,6 +13,6 @@ pub fn to_le(this: u32) -> u32 {
     }
     #[cfg(not(target_endian = "little"))]
     {
-        this.swap_bytes()
+        swap_bytes(this)
     }
 }
index 35fea5a049387804a8e131c0fcf33655d8e18859..1141758b14a7b70d9079129cb7bc47842c2fde06 100644 (file)
@@ -232,24 +232,6 @@ macro_rules! impl_uint {
                     }
                 }
 
-                pub fn to_le(self) -> Self {
-                    #[cfg(target_endian = "little")]
-                    {
-                        self
-                    }
-                }
-
-                pub const fn from_le_bytes(bytes: [u8; mem::size_of::<Self>()]) -> Self {
-                    Self::from_le(Self::from_ne_bytes(bytes))
-                }
-
-                pub const fn from_le(x: Self) -> Self {
-                    #[cfg(target_endian = "little")]
-                    {
-                        x
-                    }
-                }
-
                 pub const fn from_ne_bytes(bytes: [u8; mem::size_of::<Self>()]) -> Self {
                     unsafe { mem::transmute(bytes) }
                 }