rust/src/libstd
bors 11946956a6 Auto merge of #35969 - bluss:memrchr-alignment, r=nagisa
memrchr: Correct aligned offset computation

The memrchr fallback did not compute the offset correctly. It was
intentioned to land on usize-aligned addresses but did not.
This was suspected to have resulted in a crash on ARMv7!

This bug affected non-linux platforms.

I think like this, if we have a slice with pointer `ptr` and length
`len`, we want to find the last usize-aligned offset in the slice.
The correct computation should be:

For example if ptr = 1 and len = 6, and `size_of::<usize>()` is 4:

```
[ x x x x x x ]
  1 2 3 4 5 6
        ^-- last aligned address at offset 3 from the start.
```

The last aligned address is ptr + len - (ptr + len) % usize_size.

Compute offset from the start as:

offset = len - (ptr + len) % usize_size = 6 - (1 + 6) % 4 = 6 - 3 = 3.

I believe the function's return value was always correct previously, if
the platform supported unaligned addresses.

Fixes #35967
2016-08-27 07:52:20 -07:00
..
collections Auto merge of #35906 - jseyfried:local_prelude, r=eddyb 2016-08-25 20:45:32 -07:00
ffi Use #[prelude_import] in libstd. 2016-08-24 22:12:48 +00:00
io Use #[prelude_import] in libstd. 2016-08-24 22:12:48 +00:00
net Use #[prelude_import] in libstd. 2016-08-24 22:12:48 +00:00
num Use #[prelude_import] in libstd. 2016-08-24 22:12:48 +00:00
os std: Fix up stabilization discrepancies 2016-06-23 14:08:11 -07:00
prelude End stdlib module summaries with a full stop. 2016-03-04 17:37:11 -05:00
rand std: restructure rand os code into sys modules 2016-02-17 16:21:32 -08:00
sync Use #[prelude_import] in libstd. 2016-08-24 22:12:48 +00:00
sys Auto merge of #35906 - jseyfried:local_prelude, r=eddyb 2016-08-25 20:45:32 -07:00
thread Use #[prelude_import] in libstd. 2016-08-24 22:12:48 +00:00
time std: Clean out old unstable + deprecated APIs 2016-05-30 20:46:32 -07:00
ascii.rs Use #[prelude_import] in libstd. 2016-08-24 22:12:48 +00:00
build.rs rustbuild: make backtraces (RUST_BACKTRACE) optional 2016-07-26 15:21:25 -05:00
Cargo.toml Update gcc crate dependency to 0.3.27. 2016-07-30 15:39:13 -05:00
env.rs Use #[prelude_import] in libstd. 2016-08-24 22:12:48 +00:00
error.rs Replace unnecessary uses of TraitObject with casts 2016-08-26 06:37:36 -04:00
fs.rs Use #[prelude_import] in libstd. 2016-08-24 22:12:48 +00:00
lib.rs Auto merge of #35906 - jseyfried:local_prelude, r=eddyb 2016-08-25 20:45:32 -07:00
macros.rs doc: Mention that writeln! and println! always use LF 2016-07-12 14:39:16 +09:00
memchr.rs memrchr: Use a conditional instead of subtracting a complicated min 2016-08-24 21:41:23 +02:00
panic.rs Use #[prelude_import] in libstd. 2016-08-24 22:12:48 +00:00
panicking.rs Use #[prelude_import] in libstd. 2016-08-24 22:12:48 +00:00
path.rs Use #[prelude_import] in libstd. 2016-08-24 22:12:48 +00:00
primitive_docs.rs Fix links 2016-08-18 15:43:35 +12:00
process.rs Use #[prelude_import] in libstd. 2016-08-24 22:12:48 +00:00
rt.rs Use #[prelude_import] in libstd. 2016-08-24 22:12:48 +00:00
rtdeps.rs remove some anys that are no longer necessary 2016-07-30 15:39:13 -05:00