30
30
///
31
31
/// A quick overview of attributes supported right now are:
32
32
///
33
- /// * `use_c_shim_if ` - takes a #[cfg] directive and falls back to the
34
- /// C-compiled version if `use_c` is specified .
33
+ /// * `maybe_use_optimized_c_shim ` - indicates that the Rust implementation is
34
+ /// ignored if an optimized C version was compiled .
35
35
/// * `aapcs_on_arm` - forces the ABI of the function to be `"aapcs"` on ARM and
36
36
/// the specified ABI everywhere else.
37
37
/// * `unadjusted_on_win64` - like `aapcs_on_arm` this switches to the
@@ -51,15 +51,14 @@ macro_rules! intrinsics {
51
51
// to the architecture-specific versions which should be more optimized. The
52
52
// purpose of this macro is to easily allow specifying this.
53
53
//
54
- // The argument to `use_c_shim_if` is a `#[cfg]` directive which, when true,
55
- // will cause this crate's exported version of `$name` to just redirect to
56
- // the C implementation. No symbol named `$name` will be in the object file
57
- // for this crate itself.
58
- //
59
- // When the `#[cfg]` directive is false, or when the `c` feature is
60
- // disabled, the provided implementation is used instead.
54
+ // The `#[maybe_use_optimized_c_shim]` attribute indicates that this
55
+ // intrinsic may have an optimized C version. In these situations the build
56
+ // script, if the C code is enabled and compiled, will emit a cfg directive
57
+ // to get passed to rustc for our compilation. If that cfg is set we skip
58
+ // the Rust implementation, but if the attribute is not enabled then we
59
+ // compile in the Rust implementation.
61
60
(
62
- #[ use_c_shim_if ( $ ( $cfg_clause : tt ) * ) ]
61
+ #[ maybe_use_optimized_c_shim ]
63
62
$( #[ $( $attr: tt) * ] ) *
64
63
pub extern $abi: tt fn $name: ident( $( $argname: ident: $ty: ty) ,* ) -> $ret: ty {
65
64
$( $body: tt) *
@@ -68,7 +67,7 @@ macro_rules! intrinsics {
68
67
$( $rest: tt) *
69
68
) => (
70
69
71
- #[ cfg( all ( use_c , $ ( $cfg_clause ) * ) ) ]
70
+ #[ cfg( $name = "optimized-c" ) ]
72
71
pub extern $abi fn $name( $( $argname: $ty) ,* ) -> $ret {
73
72
extern $abi {
74
73
fn $name( $( $argname: $ty) ,* ) -> $ret;
@@ -78,7 +77,7 @@ macro_rules! intrinsics {
78
77
}
79
78
}
80
79
81
- #[ cfg( not( all ( use_c , $ ( $cfg_clause ) * ) ) ) ]
80
+ #[ cfg( not( $name = "optimized-c" ) ) ]
82
81
intrinsics! {
83
82
$( #[ $( $attr) * ] ) *
84
83
pub extern $abi fn $name( $( $argname: $ty) ,* ) -> $ret {
0 commit comments