@@ -228,16 +228,21 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
228
228
let [ name] = this. check_shim ( abi, Abi :: C { unwind : false } , link_name, args) ?;
229
229
let name = this. read_scalar ( name) ?. to_i32 ( ) ?;
230
230
231
- let sysconfs = & [
232
- ( "_SC_PAGESIZE" , Scalar :: from_int ( PAGE_SIZE , this. pointer_size ( ) ) ) ,
233
- ( "_SC_NPROCESSORS_CONF" , Scalar :: from_int ( NUM_CPUS , this. pointer_size ( ) ) ) ,
234
- ( "_SC_NPROCESSORS_ONLN" , Scalar :: from_int ( NUM_CPUS , this. pointer_size ( ) ) ) ,
231
+ // FIXME: Which of these are POSIX, and which are GNU/Linux?
232
+ // At least the names seem to all also exist on macOS.
233
+ let sysconfs: & [ ( & str , fn ( & MiriEvalContext < ' _ , ' _ > ) -> Scalar < Provenance > ) ] = & [
234
+ ( "_SC_PAGESIZE" , |this| Scalar :: from_int ( PAGE_SIZE , this. pointer_size ( ) ) ) ,
235
+ ( "_SC_NPROCESSORS_CONF" , |this| Scalar :: from_int ( NUM_CPUS , this. pointer_size ( ) ) ) ,
236
+ ( "_SC_NPROCESSORS_ONLN" , |this| Scalar :: from_int ( NUM_CPUS , this. pointer_size ( ) ) ) ,
237
+ // 512 seems to be a reasonable default. The value is not critical, in
238
+ // the sense that getpwuid_r takes and checks the buffer length.
239
+ ( "_SC_GETPW_R_SIZE_MAX" , |this| Scalar :: from_int ( 512 , this. pointer_size ( ) ) )
235
240
] ;
236
241
let mut result = None ;
237
242
for & ( sysconf_name, value) in sysconfs {
238
243
let sysconf_name = this. eval_libc_i32 ( sysconf_name) ?;
239
244
if sysconf_name == name {
240
- result = Some ( value) ;
245
+ result = Some ( value ( this ) ) ;
241
246
break ;
242
247
}
243
248
}
@@ -474,6 +479,11 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
474
479
let ret = if complete { 0 } else { this. eval_libc_i32 ( "ERANGE" ) ? } ;
475
480
this. write_int ( ret, dest) ?;
476
481
}
482
+ "getpid" => {
483
+ let [ ] = this. check_shim ( abi, Abi :: C { unwind : false } , link_name, args) ?;
484
+ let result = this. getpid ( ) ?;
485
+ this. write_scalar ( Scalar :: from_i32 ( result) , dest) ?;
486
+ }
477
487
478
488
// Incomplete shims that we "stub out" just to get pre-main initialization code to work.
479
489
// These shims are enabled only when the caller is in the standard library.
@@ -500,9 +510,10 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
500
510
this. write_null ( dest) ?;
501
511
}
502
512
503
- // Querying system information
504
- "pthread_attr_getstack" => {
505
- // We don't support "pthread_attr_setstack", so we just pretend all stacks have the same values here. Hence we can mostly ignore the input `attr_place`.
513
+ "pthread_attr_getstack"
514
+ if this. frame_in_std ( ) => {
515
+ // We don't support "pthread_attr_setstack", so we just pretend all stacks have the same values here.
516
+ // Hence we can mostly ignore the input `attr_place`.
506
517
let [ attr_place, addr_place, size_place] =
507
518
this. check_shim ( abi, Abi :: C { unwind : false } , link_name, args) ?;
508
519
let _attr_place = this. deref_operand ( attr_place) ?;
@@ -535,10 +546,11 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
535
546
this. write_null ( dest) ?;
536
547
}
537
548
538
- "getpid" => {
539
- let [ ] = this. check_shim ( abi, Abi :: C { unwind : false } , link_name, args) ?;
540
- let result = this. getpid ( ) ?;
541
- this. write_scalar ( Scalar :: from_i32 ( result) , dest) ?;
549
+ "getuid"
550
+ if this. frame_in_std ( ) => {
551
+ let [ ] = this. check_shim ( abi, Abi :: C { unwind : false } , link_name, args) ?;
552
+ // FOr now, just pretend we always have this fixed UID.
553
+ this. write_int ( super :: UID , dest) ?;
542
554
}
543
555
544
556
// Platform-specific shims
0 commit comments