xref: /linux/rust/kernel/prelude.rs (revision 4ab22c543f18cfbcc2f8ae691dc5ec5cc0ac35fb)
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 pub use ::ffi::{
26     c_char,
27     c_int,
28     c_long,
29     c_longlong,
30     c_schar,
31     c_short,
32     c_uchar,
33     c_uint,
34     c_ulong,
35     c_ulonglong,
36     c_ushort,
37     c_void,
38     CStr, //
39 };
40 
41 #[doc(no_inline)]
42 pub use macros::{
43     export,
44     fmt,
45     kunit_tests,
46     module,
47     vtable, //
48 };
49 
50 pub use pin_init::{
51     init,
52     pin_data,
53     pin_init,
54     pinned_drop,
55     InPlaceWrite,
56     Init,
57     PinInit,
58     Zeroable, //
59 };
60 
61 pub use super::{
62     alloc::{
63         flags::*,
64         Box,
65         KBox,
66         KVBox,
67         KVVec,
68         KVec,
69         VBox,
70         VVec,
71         Vec, //
72     },
73     build_assert,
74     build_error,
75     const_assert,
76     current,
77     dev_alert,
78     dev_crit,
79     dev_dbg,
80     dev_emerg,
81     dev_err,
82     dev_info,
83     dev_notice,
84     dev_warn,
85     error::{
86         code::*,
87         Error,
88         Result, //
89     },
90     init::InPlaceInit,
91     pr_alert,
92     pr_crit,
93     pr_debug,
94     pr_emerg,
95     pr_err,
96     pr_info,
97     pr_notice,
98     pr_warn,
99     static_assert,
100     str::CStrExt as _,
101     try_init,
102     try_pin_init,
103     uaccess::UserPtr,
104     ThisModule, //
105 };
106 
107 // `super::std_vendor` is hidden, which makes the macro inline for some reason.
108 #[doc(no_inline)]
109 pub use super::dbg;
110