libc::c_char is not necessarily i8
This commit is contained in:
parent
9146a919b6
commit
a28d16a751
@ -144,7 +144,7 @@ pub fn run(sess: &session::Session, llmod: ModuleRef,
|
||||
// Internalize everything but the reachable symbols of the current module
|
||||
let cstrs: Vec<::std::c_str::CString> =
|
||||
reachable.iter().map(|s| s.to_c_str()).collect();
|
||||
let arr: Vec<*const i8> = cstrs.iter().map(|c| c.as_ptr()).collect();
|
||||
let arr: Vec<*const libc::c_char> = cstrs.iter().map(|c| c.as_ptr()).collect();
|
||||
let ptr = arr.as_ptr();
|
||||
unsafe {
|
||||
llvm::LLVMRustRunRestrictionPass(llmod,
|
||||
|
@ -578,7 +578,7 @@ mod tests {
|
||||
assert_eq!(*buf.offset(0), 'f' as libc::c_char);
|
||||
assert_eq!(*buf.offset(1), 'o' as libc::c_char);
|
||||
assert_eq!(*buf.offset(2), 'o' as libc::c_char);
|
||||
assert_eq!(*buf.offset(3), 0xffu8 as i8);
|
||||
assert_eq!(*buf.offset(3), 0xffu8 as libc::c_char);
|
||||
assert_eq!(*buf.offset(4), 0);
|
||||
}
|
||||
}
|
||||
|
@ -374,7 +374,7 @@ pub fn getenv_as_bytes(n: &str) -> Option<Vec<u8>> {
|
||||
if s.is_null() {
|
||||
None
|
||||
} else {
|
||||
Some(CString::new(s as *const i8, false).as_bytes_no_nul().to_vec())
|
||||
Some(CString::new(s as *const libc::c_char, false).as_bytes_no_nul().to_vec())
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ extern {
|
||||
}
|
||||
|
||||
unsafe fn check<T>(expected: &str, f: |*mut c_char| -> T) {
|
||||
let mut x = [0i8, ..50];
|
||||
let mut x = [0 as c_char, ..50];
|
||||
f(&mut x[0] as *mut c_char);
|
||||
let res = CString::new(&x[0], false);
|
||||
assert_eq!(expected, res.as_str().unwrap());
|
||||
|
Loading…
x
Reference in New Issue
Block a user