3030///
3131/// A quick overview of attributes supported right now are:
3232///
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 .
3535/// * `aapcs_on_arm` - forces the ABI of the function to be `"aapcs"` on ARM and
3636/// the specified ABI everywhere else.
3737/// * `unadjusted_on_win64` - like `aapcs_on_arm` this switches to the
@@ -51,15 +51,14 @@ macro_rules! intrinsics {
5151 // to the architecture-specific versions which should be more optimized. The
5252 // purpose of this macro is to easily allow specifying this.
5353 //
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.
6160 (
62- #[ use_c_shim_if ( $ ( $cfg_clause : tt ) * ) ]
61+ #[ maybe_use_optimized_c_shim ]
6362 $( #[ $( $attr: tt) * ] ) *
6463 pub extern $abi: tt fn $name: ident( $( $argname: ident: $ty: ty) ,* ) -> $ret: ty {
6564 $( $body: tt) *
@@ -68,7 +67,7 @@ macro_rules! intrinsics {
6867 $( $rest: tt) *
6968 ) => (
7069
71- #[ cfg( all ( use_c , $ ( $cfg_clause ) * ) ) ]
70+ #[ cfg( $name = "optimized-c" ) ]
7271 pub extern $abi fn $name( $( $argname: $ty) ,* ) -> $ret {
7372 extern $abi {
7473 fn $name( $( $argname: $ty) ,* ) -> $ret;
@@ -78,7 +77,7 @@ macro_rules! intrinsics {
7877 }
7978 }
8079
81- #[ cfg( not( all ( use_c , $ ( $cfg_clause ) * ) ) ) ]
80+ #[ cfg( not( $name = "optimized-c" ) ) ]
8281 intrinsics! {
8382 $( #[ $( $attr) * ] ) *
8483 pub extern $abi fn $name( $( $argname: $ty) ,* ) -> $ret {
0 commit comments