@@ -175,7 +175,7 @@ pub struct RrosHeap {
175175 pub buckets : [ u32 ; RROS_HEAP_MAX_BUCKETS as usize ] ,
176176 /// `lock` is an optional SpinLock used for ensuring thread-safety in the `RrosHeap`.
177177 /// It is initialized in the `init` method of the `RrosHeap` struct.
178- pub lock : Option < SpinLock < i32 > > ,
178+ pub lock : Option < Pin < Box < SpinLock < i32 > > > > ,
179179}
180180
181181/// Implementation of the `RrosHeap` struct.
@@ -192,9 +192,13 @@ impl RrosHeap {
192192 return Err ( crate :: Error :: EINVAL ) ;
193193 }
194194
195- let mut spinlock = unsafe { SpinLock :: new ( 1 ) } ;
196- let pinned = unsafe { Pin :: new_unchecked ( & mut spinlock) } ;
197- spinlock_init ! ( pinned, "spinlock" ) ;
195+ static lock_name: & ' static CStr = crate :: c_str!( "spinlock" ) ;
196+ static mut CLASS : core:: mem:: MaybeUninit < crate :: sync:: LockClassKey > = core:: mem:: MaybeUninit :: uninit ( ) ;
197+ static lock_key : & ' static crate :: sync:: LockClassKey = unsafe { & * CLASS . as_ptr ( ) } ;
198+ let mut spinlock_init = unsafe { SpinLock :: new ( 1 , lock_name, lock_key) } ;
199+ // let pinned = unsafe { Pin::new_unchecked(&mut spinlock) };
200+ // spinlock_init!(pinned, "spinlock");
201+ let mut spinlock= Box :: pin_init ( spinlock_init) . unwrap ( ) ;
198202 self . lock = Some ( spinlock) ;
199203
200204 for i in self . buckets . iter_mut ( ) {
0 commit comments