@@ -233,6 +233,64 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
233
233
this. write_null ( dest) ?;
234
234
}
235
235
236
+ // Synchronization primitives
237
+ "pthread_mutexattr_init" => {
238
+ let result = this. pthread_mutexattr_init ( args[ 0 ] ) ?;
239
+ this. write_scalar ( Scalar :: from_i32 ( result) , dest) ?;
240
+ }
241
+ "pthread_mutexattr_settype" => {
242
+ let result = this. pthread_mutexattr_settype ( args[ 0 ] , args[ 1 ] ) ?;
243
+ this. write_scalar ( Scalar :: from_i32 ( result) , dest) ?;
244
+ }
245
+ "pthread_mutexattr_destroy" => {
246
+ let result = this. pthread_mutexattr_destroy ( args[ 0 ] ) ?;
247
+ this. write_scalar ( Scalar :: from_i32 ( result) , dest) ?;
248
+ }
249
+ "pthread_mutex_init" => {
250
+ let result = this. pthread_mutex_init ( args[ 0 ] , args[ 1 ] ) ?;
251
+ this. write_scalar ( Scalar :: from_i32 ( result) , dest) ?;
252
+ }
253
+ "pthread_mutex_lock" => {
254
+ let result = this. pthread_mutex_lock ( args[ 0 ] ) ?;
255
+ this. write_scalar ( Scalar :: from_i32 ( result) , dest) ?;
256
+ }
257
+ "pthread_mutex_trylock" => {
258
+ let result = this. pthread_mutex_trylock ( args[ 0 ] ) ?;
259
+ this. write_scalar ( Scalar :: from_i32 ( result) , dest) ?;
260
+ }
261
+ "pthread_mutex_unlock" => {
262
+ let result = this. pthread_mutex_unlock ( args[ 0 ] ) ?;
263
+ this. write_scalar ( Scalar :: from_i32 ( result) , dest) ?;
264
+ }
265
+ "pthread_mutex_destroy" => {
266
+ let result = this. pthread_mutex_destroy ( args[ 0 ] ) ?;
267
+ this. write_scalar ( Scalar :: from_i32 ( result) , dest) ?;
268
+ }
269
+ "pthread_rwlock_rdlock" => {
270
+ let result = this. pthread_rwlock_rdlock ( args[ 0 ] ) ?;
271
+ this. write_scalar ( Scalar :: from_i32 ( result) , dest) ?;
272
+ }
273
+ "pthread_rwlock_tryrdlock" => {
274
+ let result = this. pthread_rwlock_tryrdlock ( args[ 0 ] ) ?;
275
+ this. write_scalar ( Scalar :: from_i32 ( result) , dest) ?;
276
+ }
277
+ "pthread_rwlock_wrlock" => {
278
+ let result = this. pthread_rwlock_wrlock ( args[ 0 ] ) ?;
279
+ this. write_scalar ( Scalar :: from_i32 ( result) , dest) ?;
280
+ }
281
+ "pthread_rwlock_trywrlock" => {
282
+ let result = this. pthread_rwlock_trywrlock ( args[ 0 ] ) ?;
283
+ this. write_scalar ( Scalar :: from_i32 ( result) , dest) ?;
284
+ }
285
+ "pthread_rwlock_unlock" => {
286
+ let result = this. pthread_rwlock_unlock ( args[ 0 ] ) ?;
287
+ this. write_scalar ( Scalar :: from_i32 ( result) , dest) ?;
288
+ }
289
+ "pthread_rwlock_destroy" => {
290
+ let result = this. pthread_rwlock_destroy ( args[ 0 ] ) ?;
291
+ this. write_scalar ( Scalar :: from_i32 ( result) , dest) ?;
292
+ }
293
+
236
294
// Better error for attempts to create a thread
237
295
"pthread_create" => {
238
296
throw_unsup_format ! ( "Miri does not support threading" ) ;
@@ -255,25 +313,12 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
255
313
this. write_null ( dest) ?;
256
314
}
257
315
258
- // Incomplete shims that we "stub out" just to get pre-main initialziation code to work.
316
+ // Incomplete shims that we "stub out" just to get pre-main initialization code to work.
259
317
// These shims are enabled only when the caller is in the standard library.
260
318
| "pthread_attr_init"
261
319
| "pthread_attr_destroy"
262
320
| "pthread_self"
263
- | "pthread_attr_setstacksize" if this. frame ( ) . instance . to_string ( ) . starts_with ( "std::sys::unix::" ) => {
264
- this. write_null ( dest) ?;
265
- }
266
- | "pthread_mutexattr_init"
267
- | "pthread_mutexattr_settype"
268
- | "pthread_mutex_init"
269
- | "pthread_mutexattr_destroy"
270
- | "pthread_mutex_lock"
271
- | "pthread_mutex_unlock"
272
- | "pthread_mutex_destroy"
273
- | "pthread_rwlock_rdlock"
274
- | "pthread_rwlock_unlock"
275
- | "pthread_rwlock_wrlock"
276
- | "pthread_rwlock_destroy"
321
+ | "pthread_attr_setstacksize"
277
322
| "pthread_condattr_init"
278
323
| "pthread_condattr_setclock"
279
324
| "pthread_cond_init"
@@ -282,6 +327,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
282
327
=> {
283
328
this. write_null ( dest) ?;
284
329
}
330
+
285
331
| "signal"
286
332
| "sigaction"
287
333
| "sigaltstack"
0 commit comments