Skip to content

Commit

Permalink
Rollup merge of rust-lang#40832 - pftbest:fix_msp430, r=stjepang
Browse files Browse the repository at this point in the history
libcore: fix compilation on 16bit target (MSP430).

Since PR rust-lang#40601 has been merged, libcore no longer compiles on MSP430.
The reason is this code in `break_patterns`:
```rust
 let mut random = len;
 random ^= random << 13;
 random ^= random >> 17;
 random ^= random << 5;
 random &= modulus - 1;
```
It assumes that `len` is at least a 32 bit integer.
As a workaround replace `break_patterns` with an empty function for 16bit targets.

cc @stjepang
cc @alexcrichton
  • Loading branch information
frewsxcv committed Mar 29, 2017
2 parents 7f1083e + b909364 commit 233e0f3
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/libcore/slice/sort.rs
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,9 @@ fn break_patterns<T>(v: &mut [T]) {
// we first take it modulo a power of two, and then decrease by `len` until it fits
// into the range `[0, len - 1]`.
let mut other = gen_usize() & (modulus - 1);
while other >= len {

// `other` is guaranteed to be less than `2 * len`.
if other >= len {
other -= len;
}

Expand Down

0 comments on commit 233e0f3

Please sign in to comment.