Skip to content

Commit e1b61a0

Browse files
committed
rand_xorshift: fix Endianness in from_rng
1 parent 10979d6 commit e1b61a0

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

rand_xorshift/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

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

1011
## [0.1.1] - 2019-01-04
1112
- Reorganise code and tests; tweak doc

rand_xorshift/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,10 @@ impl SeedableRng for XorShiftRng {
110110
let slice = slice::from_raw_parts_mut(ptr, 4 * 4);
111111
rng.try_fill_bytes(slice)?;
112112
}
113+
for v in seed_u32.iter_mut() {
114+
// enforce LE for consistency across platforms
115+
*v = v.to_le();
116+
}
113117
if !seed_u32.iter().all(|&x| x == 0) { break; }
114118
}
115119

0 commit comments

Comments
 (0)