diff --git a/src/shims/unix/freebsd/foreign_items.rs b/src/shims/unix/freebsd/foreign_items.rs index 7c843e106e..fe7d4641a9 100644 --- a/src/shims/unix/freebsd/foreign_items.rs +++ b/src/shims/unix/freebsd/foreign_items.rs @@ -3,6 +3,7 @@ use rustc_target::spec::abi::Abi; use crate::*; use shims::foreign_items::EmulateForeignItemResult; +use shims::unix::fs::EvalContextExt as _; use shims::unix::thread::EvalContextExt as _; pub fn is_dyn_sym(_name: &str) -> bool { @@ -62,6 +63,15 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { this.gen_random(ptr, len)?; this.write_scalar(Scalar::from_target_usize(len, this), dest)?; } + "ftruncate" => { + if this.tcx.sess.target.pointer_width == 32 { + throw_unsup_format!("`ftruncate` is not supported on 32 bits",); + } + let [fd, length] = + this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?; + let result = this.ftruncate64(fd, length)?; + this.write_scalar(result, dest)?; + } // errno "__error" => { diff --git a/tests/pass-dep/shims/libc-misc.rs b/tests/pass-dep/shims/libc-misc.rs index de1acb13cb..e9f9b15795 100644 --- a/tests/pass-dep/shims/libc-misc.rs +++ b/tests/pass-dep/shims/libc-misc.rs @@ -238,7 +238,7 @@ fn test_isatty() { } } -#[cfg(not(target_os = "freebsd"))] +#[cfg(not(all(target_os = "freebsd", pointer_width = "32")))] fn test_posix_mkstemp() { use std::ffi::CString; use std::ffi::OsStr; @@ -406,7 +406,7 @@ fn test_reallocarray() { fn main() { test_posix_gettimeofday(); - #[cfg(not(target_os = "freebsd"))] // FIXME we should support this on FreeBSD as well + #[cfg(not(all(target_os = "freebsd", pointer_width = "32")))] test_posix_mkstemp(); test_posix_realpath_alloc();