From 84e835aa1cd2dd0d4940377c04a28917c5ea7a1e Mon Sep 17 00:00:00 2001 From: Tony Arcieri Date: Thu, 22 Oct 2026 21:44:27 -0600 Subject: [PATCH] ctutils: import `core::hint::black_box` in `primitives` module --- ctutils/src/primitives.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/ctutils/src/primitives.rs b/ctutils/src/primitives.rs index f1060a57..d2fc677c 100644 --- a/ctutils/src/primitives.rs +++ b/ctutils/src/primitives.rs @@ -7,7 +7,9 @@ //! be checked for the target and compiler in use. //! //! Native zero counts are used when supported and advertised by the target configuration. + use crate::Choice; +use core::hint::black_box; /// Bitwise less-than-or equal: returns `1` if `x <= y`, and otherwise returns `0`. /// @@ -52,7 +54,7 @@ macro_rules! comparison_primitives { pub(crate) const fn $le(lhs: $ty, rhs: $ty) -> Choice { let bit = bitle!(lhs, rhs, <$ty>::BITS); #[cfg(all(target_arch = "arm", not(target_has_atomic = "ptr")))] - let bit = core::hint::black_box(bit); + let bit = black_box(bit); Choice::$from_lsb(bit) } @@ -67,7 +69,7 @@ macro_rules! comparison_primitives { pub(crate) const fn $lt(lhs: $ty, rhs: $ty) -> Choice { let bit = bitlt!(lhs, rhs, <$ty>::BITS); #[cfg(all(target_arch = "arm", not(target_has_atomic = "ptr")))] - let bit = core::hint::black_box(bit); + let bit = black_box(bit); Choice::$from_lsb(bit) } @@ -75,7 +77,7 @@ macro_rules! comparison_primitives { pub(crate) const fn $nz(value: $ty) -> Choice { let bit = bitnz!(value, <$ty>::BITS); #[cfg(all(target_arch = "arm", not(target_has_atomic = "ptr")))] - let bit = core::hint::black_box(bit); + let bit = black_box(bit); Choice::$from_lsb(bit) } }; @@ -98,7 +100,7 @@ macro_rules! borrowing_sub_primitives { // optimization on older compilers: https://github.com/rust-lang/rust/issues/149522 // Keep the full-width bit opaque before narrowing it to Choice, so a caller's // masked add-back cannot be folded into a secret-dependent branch. - let borrow = core::hint::black_box(bitborrow!(lhs, rhs, difference, <$ty>::BITS)); + let borrow = black_box(bitborrow!(lhs, rhs, difference, <$ty>::BITS)); (difference, Choice::$from_lsb(borrow)) } };