cmov 0.5.3

Conditional move CPU intrinsics which are guaranteed on major platforms (ARM32/ARM64, x86/x86_64, RISC-V) to execute in constant-time and not be rewritten as branches by the compiler. Provides wrappers for the CMOV family of instructions on x86/x86_64 and CSEL on AArch64, along with a portable "best-effort" pure Rust fallback implementation.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
//! Tests for previous bugs in the implementation.

use cmov::CmovEq;

#[test]
fn u64_cmoveq() {
    let n = 0x8200_0000_0000_0000u64;
    let mut cond = 0u8;
    n.cmoveq(&0, 1u8, &mut cond);

    // 0x8200_0000_0000_0000 is not equal to 0
    assert_eq!(cond, 0);
}