@@ -126,18 +126,16 @@ unsafe impl<T> PinInit<SpinLock<T>> for Init<T> {
126
126
self ,
127
127
slot : * mut SpinLock < T > ,
128
128
) -> core:: result:: Result < ( ) , core:: convert:: Infallible > {
129
- fn init_spinlock (
130
- name : & ' static CStr ,
131
- key : & ' static LockClassKey ,
132
- ) -> impl PinInit < Opaque < bindings:: spinlock > > {
133
- let init = move |slot : * mut Opaque < bindings:: spinlock > | unsafe {
134
- bindings:: __spin_lock_init ( Opaque :: raw_get ( slot) , name. as_char_ptr ( ) , key. get ( ) ) ;
135
- Ok ( ( ) )
136
- } ;
137
- unsafe { init:: pin_init_from_closure ( init) }
138
- }
139
129
let init = pin_init ! ( SpinLock <T > {
140
- spin_lock: init_spinlock( self . name, self . key) ,
130
+ // SAFETY: __spin_lock_init is an initializer function and name and key are valid
131
+ // parameters.
132
+ spin_lock: unsafe {
133
+ init:: common:: ffi_init2(
134
+ bindings:: __spin_lock_init,
135
+ self . name. as_char_ptr( ) ,
136
+ self . key. get( ) ,
137
+ )
138
+ } ,
141
139
data: UnsafeCell :: new( self . data) ,
142
140
_pin: PhantomPinned ,
143
141
} ) ;
@@ -317,22 +315,16 @@ unsafe impl<T> PinInit<RawSpinLock<T>> for RInit<T> {
317
315
self ,
318
316
slot : * mut RawSpinLock < T > ,
319
317
) -> core:: result:: Result < ( ) , core:: convert:: Infallible > {
320
- fn init_spinlock (
321
- name : & ' static CStr ,
322
- key : & ' static LockClassKey ,
323
- ) -> impl PinInit < Opaque < bindings:: raw_spinlock > > {
324
- let init = move |place : * mut Opaque < bindings:: raw_spinlock > | unsafe {
325
- bindings:: _raw_spin_lock_init (
326
- Opaque :: raw_get ( place) ,
327
- name. as_char_ptr ( ) ,
328
- key. get ( ) ,
329
- ) ;
330
- Ok ( ( ) )
331
- } ;
332
- unsafe { init:: pin_init_from_closure ( init) }
333
- }
334
318
let init = pin_init ! ( RawSpinLock <T > {
335
- spin_lock: init_spinlock( self . name, self . key) ,
319
+ // SAFETY: _raw_spin_lock_init is an initializer function and name and key are valid
320
+ // parameters.
321
+ spin_lock: unsafe {
322
+ init:: common:: ffi_init2(
323
+ bindings:: _raw_spin_lock_init,
324
+ self . name. as_char_ptr( ) ,
325
+ self . key. get( ) ,
326
+ )
327
+ } ,
336
328
data: UnsafeCell :: new( self . data) ,
337
329
_pin: PhantomPinned ,
338
330
} ) ;
0 commit comments