Skip to content

Commit 3f00639

Browse files
committed
zephyr: object: Reorder declarations
Move the Wrapped trait above the StaticKernelObject so that the traits are immediately declared after the type the apply to. Signed-off-by: David Brown <[email protected]>
1 parent c180d5a commit 3f00639

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

zephyr/src/object.rs

+22-22
Original file line numberDiff line numberDiff line change
@@ -91,28 +91,6 @@ use crate::sync::atomic::{AtomicUsize, Ordering};
9191
// the mutations happen from C code, so this is less important than the data being placed in the
9292
// proper section. Many will have the link section overridden by the `kobj_define` macro.
9393

94-
/// A kernel object represented statically in Rust code.
95-
///
96-
/// These should not be declared directly by the user, as they generally need linker decorations to
97-
/// be properly registered in Zephyr as kernel objects. The object has the underlying Zephyr type
98-
/// T, and the wrapper type W.
99-
///
100-
/// Kernel objects will have their `StaticThing` implemented as `StaticKernelObject<kobj>` where
101-
/// `kobj` is the type of the underlying Zephyr object. `Thing` will usually be a struct with a
102-
/// single field, which is a `*mut kobj`.
103-
///
104-
/// TODO: Can we avoid the public fields with a const new method?
105-
///
106-
/// TODO: Handling const-defined alignment for these.
107-
pub struct StaticKernelObject<T> {
108-
#[allow(dead_code)]
109-
/// The underlying zephyr kernel object.
110-
pub value: UnsafeCell<T>,
111-
/// Initialization status of this object. Most objects will start uninitialized and be
112-
/// initialized manually.
113-
pub init: AtomicUsize,
114-
}
115-
11694
/// Define the Wrapping of a kernel object.
11795
///
11896
/// This trait defines the association between a static kernel object and the two associated Rust
@@ -154,6 +132,28 @@ pub const KOBJ_INITING: usize = 1;
154132
/// take has been called. And shouldn't be allowed additional times.
155133
pub const KOBJ_INITIALIZED: usize = 2;
156134

135+
/// A kernel object represented statically in Rust code.
136+
///
137+
/// These should not be declared directly by the user, as they generally need linker decorations to
138+
/// be properly registered in Zephyr as kernel objects. The object has the underlying Zephyr type
139+
/// T, and the wrapper type W.
140+
///
141+
/// Kernel objects will have their `StaticThing` implemented as `StaticKernelObject<kobj>` where
142+
/// `kobj` is the type of the underlying Zephyr object. `Thing` will usually be a struct with a
143+
/// single field, which is a `*mut kobj`.
144+
///
145+
/// TODO: Can we avoid the public fields with a const new method?
146+
///
147+
/// TODO: Handling const-defined alignment for these.
148+
pub struct StaticKernelObject<T> {
149+
#[allow(dead_code)]
150+
/// The underlying zephyr kernel object.
151+
pub value: UnsafeCell<T>,
152+
/// Initialization status of this object. Most objects will start uninitialized and be
153+
/// initialized manually.
154+
pub init: AtomicUsize,
155+
}
156+
157157
impl<T> StaticKernelObject<T>
158158
where
159159
StaticKernelObject<T>: Wrapped,

0 commit comments

Comments
 (0)