xref: /linux-6.15/rust/bindings/lib.rs (revision f85bea18)
18326ac05SMiguel Ojeda // SPDX-License-Identifier: GPL-2.0
28326ac05SMiguel Ojeda 
38326ac05SMiguel Ojeda //! Bindings.
48326ac05SMiguel Ojeda //!
58326ac05SMiguel Ojeda //! Imports the generated bindings by `bindgen`.
68326ac05SMiguel Ojeda //!
78326ac05SMiguel Ojeda //! This crate may not be directly used. If you need a kernel C API that is
88326ac05SMiguel Ojeda //! not ported or wrapped in the `kernel` crate, then do so first instead of
98326ac05SMiguel Ojeda //! using this crate.
108326ac05SMiguel Ojeda 
118326ac05SMiguel Ojeda #![no_std]
128326ac05SMiguel Ojeda // See <https://github.com/rust-lang/rust-bindgen/issues/1651>.
138326ac05SMiguel Ojeda #![cfg_attr(test, allow(deref_nullptr))]
148326ac05SMiguel Ojeda #![cfg_attr(test, allow(unaligned_references))]
158326ac05SMiguel Ojeda #![cfg_attr(test, allow(unsafe_op_in_unsafe_fn))]
168326ac05SMiguel Ojeda #![allow(
178326ac05SMiguel Ojeda     clippy::all,
188326ac05SMiguel Ojeda     missing_docs,
198326ac05SMiguel Ojeda     non_camel_case_types,
208326ac05SMiguel Ojeda     non_upper_case_globals,
218326ac05SMiguel Ojeda     non_snake_case,
228326ac05SMiguel Ojeda     improper_ctypes,
238326ac05SMiguel Ojeda     unreachable_pub,
248326ac05SMiguel Ojeda     unsafe_op_in_unsafe_fn
258326ac05SMiguel Ojeda )]
268326ac05SMiguel Ojeda 
27*f85bea18SMiguel Ojeda #[allow(dead_code)]
288326ac05SMiguel Ojeda mod bindings_raw {
298326ac05SMiguel Ojeda     // Use glob import here to expose all helpers.
308326ac05SMiguel Ojeda     // Symbols defined within the module will take precedence to the glob import.
318326ac05SMiguel Ojeda     pub use super::bindings_helper::*;
328326ac05SMiguel Ojeda     include!(concat!(
338326ac05SMiguel Ojeda         env!("OBJTREE"),
348326ac05SMiguel Ojeda         "/rust/bindings/bindings_generated.rs"
358326ac05SMiguel Ojeda     ));
368326ac05SMiguel Ojeda }
378326ac05SMiguel Ojeda 
388326ac05SMiguel Ojeda // When both a directly exposed symbol and a helper exists for the same function,
398326ac05SMiguel Ojeda // the directly exposed symbol is preferred and the helper becomes dead code, so
408326ac05SMiguel Ojeda // ignore the warning here.
418326ac05SMiguel Ojeda #[allow(dead_code)]
428326ac05SMiguel Ojeda mod bindings_helper {
438326ac05SMiguel Ojeda     // Import the generated bindings for types.
449dc04365SWedson Almeida Filho     use super::bindings_raw::*;
458326ac05SMiguel Ojeda     include!(concat!(
468326ac05SMiguel Ojeda         env!("OBJTREE"),
478326ac05SMiguel Ojeda         "/rust/bindings/bindings_helpers_generated.rs"
488326ac05SMiguel Ojeda     ));
498326ac05SMiguel Ojeda }
508326ac05SMiguel Ojeda 
518326ac05SMiguel Ojeda pub use bindings_raw::*;
52