Skip to main content

kernel/
prelude.rs

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)]
15pub 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)]
26pub 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)]
43pub use macros::{
44    export,
45    fmt,
46    kunit_tests,
47    module,
48    vtable, //
49};
50
51#[doc(no_inline)]
52pub 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)]
64pub use zerocopy::{
65    FromBytes,
66    IntoBytes, //
67};
68
69#[doc(no_inline)]
70pub use zerocopy_derive::{
71    FromBytes,
72    IntoBytes, //
73};
74
75#[doc(no_inline)]
76pub use super::{
77    alloc::{
78        flags::*,
79        Box,
80        KBox,
81        KVBox,
82        KVVec,
83        KVec,
84        VBox,
85        VVec,
86        Vec, //
87    },
88    build_assert::{
89        build_assert,
90        build_error,
91        const_assert,
92        static_assert, //
93    },
94    current,
95    dev_alert,
96    dev_crit,
97    dev_dbg,
98    dev_emerg,
99    dev_err,
100    dev_info,
101    dev_notice,
102    dev_warn,
103    error::{
104        code::*,
105        Error,
106        Result, //
107    },
108    init::InPlaceInit,
109    pr_alert,
110    pr_crit,
111    pr_debug,
112    pr_emerg,
113    pr_err,
114    pr_info,
115    pr_notice,
116    pr_warn,
117    str::CStrExt as _,
118    try_init,
119    try_pin_init,
120    uaccess::UserPtr,
121    ThisModule, //
122};
123
124// `super::std_vendor` is hidden, which makes the macro inline for some reason.
125#[doc(no_inline)]
126pub use super::dbg;