From 77bd4dc65406ba3cedbc779e6f6280868231912e Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Mon, 10 Jul 2017 17:06:38 -0700 Subject: Disable big-endian simd in swap_nonoverlapping_bytes This is a workaround for #42778, which was git-bisected to #40454's optimizations to `mem::swap`, later moved to `ptr` in #42819. Natively compiled rustc couldn't even compile stage1 libcore on powerpc64 and s390x, but they work fine without this `repr(simd)`. Since powerpc64le works OK, it seems probably related to being big-endian. The underlying problem is not yet known, but this at least makes those architectures functional again in the meantime. cc @arielb1 --- src/libcore/ptr.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/libcore') diff --git a/src/libcore/ptr.rs b/src/libcore/ptr.rs index 92470299366..4f118f58441 100644 --- a/src/libcore/ptr.rs +++ b/src/libcore/ptr.rs @@ -160,7 +160,10 @@ unsafe fn swap_nonoverlapping_bytes(x: *mut u8, y: *mut u8, len: usize) { // #[repr(simd)], even if we don't actually use this struct directly. // // FIXME repr(simd) broken on emscripten and redox - #[cfg_attr(not(any(target_os = "emscripten", target_os = "redox")), repr(simd))] + // It's also broken on big-endian powerpc64 and s390x. #42778 + #[cfg_attr(not(any(target_os = "emscripten", target_os = "redox", + target_endian = "big")), + repr(simd))] struct Block(u64, u64, u64, u64); struct UnalignedBlock(u64, u64, u64, u64); -- cgit 1.4.1-3-g733a5 From b90e5107c0e460486f5e3992d92907c3a038e6fc Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Wed, 5 Jul 2017 20:21:29 +0200 Subject: Forward more Iterator methods for str::Bytes These are overridden by slice::Iter --- src/libcore/str/mod.rs | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'src/libcore') diff --git a/src/libcore/str/mod.rs b/src/libcore/str/mod.rs index 624c3638df5..3862b4a2eb0 100644 --- a/src/libcore/str/mod.rs +++ b/src/libcore/str/mod.rs @@ -710,6 +710,37 @@ impl<'a> Iterator for Bytes<'a> { fn nth(&mut self, n: usize) -> Option { self.0.nth(n) } + + #[inline] + fn all(&mut self, f: F) -> bool where F: FnMut(Self::Item) -> bool { + self.0.all(f) + } + + #[inline] + fn any(&mut self, f: F) -> bool where F: FnMut(Self::Item) -> bool { + self.0.any(f) + } + + #[inline] + fn find

(&mut self, predicate: P) -> Option where + P: FnMut(&Self::Item) -> bool + { + self.0.find(predicate) + } + + #[inline] + fn position

(&mut self, predicate: P) -> Option where + P: FnMut(Self::Item) -> bool + { + self.0.position(predicate) + } + + #[inline] + fn rposition

(&mut self, predicate: P) -> Option where + P: FnMut(Self::Item) -> bool + { + self.0.rposition(predicate) + } } #[stable(feature = "rust1", since = "1.0.0")] @@ -718,6 +749,13 @@ impl<'a> DoubleEndedIterator for Bytes<'a> { fn next_back(&mut self) -> Option { self.0.next_back() } + + #[inline] + fn rfind

(&mut self, predicate: P) -> Option where + P: FnMut(&Self::Item) -> bool + { + self.0.rfind(predicate) + } } #[stable(feature = "rust1", since = "1.0.0")] -- cgit 1.4.1-3-g733a5 From 2007987099309e05c08d65e6a0e722c5ec1d0653 Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Wed, 5 Jul 2017 20:23:55 +0200 Subject: Forward more Iterator methods for iter::Rev `position` could not be implemented because calling `rposition` on the inner iterator would require more trait bounds. --- src/libcore/iter/mod.rs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/libcore') diff --git a/src/libcore/iter/mod.rs b/src/libcore/iter/mod.rs index decd718d65e..79e6b11beac 100644 --- a/src/libcore/iter/mod.rs +++ b/src/libcore/iter/mod.rs @@ -359,11 +359,19 @@ impl Iterator for Rev where I: DoubleEndedIterator { #[inline] fn size_hint(&self) -> (usize, Option) { self.iter.size_hint() } + #[inline] fn find

(&mut self, predicate: P) -> Option where P: FnMut(&Self::Item) -> bool { self.iter.rfind(predicate) } + + #[inline] + fn rposition

(&mut self, predicate: P) -> Option where + P: FnMut(Self::Item) -> bool + { + self.iter.position(predicate) + } } #[stable(feature = "rust1", since = "1.0.0")] -- cgit 1.4.1-3-g733a5