Skip to content

Commit dec2057

Browse files
committed
Fix compilation errors after rebase.
1 parent 90590a3 commit dec2057

File tree

2 files changed

+39
-25
lines changed

2 files changed

+39
-25
lines changed

src/shims/foreign_items/posix.rs

+24-10
Original file line numberDiff line numberDiff line change
@@ -331,42 +331,52 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
331331
this.write_scalar(Scalar::from_i32(result), dest)?;
332332
}
333333
"pthread_condattr_init" => {
334-
let result = this.pthread_condattr_init(args[0])?;
334+
let &[attr] = check_arg_count(args)?;
335+
let result = this.pthread_condattr_init(attr)?;
335336
this.write_scalar(Scalar::from_i32(result), dest)?;
336337
}
337338
"pthread_condattr_setclock" => {
338-
let result = this.pthread_condattr_setclock(args[0], args[1])?;
339+
let &[attr, clock_id] = check_arg_count(args)?;
340+
let result = this.pthread_condattr_setclock(attr, clock_id)?;
339341
this.write_scalar(Scalar::from_i32(result), dest)?;
340342
}
341343
"pthread_condattr_getclock" => {
342-
let result = this.pthread_condattr_getclock(args[0], args[1])?;
344+
let &[attr, clock_id] = check_arg_count(args)?;
345+
let result = this.pthread_condattr_getclock(attr, clock_id)?;
343346
this.write_scalar(Scalar::from_i32(result), dest)?;
344347
}
345348
"pthread_condattr_destroy" => {
346-
let result = this.pthread_condattr_destroy(args[0])?;
349+
let &[attr] = check_arg_count(args)?;
350+
let result = this.pthread_condattr_destroy(attr)?;
347351
this.write_scalar(Scalar::from_i32(result), dest)?;
348352
}
349353
"pthread_cond_init" => {
350-
let result = this.pthread_cond_init(args[0], args[1])?;
354+
let &[cond, attr] = check_arg_count(args)?;
355+
let result = this.pthread_cond_init(cond, attr)?;
351356
this.write_scalar(Scalar::from_i32(result), dest)?;
352357
}
353358
"pthread_cond_signal" => {
354-
let result = this.pthread_cond_signal(args[0])?;
359+
let &[cond] = check_arg_count(args)?;
360+
let result = this.pthread_cond_signal(cond)?;
355361
this.write_scalar(Scalar::from_i32(result), dest)?;
356362
}
357363
"pthread_cond_broadcast" => {
358-
let result = this.pthread_cond_broadcast(args[0])?;
364+
let &[cond] = check_arg_count(args)?;
365+
let result = this.pthread_cond_broadcast(cond)?;
359366
this.write_scalar(Scalar::from_i32(result), dest)?;
360367
}
361368
"pthread_cond_wait" => {
362-
let result = this.pthread_cond_wait(args[0], args[1])?;
369+
let &[cond, mutex] = check_arg_count(args)?;
370+
let result = this.pthread_cond_wait(cond, mutex)?;
363371
this.write_scalar(Scalar::from_i32(result), dest)?;
364372
}
365373
"pthread_cond_timedwait" => {
366-
this.pthread_cond_timedwait(args[0], args[1], args[2], dest)?;
374+
let &[cond, mutex, abstime] = check_arg_count(args)?;
375+
this.pthread_cond_timedwait(cond, mutex, abstime, dest)?;
367376
}
368377
"pthread_cond_destroy" => {
369-
let result = this.pthread_cond_destroy(args[0])?;
378+
let &[cond] = check_arg_count(args)?;
379+
let result = this.pthread_cond_destroy(cond)?;
370380
this.write_scalar(Scalar::from_i32(result), dest)?;
371381
}
372382

@@ -430,6 +440,10 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
430440

431441
| "pthread_attr_init"
432442
| "pthread_attr_destroy"
443+
if this.frame().instance.to_string().starts_with("std::sys::unix::") => {
444+
let &[_] = check_arg_count(args)?;
445+
this.write_null(dest)?;
446+
}
433447
| "pthread_attr_setstacksize"
434448
if this.frame().instance.to_string().starts_with("std::sys::unix::") => {
435449
let &[_, _] = check_arg_count(args)?;

src/shims/sync.rs

+15-15
Original file line numberDiff line numberDiff line change
@@ -129,14 +129,14 @@ fn mutex_set_kind<'mir, 'tcx: 'mir>(
129129
fn mutex_get_id<'mir, 'tcx: 'mir>(
130130
ecx: &MiriEvalContext<'mir, 'tcx>,
131131
mutex_op: OpTy<'tcx, Tag>,
132-
) -> InterpResult<'tcx, ScalarMaybeUndef<Tag>> {
132+
) -> InterpResult<'tcx, ScalarMaybeUninit<Tag>> {
133133
get_at_offset(ecx, mutex_op, 4, ecx.machine.layouts.u32, PTHREAD_MUTEX_T_MIN_SIZE)
134134
}
135135

136136
fn mutex_set_id<'mir, 'tcx: 'mir>(
137137
ecx: &mut MiriEvalContext<'mir, 'tcx>,
138138
mutex_op: OpTy<'tcx, Tag>,
139-
id: impl Into<ScalarMaybeUndef<Tag>>,
139+
id: impl Into<ScalarMaybeUninit<Tag>>,
140140
) -> InterpResult<'tcx, ()> {
141141
set_at_offset(ecx, mutex_op, 4, id, ecx.machine.layouts.u32, PTHREAD_MUTEX_T_MIN_SIZE)
142142
}
@@ -176,7 +176,7 @@ fn rwlock_get_id<'mir, 'tcx: 'mir>(
176176
fn rwlock_set_id<'mir, 'tcx: 'mir>(
177177
ecx: &mut MiriEvalContext<'mir, 'tcx>,
178178
rwlock_op: OpTy<'tcx, Tag>,
179-
id: impl Into<ScalarMaybeUndef<Tag>>,
179+
id: impl Into<ScalarMaybeUninit<Tag>>,
180180
) -> InterpResult<'tcx, ()> {
181181
set_at_offset(ecx, rwlock_op, 4, id, ecx.machine.layouts.u32, PTHREAD_RWLOCK_T_MIN_SIZE)
182182
}
@@ -208,14 +208,14 @@ const PTHREAD_CONDATTR_T_MIN_SIZE: u64 = 4;
208208
fn condattr_get_clock_id<'mir, 'tcx: 'mir>(
209209
ecx: &MiriEvalContext<'mir, 'tcx>,
210210
attr_op: OpTy<'tcx, Tag>,
211-
) -> InterpResult<'tcx, ScalarMaybeUndef<Tag>> {
211+
) -> InterpResult<'tcx, ScalarMaybeUninit<Tag>> {
212212
get_at_offset(ecx, attr_op, 0, ecx.machine.layouts.i32, PTHREAD_CONDATTR_T_MIN_SIZE)
213213
}
214214

215215
fn condattr_set_clock_id<'mir, 'tcx: 'mir>(
216216
ecx: &mut MiriEvalContext<'mir, 'tcx>,
217217
attr_op: OpTy<'tcx, Tag>,
218-
clock_id: impl Into<ScalarMaybeUndef<Tag>>,
218+
clock_id: impl Into<ScalarMaybeUninit<Tag>>,
219219
) -> InterpResult<'tcx, ()> {
220220
set_at_offset(ecx, attr_op, 0, clock_id, ecx.machine.layouts.i32, PTHREAD_CONDATTR_T_MIN_SIZE)
221221
}
@@ -234,14 +234,14 @@ const PTHREAD_COND_T_MIN_SIZE: u64 = 12;
234234
fn cond_get_id<'mir, 'tcx: 'mir>(
235235
ecx: &MiriEvalContext<'mir, 'tcx>,
236236
cond_op: OpTy<'tcx, Tag>,
237-
) -> InterpResult<'tcx, ScalarMaybeUndef<Tag>> {
237+
) -> InterpResult<'tcx, ScalarMaybeUninit<Tag>> {
238238
get_at_offset(ecx, cond_op, 4, ecx.machine.layouts.u32, PTHREAD_COND_T_MIN_SIZE)
239239
}
240240

241241
fn cond_set_id<'mir, 'tcx: 'mir>(
242242
ecx: &mut MiriEvalContext<'mir, 'tcx>,
243243
cond_op: OpTy<'tcx, Tag>,
244-
id: impl Into<ScalarMaybeUndef<Tag>>,
244+
id: impl Into<ScalarMaybeUninit<Tag>>,
245245
) -> InterpResult<'tcx, ()> {
246246
set_at_offset(ecx, cond_op, 4, id, ecx.machine.layouts.u32, PTHREAD_COND_T_MIN_SIZE)
247247
}
@@ -265,14 +265,14 @@ fn cond_get_or_create_id<'mir, 'tcx: 'mir>(
265265
fn cond_get_clock_id<'mir, 'tcx: 'mir>(
266266
ecx: &MiriEvalContext<'mir, 'tcx>,
267267
cond_op: OpTy<'tcx, Tag>,
268-
) -> InterpResult<'tcx, ScalarMaybeUndef<Tag>> {
268+
) -> InterpResult<'tcx, ScalarMaybeUninit<Tag>> {
269269
get_at_offset(ecx, cond_op, 8, ecx.machine.layouts.i32, PTHREAD_COND_T_MIN_SIZE)
270270
}
271271

272272
fn cond_set_clock_id<'mir, 'tcx: 'mir>(
273273
ecx: &mut MiriEvalContext<'mir, 'tcx>,
274274
cond_op: OpTy<'tcx, Tag>,
275-
clock_id: impl Into<ScalarMaybeUndef<Tag>>,
275+
clock_id: impl Into<ScalarMaybeUninit<Tag>>,
276276
) -> InterpResult<'tcx, ()> {
277277
set_at_offset(ecx, cond_op, 8, clock_id, ecx.machine.layouts.i32, PTHREAD_COND_T_MIN_SIZE)
278278
}
@@ -518,8 +518,8 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
518518
throw_ub_format!("destroyed a locked mutex");
519519
}
520520

521-
mutex_set_kind(this, mutex_op, ScalarMaybeUndef::Undef)?;
522-
mutex_set_id(this, mutex_op, ScalarMaybeUndef::Undef)?;
521+
mutex_set_kind(this, mutex_op, ScalarMaybeUninit::Uninit)?;
522+
mutex_set_id(this, mutex_op, ScalarMaybeUninit::Uninit)?;
523523

524524
Ok(0)
525525
}
@@ -643,7 +643,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
643643
throw_ub_format!("destroyed a locked rwlock");
644644
}
645645

646-
rwlock_set_id(this, rwlock_op, ScalarMaybeUndef::Undef)?;
646+
rwlock_set_id(this, rwlock_op, ScalarMaybeUninit::Uninit)?;
647647

648648
Ok(0)
649649
}
@@ -696,7 +696,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
696696
fn pthread_condattr_destroy(&mut self, attr_op: OpTy<'tcx, Tag>) -> InterpResult<'tcx, i32> {
697697
let this = self.eval_context_mut();
698698

699-
condattr_set_clock_id(this, attr_op, ScalarMaybeUndef::Undef)?;
699+
condattr_set_clock_id(this, attr_op, ScalarMaybeUninit::Uninit)?;
700700

701701
Ok(0)
702702
}
@@ -835,8 +835,8 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
835835
if this.condvar_is_awaited(id) {
836836
throw_ub_format!("destroyed an awaited conditional variable");
837837
}
838-
cond_set_id(this, cond_op, ScalarMaybeUndef::Undef)?;
839-
cond_set_clock_id(this, cond_op, ScalarMaybeUndef::Undef)?;
838+
cond_set_id(this, cond_op, ScalarMaybeUninit::Uninit)?;
839+
cond_set_clock_id(this, cond_op, ScalarMaybeUninit::Uninit)?;
840840

841841
Ok(0)
842842
}

0 commit comments

Comments
 (0)