Skip to content

Commit ba95d52

Browse files
committed
pick more clear names for the types
1 parent 9265a6e commit ba95d52

3 files changed

Lines changed: 19 additions & 22 deletions

File tree

‎src/tools/miri/src/shims/unix/macos/sync.rs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
1313
usecrate::*;
1414

15-
structLockData{
15+
structMacOsUnfairLock{
1616
id:MutexId,
1717
}
1818

@@ -25,11 +25,11 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
2525
// that's just implicitly creating a new lock at the new location.
2626
let(alloc, offset, _) = this.ptr_get_alloc_id(lock.ptr(),0)?;
2727
let(alloc_extra, machine) = this.get_alloc_extra_mut(alloc)?;
28-
ifletSome(data) = alloc_extra.get_sync::<LockData>(offset){
28+
ifletSome(data) = alloc_extra.get_sync::<MacOsUnfairLock>(offset){
2929
interp_ok(data.id)
3030
}else{
3131
let id = machine.sync.mutex_create();
32-
alloc_extra.sync.insert(offset,Box::new(LockData{ id }));
32+
alloc_extra.sync.insert(offset,Box::new(MacOsUnfairLock{ id }));
3333
interp_ok(id)
3434
}
3535
}

‎src/tools/miri/src/shims/unix/sync.rs‎

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,7 @@ enum MutexKind {
117117
}
118118

119119
#[derive(Debug,Clone,Copy)]
120-
/// Additional data that we attach with each mutex instance.
121-
structMutexData{
120+
structPthreadMutex{
122121
id:MutexId,
123122
kind:MutexKind,
124123
}
@@ -173,10 +172,10 @@ fn mutex_create<'tcx>(
173172
ecx:&mutMiriInterpCx<'tcx>,
174173
mutex_ptr:&OpTy<'tcx>,
175174
kind:MutexKind,
176-
) -> InterpResult<'tcx,MutexData>{
175+
) -> InterpResult<'tcx,PthreadMutex>{
177176
let mutex = ecx.deref_pointer(mutex_ptr)?;
178177
let id = ecx.machine.sync.mutex_create();
179-
let data = MutexData{ id, kind };
178+
let data = PthreadMutex{ id, kind };
180179
lazy_sync_init(ecx,&mutex,mutex_init_offset(ecx)?, data)?;
181180
interp_ok(data)
182181
}
@@ -188,12 +187,12 @@ fn mutex_create<'tcx>(
188187
fnmutex_get_data<'tcx,'a>(
189188
ecx:&'amutMiriInterpCx<'tcx>,
190189
mutex_ptr:&OpTy<'tcx>,
191-
) -> InterpResult<'tcx,MutexData>{
190+
) -> InterpResult<'tcx,PthreadMutex>{
192191
let mutex = ecx.deref_pointer(mutex_ptr)?;
193192
lazy_sync_get_data(ecx,&mutex,mutex_init_offset(ecx)?,"pthread_mutex_t", |ecx| {
194193
let kind = mutex_kind_from_static_initializer(ecx,&mutex)?;
195194
let id = ecx.machine.sync.mutex_create();
196-
interp_ok(MutexData{ id, kind })
195+
interp_ok(PthreadMutex{ id, kind })
197196
})
198197
}
199198

@@ -228,8 +227,7 @@ fn mutex_kind_from_static_initializer<'tcx>(
228227
// - init: u32
229228

230229
#[derive(Debug,Copy,Clone)]
231-
/// Additional data that we attach with each rwlock instance.
232-
structRwLockData{
230+
structPthreadRwLock{
233231
id:RwLockId,
234232
}
235233

@@ -261,7 +259,7 @@ fn rwlock_init_offset<'tcx>(ecx: &MiriInterpCx<'tcx>) -> InterpResult<'tcx, Size
261259
fnrwlock_get_data<'tcx>(
262260
ecx:&mutMiriInterpCx<'tcx>,
263261
rwlock_ptr:&OpTy<'tcx>,
264-
) -> InterpResult<'tcx,RwLockData>{
262+
) -> InterpResult<'tcx,PthreadRwLock>{
265263
let rwlock = ecx.deref_pointer(rwlock_ptr)?;
266264
lazy_sync_get_data(ecx,&rwlock,rwlock_init_offset(ecx)?,"pthread_rwlock_t", |ecx| {
267265
if !bytewise_equal_atomic_relaxed(
@@ -272,7 +270,7 @@ fn rwlock_get_data<'tcx>(
272270
throw_unsup_format!("unsupported static initializer used for `pthread_rwlock_t`");
273271
}
274272
let id = ecx.machine.sync.rwlock_create();
275-
interp_ok(RwLockData{ id })
273+
interp_ok(PthreadRwLock{ id })
276274
})
277275
}
278276

@@ -366,8 +364,7 @@ enum ClockId {
366364
}
367365

368366
#[derive(Debug,Copy,Clone)]
369-
/// Additional data that we attach with each cond instance.
370-
structCondData{
367+
structPthreadCondvar{
371368
id:CondvarId,
372369
clock:ClockId,
373370
}
@@ -376,18 +373,18 @@ fn cond_create<'tcx>(
376373
ecx:&mutMiriInterpCx<'tcx>,
377374
cond_ptr:&OpTy<'tcx>,
378375
clock:ClockId,
379-
) -> InterpResult<'tcx,CondData>{
376+
) -> InterpResult<'tcx,PthreadCondvar>{
380377
let cond = ecx.deref_pointer(cond_ptr)?;
381378
let id = ecx.machine.sync.condvar_create();
382-
let data = CondData{ id, clock };
379+
let data = PthreadCondvar{ id, clock };
383380
lazy_sync_init(ecx,&cond,cond_init_offset(ecx)?, data)?;
384381
interp_ok(data)
385382
}
386383

387384
fncond_get_data<'tcx>(
388385
ecx:&mutMiriInterpCx<'tcx>,
389386
cond_ptr:&OpTy<'tcx>,
390-
) -> InterpResult<'tcx,CondData>{
387+
) -> InterpResult<'tcx,PthreadCondvar>{
391388
let cond = ecx.deref_pointer(cond_ptr)?;
392389
lazy_sync_get_data(ecx,&cond,cond_init_offset(ecx)?,"pthread_cond_t", |ecx| {
393390
if !bytewise_equal_atomic_relaxed(
@@ -399,7 +396,7 @@ fn cond_get_data<'tcx>(
399396
}
400397
// This used the static initializer. The clock there is always CLOCK_REALTIME.
401398
let id = ecx.machine.sync.condvar_create();
402-
interp_ok(CondData{ id,clock:ClockId::Realtime})
399+
interp_ok(PthreadCondvar{ id,clock:ClockId::Realtime})
403400
})
404401
}
405402

‎src/tools/miri/src/shims/windows/sync.rs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use crate::concurrency::sync::lazy_sync_get_data;
77
usecrate::*;
88

99
#[derive(Copy,Clone)]
10-
structInitOnceData{
10+
structWindowsInitOnce{
1111
id:InitOnceId,
1212
}
1313

@@ -19,7 +19,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
1919
fninit_once_get_data(
2020
&mutself,
2121
init_once_ptr:&OpTy<'tcx>,
22-
) -> InterpResult<'tcx,InitOnceData>{
22+
) -> InterpResult<'tcx,WindowsInitOnce>{
2323
let this = self.eval_context_mut();
2424

2525
let init_once = this.deref_pointer(init_once_ptr)?;
@@ -28,7 +28,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
2828
lazy_sync_get_data(this,&init_once, init_offset,"INIT_ONCE", |this| {
2929
// TODO: check that this is still all-zero.
3030
let id = this.machine.sync.init_once_create();
31-
interp_ok(InitOnceData{ id })
31+
interp_ok(WindowsInitOnce{ id })
3232
})
3333
}
3434

0 commit comments

Comments
 (0)