File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -30,20 +30,28 @@ pub struct LockClassKey(Opaque<bindings::lock_class_key>);
3030unsafe impl Sync for LockClassKey { }
3131
3232impl LockClassKey {
33+ /// Creates a new lock class key.
34+ pub const fn new ( ) -> Self {
35+ Self ( Opaque :: uninit ( ) )
36+ }
37+
3338 pub ( crate ) fn as_ptr ( & self ) -> * mut bindings:: lock_class_key {
3439 self . 0 . get ( )
3540 }
3641}
3742
43+ impl Default for LockClassKey {
44+ fn default ( ) -> Self {
45+ Self :: new ( )
46+ }
47+ }
48+
3849/// Defines a new static lock class and returns a pointer to it.
3950#[ doc( hidden) ]
4051#[ macro_export]
4152macro_rules! static_lock_class {
4253 ( ) => { {
43- static CLASS : $crate:: sync:: LockClassKey =
44- // SAFETY: lockdep expects uninitialized memory when it's handed a statically allocated
45- // lock_class_key
46- unsafe { :: core:: mem:: MaybeUninit :: uninit( ) . assume_init( ) } ;
54+ static CLASS : $crate:: sync:: LockClassKey = $crate:: sync:: LockClassKey :: new( ) ;
4755 & CLASS
4856 } } ;
4957}
You can’t perform that action at this time.
0 commit comments