@@ -233,113 +233,101 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
233
233
this. write_null ( dest) ?;
234
234
}
235
235
236
- // Better error for attempts to create a thread
237
- "pthread_create" => {
238
- throw_unsup_format ! ( "Miri does not support threading" ) ;
239
- }
240
-
241
- // Miscellaneous
242
- "isatty" => {
243
- let _fd = this. read_scalar ( args[ 0 ] ) ?. to_i32 ( ) ?;
244
- // "returns 1 if fd is an open file descriptor referring to a terminal; otherwise 0 is returned, and errno is set to indicate the error"
245
- // FIXME: we just say nothing is a terminal.
246
- let enotty = this. eval_libc ( "ENOTTY" ) ?;
247
- this. set_last_error ( enotty) ?;
248
- this. write_null ( dest) ?;
249
- }
250
- "pthread_atfork" => {
251
- let _prepare = this. read_scalar ( args[ 0 ] ) ?. not_undef ( ) ?;
252
- let _parent = this. read_scalar ( args[ 1 ] ) ?. not_undef ( ) ?;
253
- let _child = this. read_scalar ( args[ 1 ] ) ?. not_undef ( ) ?;
254
- // We do not support forking, so there is nothing to do here.
255
- this. write_null ( dest) ?;
256
- }
257
-
258
- // Incomplete shims that we "stub out" just to get pre-main initialization code to work.
259
- // These shims are enabled only when the caller is in the standard library.
260
- | "pthread_attr_init"
261
- | "pthread_attr_destroy"
262
- | "pthread_self"
263
- | "pthread_attr_setstacksize"
264
- | "pthread_condattr_init"
265
- | "pthread_condattr_setclock"
266
- | "pthread_cond_init"
267
- | "pthread_condattr_destroy"
268
- | "pthread_cond_destroy" if this. frame ( ) . instance . to_string ( ) . starts_with ( "std::sys::unix::" )
269
- => {
270
- this. write_null ( dest) ?;
271
- }
272
-
236
+ // Synchronization primitives
273
237
"pthread_mutexattr_init" => {
274
238
let result = this. pthread_mutexattr_init ( args[ 0 ] ) ?;
275
239
this. write_scalar ( Scalar :: from_i32 ( result) , dest) ?;
276
240
}
277
-
278
241
"pthread_mutexattr_settype" => {
279
242
let result = this. pthread_mutexattr_settype ( args[ 0 ] , args[ 1 ] ) ?;
280
243
this. write_scalar ( Scalar :: from_i32 ( result) , dest) ?;
281
244
}
282
-
283
245
"pthread_mutexattr_destroy" => {
284
246
let result = this. pthread_mutexattr_destroy ( args[ 0 ] ) ?;
285
247
this. write_scalar ( Scalar :: from_i32 ( result) , dest) ?;
286
248
}
287
-
288
249
"pthread_mutex_init" => {
289
250
let result = this. pthread_mutex_init ( args[ 0 ] , args[ 1 ] ) ?;
290
251
this. write_scalar ( Scalar :: from_i32 ( result) , dest) ?;
291
252
}
292
-
293
253
"pthread_mutex_lock" => {
294
254
let result = this. pthread_mutex_lock ( args[ 0 ] ) ?;
295
255
this. write_scalar ( Scalar :: from_i32 ( result) , dest) ?;
296
256
}
297
-
298
257
"pthread_mutex_trylock" => {
299
258
let result = this. pthread_mutex_trylock ( args[ 0 ] ) ?;
300
259
this. write_scalar ( Scalar :: from_i32 ( result) , dest) ?;
301
260
}
302
-
303
261
"pthread_mutex_unlock" => {
304
262
let result = this. pthread_mutex_unlock ( args[ 0 ] ) ?;
305
263
this. write_scalar ( Scalar :: from_i32 ( result) , dest) ?;
306
264
}
307
-
308
265
"pthread_mutex_destroy" => {
309
266
let result = this. pthread_mutex_destroy ( args[ 0 ] ) ?;
310
267
this. write_scalar ( Scalar :: from_i32 ( result) , dest) ?;
311
268
}
312
-
313
269
"pthread_rwlock_rdlock" => {
314
270
let result = this. pthread_rwlock_rdlock ( args[ 0 ] ) ?;
315
271
this. write_scalar ( Scalar :: from_i32 ( result) , dest) ?;
316
272
}
317
-
318
273
"pthread_rwlock_tryrdlock" => {
319
274
let result = this. pthread_rwlock_tryrdlock ( args[ 0 ] ) ?;
320
275
this. write_scalar ( Scalar :: from_i32 ( result) , dest) ?;
321
276
}
322
-
323
277
"pthread_rwlock_wrlock" => {
324
278
let result = this. pthread_rwlock_wrlock ( args[ 0 ] ) ?;
325
279
this. write_scalar ( Scalar :: from_i32 ( result) , dest) ?;
326
280
}
327
-
328
281
"pthread_rwlock_trywrlock" => {
329
282
let result = this. pthread_rwlock_trywrlock ( args[ 0 ] ) ?;
330
283
this. write_scalar ( Scalar :: from_i32 ( result) , dest) ?;
331
284
}
332
-
333
285
"pthread_rwlock_unlock" => {
334
286
let result = this. pthread_rwlock_unlock ( args[ 0 ] ) ?;
335
287
this. write_scalar ( Scalar :: from_i32 ( result) , dest) ?;
336
288
}
337
-
338
289
"pthread_rwlock_destroy" => {
339
290
let result = this. pthread_rwlock_destroy ( args[ 0 ] ) ?;
340
291
this. write_scalar ( Scalar :: from_i32 ( result) , dest) ?;
341
292
}
342
293
294
+ // Better error for attempts to create a thread
295
+ "pthread_create" => {
296
+ throw_unsup_format ! ( "Miri does not support threading" ) ;
297
+ }
298
+
299
+ // Miscellaneous
300
+ "isatty" => {
301
+ let _fd = this. read_scalar ( args[ 0 ] ) ?. to_i32 ( ) ?;
302
+ // "returns 1 if fd is an open file descriptor referring to a terminal; otherwise 0 is returned, and errno is set to indicate the error"
303
+ // FIXME: we just say nothing is a terminal.
304
+ let enotty = this. eval_libc ( "ENOTTY" ) ?;
305
+ this. set_last_error ( enotty) ?;
306
+ this. write_null ( dest) ?;
307
+ }
308
+ "pthread_atfork" => {
309
+ let _prepare = this. read_scalar ( args[ 0 ] ) ?. not_undef ( ) ?;
310
+ let _parent = this. read_scalar ( args[ 1 ] ) ?. not_undef ( ) ?;
311
+ let _child = this. read_scalar ( args[ 1 ] ) ?. not_undef ( ) ?;
312
+ // We do not support forking, so there is nothing to do here.
313
+ this. write_null ( dest) ?;
314
+ }
315
+
316
+ // Incomplete shims that we "stub out" just to get pre-main initialization code to work.
317
+ // These shims are enabled only when the caller is in the standard library.
318
+ | "pthread_attr_init"
319
+ | "pthread_attr_destroy"
320
+ | "pthread_self"
321
+ | "pthread_attr_setstacksize"
322
+ | "pthread_condattr_init"
323
+ | "pthread_condattr_setclock"
324
+ | "pthread_cond_init"
325
+ | "pthread_condattr_destroy"
326
+ | "pthread_cond_destroy" if this. frame ( ) . instance . to_string ( ) . starts_with ( "std::sys::unix::" )
327
+ => {
328
+ this. write_null ( dest) ?;
329
+ }
330
+
343
331
| "signal"
344
332
| "sigaction"
345
333
| "sigaltstack"
0 commit comments