Skip to content

Commit

Permalink
Stage10 (#16)
Browse files Browse the repository at this point in the history
* remove most `const_as_ref` and `const_as_mut`

* Improve InlAwi construction performance

* Introduce `Digit`

* fixes

* add digit configuration flags and more

* fix bug

* fix bug with `subdigits`

* introduce `bits` macro

* enable more `bits` cases

* test the new macro

* test fix

* add missing `_` to `digit_cin_mul_`

* Version 0.10.0
  • Loading branch information
AaronKutch authored Mar 11, 2023
1 parent 75f7fdb commit 71b35e8
Show file tree
Hide file tree
Showing 68 changed files with 1,713 additions and 726 deletions.
31 changes: 20 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ env:
# NOTE: do not set RUSTFLAGS here, because it overwrites
# what `.cargo/config.toml` sets for `no_alloc_build`
RUST_BACKTRACE: 1
# we can't use `--all-features` because of the `_digits` flags, use
ALL_FEATURES: "--features=const_support,std,zeroize_support,rand_support,serde_support,dag,try_support,debug"
NON_STD_FEATURES: "--features=const_support,zeroize_support,rand_support,serde_support"

jobs:
test_suite:
Expand All @@ -21,9 +24,14 @@ jobs:
rustup default nightly
- name: Run test suite
run: |
cargo bench
cargo test --all-features
cargo test --release --all-features
cargo bench $ALL_FEATURES
cargo test $ALL_FEATURES
cargo test --release $ALL_FEATURES
cargo test $ALL_FEATURES,u8_digits
cargo test $ALL_FEATURES,u16_digits
cargo test $ALL_FEATURES,u32_digits
cargo test $ALL_FEATURES,u64_digits
cargo test $ALL_FEATURES,u128_digits
miri:
name: Miri
Expand All @@ -41,7 +49,7 @@ jobs:
rustup component add miri
- name: Run test suite with Miri
run: |
cargo miri test
cargo miri test $ALL_FEATURES
# we run `cargo doc` here, because running `cargo doc` anywhere somehow requires `core` from the
# target in no_alloc_test
Expand All @@ -55,10 +63,10 @@ jobs:
rustup set profile minimal
rustup default nightly
rustup target add riscv32i-unknown-none-elf
# no_alloc_test has `rand_support` and `serde_support` enabled in its `Cargo.toml`
# no_alloc_test has `NON_STD_FEATURES` enabled in its `Cargo.toml`
- name: Run `cargo doc` and `cargo build`
run: |
cargo doc --all-features
cargo doc $ALL_FEATURES
cd no_alloc_test && cargo build --target riscv32i-unknown-none-elf
stable_build:
Expand All @@ -74,12 +82,13 @@ jobs:
# mistakes, so we test several combinations here
- name: Run `cargo build`
run: |
cargo run --bin stable --no-default-features --features=std,rand_support,serde_support,zeroize_support,dag,debug
cargo build --no-default-features --features=std,rand_support,serde_support,zeroize_support,dag,debug
cargo build --no-default-features --features=std
cargo build --no-default-features --features=alloc
cargo build --no-default-features --features=std
cargo build --no-default-features --features=zeroize_support
cargo build --no-default-features --features=rand_support
cargo build --no-default-features --features=serde_support
cargo build --no-default-features --features=zeroize_support
cargo build --no-default-features --features=dag
cargo build --no-default-features --features=debug
cargo build --no-default-features
Expand Down Expand Up @@ -114,7 +123,7 @@ jobs:
- name: Run `cargo clippy`
# note: run clippy on no_alloc_test manually
run: |
cargo clippy --all --all-targets --all-features -- -D clippy::all
cargo clippy --all --all-targets $ALL_FEATURES -- -D clippy::all
# makes sure the tests work on 32 bit and 64 bit big endian targets
cross-compile-big-endian:
Expand All @@ -126,5 +135,5 @@ jobs:
rustup set profile minimal
rustup default nightly
cargo install cross
cross test --target mips64-unknown-linux-gnuabi64 --all-features
cross test --target mips-unknown-linux-gnu --all-features
cross test --target mips64-unknown-linux-gnuabi64 $ALL_FEATURES
cross test --target mips-unknown-linux-gnu $ALL_FEATURES
25 changes: 25 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,30 @@
# Changelog

## [0.10.0] - 2023-03-11
### Fixes
- Fixed that the overflow check in `chars_upper_bound` and `bits_upper_bound` was completely broken
- Greatly improved the efficiency of `awint` on restricted architectures such as AVR
- Fixed that `inlawi!` could cause double the necessary stack usage on all platforms
- Macro constants are now compiled down to `&'static [u8]` or `&'static Bits`
- `awint` should now theoretically work with 128 bit architectures like riscv128

### Additions
- Added `Digit`, a type alias for the underlying storage element for `Bits`. Also added various
primitive related functions for it.
- Added feature flags to control `Digit`
- Added the `bits` macro for creating `&'static Bits` constants easily
- Enabled `const` PartialEq

### Changes
- Replaced `usize` with `Digit` where applicable. This does not immediately change things for common
architectures, but `Digit` can be different from `usize` now.
- Renamed `short_` functions to `digit_` functions
- Added missing `_` suffix to `digit_cin_mul_`
- `Digit` has a minimum guaranteed maximum value of `u8::MAX` rather than `u16::MAX`
- `const_as_ref` and `const_as_mut` removed from `InlAwi` and `ExtAwi` (although it still exists as
a hidden function on `Bits` for macro purposes)
- Many changes to hidden and unstable items

## [0.9.0] - 2023-02-28
### Fixes
- Added a limiter to `FP::to_vec_general` and downstream string formatting to prevent easy resource
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ system depending on these feature flags:
Note: By default, "const_support" and "std" are turned on, use `default-features = false` and
select specific features to avoid requiring nightly.

NOTE: As of Rust 1.64, if you try to use "const_support" with the macros you may get strange
NOTE: As of Rust 1.66, if you try to use "const_support" with the macros you may get strange
"erroneous constant used" and "deref_mut" errors unless you add all of
```
#![feature(const_trait_impl)]
Expand Down
18 changes: 12 additions & 6 deletions awint/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "awint"
# note: when bumping versions, update `rust-version` in `awint_internals/Cargo.toml` and in
# `ci.yml`, and add date to changelog
version = "0.9.0" # no 1.0 at least until `const_support` is all stabilized
version = "0.10.0" # no 1.0 at least until `const_support` is all stabilized
edition = "2021"
authors = ["Aaron Kutch <aaronkutch@att.net>"]
license = "MIT OR Apache-2.0"
Expand All @@ -14,11 +14,11 @@ keywords = ["int", "integer", "big", "math", "no_std"]
categories = ["data-structures", "mathematics", "algorithms", "no-std"]

[dependencies]
awint_core = { version = "0.9.0", path = "../awint_core", default-features = false }
awint_dag = { version = "0.9.0", path = "../awint_dag", default-features = false, optional = true }
awint_ext = { version = "0.9.0", path = "../awint_ext", default-features = false, optional = true }
awint_macro_internals = { version = "0.9.0", path = "../awint_macro_internals", default-features = false, optional = true }
awint_macros = { version = "0.9.0", path = "../awint_macros" }
awint_core = { version = "0.10.0", path = "../awint_core", default-features = false }
awint_dag = { version = "0.10.0", path = "../awint_dag", default-features = false, optional = true }
awint_ext = { version = "0.10.0", path = "../awint_ext", default-features = false, optional = true }
awint_macro_internals = { version = "0.10.0", path = "../awint_macro_internals", default-features = false, optional = true }
awint_macros = { version = "0.10.0", path = "../awint_macros" }

# note: running the tests requires `--all-features`
[features]
Expand All @@ -40,3 +40,9 @@ zeroize_support = ["awint_ext/zeroize_support"]
# Turns on `awint_dag` support. Note: this activates `std`.
dag = ["awint_dag", "std"]
debug = ["awint_dag/debug", "awint_macro_internals/debug"]
# Only zero or one of these should be active
u8_digits = ["awint_core/u8_digits"] # Note: this is automatically active for AVR
u16_digits = ["awint_core/u16_digits"]
u32_digits = ["awint_core/u32_digits"]
u64_digits = ["awint_core/u64_digits"]
u128_digits = ["awint_core/u128_digits"]
10 changes: 8 additions & 2 deletions awint_core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "awint_core"
version = "0.9.0"
version = "0.10.0"
edition = "2021"
authors = ["Aaron Kutch <aaronkutch@att.net>"]
license = "MIT OR Apache-2.0"
Expand All @@ -12,7 +12,7 @@ keywords = ["int", "integer", "big", "math", "no_std"]
categories = ["data-structures", "mathematics", "algorithms", "no-std"]

[dependencies]
awint_internals = { version = "0.9.0", path = "../awint_internals", default-features = false }
awint_internals = { version = "0.10.0", path = "../awint_internals", default-features = false }
const_fn = "0.4"
rand_core = { version = "0.6", default-features = false, optional = true }
serde = { version = "1.0", default-features = false, optional = true }
Expand All @@ -33,3 +33,9 @@ rand_support = ["rand_core"]
# Turns on `serde` support
serde_support = ["serde"]
zeroize_support = ["zeroize"]
# Only zero or one of these should be active
u8_digits = ["awint_internals/u8_digits"]
u16_digits = ["awint_internals/u16_digits"]
u32_digits = ["awint_internals/u32_digits"]
u64_digits = ["awint_internals/u64_digits"]
u128_digits = ["awint_internals/u128_digits"]
Loading

0 comments on commit 71b35e8

Please sign in to comment.