Skip to content
Snippets Groups Projects

lcg48 refactor

Merged Peter Limkilde Svendsen requested to merge plimkilde/relibc:lcg48_refactor into master
2 files
+ 7
11
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -39,13 +39,9 @@ pub fn u48_from_ushort_arr3(arr: &[c_ushort; 3]) -> u64 {
u64::from(arr[0] as u16) | (u64::from(arr[1] as u16) << 16) | (u64::from(arr[2] as u16) << 32)
}
/// Set a size-3 array of unsigned short from a 48-bit integer.
pub fn set_ushort_arr3_from_u48(arr: &mut [c_ushort; 3], value: u64) {
*arr = [
c_ushort::from(value as u16),
c_ushort::from((value >> 16) as u16),
c_ushort::from((value >> 32) as u16),
];
/// Make a size-3 array of unsigned short from a 48-bit integer.
pub fn ushort_arr3_from_u48(value: u64) -> [c_ushort; 3] {
[c_ushort::from(value as u16), c_ushort::from((value >> 16) as u16), c_ushort::from((value >> 32) as u16)]
}
/// Advances the buffer from the input argument to the next element in
@@ -63,7 +59,7 @@ pub unsafe fn generator_step(xsubi: &mut [c_ushort; 3]) -> u64 {
let new_xsubi_value: u64 =
A.wrapping_mul(old_xsubi_value).wrapping_add(u64::from(C)) & 0xffff_ffff_ffff;
set_ushort_arr3_from_u48(xsubi, new_xsubi_value);
*xsubi = ushort_arr3_from_u48(new_xsubi_value);
new_xsubi_value
}
Loading