mirror of
https://github.com/rust-lang/rust.git
synced 2024-10-30 05:51:58 +00:00
Upgrade libuv to the current master + our patches
There were two main differences with the old libuv and the master version: 1. The uv_last_error function is now gone. The error code returned by each function is the "last error" so now a UvError is just a wrapper around a c_int. 2. The repo no longer includes a makefile, and the build system has change. According to the build directions on joyent/libuv, this now downloads a `gyp` program into the `libuv/build` directory and builds using that. This shouldn't add any dependences on autotools or anything like that. Closes #8407 Closes #6567 Closes #6315
This commit is contained in:
parent
578e680477
commit
ed204257a0
2
.gitmodules
vendored
2
.gitmodules
vendored
@ -4,5 +4,5 @@
|
||||
branch = master
|
||||
[submodule "src/libuv"]
|
||||
path = src/libuv
|
||||
url = https://github.com/brson/libuv.git
|
||||
url = https://github.com/alexcrichton/libuv.git
|
||||
branch = master
|
||||
|
33
mk/rt.mk
33
mk/rt.mk
@ -163,34 +163,44 @@ LIBUV_DEPS := $$(wildcard \
|
||||
$$(S)src/libuv/*/*/*/*)
|
||||
endif
|
||||
|
||||
LIBUV_GYP := $$(S)src/libuv/build/gyp
|
||||
LIBUV_MAKEFILE := $$(S)src/libuv/out/Makefile
|
||||
LIBUV_NO_LOAD = run-benchmarks.target.mk run-tests.target.mk \
|
||||
uv_dtrace_header.target.mk uv_dtrace_provider.target.mk
|
||||
|
||||
# XXX: Shouldn't need platform-specific conditions here
|
||||
ifdef CFG_WINDOWSY_$(1)
|
||||
$$(LIBUV_LIB_$(1)_$(2)): $$(LIBUV_DEPS)
|
||||
$$(LIBUV_LIB_$(1)_$(2)): $$(LIBUV_DEPS) $$(LIBUV_MAKEFILE)
|
||||
$$(Q)$$(MAKE) -C $$(S)src/libuv/ \
|
||||
builddir_name="$$(CFG_BUILD_DIR)/rt/$(1)/stage$(2)/libuv" \
|
||||
builddir="$$(CFG_BUILD_DIR)/rt/$(1)/stage$(2)/libuv" \
|
||||
OS=mingw \
|
||||
BUILDTYPE=Release \
|
||||
NO_LOAD="$$(LIBUV_NO_LOAD)" \
|
||||
V=$$(VERBOSE)
|
||||
else ifeq ($(OSTYPE_$(1)), linux-androideabi)
|
||||
$$(LIBUV_LIB_$(1)_$(2)): $$(LIBUV_DEPS)
|
||||
$$(LIBUV_LIB_$(1)_$(2)): $$(LIBUV_DEPS) $$(LIBUV_MAKEFILE)
|
||||
$$(Q)$$(MAKE) -C $$(S)src/libuv/ \
|
||||
CFLAGS="$$(CFG_GCCISH_CFLAGS) $$(LIBUV_FLAGS_$$(HOST_$(1))) $$(SNAP_DEFINES)" \
|
||||
LDFLAGS="$$(CFG_GCCISH_LINK_FLAGS) $$(LIBUV_FLAGS_$$(HOST_$(1)))" \
|
||||
CC="$$(CC_$(1))" \
|
||||
CXX="$$(CXX_$(1))" \
|
||||
AR="$$(AR_$(1))" \
|
||||
BUILDTYPE=Release \
|
||||
builddir_name="$$(CFG_BUILD_DIR)/rt/$(1)/stage$(2)/libuv" \
|
||||
builddir="$$(CFG_BUILD_DIR)/rt/$(1)/stage$(2)/libuv" \
|
||||
host=android OS=linux \
|
||||
BUILDTYPE=Release \
|
||||
NO_LOAD="$$(LIBUV_NO_LOAD)" \
|
||||
V=$$(VERBOSE)
|
||||
else
|
||||
$$(LIBUV_LIB_$(1)_$(2)): $$(LIBUV_DEPS)
|
||||
$$(Q)$$(MAKE) -C $$(S)src/libuv/ \
|
||||
$$(LIBUV_LIB_$(1)_$(2)): $$(LIBUV_DEPS) $$(LIBUV_MAKEFILE)
|
||||
$$(Q)$$(MAKE) -C $$(S)src/libuv/out \
|
||||
CFLAGS="$$(CFG_GCCISH_CFLAGS) $$(LIBUV_FLAGS_$$(HOST_$(1))) $$(SNAP_DEFINES)" \
|
||||
LDFLAGS="$$(CFG_GCCISH_LINK_FLAGS) $$(LIBUV_FLAGS_$$(HOST_$(1)))" \
|
||||
CC="$$(CC_$(1))" \
|
||||
CXX="$$(CXX_$(1))" \
|
||||
AR="$$(AR_$(1))" \
|
||||
builddir_name="$$(CFG_BUILD_DIR)/rt/$(1)/stage$(2)/libuv" \
|
||||
builddir="$$(CFG_BUILD_DIR)/rt/$(1)/stage$(2)/libuv" \
|
||||
BUILDTYPE=Release \
|
||||
NO_LOAD="$$(LIBUV_NO_LOAD)" \
|
||||
V=$$(VERBOSE)
|
||||
endif
|
||||
|
||||
@ -250,6 +260,13 @@ endif
|
||||
|
||||
endef
|
||||
|
||||
$(LIBUV_GYP):
|
||||
mkdir -p $(S)src/libuv/build
|
||||
git clone https://git.chromium.org/external/gyp.git $(S)src/libuv/build/gyp
|
||||
|
||||
$(LIBUV_MAKEFILE): $(LIBUV_GYP)
|
||||
(cd $(S)src/libuv/ && ./gyp_uv -f make)
|
||||
|
||||
# Instantiate template for all stages
|
||||
$(foreach stage,$(STAGES), \
|
||||
$(foreach target,$(CFG_TARGET_TRIPLES), \
|
||||
|
@ -166,7 +166,7 @@ mod test {
|
||||
do run_in_newsched_task {
|
||||
let mut called = false;
|
||||
do io_error::cond.trap(|e| {
|
||||
assert!(e.kind == ConnectionRefused);
|
||||
assert_eq!(e.kind, ConnectionRefused);
|
||||
called = true;
|
||||
}).inside {
|
||||
let addr = SocketAddr { ip: Ipv4Addr(0, 0, 0, 0), port: 1 };
|
||||
|
@ -202,12 +202,12 @@ impl<H, W: Watcher + NativeHandle<*H>> WatcherInterop for W {
|
||||
// XXX: Need to define the error constants like EOF so they can be
|
||||
// compared to the UvError type
|
||||
|
||||
pub struct UvError(uvll::uv_err_t);
|
||||
pub struct UvError(c_int);
|
||||
|
||||
impl UvError {
|
||||
pub fn name(&self) -> ~str {
|
||||
unsafe {
|
||||
let inner = match self { &UvError(ref a) => a };
|
||||
let inner = match self { &UvError(a) => a };
|
||||
let name_str = uvll::err_name(inner);
|
||||
assert!(name_str.is_not_null());
|
||||
from_c_str(name_str)
|
||||
@ -216,7 +216,7 @@ impl UvError {
|
||||
|
||||
pub fn desc(&self) -> ~str {
|
||||
unsafe {
|
||||
let inner = match self { &UvError(ref a) => a };
|
||||
let inner = match self { &UvError(a) => a };
|
||||
let desc_str = uvll::strerror(inner);
|
||||
assert!(desc_str.is_not_null());
|
||||
from_c_str(desc_str)
|
||||
@ -224,7 +224,7 @@ impl UvError {
|
||||
}
|
||||
|
||||
pub fn is_eof(&self) -> bool {
|
||||
self.code == uvll::EOF
|
||||
**self == uvll::EOF
|
||||
}
|
||||
}
|
||||
|
||||
@ -236,18 +236,10 @@ impl ToStr for UvError {
|
||||
|
||||
#[test]
|
||||
fn error_smoke_test() {
|
||||
let err = uvll::uv_err_t { code: 1, sys_errno_: 1 };
|
||||
let err: UvError = UvError(err);
|
||||
let err: UvError = UvError(uvll::EOF);
|
||||
assert_eq!(err.to_str(), ~"EOF: end of file");
|
||||
}
|
||||
|
||||
pub fn last_uv_error<H, W: Watcher + NativeHandle<*H>>(watcher: &W) -> UvError {
|
||||
unsafe {
|
||||
let loop_ = watcher.event_loop();
|
||||
UvError(uvll::last_error(loop_.native_handle()))
|
||||
}
|
||||
}
|
||||
|
||||
pub fn uv_error_to_io_error(uverr: UvError) -> IoError {
|
||||
unsafe {
|
||||
// Importing error constants
|
||||
@ -255,10 +247,10 @@ pub fn uv_error_to_io_error(uverr: UvError) -> IoError {
|
||||
use rt::io::*;
|
||||
|
||||
// uv error descriptions are static
|
||||
let c_desc = uvll::strerror(&*uverr);
|
||||
let c_desc = uvll::strerror(*uverr);
|
||||
let desc = str::raw::c_str_to_static_slice(c_desc);
|
||||
|
||||
let kind = match uverr.code {
|
||||
let kind = match *uverr {
|
||||
UNKNOWN => OtherIoError,
|
||||
OK => OtherIoError,
|
||||
EOF => EndOfFile,
|
||||
@ -266,8 +258,8 @@ pub fn uv_error_to_io_error(uverr: UvError) -> IoError {
|
||||
ECONNREFUSED => ConnectionRefused,
|
||||
ECONNRESET => ConnectionReset,
|
||||
EPIPE => BrokenPipe,
|
||||
_ => {
|
||||
rtdebug!("uverr.code %u", uverr.code as uint);
|
||||
err => {
|
||||
rtdebug!("uverr.code %d", err as int);
|
||||
// XXX: Need to map remaining uv error types
|
||||
OtherIoError
|
||||
}
|
||||
@ -282,30 +274,13 @@ pub fn uv_error_to_io_error(uverr: UvError) -> IoError {
|
||||
}
|
||||
|
||||
/// Given a uv handle, convert a callback status to a UvError
|
||||
pub fn status_to_maybe_uv_error_with_loop(
|
||||
loop_: *uvll::uv_loop_t,
|
||||
status: c_int) -> Option<UvError> {
|
||||
if status != -1 {
|
||||
pub fn status_to_maybe_uv_error<T, U: Watcher + NativeHandle<*T>>(
|
||||
handle: U, status: c_int) -> Option<UvError>
|
||||
{
|
||||
if status >= 0 {
|
||||
None
|
||||
} else {
|
||||
unsafe {
|
||||
rtdebug!("loop: %x", loop_ as uint);
|
||||
let err = uvll::last_error(loop_);
|
||||
Some(UvError(err))
|
||||
}
|
||||
}
|
||||
}
|
||||
/// Given a uv handle, convert a callback status to a UvError
|
||||
pub fn status_to_maybe_uv_error<T, U: Watcher + NativeHandle<*T>>(handle: U,
|
||||
status: c_int) -> Option<UvError> {
|
||||
if status != -1 {
|
||||
None
|
||||
} else {
|
||||
unsafe {
|
||||
rtdebug!("handle: %x", handle.native_handle() as uint);
|
||||
let loop_ = uvll::get_loop_for_uv_handle(handle.native_handle());
|
||||
status_to_maybe_uv_error_with_loop(loop_, status)
|
||||
}
|
||||
Some(UvError(status))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -16,7 +16,6 @@ use rt::uv::{AllocCallback, ConnectionCallback, ReadCallback, UdpReceiveCallback
|
||||
use rt::uv::{Loop, Watcher, Request, UvError, Buf, NativeHandle, NullCallback,
|
||||
status_to_maybe_uv_error};
|
||||
use rt::io::net::ip::{SocketAddr, Ipv4Addr, Ipv6Addr};
|
||||
use rt::uv::last_uv_error;
|
||||
use vec;
|
||||
use str;
|
||||
use from_str::{FromStr};
|
||||
@ -232,7 +231,7 @@ impl TcpWatcher {
|
||||
};
|
||||
match result {
|
||||
0 => Ok(()),
|
||||
_ => Err(last_uv_error(self)),
|
||||
_ => Err(UvError(result)),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -327,7 +326,7 @@ impl UdpWatcher {
|
||||
};
|
||||
match result {
|
||||
0 => Ok(()),
|
||||
_ => Err(last_uv_error(self)),
|
||||
_ => Err(UvError(result)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -37,21 +37,34 @@ use libc::{malloc, free};
|
||||
use libc;
|
||||
use prelude::*;
|
||||
use ptr;
|
||||
use str;
|
||||
use vec;
|
||||
|
||||
pub static UNKNOWN: c_int = -1;
|
||||
pub static OK: c_int = 0;
|
||||
pub static EOF: c_int = 1;
|
||||
pub static EADDRINFO: c_int = 2;
|
||||
pub static EACCES: c_int = 3;
|
||||
pub static ECONNREFUSED: c_int = 12;
|
||||
pub static ECONNRESET: c_int = 13;
|
||||
pub static EPIPE: c_int = 36;
|
||||
pub use self::errors::*;
|
||||
|
||||
pub struct uv_err_t {
|
||||
code: c_int,
|
||||
sys_errno_: c_int
|
||||
pub static OK: c_int = 0;
|
||||
pub static EOF: c_int = -4095;
|
||||
pub static UNKNOWN: c_int = -4094;
|
||||
|
||||
// uv-errno.h redefines error codes for windows, but not for unix...
|
||||
|
||||
#[cfg(windows)]
|
||||
pub mod errors {
|
||||
use libc::c_int;
|
||||
|
||||
pub static EACCES: c_int = -4093;
|
||||
pub static ECONNREFUSED: c_int = -4079;
|
||||
pub static ECONNRESET: c_int = -4078;
|
||||
pub static EPIPE: c_int = -4048;
|
||||
}
|
||||
#[cfg(not(windows))]
|
||||
pub mod errors {
|
||||
use libc;
|
||||
use libc::c_int;
|
||||
|
||||
pub static EACCES: c_int = -libc::EACCES;
|
||||
pub static ECONNREFUSED: c_int = -libc::ECONNREFUSED;
|
||||
pub static ECONNRESET: c_int = -libc::ECONNRESET;
|
||||
pub static EPIPE: c_int = -libc::EPIPE;
|
||||
}
|
||||
|
||||
pub struct uv_buf_t {
|
||||
@ -487,20 +500,12 @@ pub unsafe fn read_stop(stream: *uv_stream_t) -> c_int {
|
||||
return rust_uv_read_stop(stream as *c_void);
|
||||
}
|
||||
|
||||
pub unsafe fn last_error(loop_handle: *c_void) -> uv_err_t {
|
||||
pub unsafe fn strerror(err: c_int) -> *c_char {
|
||||
#[fixed_stack_segment]; #[inline(never)];
|
||||
|
||||
return rust_uv_last_error(loop_handle);
|
||||
}
|
||||
|
||||
pub unsafe fn strerror(err: *uv_err_t) -> *c_char {
|
||||
#[fixed_stack_segment]; #[inline(never)];
|
||||
|
||||
return rust_uv_strerror(err);
|
||||
}
|
||||
pub unsafe fn err_name(err: *uv_err_t) -> *c_char {
|
||||
pub unsafe fn err_name(err: c_int) -> *c_char {
|
||||
#[fixed_stack_segment]; #[inline(never)];
|
||||
|
||||
return rust_uv_err_name(err);
|
||||
}
|
||||
|
||||
@ -720,22 +725,6 @@ pub unsafe fn get_len_from_buf(buf: uv_buf_t) -> size_t {
|
||||
|
||||
return rust_uv_get_len_from_buf(buf);
|
||||
}
|
||||
pub unsafe fn get_last_err_info(uv_loop: *c_void) -> ~str {
|
||||
let err = last_error(uv_loop);
|
||||
let err_ptr = ptr::to_unsafe_ptr(&err);
|
||||
let err_name = str::raw::from_c_str(err_name(err_ptr));
|
||||
let err_msg = str::raw::from_c_str(strerror(err_ptr));
|
||||
return fmt!("LIBUV ERROR: name: %s msg: %s",
|
||||
err_name, err_msg);
|
||||
}
|
||||
|
||||
pub unsafe fn get_last_err_data(uv_loop: *c_void) -> uv_err_data {
|
||||
let err = last_error(uv_loop);
|
||||
let err_ptr = ptr::to_unsafe_ptr(&err);
|
||||
let err_name = str::raw::from_c_str(err_name(err_ptr));
|
||||
let err_msg = str::raw::from_c_str(strerror(err_ptr));
|
||||
uv_err_data { err_name: err_name, err_msg: err_msg }
|
||||
}
|
||||
|
||||
pub struct uv_err_data {
|
||||
err_name: ~str,
|
||||
@ -768,9 +757,8 @@ extern {
|
||||
cb: uv_async_cb) -> c_int;
|
||||
fn rust_uv_tcp_init(loop_handle: *c_void, handle_ptr: *uv_tcp_t) -> c_int;
|
||||
fn rust_uv_buf_init(out_buf: *uv_buf_t, base: *u8, len: size_t);
|
||||
fn rust_uv_last_error(loop_handle: *c_void) -> uv_err_t;
|
||||
fn rust_uv_strerror(err: *uv_err_t) -> *c_char;
|
||||
fn rust_uv_err_name(err: *uv_err_t) -> *c_char;
|
||||
fn rust_uv_strerror(err: c_int) -> *c_char;
|
||||
fn rust_uv_err_name(err: c_int) -> *c_char;
|
||||
fn rust_uv_ip4_addrp(ip: *u8, port: c_int) -> *sockaddr_in;
|
||||
fn rust_uv_ip6_addrp(ip: *u8, port: c_int) -> *sockaddr_in6;
|
||||
fn rust_uv_free_ip4_addr(addr: *sockaddr_in);
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit dfae9c3e958dc086d9c0ab068cd76d196c95a433
|
||||
Subproject commit fb2fc332dc2bce0c72818a45f3b8c6824d5e046e
|
@ -329,20 +329,13 @@ rust_uv_get_len_from_buf(uv_buf_t buf) {
|
||||
return buf.len;
|
||||
}
|
||||
|
||||
extern "C" uv_err_t
|
||||
rust_uv_last_error(uv_loop_t* loop) {
|
||||
return uv_last_error(loop);
|
||||
}
|
||||
|
||||
extern "C" const char*
|
||||
rust_uv_strerror(uv_err_t* err_ptr) {
|
||||
uv_err_t err = *err_ptr;
|
||||
rust_uv_strerror(int err) {
|
||||
return uv_strerror(err);
|
||||
}
|
||||
|
||||
extern "C" const char*
|
||||
rust_uv_err_name(uv_err_t* err_ptr) {
|
||||
uv_err_t err = *err_ptr;
|
||||
rust_uv_err_name(int err) {
|
||||
return uv_err_name(err);
|
||||
}
|
||||
|
||||
|
@ -47,7 +47,6 @@ rust_uv_timer_start
|
||||
rust_uv_timer_stop
|
||||
rust_uv_tcp_init
|
||||
rust_uv_buf_init
|
||||
rust_uv_last_error
|
||||
rust_uv_strerror
|
||||
rust_uv_err_name
|
||||
rust_uv_ip4_addr
|
||||
@ -191,4 +190,4 @@ rust_drop_global_args_lock
|
||||
rust_take_change_dir_lock
|
||||
rust_drop_change_dir_lock
|
||||
rust_get_test_int
|
||||
rust_get_task
|
||||
rust_get_task
|
||||
|
Loading…
Reference in New Issue
Block a user