Skip to content

Commit 58278ca

Browse files
committed
Work around bugs in 32-bit enum FFI
cc #10308
1 parent 69aa114 commit 58278ca

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

src/librustuv/tty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ impl RtioTTY for TtyWatcher {
8888
}
8989

9090
fn isatty(&self) -> bool {
91-
unsafe { uvll::uv_guess_handle(self.fd) == uvll::UV_TTY }
91+
unsafe { uvll::guess_handle(self.fd) == uvll::UV_TTY as libc::c_int }
9292
}
9393
}
9494

src/librustuv/uvll.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -671,6 +671,11 @@ pub unsafe fn populate_stat(req_in: *uv_fs_t, stat_out: *uv_stat_t) {
671671

672672
rust_uv_populate_uv_stat(req_in, stat_out)
673673
}
674+
pub unsafe fn guess_handle(handle: c_int) -> c_int {
675+
#[fixed_stack_segment]; #[inline(never)];
676+
677+
rust_uv_guess_handle(handle)
678+
}
674679

675680

676681
// uv_support is the result of compiling rust_uv.cpp
@@ -728,6 +733,7 @@ extern {
728733
fn rust_set_stdio_container_stream(c: *uv_stdio_container_t,
729734
stream: *uv_stream_t);
730735
fn rust_uv_process_pid(p: *uv_process_t) -> c_int;
736+
fn rust_uv_guess_handle(fd: c_int) -> c_int;
731737
}
732738

733739
// generic uv functions
@@ -861,7 +867,6 @@ externfn!(fn uv_tty_init(l: *uv_loop_t, tty: *uv_tty_t, fd: c_int,
861867
externfn!(fn uv_tty_set_mode(tty: *uv_tty_t, mode: c_int) -> c_int)
862868
externfn!(fn uv_tty_get_winsize(tty: *uv_tty_t, width: *c_int,
863869
height: *c_int) -> c_int)
864-
externfn!(fn uv_guess_handle(fd: c_int) -> uv_handle_type)
865870

866871
// signals
867872
externfn!(fn uv_signal_init(loop_: *uv_loop_t, handle: *uv_signal_t) -> c_int)

src/rt/rust_uv.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,3 +334,8 @@ extern "C" int
334334
rust_uv_process_pid(uv_process_t* p) {
335335
return p->pid;
336336
}
337+
338+
extern "C" int
339+
rust_uv_guess_handle(int fd) {
340+
return uv_guess_handle(fd);
341+
}

0 commit comments

Comments
 (0)