// Align must be power of 2, and also at least ptr-sized (POSIX rules).
// But failure to adhere to this is not UB, it's an error condition.
if !align.is_power_of_two() || align < this.pointer_size().bytes() {
- let einval = this.eval_libc_i32("EINVAL")?;
+ let einval = this.eval_libc_i32("EINVAL");
this.write_int(einval, dest)?;
} else {
if size == 0 {
// FIXME: Which of these are POSIX, and which are GNU/Linux?
// At least the names seem to all also exist on macOS.
let sysconfs: &[(&str, fn(&MiriInterpCx<'_, '_>) -> Scalar<Provenance>)] = &[
- ("_SC_PAGESIZE", |this| Scalar::from_int(PAGE_SIZE, this.pointer_size())),
+ ("_SC_PAGESIZE", |this| Scalar::from_int(this.machine.page_size, this.pointer_size())),
("_SC_NPROCESSORS_CONF", |this| Scalar::from_int(this.machine.num_cpus, this.pointer_size())),
("_SC_NPROCESSORS_ONLN", |this| Scalar::from_int(this.machine.num_cpus, this.pointer_size())),
// 512 seems to be a reasonable default. The value is not critical, in
];
let mut result = None;
for &(sysconf_name, value) in sysconfs {
- let sysconf_name = this.eval_libc_i32(sysconf_name)?;
+ let sysconf_name = this.eval_libc_i32(sysconf_name);
if sysconf_name == name {
result = Some(value(this));
break;
None => format!("<unknown errnum in strerror_r: {errnum}>"),
};
let (complete, _) = this.write_os_str_to_c_str(OsStr::new(&formatted), buf, buflen)?;
- let ret = if complete { 0 } else { this.eval_libc_i32("ERANGE")? };
+ let ret = if complete { 0 } else { this.eval_libc_i32("ERANGE") };
this.write_int(ret, dest)?;
}
"getpid" => {
if this.frame_in_std() => {
let [_attr, guard_size] = this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;
let guard_size = this.deref_operand(guard_size)?;
- let guard_size_layout = this.libc_ty_layout("size_t")?;
- this.write_scalar(Scalar::from_uint(crate::PAGE_SIZE, guard_size_layout.size), &guard_size.into())?;
+ let guard_size_layout = this.libc_ty_layout("size_t");
+ this.write_scalar(Scalar::from_uint(this.machine.page_size, guard_size_layout.size), &guard_size.into())?;
// Return success (`0`).
this.write_null(dest)?;
let size_place = this.deref_operand(size_place)?;
this.write_scalar(
- Scalar::from_uint(STACK_ADDR, this.pointer_size()),
+ Scalar::from_uint(this.machine.stack_addr, this.pointer_size()),
&addr_place.into(),
)?;
this.write_scalar(
- Scalar::from_uint(STACK_SIZE, this.pointer_size()),
+ Scalar::from_uint(this.machine.stack_size, this.pointer_size()),
&size_place.into(),
)?;
this.write_null(dest)?;
} else {
this.write_null(&result.into())?;
- this.write_scalar(this.eval_libc("ERANGE")?, dest)?;
+ this.write_scalar(this.eval_libc("ERANGE"), dest)?;
}
}