Skip to content

Commit 2cd255d

Browse files
committed
Support cfg_attr attributes in intrinsics!() macro.
1 parent 4117da3 commit 2cd255d

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

src/macros.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,35 @@ macro_rules! public_test_dep {
6161
macro_rules! intrinsics {
6262
() => ();
6363

64+
// Support cfg_attr:
65+
(
66+
#[cfg_attr($e:meta, $($attr:tt)*)]
67+
$(#[$($attrs:tt)*])*
68+
pub extern $abi:tt fn $name:ident( $($argname:ident: $ty:ty),* ) $(-> $ret:ty)? {
69+
$($body:tt)*
70+
}
71+
$($rest:tt)*
72+
) => (
73+
#[cfg($e)]
74+
intrinsics! {
75+
#[$($attr)*]
76+
$(#[$($attrs)*])*
77+
pub extern $abi fn $name($($argname: $ty),*) $(-> $ret)? {
78+
$($body)*
79+
}
80+
}
81+
82+
#[cfg(not($e))]
83+
intrinsics! {
84+
$(#[$($attrs)*])*
85+
pub extern $abi fn $name($($argname: $ty),*) $(-> $ret)? {
86+
$($body)*
87+
}
88+
}
89+
90+
intrinsics!($($rest)*);
91+
);
92+
6493
// Right now there's a bunch of architecture-optimized intrinsics in the
6594
// stock compiler-rt implementation. Not all of these have been ported over
6695
// to Rust yet so when the `c` feature of this crate is enabled we fall back

0 commit comments

Comments
 (0)