We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e4c2f44 commit 99bd76cCopy full SHA for 99bd76c
vmm_core/virt_mshv/src/lib.rs
@@ -1321,8 +1321,21 @@ fn hvu128_to_u128(r: &hv_u128) -> u128 {
1321
1322
fn u128_to_hvu128(value: u128) -> hv_u128 {
1323
hv_u128 {
1324
- high_part: (value & (u64::MAX as u128)) as u64,
1325
- low_part: (value >> 64) as u64,
+ high_part: (value >> 64) as u64,
+ low_part: (value & (u64::MAX as u128)) as u64,
1326
+ }
1327
+}
1328
+
1329
+#[cfg(test)]
1330
+mod tests {
1331
+ use super::*;
1332
1333
+ #[test]
1334
+ fn u128_roundtrip() {
1335
+ let original = 0x0123_4567_89ab_cdef_fedc_ba98_7654_3210;
1336
+ let hv = u128_to_hvu128(original);
1337
+ let roundtrip = hvu128_to_u128(&hv);
1338
+ assert_eq!(roundtrip, original);
1339
}
1340
1341
0 commit comments