Skip to content

Commit

Permalink
rand_xorshift: fix Endianness in from_rng
Browse files Browse the repository at this point in the history
  • Loading branch information
dhardy committed Jun 6, 2019
1 parent 10979d6 commit e1b61a0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions rand_xorshift/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [0.1.2] - 2019-06-06
- Bump `rand_core` version
- Make XorShiftRng::from_rng portable by enforcing Endianness (#815)

## [0.1.1] - 2019-01-04
- Reorganise code and tests; tweak doc
Expand Down
4 changes: 4 additions & 0 deletions rand_xorshift/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ impl SeedableRng for XorShiftRng {
let slice = slice::from_raw_parts_mut(ptr, 4 * 4);
rng.try_fill_bytes(slice)?;
}
for v in seed_u32.iter_mut() {
// enforce LE for consistency across platforms
*v = v.to_le();
}
if !seed_u32.iter().all(|&x| x == 0) { break; }
}

Expand Down

0 comments on commit e1b61a0

Please sign in to comment.