Skip to main content

macros/
export.rs

1// SPDX-License-Identifier: GPL-2.0
2
3use proc_macro2::TokenStream;
4use quote::quote;
5
6/// Please see [`crate::export`] for documentation.
7pub(crate) fn export(f: syn::ItemFn) -> TokenStream {
8    let name = &f.sig.ident;
9
10    quote! {
11        // This verifies that the function has the same signature as the declaration generated by
12        // bindgen. It makes use of the fact that all branches of an if/else must have the same
13        // type.
14        const _: () = {
15            if true {
16                ::kernel::bindings::#name
17            } else {
18                #name
19            };
20        };
21
22        #[no_mangle]
23        #f
24    }
25}