Use pointers to c_char
instead of i8
in miri_host_to_target_path
This makes sure that the interface of `miri_host_to_target_path` is compatible with `CStr` for targets where `c_char` is unsigned (such as ARM). This commit changes the signature of `miri_host_to_target_path` in the README and in all test cases.
This commit is contained in:
parent
a80f5272c6
commit
d4d7edfdf3
@ -590,7 +590,7 @@ extern "Rust" {
|
||||
/// `out` must point to at least `out_size` many bytes, and the result will be stored there
|
||||
/// with a null terminator.
|
||||
/// Returns 0 if the `out` buffer was large enough, and the required size otherwise.
|
||||
fn miri_host_to_target_path(path: *const i8, out: *mut i8, out_size: usize) -> usize;
|
||||
fn miri_host_to_target_path(path: *const c_char, out: *mut c_char, out_size: usize) -> usize;
|
||||
}
|
||||
```
|
||||
|
||||
|
@ -23,7 +23,7 @@ fn main() {
|
||||
// (We rely on the test runner to always disable isolation when passing no arguments.)
|
||||
if std::env::args().len() <= 1 {
|
||||
fn host_to_target_path(path: String) -> PathBuf {
|
||||
use std::ffi::{CStr, CString};
|
||||
use std::ffi::{c_char, CStr, CString};
|
||||
|
||||
let path = CString::new(path).unwrap();
|
||||
let mut out = Vec::with_capacity(1024);
|
||||
@ -31,8 +31,8 @@ fn main() {
|
||||
unsafe {
|
||||
extern "Rust" {
|
||||
fn miri_host_to_target_path(
|
||||
path: *const i8,
|
||||
out: *mut i8,
|
||||
path: *const c_char,
|
||||
out: *mut c_char,
|
||||
out_size: usize,
|
||||
) -> usize;
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ fn main() {
|
||||
println!("subcrate running");
|
||||
|
||||
fn host_to_target_path(path: String) -> PathBuf {
|
||||
use std::ffi::{CStr, CString};
|
||||
use std::ffi::{c_char, CStr, CString};
|
||||
|
||||
let path = CString::new(path).unwrap();
|
||||
let mut out = Vec::with_capacity(1024);
|
||||
@ -13,8 +13,8 @@ fn main() {
|
||||
unsafe {
|
||||
extern "Rust" {
|
||||
fn miri_host_to_target_path(
|
||||
path: *const i8,
|
||||
out: *mut i8,
|
||||
path: *const c_char,
|
||||
out: *mut c_char,
|
||||
out_size: usize,
|
||||
) -> usize;
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ fn main() {
|
||||
println!("subcrate testing");
|
||||
|
||||
fn host_to_target_path(path: String) -> PathBuf {
|
||||
use std::ffi::{CStr, CString};
|
||||
use std::ffi::{c_char, CStr, CString};
|
||||
|
||||
let path = CString::new(path).unwrap();
|
||||
let mut out = Vec::with_capacity(1024);
|
||||
@ -16,8 +16,8 @@ fn main() {
|
||||
unsafe {
|
||||
extern "Rust" {
|
||||
fn miri_host_to_target_path(
|
||||
path: *const i8,
|
||||
out: *mut i8,
|
||||
path: *const c_char,
|
||||
out: *mut c_char,
|
||||
out_size: usize,
|
||||
) -> usize;
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
#![feature(io_error_uncategorized)]
|
||||
|
||||
use std::convert::TryInto;
|
||||
use std::ffi::{CStr, CString};
|
||||
use std::ffi::{c_char, CStr, CString};
|
||||
use std::fs::{canonicalize, remove_dir_all, remove_file, File};
|
||||
use std::io::{Error, ErrorKind, Write};
|
||||
use std::os::unix::ffi::OsStrExt;
|
||||
@ -31,7 +31,11 @@ fn tmp() -> PathBuf {
|
||||
|
||||
unsafe {
|
||||
extern "Rust" {
|
||||
fn miri_host_to_target_path(path: *const i8, out: *mut i8, out_size: usize) -> usize;
|
||||
fn miri_host_to_target_path(
|
||||
path: *const c_char,
|
||||
out: *mut c_char,
|
||||
out_size: usize,
|
||||
) -> usize;
|
||||
}
|
||||
let ret = miri_host_to_target_path(path.as_ptr(), out.as_mut_ptr(), out.capacity());
|
||||
assert_eq!(ret, 0);
|
||||
|
@ -7,7 +7,7 @@ use std::os::unix::io::AsRawFd;
|
||||
use std::path::PathBuf;
|
||||
|
||||
fn tmp() -> PathBuf {
|
||||
use std::ffi::{CStr, CString};
|
||||
use std::ffi::{c_char, CStr, CString};
|
||||
|
||||
let path = std::env::var("MIRI_TEMP")
|
||||
.unwrap_or_else(|_| std::env::temp_dir().into_os_string().into_string().unwrap());
|
||||
@ -17,7 +17,11 @@ fn tmp() -> PathBuf {
|
||||
|
||||
unsafe {
|
||||
extern "Rust" {
|
||||
fn miri_host_to_target_path(path: *const i8, out: *mut i8, out_size: usize) -> usize;
|
||||
fn miri_host_to_target_path(
|
||||
path: *const c_char,
|
||||
out: *mut c_char,
|
||||
out_size: usize,
|
||||
) -> usize;
|
||||
}
|
||||
let ret = miri_host_to_target_path(path.as_ptr(), out.as_mut_ptr(), out.capacity());
|
||||
assert_eq!(ret, 0);
|
||||
|
@ -6,7 +6,7 @@
|
||||
#![feature(is_terminal)]
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::ffi::OsString;
|
||||
use std::ffi::{c_char, OsString};
|
||||
use std::fs::{
|
||||
canonicalize, create_dir, read_dir, read_link, remove_dir, remove_dir_all, remove_file, rename,
|
||||
File, OpenOptions,
|
||||
@ -39,7 +39,11 @@ fn host_to_target_path(path: String) -> PathBuf {
|
||||
|
||||
unsafe {
|
||||
extern "Rust" {
|
||||
fn miri_host_to_target_path(path: *const i8, out: *mut i8, out_size: usize) -> usize;
|
||||
fn miri_host_to_target_path(
|
||||
path: *const c_char,
|
||||
out: *mut c_char,
|
||||
out_size: usize,
|
||||
) -> usize;
|
||||
}
|
||||
let ret = miri_host_to_target_path(path.as_ptr(), out.as_mut_ptr(), out.capacity());
|
||||
assert_eq!(ret, 0);
|
||||
|
Loading…
x
Reference in New Issue
Block a user