Skip to content

Commit 53982b6

Browse files
committed
rollup merge of rust-lang#19787: akiss77/fix-i8-c_char
On AArch64, libc::c_char is u8. There are some places in the code where i8 is assumed, which causes compilation errors. (AArch64 is not officially supported yet, but this change does not hurt any other targets and makes the code future-proof.)
2 parents 0b214bf + a28d16a commit 53982b6

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

src/librustc_trans/back/lto.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ pub fn run(sess: &session::Session, llmod: ModuleRef,
140140
// Internalize everything but the reachable symbols of the current module
141141
let cstrs: Vec<::std::c_str::CString> =
142142
reachable.iter().map(|s| s.to_c_str()).collect();
143-
let arr: Vec<*const i8> = cstrs.iter().map(|c| c.as_ptr()).collect();
143+
let arr: Vec<*const libc::c_char> = cstrs.iter().map(|c| c.as_ptr()).collect();
144144
let ptr = arr.as_ptr();
145145
unsafe {
146146
llvm::LLVMRustRunRestrictionPass(llmod,

src/librustrt/c_str.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,7 @@ mod tests {
603603
assert_eq!(*buf.offset(0), 'f' as libc::c_char);
604604
assert_eq!(*buf.offset(1), 'o' as libc::c_char);
605605
assert_eq!(*buf.offset(2), 'o' as libc::c_char);
606-
assert_eq!(*buf.offset(3), 0xffu8 as i8);
606+
assert_eq!(*buf.offset(3), 0xffu8 as libc::c_char);
607607
assert_eq!(*buf.offset(4), 0);
608608
}
609609
}

src/libstd/os.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ pub fn getenv_as_bytes(n: &str) -> Option<Vec<u8>> {
378378
if s.is_null() {
379379
None
380380
} else {
381-
Some(CString::new(s as *const i8, false).as_bytes_no_nul().to_vec())
381+
Some(CString::new(s as *const libc::c_char, false).as_bytes_no_nul().to_vec())
382382
}
383383
})
384384
}

src/test/run-pass/variadic-ffi.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ extern {
1919
}
2020

2121
unsafe fn check<T>(expected: &str, f: |*mut c_char| -> T) {
22-
let mut x = [0i8, ..50];
22+
let mut x = [0 as c_char, ..50];
2323
f(&mut x[0] as *mut c_char);
2424
let res = CString::new(&x[0], false);
2525
assert_eq!(expected, res.as_str().unwrap());

0 commit comments

Comments
 (0)