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::FromBytes;
65
66#[doc(no_inline)]
67pub use zerocopy_derive::FromBytes;
68
69#[doc(no_inline)]
70pub 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_error,
84    const_assert,
85    current,
86    dev_alert,
87    dev_crit,
88    dev_dbg,
89    dev_emerg,
90    dev_err,
91    dev_info,
92    dev_notice,
93    dev_warn,
94    error::{
95        code::*,
96        Error,
97        Result, //
98    },
99    init::InPlaceInit,
100    pr_alert,
101    pr_crit,
102    pr_debug,
103    pr_emerg,
104    pr_err,
105    pr_info,
106    pr_notice,
107    pr_warn,
108    static_assert,
109    str::CStrExt as _,
110    try_init,
111    try_pin_init,
112    uaccess::UserPtr,
113    ThisModule, //
114};
115
116// `super::std_vendor` is hidden, which makes the macro inline for some reason.
117#[doc(no_inline)]
118pub use super::dbg;