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
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion cpubits/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "cpubits"
version = "0.1.0-pre.0"
version = "0.1.0-pre.1"
authors = ["RustCrypto Developers"]
license = "MIT OR Apache-2.0"
documentation = "https://docs.rs/cpubits"
Expand Down
44 changes: 44 additions & 0 deletions cpubits/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,53 @@
//! 64 => { pub type Word = u64; }
//! }
//! ```
//!
//! You can also use the shortened form of the above syntax which implicitly promotes 16-bit
//! platforms to 32-bit ones:
//!
//! ```
//! cpubits::cpubits! {
//! 32 => { pub type Word = u32; }
//! 64 => { pub type Word = u64; }
//! }
//! ```
//!
//! 32-bit and 64-bit platforms can also be combined to differentiate them from 16-bit ones, e.g.
//! `16 => { ... }, 32 | 64 => { ... }`, and `32 | 64` can be shortened to just `32` in such a case.

#[macro_export]
macro_rules! cpubits {
(
16 => { $( $tokens16:tt )* }
32 => { $( $tokens32:tt )* }
) => {
$crate::cpubits! {
16 => { $( $tokens16 )* }
32 | 64 => { $( $tokens32 )* }
}
};

(
32 => { $( $tokens32:tt )* }
64 => { $( $tokens64:tt )* }
) => {
$crate::cpubits! {
16 | 32 => { $( $tokens32 )* }
64 => { $( $tokens64 )* }
}
};

(
16 => { $( $tokens16:tt )* }
32 | 64 => { $( $tokens32:tt )* }
) => {
$crate::cpubits! {
16 => { $( $tokens16 )* }
32 => { $( $tokens32 )* }
64 => { $( $tokens32 )* }
}
};

(
16 | 32 => { $( $tokens32:tt )* }
64 => { $( $tokens64:tt )* }
Expand Down