aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorArthur Cohen <arthur.cohen@embecosm.com>2024-01-18 17:24:01 +0100
committerArthur Cohen <arthur.cohen@embecosm.com>2025-03-21 12:56:56 +0100
commitffecc9a97247b73de657a1fc0c81cf824bfd72c6 (patch)
tree126aecf5824357f8f856f3295d4333d7f78ca0d9 /gcc
parent469d668f6fac45dcd72182d1075285c761acac94 (diff)
downloadgcc-ffecc9a97247b73de657a1fc0c81cf824bfd72c6.zip
gcc-ffecc9a97247b73de657a1fc0c81cf824bfd72c6.tar.gz
gcc-ffecc9a97247b73de657a1fc0c81cf824bfd72c6.tar.bz2
gccrs: testsuite: Fix missing handling of little endian.
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.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/testsuite/rust/compile/issue-1446.rs10
-rw-r--r--gcc/testsuite/rust/compile/iterators1.rs18
2 files changed, 9 insertions, 19 deletions
diff --git a/gcc/testsuite/rust/compile/issue-1446.rs b/gcc/testsuite/rust/compile/issue-1446.rs
index 8bfa42b..969ad38 100644
--- a/gcc/testsuite/rust/compile/issue-1446.rs
+++ b/gcc/testsuite/rust/compile/issue-1446.rs
@@ -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)
}
}
diff --git a/gcc/testsuite/rust/compile/iterators1.rs b/gcc/testsuite/rust/compile/iterators1.rs
index 35fea5a..1141758 100644
--- a/gcc/testsuite/rust/compile/iterators1.rs
+++ b/gcc/testsuite/rust/compile/iterators1.rs
@@ -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) }
}