]> git.proxmox.com Git - rustc.git/blame - src/libunwind/macros.rs
New upstream version 1.36.0+dfsg1
[rustc.git] / src / libunwind / macros.rs
CommitLineData
83c7162d 1/// A macro for defining `#[cfg]` if-else statements.
abe05a73
XL
2///
3/// This is similar to the `if/elif` C preprocessor macro by allowing definition
4/// of a cascade of `#[cfg]` cases, emitting the implementation which matches
5/// first.
6///
83c7162d 7/// This allows you to conveniently provide a long list `#[cfg]`'d blocks of code
abe05a73
XL
8/// without having to rewrite each clause multiple times.
9macro_rules! cfg_if {
10 ($(
11 if #[cfg($($meta:meta),*)] { $($it:item)* }
12 ) else * else {
13 $($it2:item)*
14 }) => {
15 __cfg_if_items! {
16 () ;
17 $( ( ($($meta),*) ($($it)*) ), )*
18 ( () ($($it2)*) ),
19 }
20 }
21}
22
23macro_rules! __cfg_if_items {
24 (($($not:meta,)*) ; ) => {};
25 (($($not:meta,)*) ; ( ($($m:meta),*) ($($it:item)*) ), $($rest:tt)*) => {
26 __cfg_if_apply! { cfg(all(not(any($($not),*)), $($m,)*)), $($it)* }
27 __cfg_if_items! { ($($not,)* $($m,)*) ; $($rest)* }
28 }
29}
30
31macro_rules! __cfg_if_apply {
32 ($m:meta, $($it:item)*) => {
33 $(#[$m] $it)*
34 }
35}