Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions ctutils/src/traits/ct_eq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,19 @@ macro_rules! impl_ct_eq_with_cmov_eq {

impl_ct_eq_with_cmov_eq!(i8, i16, i32, i64, i128, u8, u16, u32, u64, u128);

#[cfg(any(target_pointer_width = "32", target_pointer_width = "64"))]
impl CtEq for isize {
#[cfg(target_pointer_width = "32")]
fn ct_eq(&self, other: &Self) -> Choice {
(*self as i32).ct_eq(&(*other as i32))
}

#[cfg(target_pointer_width = "64")]
fn ct_eq(&self, other: &Self) -> Choice {
(*self as i64).ct_eq(&(*other as i64))
}
}

#[cfg(any(target_pointer_width = "32", target_pointer_width = "64"))]
impl CtEq for usize {
#[cfg(target_pointer_width = "32")]
Expand Down
15 changes: 15 additions & 0 deletions ctutils/src/traits/ct_select.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,21 @@ macro_rules! impl_ct_select_with_cmov {

impl_ct_select_with_cmov!(i8, i16, i32, i64, i128, u8, u16, u32, u64, u128);

#[cfg(any(target_pointer_width = "32", target_pointer_width = "64"))]
impl CtSelect for isize {
#[cfg(target_pointer_width = "32")]
#[inline]
fn ct_select(&self, other: &Self, choice: Choice) -> Self {
(*self as i32).ct_select(&(*other as i32), choice) as isize
}

#[cfg(target_pointer_width = "64")]
#[inline]
fn ct_select(&self, other: &Self, choice: Choice) -> Self {
(*self as i64).ct_select(&(*other as i64), choice) as isize
}
}

#[cfg(any(target_pointer_width = "32", target_pointer_width = "64"))]
impl CtSelect for usize {
#[cfg(target_pointer_width = "32")]
Expand Down