mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs.git
synced 2026-10-28 12:53:14 +01:00
This eliminates the custom `function_name` helper. Reviewed-by: Tamir Duberstein <[email protected]> Reviewed-by: Benno Lossin <[email protected]> Signed-off-by: Gary Guo <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Miguel Ojeda <[email protected]>
26 lines
644 B
Rust
26 lines
644 B
Rust
// SPDX-License-Identifier: GPL-2.0
|
|
|
|
use proc_macro2::TokenStream;
|
|
use quote::quote;
|
|
|
|
/// Please see [`crate::export`] for documentation.
|
|
pub(crate) fn export(f: syn::ItemFn) -> TokenStream {
|
|
let name = &f.sig.ident;
|
|
|
|
quote! {
|
|
// This verifies that the function has the same signature as the declaration generated by
|
|
// bindgen. It makes use of the fact that all branches of an if/else must have the same
|
|
// type.
|
|
const _: () = {
|
|
if true {
|
|
::kernel::bindings::#name
|
|
} else {
|
|
#name
|
|
};
|
|
};
|
|
|
|
#[no_mangle]
|
|
#f
|
|
}
|
|
}
|