Skip to main content

masknz

Macro masknz 

Source
macro_rules! masknz {
    ($value:tt : $uint:ident) => { ... };
}
Expand description

Generates a mask the width of the given unsigned integer type $uint if the input value is non-zero.

Uses core::hint::black_box to coerce our desired codegen based on real-world observations of the assembly generated by Rust/LLVM.

Implemented as a macro instead of a generic function because it uses functionality for which there aren’t available core traits, e.g. wrapping_neg.

See also:

  • CVE-2026-23519
  • RustCrypto/utils#1332