Files

26 lines
644 B
Rust
Raw Permalink Normal View History

2025-03-03 08:45:14 +00:00
// SPDX-License-Identifier: GPL-2.0
use proc_macro2::TokenStream;
use quote::quote;
2025-03-03 08:45:14 +00:00
/// Please see [`crate::export`] for documentation.
2026-01-12 17:07:17 +00:00
pub(crate) fn export(f: syn::ItemFn) -> TokenStream {
let name = &f.sig.ident;
2025-03-03 08:45:14 +00:00
2026-01-12 17:07:17 +00:00
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.
2025-03-03 08:45:14 +00:00
const _: () = {
if true {
::kernel::bindings::#name
} else {
#name
};
};
2026-01-12 17:07:17 +00:00
#[no_mangle]
#f
}
2025-03-03 08:45:14 +00:00
}