Skip to content

Commit

Permalink
libc-misc test freebsd fixes attempt
Browse files Browse the repository at this point in the history
  • Loading branch information
devnexen committed Nov 18, 2023
1 parent 1d4e6e7 commit c1e48a9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
10 changes: 10 additions & 0 deletions src/shims/unix/freebsd/foreign_items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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" => {
Expand Down
4 changes: 2 additions & 2 deletions tests/pass-dep/shims/libc-misc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit c1e48a9

Please sign in to comment.