Skip to content

Commit

Permalink
fixup! Remove limb_width32 and limb_width64 features
Browse files Browse the repository at this point in the history
  • Loading branch information
Piotr Osiewicz committed Sep 3, 2023
1 parent c754f03 commit 16e04ce
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 6 deletions.
28 changes: 24 additions & 4 deletions src/lexical/math.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,19 @@ impl LimbConfig for LimbConfig64 {
const LARGE_POWERS: &'static [&'static [Self::Limb]] = &super::large_powers64::POW5;
}

#[cfg(any(target_arch = "aarch64", target_arch = "mips64", target_arch = "powerpc64", target_arch = x86_64))]
#[cfg(any(
target_arch = "aarch64",
target_arch = "mips64",
target_arch = "powerpc64",
target_arch = "x86_64"
))]
type PlatformLimbConfig = LimbConfig64;
#[cfg(not(any(target_arch = "aarch64", target_arch = "mips64", target_arch = "powerpc64", target_arch = x86_64)))]
#[cfg(not(any(
target_arch = "aarch64",
target_arch = "mips64",
target_arch = "powerpc64",
target_arch = "x86_64"
)))]
type PlatformLimbConfig = LimbConfig32;

pub type Limb = <PlatformLimbConfig as LimbConfig>::Limb;
Expand All @@ -95,14 +105,24 @@ fn as_wide<T: Integer>(t: T) -> Wide {

/// Split u64 into limbs, in little-endian order.
#[inline]
#[cfg(limb_width_32)]
#[cfg(not(any(
target_arch = "aarch64",
target_arch = "mips64",
target_arch = "powerpc64",
target_arch = "x86_64"
)))]
fn split_u64(x: u64) -> [Limb; 2] {
[as_limb(x), as_limb(x >> 32)]
}

/// Split u64 into limbs, in little-endian order.
#[inline]
#[cfg(limb_width_64)]
#[cfg(any(
target_arch = "aarch64",
target_arch = "mips64",
target_arch = "powerpc64",
target_arch = "x86_64"
))]
fn split_u64(x: u64) -> [Limb; 1] {
[as_limb(x)]
}
Expand Down
14 changes: 12 additions & 2 deletions tests/lexical/math.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,22 @@ impl Math for Bigint {
}
}

#[cfg(limb_width_32)]
#[cfg(not(any(
target_arch = "aarch64",
target_arch = "mips64",
target_arch = "powerpc64",
target_arch = "x86_64"
)))]
pub(crate) fn from_u32(x: &[u32]) -> Vec<Limb> {
x.iter().cloned().collect()
}

#[cfg(limb_width_64)]
#[cfg(any(
target_arch = "aarch64",
target_arch = "mips64",
target_arch = "powerpc64",
target_arch = "x86_64"
))]
pub(crate) fn from_u32(x: &[u32]) -> Vec<Limb> {
let mut v = Vec::<Limb>::default();
for xi in x.chunks(2) {
Expand Down

0 comments on commit 16e04ce

Please sign in to comment.