From 9d9ed61c5a97562b93a2326f33922783ed509d47 Mon Sep 17 00:00:00 2001 From: Saúl Ibarra Corretgé Date: Fri, 21 Nov 2014 15:43:12 +0100 Subject: deps: update libuv to 1.0.0 PR-URL: https://github.com/joyent/node/pull/8762 Reviewed-by: Trevor Norris --- deps/uv/src/unix/core.c | 3 -- deps/uv/src/unix/internal.h | 8 ------ deps/uv/src/unix/thread.c | 50 +++++++++++++++++++++++++++++++++ deps/uv/src/unix/tty.c | 7 +---- deps/uv/src/uv-common.c | 58 --------------------------------------- deps/uv/src/win/fs.c | 13 +++++---- deps/uv/src/win/thread.c | 67 +++++++++++++++++++++++++++++++++++++++++++++ deps/uv/src/win/util.c | 3 +- deps/uv/src/win/winsock.h | 19 +++++++++++++ 9 files changed, 146 insertions(+), 82 deletions(-) (limited to 'deps/uv/src') diff --git a/deps/uv/src/unix/core.c b/deps/uv/src/unix/core.c index 7add085fea..e6a076831c 100644 --- a/deps/uv/src/unix/core.c +++ b/deps/uv/src/unix/core.c @@ -310,8 +310,6 @@ int uv_run(uv_loop_t* loop, uv_run_mode mode) { uv__update_time(loop); while (r != 0 && loop->stop_flag == 0) { - UV_TICK_START(loop, mode); - uv__update_time(loop); uv__run_timers(loop); uv__run_pending(loop); @@ -340,7 +338,6 @@ int uv_run(uv_loop_t* loop, uv_run_mode mode) { } r = uv__loop_alive(loop); - UV_TICK_STOP(loop, mode); if (mode & (UV_RUN_ONCE | UV_RUN_NOWAIT)) break; diff --git a/deps/uv/src/unix/internal.h b/deps/uv/src/unix/internal.h index d5bc3109f0..b94508cba5 100644 --- a/deps/uv/src/unix/internal.h +++ b/deps/uv/src/unix/internal.h @@ -306,12 +306,4 @@ UV_UNUSED(static char* uv__basename_r(const char* path)) { return s + 1; } - -#ifdef HAVE_DTRACE -#include "uv-dtrace.h" -#else -#define UV_TICK_START(arg0, arg1) -#define UV_TICK_STOP(arg0, arg1) -#endif - #endif /* UV_UNIX_INTERNAL_H_ */ diff --git a/deps/uv/src/unix/thread.c b/deps/uv/src/unix/thread.c index 522426f634..7a55bd6324 100644 --- a/deps/uv/src/unix/thread.c +++ b/deps/uv/src/unix/thread.c @@ -31,11 +31,61 @@ #undef NANOSEC #define NANOSEC ((uint64_t) 1e9) + +struct thread_ctx { + void (*entry)(void* arg); + void* arg; +}; + + +static void* uv__thread_start(void *arg) +{ + struct thread_ctx *ctx_p; + struct thread_ctx ctx; + + ctx_p = arg; + ctx = *ctx_p; + free(ctx_p); + ctx.entry(ctx.arg); + + return 0; +} + + +int uv_thread_create(uv_thread_t *tid, void (*entry)(void *arg), void *arg) { + struct thread_ctx* ctx; + int err; + + ctx = malloc(sizeof(*ctx)); + if (ctx == NULL) + return UV_ENOMEM; + + ctx->entry = entry; + ctx->arg = arg; + + err = pthread_create(tid, NULL, uv__thread_start, ctx); + + if (err) + free(ctx); + + return err ? -1 : 0; +} + + +uv_thread_t uv_thread_self(void) { + return pthread_self(); +} + int uv_thread_join(uv_thread_t *tid) { return -pthread_join(*tid, NULL); } +int uv_thread_equal(const uv_thread_t* t1, const uv_thread_t* t2) { + return pthread_equal(*t1, *t2); +} + + int uv_mutex_init(uv_mutex_t* mutex) { #if defined(NDEBUG) || !defined(PTHREAD_MUTEX_ERRORCHECK) return -pthread_mutex_init(mutex, NULL); diff --git a/deps/uv/src/unix/tty.c b/deps/uv/src/unix/tty.c index 7ae19905fb..82fa27cc12 100644 --- a/deps/uv/src/unix/tty.c +++ b/deps/uv/src/unix/tty.c @@ -123,12 +123,7 @@ int uv_tty_set_mode(uv_tty_t* tty, int mode) { uv_spinlock_unlock(&termios_spinlock); raw = tty->orig_termios; - raw.c_iflag &= ~(BRKINT | ICRNL | INPCK | ISTRIP | IXON); - raw.c_oflag |= (ONLCR); - raw.c_cflag |= (CS8); - raw.c_lflag &= ~(ECHO | ICANON | IEXTEN | ISIG); - raw.c_cc[VMIN] = 1; - raw.c_cc[VTIME] = 0; + cfmakeraw(&raw); /* Put terminal in raw mode after draining */ if (tcsetattr(fd, TCSADRAIN, &raw)) diff --git a/deps/uv/src/uv-common.c b/deps/uv/src/uv-common.c index 97727baa54..5ba1ea4df4 100644 --- a/deps/uv/src/uv-common.c +++ b/deps/uv/src/uv-common.c @@ -257,64 +257,6 @@ int uv_udp_recv_stop(uv_udp_t* handle) { } -struct thread_ctx { - void (*entry)(void* arg); - void* arg; -}; - - -#ifdef _WIN32 -static UINT __stdcall uv__thread_start(void* arg) -#else -static void* uv__thread_start(void *arg) -#endif -{ - struct thread_ctx *ctx_p; - struct thread_ctx ctx; - - ctx_p = arg; - ctx = *ctx_p; - free(ctx_p); - ctx.entry(ctx.arg); - - return 0; -} - - -int uv_thread_create(uv_thread_t *tid, void (*entry)(void *arg), void *arg) { - struct thread_ctx* ctx; - int err; - - ctx = malloc(sizeof(*ctx)); - if (ctx == NULL) - return UV_ENOMEM; - - ctx->entry = entry; - ctx->arg = arg; - -#ifdef _WIN32 - *tid = (HANDLE) _beginthreadex(NULL, 0, uv__thread_start, ctx, 0, NULL); - err = *tid ? 0 : errno; -#else - err = pthread_create(tid, NULL, uv__thread_start, ctx); -#endif - - if (err) - free(ctx); - - return err ? -1 : 0; -} - - -unsigned long uv_thread_self(void) { -#ifdef _WIN32 - return (unsigned long) GetCurrentThreadId(); -#else - return (unsigned long) pthread_self(); -#endif -} - - void uv_walk(uv_loop_t* loop, uv_walk_cb walk_cb, void* arg) { QUEUE* q; uv_handle_t* h; diff --git a/deps/uv/src/win/fs.c b/deps/uv/src/win/fs.c index 11d20f2dbd..13af7c41a3 100644 --- a/deps/uv/src/win/fs.c +++ b/deps/uv/src/win/fs.c @@ -557,11 +557,6 @@ void fs__read(uv_fs_t* req) { if (offset != -1) { memset(&overlapped, 0, sizeof overlapped); - - offset_.QuadPart = offset; - overlapped.Offset = offset_.LowPart; - overlapped.OffsetHigh = offset_.HighPart; - overlapped_ptr = &overlapped; } else { overlapped_ptr = NULL; @@ -571,6 +566,13 @@ void fs__read(uv_fs_t* req) { bytes = 0; do { DWORD incremental_bytes; + + if (offset != -1) { + offset_.QuadPart = offset + bytes; + overlapped.Offset = offset_.LowPart; + overlapped.OffsetHigh = offset_.HighPart; + } + result = ReadFile(handle, req->bufs[index].base, req->bufs[index].len, @@ -623,7 +625,6 @@ void fs__write(uv_fs_t* req) { do { DWORD incremental_bytes; - /* WriteFile() does not advance overlapped as ReadFile() does. */ if (offset != -1) { offset_.QuadPart = offset + bytes; overlapped.Offset = offset_.LowPart; diff --git a/deps/uv/src/win/thread.c b/deps/uv/src/win/thread.c index ccc5579fa7..7143743926 100644 --- a/deps/uv/src/win/thread.c +++ b/deps/uv/src/win/thread.c @@ -117,6 +117,68 @@ void uv_once(uv_once_t* guard, void (*callback)(void)) { uv__once_inner(guard, callback); } +static UV_THREAD_LOCAL uv_thread_t uv__current_thread = NULL; + +struct thread_ctx { + void (*entry)(void* arg); + void* arg; + uv_thread_t self; +}; + + +static UINT __stdcall uv__thread_start(void* arg) +{ + struct thread_ctx *ctx_p; + struct thread_ctx ctx; + + ctx_p = arg; + ctx = *ctx_p; + free(ctx_p); + + uv__current_thread = ctx.self; + ctx.entry(ctx.arg); + + return 0; +} + + +int uv_thread_create(uv_thread_t *tid, void (*entry)(void *arg), void *arg) { + struct thread_ctx* ctx; + int err; + HANDLE thread; + + ctx = malloc(sizeof(*ctx)); + if (ctx == NULL) + return UV_ENOMEM; + + ctx->entry = entry; + ctx->arg = arg; + + /* Create the thread in suspended state so we have a chance to pass + * its own creation handle to it */ + thread = (HANDLE) _beginthreadex(NULL, + 0, + uv__thread_start, + ctx, + CREATE_SUSPENDED, + NULL); + if (thread == NULL) { + err = errno; + free(ctx); + } else { + err = 0; + *tid = thread; + ctx->self = thread; + ResumeThread(thread); + } + + return err; +} + + +uv_thread_t uv_thread_self(void) { + return uv__current_thread; +} int uv_thread_join(uv_thread_t *tid) { if (WaitForSingleObject(*tid, INFINITE)) @@ -129,6 +191,11 @@ int uv_thread_join(uv_thread_t *tid) { } +int uv_thread_equal(const uv_thread_t* t1, const uv_thread_t* t2) { + return *t1 == *t2; +} + + int uv_mutex_init(uv_mutex_t* mutex) { InitializeCriticalSection(mutex); return 0; diff --git a/deps/uv/src/win/util.c b/deps/uv/src/win/util.c index b7dba7bbda..0bcb721a52 100644 --- a/deps/uv/src/win/util.c +++ b/deps/uv/src/win/util.c @@ -1037,7 +1037,8 @@ int uv_interface_addresses(uv_interface_address_t** addresses_ptr, /* XP has no OnLinkPrefixLength field. */ if (is_vista_or_greater) { - prefix_len = unicast_address->OnLinkPrefixLength; + prefix_len = + ((IP_ADAPTER_UNICAST_ADDRESS_LH*) unicast_address)->OnLinkPrefixLength; } else { /* Prior to Windows Vista the FirstPrefix pointed to the list with * single prefix for each IP address assigned to the adapter. diff --git a/deps/uv/src/win/winsock.h b/deps/uv/src/win/winsock.h index 957d08ec19..7c007ab493 100644 --- a/deps/uv/src/win/winsock.h +++ b/deps/uv/src/win/winsock.h @@ -166,6 +166,25 @@ typedef struct _IP_ADAPTER_UNICAST_ADDRESS_XP { ULONG LeaseLifetime; } IP_ADAPTER_UNICAST_ADDRESS_XP,*PIP_ADAPTER_UNICAST_ADDRESS_XP; +typedef struct _IP_ADAPTER_UNICAST_ADDRESS_LH { + union { + ULONGLONG Alignment; + struct { + ULONG Length; + DWORD Flags; + }; + }; + struct _IP_ADAPTER_UNICAST_ADDRESS_LH *Next; + SOCKET_ADDRESS Address; + IP_PREFIX_ORIGIN PrefixOrigin; + IP_SUFFIX_ORIGIN SuffixOrigin; + IP_DAD_STATE DadState; + ULONG ValidLifetime; + ULONG PreferredLifetime; + ULONG LeaseLifetime; + UINT8 OnLinkPrefixLength; +} IP_ADAPTER_UNICAST_ADDRESS_LH,*PIP_ADAPTER_UNICAST_ADDRESS_LH; + #endif #endif /* UV_WIN_WINSOCK_H_ */ -- cgit v1.2.3