@@ -190,19 +190,11 @@ fn mutex_get_data<'tcx, 'a>(
190
190
mutex_ptr : & OpTy < ' tcx > ,
191
191
) -> InterpResult < ' tcx , MutexData > {
192
192
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| {
202
194
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
+ } )
206
198
}
207
199
208
200
/// Returns the kind of a static initializer.
@@ -271,13 +263,7 @@ fn rwlock_get_data<'tcx>(
271
263
rwlock_ptr : & OpTy < ' tcx > ,
272
264
) -> InterpResult < ' tcx , RwLockData > {
273
265
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| {
281
267
if !bytewise_equal_atomic_relaxed (
282
268
ecx,
283
269
& rwlock,
@@ -286,10 +272,8 @@ fn rwlock_get_data<'tcx>(
286
272
throw_unsup_format ! ( "unsupported static initializer used for `pthread_rwlock_t`" ) ;
287
273
}
288
274
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
+ } )
293
277
}
294
278
295
279
// # pthread_condattr_t
@@ -405,21 +389,18 @@ fn cond_get_data<'tcx>(
405
389
cond_ptr : & OpTy < ' tcx > ,
406
390
) -> InterpResult < ' tcx , CondData > {
407
391
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| {
414
393
if !bytewise_equal_atomic_relaxed (
415
394
ecx,
416
395
& cond,
417
396
& ecx. eval_path ( & [ "libc" , "PTHREAD_COND_INITIALIZER" ] ) ,
418
397
) ? {
419
398
throw_unsup_format ! ( "unsupported static initializer used for `pthread_cond_t`" ) ;
420
399
}
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
+ } )
423
404
}
424
405
425
406
impl < ' tcx > EvalContextExt < ' tcx > for crate :: MiriInterpCx < ' tcx > { }
0 commit comments