Skip to content

Commit

Permalink
Work around bugs in 32-bit enum FFI
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcrichton committed Nov 10, 2013
1 parent 1bdaea8 commit 0df8b00
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/librustuv/tty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ impl RtioTTY for TtyWatcher {
}

fn isatty(&self) -> bool {
unsafe { uvll::uv_guess_handle(self.fd) == uvll::UV_TTY }
unsafe { uvll::guess_handle(self.fd) == uvll::UV_TTY as libc::c_int }
}
}

Expand Down
7 changes: 6 additions & 1 deletion src/librustuv/uvll.rs
Original file line number Diff line number Diff line change
Expand Up @@ -671,6 +671,11 @@ pub unsafe fn populate_stat(req_in: *uv_fs_t, stat_out: *uv_stat_t) {

rust_uv_populate_uv_stat(req_in, stat_out)
}
pub unsafe fn guess_handle(handle: c_int) -> c_int {
#[fixed_stack_segment]; #[inline(never)];

rust_uv_guess_handle(handle)
}


// uv_support is the result of compiling rust_uv.cpp
Expand Down Expand Up @@ -728,6 +733,7 @@ extern {
fn rust_set_stdio_container_stream(c: *uv_stdio_container_t,
stream: *uv_stream_t);
fn rust_uv_process_pid(p: *uv_process_t) -> c_int;
fn rust_uv_guess_handle(fd: c_int) -> c_int;
}

// generic uv functions
Expand Down Expand Up @@ -861,7 +867,6 @@ externfn!(fn uv_tty_init(l: *uv_loop_t, tty: *uv_tty_t, fd: c_int,
externfn!(fn uv_tty_set_mode(tty: *uv_tty_t, mode: c_int) -> c_int)
externfn!(fn uv_tty_get_winsize(tty: *uv_tty_t, width: *c_int,
height: *c_int) -> c_int)
externfn!(fn uv_guess_handle(fd: c_int) -> uv_handle_type)

// signals
externfn!(fn uv_signal_init(loop_: *uv_loop_t, handle: *uv_signal_t) -> c_int)
Expand Down
5 changes: 5 additions & 0 deletions src/rt/rust_uv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -334,3 +334,8 @@ extern "C" int
rust_uv_process_pid(uv_process_t* p) {
return p->pid;
}

extern "C" int
rust_uv_guess_handle(int fd) {
return uv_guess_handle(fd);
}

0 comments on commit 0df8b00

Please sign in to comment.