1 // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
12 * Low-level bindings to the libuv library.
14 * This module contains a set of direct, 'bare-metal' wrappers around
17 * We're not bothering yet to redefine uv's structs as Rust structs
18 * because they are quite large and change often between versions.
19 * The maintenance burden is just too high. Instead we use the uv's
20 * `uv_handle_size` and `uv_req_size` to find the correct size of the
21 * structs and allocate them on the heap. This can be revisited later.
23 * There are also a collection of helper functions to ease interacting
24 * with the low-level API.
26 * As new functionality, existent in uv.h, is added to the rust stdlib,
27 * the mappings should be added in this module.
30 #[allow(non_camel_case_types)]; // C types
32 use std::libc::{size_t, c_int, c_uint, c_void, c_char, uintptr_t};
33 use std::libc::ssize_t;
34 use std::libc::{malloc, free};
39 pub use self::errors::*;
41 pub static OK: c_int = 0;
42 pub static EOF: c_int = -4095;
43 pub static UNKNOWN: c_int = -4094;
45 // uv-errno.h redefines error codes for windows, but not for unix...
51 pub static EACCES: c_int = -4093;
52 pub static ECONNREFUSED: c_int = -4079;
53 pub static ECONNRESET: c_int = -4078;
54 pub static ENOTCONN: c_int = -4054;
55 pub static EPIPE: c_int = -4048;
56 pub static ECONNABORTED: c_int = -4080;
63 pub static EACCES: c_int = -libc::EACCES;
64 pub static ECONNREFUSED: c_int = -libc::ECONNREFUSED;
65 pub static ECONNRESET: c_int = -libc::ECONNRESET;
66 pub static ENOTCONN: c_int = -libc::ENOTCONN;
67 pub static EPIPE: c_int = -libc::EPIPE;
68 pub static ECONNABORTED: c_int = -libc::ECONNABORTED;
71 pub static PROCESS_SETUID: c_int = 1 << 0;
72 pub static PROCESS_SETGID: c_int = 1 << 1;
73 pub static PROCESS_WINDOWS_VERBATIM_ARGUMENTS: c_int = 1 << 2;
74 pub static PROCESS_DETACHED: c_int = 1 << 3;
75 pub static PROCESS_WINDOWS_HIDE: c_int = 1 << 4;
77 pub static STDIO_IGNORE: c_int = 0x00;
78 pub static STDIO_CREATE_PIPE: c_int = 0x01;
79 pub static STDIO_INHERIT_FD: c_int = 0x02;
80 pub static STDIO_INHERIT_STREAM: c_int = 0x04;
81 pub static STDIO_READABLE_PIPE: c_int = 0x10;
82 pub static STDIO_WRITABLE_PIPE: c_int = 0x20;
84 // see libuv/include/uv-unix.h
91 // see libuv/include/uv-win.h
98 pub struct uv_process_options_t {
101 args: **libc::c_char,
105 stdio_count: libc::c_int,
106 stdio: *uv_stdio_container_t,
111 // These fields are private because they must be interfaced with through the
113 pub struct uv_stdio_container_t {
114 priv flags: libc::c_int,
115 priv stream: *uv_stream_t,
118 pub type uv_handle_t = c_void;
119 pub type uv_loop_t = c_void;
120 pub type uv_idle_t = c_void;
121 pub type uv_tcp_t = c_void;
122 pub type uv_udp_t = c_void;
123 pub type uv_connect_t = c_void;
124 pub type uv_connection_t = c_void;
125 pub type uv_write_t = c_void;
126 pub type uv_async_t = c_void;
127 pub type uv_timer_t = c_void;
128 pub type uv_stream_t = c_void;
129 pub type uv_fs_t = c_void;
130 pub type uv_udp_send_t = c_void;
131 pub type uv_getaddrinfo_t = c_void;
132 pub type uv_process_t = c_void;
133 pub type uv_pipe_t = c_void;
134 pub type uv_tty_t = c_void;
135 pub type uv_signal_t = c_void;
137 pub struct uv_timespec_t {
138 tv_sec: libc::c_long,
139 tv_nsec: libc::c_long
142 pub struct uv_stat_t {
143 st_dev: libc::uint64_t,
144 st_mode: libc::uint64_t,
145 st_nlink: libc::uint64_t,
146 st_uid: libc::uint64_t,
147 st_gid: libc::uint64_t,
148 st_rdev: libc::uint64_t,
149 st_ino: libc::uint64_t,
150 st_size: libc::uint64_t,
151 st_blksize: libc::uint64_t,
152 st_blocks: libc::uint64_t,
153 st_flags: libc::uint64_t,
154 st_gen: libc::uint64_t,
155 st_atim: uv_timespec_t,
156 st_mtim: uv_timespec_t,
157 st_ctim: uv_timespec_t,
158 st_birthtim: uv_timespec_t
162 pub fn new() -> uv_stat_t {
176 st_atim: uv_timespec_t { tv_sec: 0, tv_nsec: 0 },
177 st_mtim: uv_timespec_t { tv_sec: 0, tv_nsec: 0 },
178 st_ctim: uv_timespec_t { tv_sec: 0, tv_nsec: 0 },
179 st_birthtim: uv_timespec_t { tv_sec: 0, tv_nsec: 0 }
182 pub fn is_file(&self) -> bool {
183 ((self.st_mode) & libc::S_IFMT as libc::uint64_t) == libc::S_IFREG as libc::uint64_t
185 pub fn is_dir(&self) -> bool {
186 ((self.st_mode) & libc::S_IFMT as libc::uint64_t) == libc::S_IFDIR as libc::uint64_t
190 pub type uv_idle_cb = extern "C" fn(handle: *uv_idle_t,
192 pub type uv_alloc_cb = extern "C" fn(stream: *uv_stream_t,
193 suggested_size: size_t) -> uv_buf_t;
194 pub type uv_read_cb = extern "C" fn(stream: *uv_stream_t,
197 pub type uv_udp_send_cb = extern "C" fn(req: *uv_udp_send_t,
199 pub type uv_udp_recv_cb = extern "C" fn(handle: *uv_udp_t,
204 pub type uv_close_cb = extern "C" fn(handle: *uv_handle_t);
205 pub type uv_walk_cb = extern "C" fn(handle: *uv_handle_t,
207 pub type uv_async_cb = extern "C" fn(handle: *uv_async_t,
209 pub type uv_connect_cb = extern "C" fn(handle: *uv_connect_t,
211 pub type uv_connection_cb = extern "C" fn(handle: *uv_connection_t,
213 pub type uv_timer_cb = extern "C" fn(handle: *uv_timer_t,
215 pub type uv_write_cb = extern "C" fn(handle: *uv_write_t,
217 pub type uv_getaddrinfo_cb = extern "C" fn(req: *uv_getaddrinfo_t,
220 pub type uv_exit_cb = extern "C" fn(handle: *uv_process_t,
223 pub type uv_signal_cb = extern "C" fn(handle: *uv_signal_t,
225 pub type uv_fs_cb = extern "C" fn(req: *uv_fs_t);
227 pub type sockaddr = c_void;
228 pub type sockaddr_in = c_void;
229 pub type sockaddr_in6 = c_void;
230 pub type sockaddr_storage = c_void;
233 pub type socklen_t = c_int;
235 // XXX: This is a standard C type. Could probably be defined in libc
236 #[cfg(target_os = "android")]
237 #[cfg(target_os = "linux")]
238 pub struct addrinfo {
243 ai_addrlen: socklen_t,
249 #[cfg(target_os = "macos")]
250 #[cfg(target_os = "freebsd")]
251 pub struct addrinfo {
256 ai_addrlen: socklen_t,
263 pub struct addrinfo {
274 #[cfg(unix)] pub type uv_uid_t = libc::types::os::arch::posix88::uid_t;
275 #[cfg(unix)] pub type uv_gid_t = libc::types::os::arch::posix88::gid_t;
276 #[cfg(windows)] pub type uv_uid_t = libc::c_uchar;
277 #[cfg(windows)] pub type uv_gid_t = libc::c_uchar;
280 pub enum uv_handle_type {
304 pub enum uv_req_type {
317 // uv_req_type may have additional fields defined by UV_REQ_TYPE_PRIVATE.
318 // See UV_REQ_TYPE_PRIVATE at libuv/include/uv-win.h
321 pub enum uv_req_type {
343 pub enum uv_membership {
348 pub unsafe fn malloc_handle(handle: uv_handle_type) -> *c_void {
349 #[fixed_stack_segment]; #[inline(never)];
351 assert!(handle != UV_UNKNOWN_HANDLE && handle != UV_HANDLE_TYPE_MAX);
352 let size = rust_uv_handle_size(handle as uint);
353 let p = malloc(size);
354 assert!(p.is_not_null());
358 pub unsafe fn free_handle(v: *c_void) {
359 #[fixed_stack_segment]; #[inline(never)];
364 pub unsafe fn malloc_req(req: uv_req_type) -> *c_void {
365 #[fixed_stack_segment]; #[inline(never)];
367 assert!(req != UV_UNKNOWN_REQ && req != UV_REQ_TYPE_MAX);
368 let size = rust_uv_req_size(req as uint);
369 let p = malloc(size);
370 assert!(p.is_not_null());
374 pub unsafe fn free_req(v: *c_void) {
375 #[fixed_stack_segment]; #[inline(never)];
381 fn handle_sanity_check() {
382 #[fixed_stack_segment]; #[inline(never)];
384 assert_eq!(UV_HANDLE_TYPE_MAX as uint, rust_uv_handle_type_max());
389 fn request_sanity_check() {
390 #[fixed_stack_segment]; #[inline(never)];
392 assert_eq!(UV_REQ_TYPE_MAX as uint, rust_uv_req_type_max());
396 // XXX Event loops ignore SIGPIPE by default.
397 pub unsafe fn loop_new() -> *c_void {
398 #[fixed_stack_segment]; #[inline(never)];
400 return rust_uv_loop_new();
403 pub unsafe fn loop_delete(loop_handle: *c_void) {
404 #[fixed_stack_segment]; #[inline(never)];
406 rust_uv_loop_delete(loop_handle);
409 pub unsafe fn run(loop_handle: *c_void) {
410 #[fixed_stack_segment]; #[inline(never)];
412 rust_uv_run(loop_handle);
415 pub unsafe fn close<T>(handle: *T, cb: uv_close_cb) {
416 #[fixed_stack_segment]; #[inline(never)];
418 rust_uv_close(handle as *c_void, cb);
421 pub unsafe fn walk(loop_handle: *c_void, cb: uv_walk_cb, arg: *c_void) {
422 #[fixed_stack_segment]; #[inline(never)];
424 rust_uv_walk(loop_handle, cb, arg);
427 pub unsafe fn idle_init(loop_handle: *uv_loop_t, handle: *uv_idle_t) -> c_int {
428 #[fixed_stack_segment]; #[inline(never)];
430 rust_uv_idle_init(loop_handle, handle)
433 pub unsafe fn idle_start(handle: *uv_idle_t, cb: uv_idle_cb) -> c_int {
434 #[fixed_stack_segment]; #[inline(never)];
436 rust_uv_idle_start(handle, cb)
439 pub unsafe fn idle_stop(handle: *uv_idle_t) -> c_int {
440 #[fixed_stack_segment]; #[inline(never)];
442 rust_uv_idle_stop(handle)
445 pub unsafe fn udp_init(loop_handle: *uv_loop_t, handle: *uv_udp_t) -> c_int {
446 #[fixed_stack_segment]; #[inline(never)];
448 return rust_uv_udp_init(loop_handle, handle);
451 pub unsafe fn udp_bind(server: *uv_udp_t, addr: *sockaddr_in, flags: c_uint) -> c_int {
452 #[fixed_stack_segment]; #[inline(never)];
454 return rust_uv_udp_bind(server, addr, flags);
457 pub unsafe fn udp_bind6(server: *uv_udp_t, addr: *sockaddr_in6, flags: c_uint) -> c_int {
458 #[fixed_stack_segment]; #[inline(never)];
460 return rust_uv_udp_bind6(server, addr, flags);
463 pub unsafe fn udp_send<T>(req: *uv_udp_send_t, handle: *T, buf_in: &[uv_buf_t],
464 addr: *sockaddr_in, cb: uv_udp_send_cb) -> c_int {
465 #[fixed_stack_segment]; #[inline(never)];
467 let buf_ptr = vec::raw::to_ptr(buf_in);
468 let buf_cnt = buf_in.len() as i32;
469 return rust_uv_udp_send(req, handle as *c_void, buf_ptr, buf_cnt, addr, cb);
472 pub unsafe fn udp_send6<T>(req: *uv_udp_send_t, handle: *T, buf_in: &[uv_buf_t],
473 addr: *sockaddr_in6, cb: uv_udp_send_cb) -> c_int {
474 #[fixed_stack_segment]; #[inline(never)];
476 let buf_ptr = vec::raw::to_ptr(buf_in);
477 let buf_cnt = buf_in.len() as i32;
478 return rust_uv_udp_send6(req, handle as *c_void, buf_ptr, buf_cnt, addr, cb);
481 pub unsafe fn udp_recv_start(server: *uv_udp_t, on_alloc: uv_alloc_cb,
482 on_recv: uv_udp_recv_cb) -> c_int {
483 #[fixed_stack_segment]; #[inline(never)];
485 return rust_uv_udp_recv_start(server, on_alloc, on_recv);
488 pub unsafe fn udp_recv_stop(server: *uv_udp_t) -> c_int {
489 #[fixed_stack_segment]; #[inline(never)];
491 return rust_uv_udp_recv_stop(server);
494 pub unsafe fn get_udp_handle_from_send_req(send_req: *uv_udp_send_t) -> *uv_udp_t {
495 #[fixed_stack_segment]; #[inline(never)];
497 return rust_uv_get_udp_handle_from_send_req(send_req);
500 pub unsafe fn udp_getsockname(handle: *uv_udp_t, name: *sockaddr_storage) -> c_int {
501 #[fixed_stack_segment]; #[inline(never)];
503 return rust_uv_udp_getsockname(handle, name);
506 pub unsafe fn udp_set_membership(handle: *uv_udp_t, multicast_addr: *c_char,
507 interface_addr: *c_char, membership: uv_membership) -> c_int {
508 #[fixed_stack_segment]; #[inline(never)];
510 return rust_uv_udp_set_membership(handle, multicast_addr, interface_addr, membership as c_int);
513 pub unsafe fn udp_set_multicast_loop(handle: *uv_udp_t, on: c_int) -> c_int {
514 #[fixed_stack_segment]; #[inline(never)];
516 return rust_uv_udp_set_multicast_loop(handle, on);
519 pub unsafe fn udp_set_multicast_ttl(handle: *uv_udp_t, ttl: c_int) -> c_int {
520 #[fixed_stack_segment]; #[inline(never)];
522 return rust_uv_udp_set_multicast_ttl(handle, ttl);
525 pub unsafe fn udp_set_ttl(handle: *uv_udp_t, ttl: c_int) -> c_int {
526 #[fixed_stack_segment]; #[inline(never)];
528 return rust_uv_udp_set_ttl(handle, ttl);
531 pub unsafe fn udp_set_broadcast(handle: *uv_udp_t, on: c_int) -> c_int {
532 #[fixed_stack_segment]; #[inline(never)];
534 return rust_uv_udp_set_broadcast(handle, on);
537 pub unsafe fn tcp_init(loop_handle: *c_void, handle: *uv_tcp_t) -> c_int {
538 #[fixed_stack_segment]; #[inline(never)];
540 return rust_uv_tcp_init(loop_handle, handle);
543 pub unsafe fn tcp_connect(connect_ptr: *uv_connect_t, tcp_handle_ptr: *uv_tcp_t,
544 addr_ptr: *sockaddr_in, after_connect_cb: uv_connect_cb) -> c_int {
545 #[fixed_stack_segment]; #[inline(never)];
547 return rust_uv_tcp_connect(connect_ptr, tcp_handle_ptr, after_connect_cb, addr_ptr);
550 pub unsafe fn tcp_connect6(connect_ptr: *uv_connect_t, tcp_handle_ptr: *uv_tcp_t,
551 addr_ptr: *sockaddr_in6, after_connect_cb: uv_connect_cb) -> c_int {
552 #[fixed_stack_segment]; #[inline(never)];
554 return rust_uv_tcp_connect6(connect_ptr, tcp_handle_ptr, after_connect_cb, addr_ptr);
557 pub unsafe fn tcp_bind(tcp_server_ptr: *uv_tcp_t, addr_ptr: *sockaddr_in) -> c_int {
558 #[fixed_stack_segment]; #[inline(never)];
560 return rust_uv_tcp_bind(tcp_server_ptr, addr_ptr);
563 pub unsafe fn tcp_bind6(tcp_server_ptr: *uv_tcp_t, addr_ptr: *sockaddr_in6) -> c_int {
564 #[fixed_stack_segment]; #[inline(never)];
566 return rust_uv_tcp_bind6(tcp_server_ptr, addr_ptr);
569 pub unsafe fn tcp_getpeername(tcp_handle_ptr: *uv_tcp_t, name: *sockaddr_storage) -> c_int {
570 #[fixed_stack_segment]; #[inline(never)];
572 return rust_uv_tcp_getpeername(tcp_handle_ptr, name);
575 pub unsafe fn tcp_getsockname(handle: *uv_tcp_t, name: *sockaddr_storage) -> c_int {
576 #[fixed_stack_segment]; #[inline(never)];
578 return rust_uv_tcp_getsockname(handle, name);
581 pub unsafe fn tcp_nodelay(handle: *uv_tcp_t, enable: c_int) -> c_int {
582 #[fixed_stack_segment]; #[inline(never)];
584 return rust_uv_tcp_nodelay(handle, enable);
587 pub unsafe fn tcp_keepalive(handle: *uv_tcp_t, enable: c_int, delay: c_uint) -> c_int {
588 #[fixed_stack_segment]; #[inline(never)];
590 return rust_uv_tcp_keepalive(handle, enable, delay);
593 pub unsafe fn tcp_simultaneous_accepts(handle: *uv_tcp_t, enable: c_int) -> c_int {
594 #[fixed_stack_segment]; #[inline(never)];
596 return rust_uv_tcp_simultaneous_accepts(handle, enable);
599 pub unsafe fn listen<T>(stream: *T, backlog: c_int,
600 cb: uv_connection_cb) -> c_int {
601 #[fixed_stack_segment]; #[inline(never)];
603 return rust_uv_listen(stream as *c_void, backlog, cb);
606 pub unsafe fn accept(server: *c_void, client: *c_void) -> c_int {
607 #[fixed_stack_segment]; #[inline(never)];
609 return rust_uv_accept(server as *c_void, client as *c_void);
612 pub unsafe fn write<T>(req: *uv_write_t,
615 cb: uv_write_cb) -> c_int {
616 #[fixed_stack_segment]; #[inline(never)];
618 let buf_ptr = vec::raw::to_ptr(buf_in);
619 let buf_cnt = buf_in.len() as i32;
620 return rust_uv_write(req as *c_void, stream as *c_void, buf_ptr, buf_cnt, cb);
622 pub unsafe fn read_start(stream: *uv_stream_t,
623 on_alloc: uv_alloc_cb,
624 on_read: uv_read_cb) -> c_int {
625 #[fixed_stack_segment]; #[inline(never)];
627 return rust_uv_read_start(stream as *c_void, on_alloc, on_read);
630 pub unsafe fn read_stop(stream: *uv_stream_t) -> c_int {
631 #[fixed_stack_segment]; #[inline(never)];
633 return rust_uv_read_stop(stream as *c_void);
636 pub unsafe fn strerror(err: c_int) -> *c_char {
637 #[fixed_stack_segment]; #[inline(never)];
638 return rust_uv_strerror(err);
640 pub unsafe fn err_name(err: c_int) -> *c_char {
641 #[fixed_stack_segment]; #[inline(never)];
642 return rust_uv_err_name(err);
645 pub unsafe fn async_init(loop_handle: *c_void,
646 async_handle: *uv_async_t,
647 cb: uv_async_cb) -> c_int {
648 #[fixed_stack_segment]; #[inline(never)];
650 return rust_uv_async_init(loop_handle, async_handle, cb);
653 pub unsafe fn async_send(async_handle: *uv_async_t) {
654 #[fixed_stack_segment]; #[inline(never)];
656 return rust_uv_async_send(async_handle);
658 pub unsafe fn buf_init(input: *u8, len: uint) -> uv_buf_t {
659 #[fixed_stack_segment]; #[inline(never)];
661 let out_buf = uv_buf_t { base: ptr::null(), len: 0 as size_t };
662 let out_buf_ptr = ptr::to_unsafe_ptr(&out_buf);
663 rust_uv_buf_init(out_buf_ptr, input, len as size_t);
667 pub unsafe fn timer_init(loop_ptr: *c_void, timer_ptr: *uv_timer_t) -> c_int {
668 #[fixed_stack_segment]; #[inline(never)];
670 return rust_uv_timer_init(loop_ptr, timer_ptr);
672 pub unsafe fn timer_start(timer_ptr: *uv_timer_t,
673 cb: uv_timer_cb, timeout: u64,
674 repeat: u64) -> c_int {
675 #[fixed_stack_segment]; #[inline(never)];
677 return rust_uv_timer_start(timer_ptr, cb, timeout, repeat);
679 pub unsafe fn timer_stop(timer_ptr: *uv_timer_t) -> c_int {
680 #[fixed_stack_segment]; #[inline(never)];
682 return rust_uv_timer_stop(timer_ptr);
685 pub unsafe fn is_ip4_addr(addr: *sockaddr) -> bool {
686 #[fixed_stack_segment]; #[inline(never)];
688 match rust_uv_is_ipv4_sockaddr(addr) { 0 => false, _ => true }
691 pub unsafe fn is_ip6_addr(addr: *sockaddr) -> bool {
692 #[fixed_stack_segment]; #[inline(never)];
694 match rust_uv_is_ipv6_sockaddr(addr) { 0 => false, _ => true }
697 pub unsafe fn malloc_ip4_addr(ip: &str, port: int) -> *sockaddr_in {
698 #[fixed_stack_segment]; #[inline(never)];
699 do ip.with_c_str |ip_buf| {
700 rust_uv_ip4_addrp(ip_buf as *u8, port as libc::c_int)
703 pub unsafe fn malloc_ip6_addr(ip: &str, port: int) -> *sockaddr_in6 {
704 #[fixed_stack_segment]; #[inline(never)];
705 do ip.with_c_str |ip_buf| {
706 rust_uv_ip6_addrp(ip_buf as *u8, port as libc::c_int)
710 pub unsafe fn malloc_sockaddr_storage() -> *sockaddr_storage {
711 #[fixed_stack_segment]; #[inline(never)];
713 rust_uv_malloc_sockaddr_storage()
716 pub unsafe fn free_sockaddr_storage(ss: *sockaddr_storage) {
717 #[fixed_stack_segment]; #[inline(never)];
719 rust_uv_free_sockaddr_storage(ss);
722 pub unsafe fn free_ip4_addr(addr: *sockaddr_in) {
723 #[fixed_stack_segment]; #[inline(never)];
725 rust_uv_free_ip4_addr(addr);
728 pub unsafe fn free_ip6_addr(addr: *sockaddr_in6) {
729 #[fixed_stack_segment]; #[inline(never)];
731 rust_uv_free_ip6_addr(addr);
734 pub unsafe fn ip4_name(addr: *sockaddr_in, dst: *u8, size: size_t) -> c_int {
735 #[fixed_stack_segment]; #[inline(never)];
737 return rust_uv_ip4_name(addr, dst, size);
740 pub unsafe fn ip6_name(addr: *sockaddr_in6, dst: *u8, size: size_t) -> c_int {
741 #[fixed_stack_segment]; #[inline(never)];
743 return rust_uv_ip6_name(addr, dst, size);
746 pub unsafe fn ip4_port(addr: *sockaddr_in) -> c_uint {
747 #[fixed_stack_segment]; #[inline(never)];
749 return rust_uv_ip4_port(addr);
752 pub unsafe fn ip6_port(addr: *sockaddr_in6) -> c_uint {
753 #[fixed_stack_segment]; #[inline(never)];
755 return rust_uv_ip6_port(addr);
758 pub unsafe fn fs_open(loop_ptr: *uv_loop_t, req: *uv_fs_t, path: *c_char, flags: int, mode: int,
760 #[fixed_stack_segment]; #[inline(never)];
762 rust_uv_fs_open(loop_ptr, req, path, flags as c_int, mode as c_int, cb)
765 pub unsafe fn fs_unlink(loop_ptr: *uv_loop_t, req: *uv_fs_t, path: *c_char,
767 #[fixed_stack_segment]; #[inline(never)];
769 rust_uv_fs_unlink(loop_ptr, req, path, cb)
771 pub unsafe fn fs_write(loop_ptr: *uv_loop_t, req: *uv_fs_t, fd: c_int, buf: *c_void,
772 len: uint, offset: i64, cb: *u8) -> c_int {
773 #[fixed_stack_segment]; #[inline(never)];
775 rust_uv_fs_write(loop_ptr, req, fd, buf, len as c_uint, offset, cb)
777 pub unsafe fn fs_read(loop_ptr: *uv_loop_t, req: *uv_fs_t, fd: c_int, buf: *c_void,
778 len: uint, offset: i64, cb: *u8) -> c_int {
779 #[fixed_stack_segment]; #[inline(never)];
781 rust_uv_fs_read(loop_ptr, req, fd, buf, len as c_uint, offset, cb)
783 pub unsafe fn fs_close(loop_ptr: *uv_loop_t, req: *uv_fs_t, fd: c_int,
785 #[fixed_stack_segment]; #[inline(never)];
787 rust_uv_fs_close(loop_ptr, req, fd, cb)
789 pub unsafe fn fs_stat(loop_ptr: *uv_loop_t, req: *uv_fs_t, path: *c_char, cb: *u8) -> c_int {
790 #[fixed_stack_segment]; #[inline(never)];
792 rust_uv_fs_stat(loop_ptr, req, path, cb)
794 pub unsafe fn fs_fstat(loop_ptr: *uv_loop_t, req: *uv_fs_t, fd: c_int, cb: *u8) -> c_int {
795 #[fixed_stack_segment]; #[inline(never)];
797 rust_uv_fs_fstat(loop_ptr, req, fd, cb)
799 pub unsafe fn fs_mkdir(loop_ptr: *uv_loop_t, req: *uv_fs_t, path: *c_char,
800 mode: c_int, cb: *u8) -> c_int {
801 #[fixed_stack_segment]; #[inline(never)];
803 rust_uv_fs_mkdir(loop_ptr, req, path, mode as c_int, cb)
805 pub unsafe fn fs_rmdir(loop_ptr: *uv_loop_t, req: *uv_fs_t, path: *c_char,
807 #[fixed_stack_segment]; #[inline(never)];
809 rust_uv_fs_rmdir(loop_ptr, req, path, cb)
811 pub unsafe fn fs_rename(loop_ptr: *uv_loop_t, req: *uv_fs_t, path: *c_char,
812 to: *c_char, cb: *u8) -> c_int {
813 #[fixed_stack_segment]; #[inline(never)];
815 rust_uv_fs_rename(loop_ptr, req, path, to, cb)
817 pub unsafe fn fs_chmod(loop_ptr: *uv_loop_t, req: *uv_fs_t, path: *c_char,
818 mode: c_int, cb: *u8) -> c_int {
819 #[fixed_stack_segment]; #[inline(never)];
821 rust_uv_fs_chmod(loop_ptr, req, path, mode as c_int, cb)
823 pub unsafe fn fs_readdir(loop_ptr: *uv_loop_t, req: *uv_fs_t, path: *c_char,
824 flags: c_int, cb: *u8) -> c_int {
825 #[fixed_stack_segment]; #[inline(never)];
827 rust_uv_fs_readdir(loop_ptr, req, path, flags, cb)
829 pub unsafe fn populate_stat(req_in: *uv_fs_t, stat_out: *uv_stat_t) {
830 #[fixed_stack_segment]; #[inline(never)];
832 rust_uv_populate_uv_stat(req_in, stat_out)
834 pub unsafe fn fs_req_cleanup(req: *uv_fs_t) {
835 #[fixed_stack_segment]; #[inline(never)];
837 rust_uv_fs_req_cleanup(req);
840 pub unsafe fn spawn(loop_ptr: *c_void, result: *uv_process_t,
841 options: uv_process_options_t) -> c_int {
842 #[fixed_stack_segment]; #[inline(never)];
843 return rust_uv_spawn(loop_ptr, result, options);
846 pub unsafe fn process_kill(p: *uv_process_t, signum: c_int) -> c_int {
847 #[fixed_stack_segment]; #[inline(never)];
848 return rust_uv_process_kill(p, signum);
851 pub unsafe fn process_pid(p: *uv_process_t) -> c_int {
852 #[fixed_stack_segment]; #[inline(never)];
853 return rust_uv_process_pid(p);
856 pub unsafe fn set_stdio_container_flags(c: *uv_stdio_container_t,
857 flags: libc::c_int) {
858 #[fixed_stack_segment]; #[inline(never)];
859 rust_set_stdio_container_flags(c, flags);
862 pub unsafe fn set_stdio_container_fd(c: *uv_stdio_container_t,
864 #[fixed_stack_segment]; #[inline(never)];
865 rust_set_stdio_container_fd(c, fd);
868 pub unsafe fn set_stdio_container_stream(c: *uv_stdio_container_t,
869 stream: *uv_stream_t) {
870 #[fixed_stack_segment]; #[inline(never)];
871 rust_set_stdio_container_stream(c, stream);
874 pub unsafe fn pipe_init(loop_ptr: *c_void, p: *uv_pipe_t, ipc: c_int) -> c_int {
875 #[fixed_stack_segment]; #[inline(never)];
876 rust_uv_pipe_init(loop_ptr, p, ipc)
879 // data access helpers
880 pub unsafe fn get_result_from_fs_req(req: *uv_fs_t) -> c_int {
881 #[fixed_stack_segment]; #[inline(never)];
883 rust_uv_get_result_from_fs_req(req)
885 pub unsafe fn get_ptr_from_fs_req(req: *uv_fs_t) -> *libc::c_void {
886 #[fixed_stack_segment]; #[inline(never)];
888 rust_uv_get_ptr_from_fs_req(req)
890 pub unsafe fn get_path_from_fs_req(req: *uv_fs_t) -> *c_char {
891 #[fixed_stack_segment]; #[inline(never)];
893 rust_uv_get_path_from_fs_req(req)
895 pub unsafe fn get_loop_from_fs_req(req: *uv_fs_t) -> *uv_loop_t {
896 #[fixed_stack_segment]; #[inline(never)];
898 rust_uv_get_loop_from_fs_req(req)
900 pub unsafe fn get_loop_from_getaddrinfo_req(req: *uv_getaddrinfo_t) -> *uv_loop_t {
901 #[fixed_stack_segment]; #[inline(never)];
903 rust_uv_get_loop_from_getaddrinfo_req(req)
905 pub unsafe fn get_loop_for_uv_handle<T>(handle: *T) -> *c_void {
906 #[fixed_stack_segment]; #[inline(never)];
908 return rust_uv_get_loop_for_uv_handle(handle as *c_void);
910 pub unsafe fn get_stream_handle_from_connect_req(connect: *uv_connect_t) -> *uv_stream_t {
911 #[fixed_stack_segment]; #[inline(never)];
913 return rust_uv_get_stream_handle_from_connect_req(connect);
915 pub unsafe fn get_stream_handle_from_write_req(write_req: *uv_write_t) -> *uv_stream_t {
916 #[fixed_stack_segment]; #[inline(never)];
918 return rust_uv_get_stream_handle_from_write_req(write_req);
920 pub unsafe fn get_data_for_uv_loop(loop_ptr: *c_void) -> *c_void {
921 #[fixed_stack_segment]; #[inline(never)];
923 rust_uv_get_data_for_uv_loop(loop_ptr)
925 pub unsafe fn set_data_for_uv_loop(loop_ptr: *c_void, data: *c_void) {
926 #[fixed_stack_segment]; #[inline(never)];
928 rust_uv_set_data_for_uv_loop(loop_ptr, data);
930 pub unsafe fn get_data_for_uv_handle<T>(handle: *T) -> *c_void {
931 #[fixed_stack_segment]; #[inline(never)];
933 return rust_uv_get_data_for_uv_handle(handle as *c_void);
935 pub unsafe fn set_data_for_uv_handle<T, U>(handle: *T, data: *U) {
936 #[fixed_stack_segment]; #[inline(never)];
938 rust_uv_set_data_for_uv_handle(handle as *c_void, data as *c_void);
940 pub unsafe fn get_data_for_req<T>(req: *T) -> *c_void {
941 #[fixed_stack_segment]; #[inline(never)];
943 return rust_uv_get_data_for_req(req as *c_void);
945 pub unsafe fn set_data_for_req<T, U>(req: *T, data: *U) {
946 #[fixed_stack_segment]; #[inline(never)];
948 rust_uv_set_data_for_req(req as *c_void, data as *c_void);
950 pub unsafe fn get_base_from_buf(buf: uv_buf_t) -> *u8 {
951 #[fixed_stack_segment]; #[inline(never)];
953 return rust_uv_get_base_from_buf(buf);
955 pub unsafe fn get_len_from_buf(buf: uv_buf_t) -> size_t {
956 #[fixed_stack_segment]; #[inline(never)];
958 return rust_uv_get_len_from_buf(buf);
960 pub unsafe fn getaddrinfo(loop_: *uv_loop_t, req: *uv_getaddrinfo_t,
961 getaddrinfo_cb: uv_getaddrinfo_cb,
962 node: *c_char, service: *c_char,
963 hints: *addrinfo) -> c_int {
964 #[fixed_stack_segment]; #[inline(never)];
965 return rust_uv_getaddrinfo(loop_, req, getaddrinfo_cb, node, service, hints);
967 pub unsafe fn freeaddrinfo(ai: *addrinfo) {
968 #[fixed_stack_segment]; #[inline(never)];
969 rust_uv_freeaddrinfo(ai);
971 pub unsafe fn pipe_open(pipe: *uv_pipe_t, file: c_int) -> c_int {
972 #[fixed_stack_segment]; #[inline(never)];
973 rust_uv_pipe_open(pipe, file)
975 pub unsafe fn pipe_bind(pipe: *uv_pipe_t, name: *c_char) -> c_int {
976 #[fixed_stack_segment]; #[inline(never)];
977 rust_uv_pipe_bind(pipe, name)
979 pub unsafe fn pipe_connect(req: *uv_connect_t, handle: *uv_pipe_t,
980 name: *c_char, cb: uv_connect_cb) {
981 #[fixed_stack_segment]; #[inline(never)];
982 rust_uv_pipe_connect(req, handle, name, cb)
984 pub unsafe fn tty_init(loop_ptr: *uv_loop_t, tty: *uv_tty_t, fd: c_int,
985 readable: c_int) -> c_int {
986 #[fixed_stack_segment]; #[inline(never)];
987 rust_uv_tty_init(loop_ptr, tty, fd, readable)
989 pub unsafe fn tty_set_mode(tty: *uv_tty_t, mode: c_int) -> c_int {
990 #[fixed_stack_segment]; #[inline(never)];
991 rust_uv_tty_set_mode(tty, mode)
993 pub unsafe fn tty_get_winsize(tty: *uv_tty_t, width: *c_int,
994 height: *c_int) -> c_int {
995 #[fixed_stack_segment]; #[inline(never)];
996 rust_uv_tty_get_winsize(tty, width, height)
998 // FIXME(#9613) this should return uv_handle_type, not a c_int
999 pub unsafe fn guess_handle(fd: c_int) -> c_int {
1000 #[fixed_stack_segment]; #[inline(never)];
1001 rust_uv_guess_handle(fd)
1004 pub unsafe fn signal_init(loop_: *uv_loop_t, handle: *uv_signal_t) -> c_int {
1005 #[fixed_stack_segment]; #[inline(never)];
1006 return rust_uv_signal_init(loop_, handle);
1008 pub unsafe fn signal_start(handle: *uv_signal_t,
1009 signal_cb: uv_signal_cb,
1010 signum: c_int) -> c_int {
1011 #[fixed_stack_segment]; #[inline(never)];
1012 return rust_uv_signal_start(handle, signal_cb, signum);
1014 pub unsafe fn signal_stop(handle: *uv_signal_t) -> c_int {
1015 #[fixed_stack_segment]; #[inline(never)];
1016 return rust_uv_signal_stop(handle);
1019 pub struct uv_err_data {
1024 // uv_support is the result of compiling rust_uv.cpp
1025 #[link_args = "-luv_support -luv"]
1028 fn rust_uv_handle_size(type_: uintptr_t) -> size_t;
1029 fn rust_uv_req_size(type_: uintptr_t) -> size_t;
1030 fn rust_uv_handle_type_max() -> uintptr_t;
1031 fn rust_uv_req_type_max() -> uintptr_t;
1034 fn rust_uv_loop_new() -> *c_void;
1035 fn rust_uv_loop_delete(lp: *c_void);
1036 fn rust_uv_run(loop_handle: *c_void);
1037 fn rust_uv_close(handle: *c_void, cb: uv_close_cb);
1038 fn rust_uv_walk(loop_handle: *c_void, cb: uv_walk_cb, arg: *c_void);
1040 fn rust_uv_idle_init(loop_handle: *uv_loop_t, handle: *uv_idle_t) -> c_int;
1041 fn rust_uv_idle_start(handle: *uv_idle_t, cb: uv_idle_cb) -> c_int;
1042 fn rust_uv_idle_stop(handle: *uv_idle_t) -> c_int;
1044 fn rust_uv_async_send(handle: *uv_async_t);
1045 fn rust_uv_async_init(loop_handle: *c_void,
1046 async_handle: *uv_async_t,
1047 cb: uv_async_cb) -> c_int;
1048 fn rust_uv_tcp_init(loop_handle: *c_void, handle_ptr: *uv_tcp_t) -> c_int;
1049 fn rust_uv_buf_init(out_buf: *uv_buf_t, base: *u8, len: size_t);
1050 fn rust_uv_strerror(err: c_int) -> *c_char;
1051 fn rust_uv_err_name(err: c_int) -> *c_char;
1052 fn rust_uv_ip4_addrp(ip: *u8, port: c_int) -> *sockaddr_in;
1053 fn rust_uv_ip6_addrp(ip: *u8, port: c_int) -> *sockaddr_in6;
1054 fn rust_uv_free_ip4_addr(addr: *sockaddr_in);
1055 fn rust_uv_free_ip6_addr(addr: *sockaddr_in6);
1056 fn rust_uv_ip4_name(src: *sockaddr_in, dst: *u8, size: size_t) -> c_int;
1057 fn rust_uv_ip6_name(src: *sockaddr_in6, dst: *u8, size: size_t) -> c_int;
1058 fn rust_uv_ip4_port(src: *sockaddr_in) -> c_uint;
1059 fn rust_uv_ip6_port(src: *sockaddr_in6) -> c_uint;
1060 fn rust_uv_tcp_connect(req: *uv_connect_t, handle: *uv_tcp_t,
1062 addr: *sockaddr_in) -> c_int;
1063 fn rust_uv_tcp_bind(tcp_server: *uv_tcp_t, addr: *sockaddr_in) -> c_int;
1064 fn rust_uv_tcp_connect6(req: *uv_connect_t, handle: *uv_tcp_t,
1066 addr: *sockaddr_in6) -> c_int;
1067 fn rust_uv_tcp_bind6(tcp_server: *uv_tcp_t, addr: *sockaddr_in6) -> c_int;
1068 fn rust_uv_tcp_getpeername(tcp_handle_ptr: *uv_tcp_t, name: *sockaddr_storage) -> c_int;
1069 fn rust_uv_tcp_getsockname(handle: *uv_tcp_t, name: *sockaddr_storage) -> c_int;
1070 fn rust_uv_tcp_nodelay(handle: *uv_tcp_t, enable: c_int) -> c_int;
1071 fn rust_uv_tcp_keepalive(handle: *uv_tcp_t, enable: c_int, delay: c_uint) -> c_int;
1072 fn rust_uv_tcp_simultaneous_accepts(handle: *uv_tcp_t, enable: c_int) -> c_int;
1074 fn rust_uv_udp_init(loop_handle: *uv_loop_t, handle_ptr: *uv_udp_t) -> c_int;
1075 fn rust_uv_udp_bind(server: *uv_udp_t, addr: *sockaddr_in, flags: c_uint) -> c_int;
1076 fn rust_uv_udp_bind6(server: *uv_udp_t, addr: *sockaddr_in6, flags: c_uint) -> c_int;
1077 fn rust_uv_udp_send(req: *uv_udp_send_t, handle: *uv_udp_t, buf_in: *uv_buf_t,
1078 buf_cnt: c_int, addr: *sockaddr_in, cb: uv_udp_send_cb) -> c_int;
1079 fn rust_uv_udp_send6(req: *uv_udp_send_t, handle: *uv_udp_t, buf_in: *uv_buf_t,
1080 buf_cnt: c_int, addr: *sockaddr_in6, cb: uv_udp_send_cb) -> c_int;
1081 fn rust_uv_udp_recv_start(server: *uv_udp_t,
1082 on_alloc: uv_alloc_cb,
1083 on_recv: uv_udp_recv_cb) -> c_int;
1084 fn rust_uv_udp_recv_stop(server: *uv_udp_t) -> c_int;
1085 fn rust_uv_get_udp_handle_from_send_req(req: *uv_udp_send_t) -> *uv_udp_t;
1086 fn rust_uv_udp_getsockname(handle: *uv_udp_t, name: *sockaddr_storage) -> c_int;
1087 fn rust_uv_udp_set_membership(handle: *uv_udp_t, multicast_addr: *c_char,
1088 interface_addr: *c_char, membership: c_int) -> c_int;
1089 fn rust_uv_udp_set_multicast_loop(handle: *uv_udp_t, on: c_int) -> c_int;
1090 fn rust_uv_udp_set_multicast_ttl(handle: *uv_udp_t, ttl: c_int) -> c_int;
1091 fn rust_uv_udp_set_ttl(handle: *uv_udp_t, ttl: c_int) -> c_int;
1092 fn rust_uv_udp_set_broadcast(handle: *uv_udp_t, on: c_int) -> c_int;
1094 fn rust_uv_is_ipv4_sockaddr(addr: *sockaddr) -> c_int;
1095 fn rust_uv_is_ipv6_sockaddr(addr: *sockaddr) -> c_int;
1096 fn rust_uv_malloc_sockaddr_storage() -> *sockaddr_storage;
1097 fn rust_uv_free_sockaddr_storage(ss: *sockaddr_storage);
1099 fn rust_uv_listen(stream: *c_void, backlog: c_int,
1100 cb: uv_connection_cb) -> c_int;
1101 fn rust_uv_accept(server: *c_void, client: *c_void) -> c_int;
1102 fn rust_uv_write(req: *c_void, stream: *c_void, buf_in: *uv_buf_t, buf_cnt: c_int,
1103 cb: uv_write_cb) -> c_int;
1104 fn rust_uv_read_start(stream: *c_void,
1105 on_alloc: uv_alloc_cb,
1106 on_read: uv_read_cb) -> c_int;
1107 fn rust_uv_read_stop(stream: *c_void) -> c_int;
1108 fn rust_uv_timer_init(loop_handle: *c_void, timer_handle: *uv_timer_t) -> c_int;
1109 fn rust_uv_timer_start(timer_handle: *uv_timer_t, cb: uv_timer_cb, timeout: libc::uint64_t,
1110 repeat: libc::uint64_t) -> c_int;
1111 fn rust_uv_timer_stop(handle: *uv_timer_t) -> c_int;
1112 fn rust_uv_fs_open(loop_ptr: *c_void, req: *uv_fs_t, path: *c_char,
1113 flags: c_int, mode: c_int, cb: *u8) -> c_int;
1114 fn rust_uv_fs_unlink(loop_ptr: *c_void, req: *uv_fs_t, path: *c_char,
1116 fn rust_uv_fs_write(loop_ptr: *c_void, req: *uv_fs_t, fd: c_int,
1117 buf: *c_void, len: c_uint, offset: i64, cb: *u8) -> c_int;
1118 fn rust_uv_fs_read(loop_ptr: *c_void, req: *uv_fs_t, fd: c_int,
1119 buf: *c_void, len: c_uint, offset: i64, cb: *u8) -> c_int;
1120 fn rust_uv_fs_close(loop_ptr: *c_void, req: *uv_fs_t, fd: c_int,
1122 fn rust_uv_fs_stat(loop_ptr: *c_void, req: *uv_fs_t, path: *c_char, cb: *u8) -> c_int;
1123 fn rust_uv_fs_fstat(loop_ptr: *c_void, req: *uv_fs_t, fd: c_int, cb: *u8) -> c_int;
1124 fn rust_uv_fs_mkdir(loop_ptr: *c_void, req: *uv_fs_t, path: *c_char,
1125 mode: c_int, cb: *u8) -> c_int;
1126 fn rust_uv_fs_rmdir(loop_ptr: *c_void, req: *uv_fs_t, path: *c_char,
1128 fn rust_uv_fs_rename(loop_ptr: *c_void, req: *uv_fs_t, path: *c_char,
1129 to: *c_char, cb: *u8) -> c_int;
1130 fn rust_uv_fs_chmod(loop_ptr: *c_void, req: *uv_fs_t, path: *c_char,
1131 mode: c_int, cb: *u8) -> c_int;
1132 fn rust_uv_fs_readdir(loop_ptr: *c_void, req: *uv_fs_t, path: *c_char,
1133 flags: c_int, cb: *u8) -> c_int;
1134 fn rust_uv_fs_req_cleanup(req: *uv_fs_t);
1135 fn rust_uv_populate_uv_stat(req_in: *uv_fs_t, stat_out: *uv_stat_t);
1136 fn rust_uv_get_result_from_fs_req(req: *uv_fs_t) -> c_int;
1137 fn rust_uv_get_ptr_from_fs_req(req: *uv_fs_t) -> *libc::c_void;
1138 fn rust_uv_get_path_from_fs_req(req: *uv_fs_t) -> *c_char;
1139 fn rust_uv_get_loop_from_fs_req(req: *uv_fs_t) -> *uv_loop_t;
1140 fn rust_uv_get_loop_from_getaddrinfo_req(req: *uv_fs_t) -> *uv_loop_t;
1142 fn rust_uv_get_stream_handle_from_connect_req(connect_req: *uv_connect_t) -> *uv_stream_t;
1143 fn rust_uv_get_stream_handle_from_write_req(write_req: *uv_write_t) -> *uv_stream_t;
1144 fn rust_uv_get_loop_for_uv_handle(handle: *c_void) -> *c_void;
1145 fn rust_uv_get_data_for_uv_loop(loop_ptr: *c_void) -> *c_void;
1146 fn rust_uv_set_data_for_uv_loop(loop_ptr: *c_void, data: *c_void);
1147 fn rust_uv_get_data_for_uv_handle(handle: *c_void) -> *c_void;
1148 fn rust_uv_set_data_for_uv_handle(handle: *c_void, data: *c_void);
1149 fn rust_uv_get_data_for_req(req: *c_void) -> *c_void;
1150 fn rust_uv_set_data_for_req(req: *c_void, data: *c_void);
1151 fn rust_uv_get_base_from_buf(buf: uv_buf_t) -> *u8;
1152 fn rust_uv_get_len_from_buf(buf: uv_buf_t) -> size_t;
1153 fn rust_uv_getaddrinfo(loop_: *uv_loop_t, req: *uv_getaddrinfo_t,
1154 getaddrinfo_cb: uv_getaddrinfo_cb,
1155 node: *c_char, service: *c_char,
1156 hints: *addrinfo) -> c_int;
1157 fn rust_uv_freeaddrinfo(ai: *addrinfo);
1158 fn rust_uv_spawn(loop_ptr: *c_void, outptr: *uv_process_t,
1159 options: uv_process_options_t) -> c_int;
1160 fn rust_uv_process_kill(p: *uv_process_t, signum: c_int) -> c_int;
1161 fn rust_uv_process_pid(p: *uv_process_t) -> c_int;
1162 fn rust_set_stdio_container_flags(c: *uv_stdio_container_t, flags: c_int);
1163 fn rust_set_stdio_container_fd(c: *uv_stdio_container_t, fd: c_int);
1164 fn rust_set_stdio_container_stream(c: *uv_stdio_container_t,
1165 stream: *uv_stream_t);
1166 fn rust_uv_pipe_init(loop_ptr: *c_void, p: *uv_pipe_t, ipc: c_int) -> c_int;
1168 fn rust_uv_pipe_open(pipe: *uv_pipe_t, file: c_int) -> c_int;
1169 fn rust_uv_pipe_bind(pipe: *uv_pipe_t, name: *c_char) -> c_int;
1170 fn rust_uv_pipe_connect(req: *uv_connect_t, handle: *uv_pipe_t,
1171 name: *c_char, cb: uv_connect_cb);
1172 fn rust_uv_tty_init(loop_ptr: *uv_loop_t, tty: *uv_tty_t, fd: c_int,
1173 readable: c_int) -> c_int;
1174 fn rust_uv_tty_set_mode(tty: *uv_tty_t, mode: c_int) -> c_int;
1175 fn rust_uv_tty_get_winsize(tty: *uv_tty_t, width: *c_int,
1176 height: *c_int) -> c_int;
1177 fn rust_uv_guess_handle(fd: c_int) -> c_int;
1179 // XXX: see comments in addrinfo.rs
1180 // These should all really be constants...
1181 //#[rust_stack] pub fn rust_SOCK_STREAM() -> c_int;
1182 //#[rust_stack] pub fn rust_SOCK_DGRAM() -> c_int;
1183 //#[rust_stack] pub fn rust_SOCK_RAW() -> c_int;
1184 //#[rust_stack] pub fn rust_IPPROTO_UDP() -> c_int;
1185 //#[rust_stack] pub fn rust_IPPROTO_TCP() -> c_int;
1186 //#[rust_stack] pub fn rust_AI_ADDRCONFIG() -> c_int;
1187 //#[rust_stack] pub fn rust_AI_ALL() -> c_int;
1188 //#[rust_stack] pub fn rust_AI_CANONNAME() -> c_int;
1189 //#[rust_stack] pub fn rust_AI_NUMERICHOST() -> c_int;
1190 //#[rust_stack] pub fn rust_AI_NUMERICSERV() -> c_int;
1191 //#[rust_stack] pub fn rust_AI_PASSIVE() -> c_int;
1192 //#[rust_stack] pub fn rust_AI_V4MAPPED() -> c_int;
1194 fn rust_uv_signal_init(loop_: *uv_loop_t, handle: *uv_signal_t) -> c_int;
1195 fn rust_uv_signal_start(handle: *uv_signal_t,
1196 signal_cb: uv_signal_cb,
1197 signum: c_int) -> c_int;
1198 fn rust_uv_signal_stop(handle: *uv_signal_t) -> c_int;
1201 externfn!(fn uv_fs_fsync(handle: *uv_loop_t, req: *uv_fs_t, file: c_int,
1203 externfn!(fn uv_fs_fdatasync(handle: *uv_loop_t, req: *uv_fs_t, file: c_int,
1205 externfn!(fn uv_fs_ftruncate(handle: *uv_loop_t, req: *uv_fs_t, file: c_int,
1206 offset: i64, cb: *u8) -> c_int)
1207 externfn!(fn uv_fs_readlink(handle: *uv_loop_t, req: *uv_fs_t, file: *c_char,
1209 externfn!(fn uv_fs_symlink(handle: *uv_loop_t, req: *uv_fs_t, src: *c_char,
1210 dst: *c_char, flags: c_int, cb: *u8) -> c_int)
1211 externfn!(fn uv_fs_link(handle: *uv_loop_t, req: *uv_fs_t, src: *c_char,
1212 dst: *c_char, cb: *u8) -> c_int)
1213 externfn!(fn uv_fs_chown(handle: *uv_loop_t, req: *uv_fs_t, src: *c_char,
1214 uid: uv_uid_t, gid: uv_gid_t, cb: *u8) -> c_int)
1215 externfn!(fn uv_fs_lstat(handle: *uv_loop_t, req: *uv_fs_t, file: *c_char,
1218 // libuv requires various system libraries to successfully link on some
1220 #[cfg(target_os = "linux")]
1221 #[link_args = "-lpthread"]
1224 #[cfg(target_os = "win32")]
1225 #[link_args = "-lWs2_32 -lpsapi -liphlpapi"]