Skip to content

Commit 5038c79

Browse files
authored
cmov: extract backends module (#1358)
Now that we have some additional modules like `array` and `slice` which aren't backends, it makes sense to group all the backends as submodules under a `backends` module for the purposes of code hygeine.
1 parent 17f5eb0 commit 5038c79

File tree

5 files changed

+19
-12
lines changed

5 files changed

+19
-12
lines changed

cmov/src/backends.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//! Backends for `cmov`, only one of which will be selected at compile-time.
2+
3+
// Architecture-specific backends for target architectures with native predication instructions
4+
#[cfg(not(miri))]
5+
#[cfg(target_arch = "aarch64")]
6+
mod aarch64;
7+
#[cfg(not(miri))]
8+
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
9+
mod x86;
10+
11+
// Fallback portable implementation for targets which don't have native predication instructions
12+
// (or if they do, aren't currently supported)
13+
#[cfg(any(
14+
not(any(target_arch = "aarch64", target_arch = "x86", target_arch = "x86_64")),
15+
miri
16+
))]
17+
mod soft;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! Portable "best effort" implementation of `Cmov`/`CmovEq`.
22
//!
3-
//! This implementation is based on portable bitwise arithmetic augmented with tactical usage of
3+
//! This implementation is based on portable arithmetic operations augmented with tactical usage of
44
//! `core::hint::black_box` based on past observations of where the optimizer has inserted branches
55
//! (see CVE-2026-23519), but the fully portable implementation cannot guarantee that the resulting
66
//! generated assembly is free of branch instructions.

cmov/src/lib.rs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,9 @@
3030
#[macro_use]
3131
mod macros;
3232

33-
#[cfg(not(miri))]
34-
#[cfg(target_arch = "aarch64")]
35-
mod aarch64;
3633
mod array;
37-
#[cfg(any(
38-
not(any(target_arch = "aarch64", target_arch = "x86", target_arch = "x86_64")),
39-
miri
40-
))]
41-
mod portable;
34+
mod backends;
4235
mod slice;
43-
#[cfg(not(miri))]
44-
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
45-
mod x86;
4636

4737
/// Condition
4838
pub type Condition = u8;

0 commit comments

Comments
 (0)