Skip to content

Commit ffc7884

Browse files
committed
testsuite: Fix missing handling of big endian.
Some failures occur in the testsuite because we did not account for the big-endian case. gcc/testsuite/ChangeLog: * rust/compile/issue-1446.rs: Add swap_bytes function. * rust/compile/iterators1.rs: Remove unused {to, from}_le functions.
1 parent 0cd26bd commit ffc7884

File tree

2 files changed

+9
-19
lines changed

2 files changed

+9
-19
lines changed
Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
1+
// fake function
2+
pub fn swap_bytes(this: u32) -> u32 {
3+
(((this) & 0xff000000) >> 24)
4+
| (((this) & 0x00ff0000) >> 8)
5+
| (((this) & 0x0000ff00) << 8)
6+
| (((this) & 0x000000ff) << 24)
7+
}
8+
19
pub fn to_le(this: u32) -> u32 {
210
#[cfg(target_endian = "little")]
311
{
412
this
513
}
614
#[cfg(not(target_endian = "little"))]
715
{
8-
this.swap_bytes()
16+
swap_bytes(this)
917
}
1018
}

gcc/testsuite/rust/compile/iterators1.rs

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -232,24 +232,6 @@ macro_rules! impl_uint {
232232
}
233233
}
234234

235-
pub fn to_le(self) -> Self {
236-
#[cfg(target_endian = "little")]
237-
{
238-
self
239-
}
240-
}
241-
242-
pub const fn from_le_bytes(bytes: [u8; mem::size_of::<Self>()]) -> Self {
243-
Self::from_le(Self::from_ne_bytes(bytes))
244-
}
245-
246-
pub const fn from_le(x: Self) -> Self {
247-
#[cfg(target_endian = "little")]
248-
{
249-
x
250-
}
251-
}
252-
253235
pub const fn from_ne_bytes(bytes: [u8; mem::size_of::<Self>()]) -> Self {
254236
unsafe { mem::transmute(bytes) }
255237
}

0 commit comments

Comments
 (0)