about summary refs log tree commit diff
diff options
context:
space:
mode:
authorBrian Anderson <banderson@mozilla.com>2014-12-13 18:24:05 -0800
committerBrian Anderson <banderson@mozilla.com>2014-12-15 06:45:35 -0800
commit53982b64f33676baf7d301d0938b8bb47bd904cc (patch)
treea5db7543d000534f5960396f8f5cbe22cc5dac62
parent0b214bfee039d7857c30a1b398dbc513d140cef1 (diff)
parenta28d16a7518eab8411eed2dd1de5c248a2a3e52c (diff)
rollup merge of #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.)
-rw-r--r--src/librustc_trans/back/lto.rs2
-rw-r--r--src/librustrt/c_str.rs2
-rw-r--r--src/libstd/os.rs2
-rw-r--r--src/test/run-pass/variadic-ffi.rs2
4 files changed, 4 insertions, 4 deletions
diff --git a/src/librustc_trans/back/lto.rs b/src/librustc_trans/back/lto.rs
index fb4d6de5f28..b9357280d06 100644
--- a/src/librustc_trans/back/lto.rs
+++ b/src/librustc_trans/back/lto.rs
@@ -140,7 +140,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,
diff --git a/src/librustrt/c_str.rs b/src/librustrt/c_str.rs
index bba81383f7b..56548344460 100644
--- a/src/librustrt/c_str.rs
+++ b/src/librustrt/c_str.rs
@@ -603,7 +603,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);
         }
     }
diff --git a/src/libstd/os.rs b/src/libstd/os.rs
index a8d854a7555..414ed87cfe4 100644
--- a/src/libstd/os.rs
+++ b/src/libstd/os.rs
@@ -378,7 +378,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())
             }
         })
     }
diff --git a/src/test/run-pass/variadic-ffi.rs b/src/test/run-pass/variadic-ffi.rs
index 570b881650a..aa71de2123c 100644
--- a/src/test/run-pass/variadic-ffi.rs
+++ b/src/test/run-pass/variadic-ffi.rs
@@ -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());