Skip to content

Commit

Permalink
Support libuv 1.9.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Qard committed Jun 15, 2016
1 parent f6870dc commit b82b21a
Show file tree
Hide file tree
Showing 3 changed files with 120 additions and 5 deletions.
4 changes: 2 additions & 2 deletions libuv-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ fn libuv_dir() -> PathBuf {
fn libuv_repo() -> String {
"https://github.com/libuv/libuv.git".to_owned()
}
fn libuv_revision() -> String {
"v1.7.5".to_owned()
fn libuv_revision() -> String {
"v1.9.1".to_owned()
}
fn libuv_lib() -> PathBuf {
if cfg!(windows) {
Expand Down
117 changes: 116 additions & 1 deletion libuv-sys/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#![allow(non_camel_case_types)]
#![allow(raw_pointer_derive)]
extern crate libc;
use libc::{c_int, c_char, c_uint, c_void, uint64_t, size_t, sockaddr, sockaddr_in6, int64_t,
ssize_t, addrinfo, c_long, sockaddr_in, sockaddr_storage};
Expand Down Expand Up @@ -88,6 +87,88 @@ pub use uv_handle_type::*;
// Not binding the individual UV_E* constants for now because they're a huge
// mess. Use uv_err_name.


#[repr(C)]
#[derive(Debug,Clone,Copy,PartialEq,Eq)]
pub enum uv_errno_t {
E2BIG = 1,
EACCES = 2,
EADDRINUSE = 3,
EADDRNOTAVAIL = 4,
EAFNOSUPPORT = 5,
EAGAIN = 6,
EAI_ADDRFAMILY = 7,
EAI_AGAIN = 8,
EAI_BADFLAGS = 9,
EAI_BADHINTS = 10,
EAI_CANCELED = 11,
EAI_FAIL = 12,
EAI_FAMILY = 13,
EAI_MEMORY = 14,
EAI_NODATA = 15,
EAI_NONAME = 16,
EAI_OVERFLOW = 17,
EAI_PROTOCOL = 18,
EAI_SERVICE = 19,
EAI_SOCKTYPE = 20,
EALREADY = 21,
EBADF = 22,
EBUSY = 23,
ECANCELED = 24,
ECHARSET = 25,
ECONNABORTED = 26,
ECONNREFUSED = 27,
ECONNRESET = 28,
EDESTADDRREQ = 29,
EEXIST = 30,
EFAULT = 31,
EFBIG = 32,
EHOSTUNREACH = 33,
EINTR = 34,
EINVAL = 35,
EIO = 36,
EISCONN = 37,
EISDIR = 38,
ELOOP = 39,
EMFILE = 40,
EMSGSIZE = 41,
ENAMETOOLONG = 42,
ENETDOWN = 43,
ENETUNREACH = 44,
ENFILE = 45,
ENOBUFS = 46,
ENODEV = 47,
ENOENT = 48,
ENOMEM = 49,
ENONET = 50,
ENOPROTOOPT = 51,
ENOSPC = 52,
ENOSYS = 53,
ENOTCONN = 54,
ENOTDIR = 55,
ENOTEMPTY = 56,
ENOTSOCK = 57,
ENOTSUP = 58,
EPERM = 59,
EPIPE = 60,
EPROTO = 61,
EPROTONOSUPPORT = 62,
EPROTOTYPE = 63,
ERANGE = 64,
EROFS = 65,
ESHUTDOWN = 66,
ESPIPE = 67,
ESRCH = 68,
ETIMEDOUT = 69,
ETXTBSY = 70,
EXDEV = 71,
UNKNOWN = 72,
EOF = 73,
ENXIO = 74,
EMLINK = 75
}
pub use uv_errno_t::*;

extern {
pub fn uv_strerror(err: c_int) -> *const c_char;
pub fn uv_err_name(err: c_int) -> *const c_char;
Expand Down Expand Up @@ -216,6 +297,8 @@ pub enum uv_req_type {
UV_WORK = 7,
UV_GETADDRINFO = 8,
UV_GETNAMEINFO = 9, // plus zero or more private types
UV_REQ_TYPE_PRIVATE = 10,
UV_REQ_TYPE_MAX = 11,
}
pub use uv_req_type::*;

Expand Down Expand Up @@ -297,6 +380,7 @@ pub type uv_poll_cb = extern "C" fn(*mut uv_poll_t, c_int, c_int);
pub enum uv_poll_event {
UV_READABLE = 1,
UV_WRITABLE = 2,
UV_DISCONNECT = 4,
}
pub use uv_poll_event::*;

Expand Down Expand Up @@ -547,6 +631,13 @@ extern {

// tcp.rst

#[repr(C)]
#[derive(Debug,Clone,Copy,PartialEq,Eq)]
pub enum uv_tcp_flags {
UV_TCP_IPV6ONLY = 1,
}
pub use uv_tcp_flags::*;

#[repr(C)]
pub struct uv_tcp_t {
pub data: *mut c_void,
Expand Down Expand Up @@ -841,6 +932,7 @@ pub enum uv_fs_type {
UV_FS_READLINK = 25,
UV_FS_CHOWN = 26,
UV_FS_FCHOWN = 27,
UV_FS_REALPATH = 28,
}
pub use uv_fs_type::*;

Expand Down Expand Up @@ -1037,8 +1129,30 @@ extern {
gid: uv_gid_t,
cb: uv_fs_cb)
-> c_int;
pub fn uv_fs_realpath(loop_: *mut uv_loop_t,
req: *mut uv_fs_t,
path: *const c_char,
cb: uv_fs_cb)
-> c_int;
}

// passwd.rst

#[repr(C)]
pub struct uv_passwd_t {
pub username: *mut c_char,
pub uid: c_long,
pub gid: c_long,
pub shell: *mut c_char,
pub homedir: *mut c_char,
}

extern {
pub fn uv_os_get_passwd(passwd: *mut uv_passwd_t) -> c_int;
pub fn uv_os_free_passwd(passwd: *mut uv_passwd_t);
}


// threadpool.rst

#[repr(C)]
Expand Down Expand Up @@ -1243,6 +1357,7 @@ extern {
pub fn uv_cwd(buffer: *mut c_char, size: *mut size_t) -> c_int;
pub fn uv_chdir(dir: *const c_char) -> c_int;
pub fn uv_os_homedir(buffer: *mut c_char, size: *mut size_t) -> c_int;
pub fn uv_os_tmpdir(buffer: *mut c_char, size: *mut size_t) -> c_int;
pub fn uv_get_free_memory() -> uint64_t;
pub fn uv_get_total_memory() -> uint64_t;
pub fn uv_hrtime() -> uint64_t;
Expand Down
4 changes: 2 additions & 2 deletions libuv/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ mod tests {
use super::*;
#[test]
fn test_version_hex() {
assert_eq!(version_hex(), 0x10705);
assert_eq!(version_hex(), 0x10901);
}

#[test]
fn test_version_string() {
assert_eq!(version_string(), "1.7.5");
assert_eq!(version_string(), "1.9.1");
}
}

0 comments on commit b82b21a

Please sign in to comment.