@@ -190,19 +190,11 @@ fn mutex_get_data<'tcx, 'a>(
190190 mutex_ptr : & OpTy < ' tcx > ,
191191) -> InterpResult < ' tcx , MutexData > {
192192 let mutex = ecx. deref_pointer ( mutex_ptr) ?;
193-
194- if let Some ( data) =
195- lazy_sync_get_data :: < MutexData > ( ecx, & mutex, mutex_init_offset ( ecx) ?, "pthread_mutex_t" ) ?
196- {
197- interp_ok ( data)
198- } else {
199- // Not yet initialized. This must be a static initializer, figure out the kind
200- // from that. We don't need to worry about races since we are the interpreter
201- // and don't let any other tread take a step.
193+ lazy_sync_get_data ( ecx, & mutex, mutex_init_offset ( ecx) ?, "pthread_mutex_t" , |ecx| {
202194 let kind = mutex_kind_from_static_initializer ( ecx, & mutex) ?;
203- // And then create the mutex like this.
204- mutex_create ( ecx , mutex_ptr , kind)
205- }
195+ let id = ecx . machine . sync . mutex_create ( ) ;
196+ interp_ok ( MutexData { id , kind } )
197+ } )
206198}
207199
208200/// Returns the kind of a static initializer.
@@ -271,13 +263,7 @@ fn rwlock_get_data<'tcx>(
271263 rwlock_ptr : & OpTy < ' tcx > ,
272264) -> InterpResult < ' tcx , RwLockData > {
273265 let rwlock = ecx. deref_pointer ( rwlock_ptr) ?;
274- let init_offset = rwlock_init_offset ( ecx) ?;
275-
276- if let Some ( data) =
277- lazy_sync_get_data :: < RwLockData > ( ecx, & rwlock, init_offset, "pthread_rwlock_t" ) ?
278- {
279- interp_ok ( data)
280- } else {
266+ lazy_sync_get_data ( ecx, & rwlock, rwlock_init_offset ( ecx) ?, "pthread_rwlock_t" , |ecx| {
281267 if !bytewise_equal_atomic_relaxed (
282268 ecx,
283269 & rwlock,
@@ -286,10 +272,8 @@ fn rwlock_get_data<'tcx>(
286272 throw_unsup_format ! ( "unsupported static initializer used for `pthread_rwlock_t`" ) ;
287273 }
288274 let id = ecx. machine . sync . rwlock_create ( ) ;
289- let data = RwLockData { id } ;
290- lazy_sync_init ( ecx, & rwlock, init_offset, data) ?;
291- interp_ok ( data)
292- }
275+ interp_ok ( RwLockData { id } )
276+ } )
293277}
294278
295279// # pthread_condattr_t
@@ -405,21 +389,18 @@ fn cond_get_data<'tcx>(
405389 cond_ptr : & OpTy < ' tcx > ,
406390) -> InterpResult < ' tcx , CondData > {
407391 let cond = ecx. deref_pointer ( cond_ptr) ?;
408- let init_offset = cond_init_offset ( ecx) ?;
409-
410- if let Some ( data) = lazy_sync_get_data :: < CondData > ( ecx, & cond, init_offset, "pthread_cond_t" ) ? {
411- interp_ok ( data)
412- } else {
413- // This used the static initializer. The clock there is always CLOCK_REALTIME.
392+ lazy_sync_get_data ( ecx, & cond, cond_init_offset ( ecx) ?, "pthread_cond_t" , |ecx| {
414393 if !bytewise_equal_atomic_relaxed (
415394 ecx,
416395 & cond,
417396 & ecx. eval_path ( & [ "libc" , "PTHREAD_COND_INITIALIZER" ] ) ,
418397 ) ? {
419398 throw_unsup_format ! ( "unsupported static initializer used for `pthread_cond_t`" ) ;
420399 }
421- cond_create ( ecx, cond_ptr, ClockId :: Realtime )
422- }
400+ // This used the static initializer. The clock there is always CLOCK_REALTIME.
401+ let id = ecx. machine . sync . condvar_create ( ) ;
402+ interp_ok ( CondData { id, clock : ClockId :: Realtime } )
403+ } )
423404}
424405
425406impl < ' tcx > EvalContextExt < ' tcx > for crate :: MiriInterpCx < ' tcx > { }
0 commit comments