aboutsummaryrefslogtreecommitdiffstats
path: root/components/servo/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'components/servo/main.rs')
-rw-r--r--components/servo/main.rs39
1 files changed, 22 insertions, 17 deletions
diff --git a/components/servo/main.rs b/components/servo/main.rs
index f2fbf67dfb3..98463ee91a6 100644
--- a/components/servo/main.rs
+++ b/components/servo/main.rs
@@ -2,8 +2,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-#![feature(phase)]
-
#![deny(unused_imports)]
#![deny(unused_variables)]
@@ -23,7 +21,7 @@ extern crate "glfw_app" as app;
extern crate compositing;
#[cfg(target_os="android")]
-#[phase(plugin, link)]
+#[macro_use]
extern crate android_glue;
#[cfg(target_os="android")]
@@ -49,7 +47,7 @@ struct BrowserWrapper {
}
#[cfg(target_os="android")]
-android_start!(main)
+android_start!(main);
#[cfg(target_os="android")]
fn get_args() -> Vec<String> {
@@ -65,29 +63,36 @@ fn get_args() -> Vec<String> {
}
#[cfg(target_os="android")]
+struct FilePtr(*mut libc::types::common::c95::FILE);
+
+#[cfg(target_os="android")]
+unsafe impl Send for FilePtr {}
+
+#[cfg(target_os="android")]
fn redirect_output(file_no: c_int) {
use libc::funcs::posix88::unistd::{pipe, dup2};
use libc::funcs::posix88::stdio::fdopen;
- use libc::c_char;
use libc::funcs::c95::stdio::fgets;
+ use servo_util::task::spawn_named;
use std::mem;
- use std::c_str::CString;
+ use std::ffi::CString;
+ use std::str::from_utf8;
unsafe {
- let mut pipes: [c_int, ..2] = [ 0, 0 ];
+ let mut pipes: [c_int; 2] = [ 0, 0 ];
pipe(pipes.as_mut_ptr());
dup2(pipes[1], file_no);
- let input_file = "r".with_c_str(|mode| {
- fdopen(pipes[0], mode)
- });
- spawn(proc() {
+ let mode = CString::from_slice("r".as_bytes());
+ let input_file = FilePtr(fdopen(pipes[0], mode.as_ptr()));
+ spawn_named("android-logger".to_owned(), move || {
loop {
- let mut read_buffer: [c_char, ..1024] = mem::zeroed();
- fgets(read_buffer.as_mut_ptr(), read_buffer.len() as i32, input_file);
- let cs = CString::new(read_buffer.as_ptr(), false);
- match cs.as_str() {
- Some(s) => android_glue::write_log(s),
- None => {},
+ let mut read_buffer: [u8; 1024] = mem::zeroed();
+ let FilePtr(input_file) = input_file;
+ fgets(read_buffer.as_mut_ptr() as *mut i8, read_buffer.len() as i32, input_file);
+ let cs = CString::from_slice(&read_buffer);
+ match from_utf8(cs.as_bytes()) {
+ Ok(s) => android_glue::write_log(s),
+ _ => {}
}
}
});