1 // SPDX-License-Identifier: GPL-2.0 2 3 //! The `kernel` prelude. 4 //! 5 //! These are the most common items used by Rust code in the kernel, 6 //! intended to be imported by all Rust code, for convenience. 7 //! 8 //! # Examples 9 //! 10 //! ``` 11 //! use kernel::prelude::*; 12 //! ``` 13 14 #[doc(no_inline)] 15 pub use core::{ 16 mem::{ 17 align_of, 18 align_of_val, 19 size_of, 20 size_of_val, // 21 }, 22 pin::Pin, // 23 }; 24 25 #[doc(no_inline)] 26 pub use ::ffi::{ 27 c_char, 28 c_int, 29 c_long, 30 c_longlong, 31 c_schar, 32 c_short, 33 c_uchar, 34 c_uint, 35 c_ulong, 36 c_ulonglong, 37 c_ushort, 38 c_void, 39 CStr, // 40 }; 41 42 #[doc(no_inline)] 43 pub use macros::{ 44 export, 45 fmt, 46 kunit_tests, 47 module, 48 vtable, // 49 }; 50 51 #[doc(no_inline)] 52 pub use pin_init::{ 53 init, 54 pin_data, 55 pin_init, 56 pinned_drop, 57 InPlaceWrite, 58 Init, 59 PinInit, 60 Zeroable, // 61 }; 62 63 #[doc(no_inline)] 64 pub use zerocopy::FromBytes; 65 66 #[doc(no_inline)] 67 pub use zerocopy_derive::FromBytes; 68 69 #[doc(no_inline)] 70 pub use super::{ 71 alloc::{ 72 flags::*, 73 Box, 74 KBox, 75 KVBox, 76 KVVec, 77 KVec, 78 VBox, 79 VVec, 80 Vec, // 81 }, 82 build_assert::{ 83 build_assert, 84 build_error, 85 const_assert, 86 static_assert, // 87 }, 88 current, 89 dev_alert, 90 dev_crit, 91 dev_dbg, 92 dev_emerg, 93 dev_err, 94 dev_info, 95 dev_notice, 96 dev_warn, 97 error::{ 98 code::*, 99 Error, 100 Result, // 101 }, 102 init::InPlaceInit, 103 pr_alert, 104 pr_crit, 105 pr_debug, 106 pr_emerg, 107 pr_err, 108 pr_info, 109 pr_notice, 110 pr_warn, 111 str::CStrExt as _, 112 try_init, 113 try_pin_init, 114 uaccess::UserPtr, 115 ThisModule, // 116 }; 117 118 // `super::std_vendor` is hidden, which makes the macro inline for some reason. 119 #[doc(no_inline)] 120 pub use super::dbg; 121