lib.rs 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. // SPDX-License-Identifier: GPL-2.0
  2. //! Bindings.
  3. //!
  4. //! Imports the generated bindings by `bindgen`.
  5. //!
  6. //! This crate may not be directly used. If you need a kernel C API that is
  7. //! not ported or wrapped in the `kernel` crate, then do so first instead of
  8. //! using this crate.
  9. #![no_std]
  10. // See <https://github.com/rust-lang/rust-bindgen/issues/1651>.
  11. #![cfg_attr(test, allow(deref_nullptr))]
  12. #![cfg_attr(test, allow(unaligned_references))]
  13. #![cfg_attr(test, allow(unsafe_op_in_unsafe_fn))]
  14. #![allow(
  15. clippy::all,
  16. missing_docs,
  17. non_camel_case_types,
  18. non_upper_case_globals,
  19. non_snake_case,
  20. improper_ctypes,
  21. unreachable_pub,
  22. unsafe_op_in_unsafe_fn
  23. )]
  24. #[allow(dead_code)]
  25. #[allow(clippy::undocumented_unsafe_blocks)]
  26. #[cfg_attr(CONFIG_RUSTC_HAS_UNNECESSARY_TRANSMUTES, allow(unnecessary_transmutes))]
  27. mod bindings_raw {
  28. // Manual definition for blocklisted types.
  29. type __kernel_size_t = usize;
  30. type __kernel_ssize_t = isize;
  31. type __kernel_ptrdiff_t = isize;
  32. // Use glob import here to expose all helpers.
  33. // Symbols defined within the module will take precedence to the glob import.
  34. pub use super::bindings_helper::*;
  35. include!(concat!(
  36. env!("OBJTREE"),
  37. "/rust/bindings/bindings_generated.rs"
  38. ));
  39. }
  40. // When both a directly exposed symbol and a helper exists for the same function,
  41. // the directly exposed symbol is preferred and the helper becomes dead code, so
  42. // ignore the warning here.
  43. #[allow(dead_code)]
  44. mod bindings_helper {
  45. // Import the generated bindings for types.
  46. use super::bindings_raw::*;
  47. include!(concat!(
  48. env!("OBJTREE"),
  49. "/rust/bindings/bindings_helpers_generated.rs"
  50. ));
  51. }
  52. pub use bindings_raw::*;