From 814bdf0f51fd3219063a44f919dfcdb6e51951f7 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Tue, 22 Jan 2013 16:21:25 +0100 Subject: [PATCH] deps: upgrade libuv to 7841f77 --- deps/uv/README.md | 15 ++++++--- deps/uv/src/unix/fs.c | 45 ++++++++++++++++++++++++++- deps/uv/src/unix/linux/syscalls.c | 4 +-- deps/uv/src/unix/linux/syscalls.h | 22 ++++++------- deps/uv/src/unix/udp.c | 3 +- deps/uv/src/uv-common.c | 8 ++--- deps/uv/src/win/udp.c | 3 +- deps/uv/test/test-tcp-bind-error.c | 2 +- deps/uv/test/test-tcp-bind6-error.c | 2 +- deps/uv/test/test-threadpool-cancel.c | 4 +++ deps/uv/uv.gyp | 9 +++--- 11 files changed, 84 insertions(+), 33 deletions(-) diff --git a/deps/uv/README.md b/deps/uv/README.md index 2d8b4367c0..e37b962fcc 100644 --- a/deps/uv/README.md +++ b/deps/uv/README.md @@ -56,7 +56,7 @@ http://nodejs.org/ For GCC (including MinGW) there are two methods building: via normal makefiles or via GYP. GYP is a meta-build system which can generate MSVS, Makefile, and XCode backends. It is best used for integration into other -projects. The old (more stable) system is using Makefiles. +projects. The old system is using plain GNU Makefiles. To build via Makefile simply execute: @@ -69,15 +69,22 @@ related files. Windows users can also build from cmd-line using msbuild. This is done by running vcbuild.bat from Visual Studio command prompt. -To have GYP generate build script for another system you will need to -checkout GYP into the project tree manually: +To have GYP generate build script for another system, make sure that +you have Python 2.6 or 2.7 installed, then checkout GYP into the +project tree manually: + mkdir -p build svn co http://gyp.googlecode.com/svn/trunk build/gyp +Or: + + mkdir -p build + git clone https://git.chromium.org/external/gyp.git build/gyp + Unix users run ./gyp_uv -f make - make + make -C out Macintosh users run diff --git a/deps/uv/src/unix/fs.c b/deps/uv/src/unix/fs.c index f01c83b4a0..6b7ac6c5a1 100644 --- a/deps/uv/src/unix/fs.c +++ b/deps/uv/src/unix/fs.c @@ -113,12 +113,55 @@ static ssize_t uv__fs_futime(uv_fs_t* req) { /* utimesat() has nanosecond resolution but we stick to microseconds * for the sake of consistency with other platforms. */ + static int no_utimesat; struct timespec ts[2]; + struct timeval tv[2]; + char path[sizeof("/proc/self/fd/") + 3 * sizeof(int)]; + int r; + + if (no_utimesat) + goto skip; + ts[0].tv_sec = req->atime; ts[0].tv_nsec = (unsigned long)(req->atime * 1000000) % 1000000 * 1000; ts[1].tv_sec = req->mtime; ts[1].tv_nsec = (unsigned long)(req->mtime * 1000000) % 1000000 * 1000; - return uv__utimesat(req->file, NULL, ts, 0); + + r = uv__utimesat(req->file, NULL, ts, 0); + if (r == 0) + return r; + + if (errno != ENOSYS) + return r; + + no_utimesat = 1; + +skip: + + tv[0].tv_sec = req->atime; + tv[0].tv_usec = (unsigned long)(req->atime * 1000000) % 1000000; + tv[1].tv_sec = req->mtime; + tv[1].tv_usec = (unsigned long)(req->mtime * 1000000) % 1000000; + snprintf(path, sizeof(path), "/proc/self/fd/%d", (int) req->file); + + r = utimes(path, tv); + if (r == 0) + return r; + + switch (errno) { + case ENOENT: + if (fcntl(req->file, F_GETFL) == -1 && errno == EBADF) + break; + /* Fall through. */ + + case EACCES: + case ENOTDIR: + errno = ENOSYS; + break; + } + + return r; + #elif defined(__APPLE__) \ || defined(__DragonFly__) \ || defined(__FreeBSD__) \ diff --git a/deps/uv/src/unix/linux/syscalls.c b/deps/uv/src/unix/linux/syscalls.c index 1f0174a6e7..870763be2e 100644 --- a/deps/uv/src/unix/linux/syscalls.c +++ b/deps/uv/src/unix/linux/syscalls.c @@ -323,7 +323,7 @@ int uv__inotify_init1(int flags) { } -int uv__inotify_add_watch(int fd, const char* path, __u32 mask) { +int uv__inotify_add_watch(int fd, const char* path, uint32_t mask) { #if defined(__NR_inotify_add_watch) return syscall(__NR_inotify_add_watch, fd, path, mask); #else @@ -332,7 +332,7 @@ int uv__inotify_add_watch(int fd, const char* path, __u32 mask) { } -int uv__inotify_rm_watch(int fd, __s32 wd) { +int uv__inotify_rm_watch(int fd, int32_t wd) { #if defined(__NR_inotify_rm_watch) return syscall(__NR_inotify_rm_watch, fd, wd); #else diff --git a/deps/uv/src/unix/linux/syscalls.h b/deps/uv/src/unix/linux/syscalls.h index e65eb45891..195a981dec 100644 --- a/deps/uv/src/unix/linux/syscalls.h +++ b/deps/uv/src/unix/linux/syscalls.h @@ -25,10 +25,10 @@ #undef _GNU_SOURCE #define _GNU_SOURCE +#include #include #include #include -#include #define UV__O_NONBLOCK 0x800 #define UV__O_CLOEXEC 0x80000 @@ -71,21 +71,21 @@ #if defined(__x86_64__) struct uv__epoll_event { - __u32 events; - __u64 data; + uint32_t events; + uint64_t data; } __attribute__((packed)); #else struct uv__epoll_event { - __u32 events; - __u64 data; + uint32_t events; + uint64_t data; }; #endif struct uv__inotify_event { - __s32 wd; - __u32 mask; - __u32 cookie; - __u32 len; + int32_t wd; + uint32_t mask; + uint32_t cookie; + uint32_t len; /* char name[0]; */ }; @@ -111,8 +111,8 @@ int uv__epoll_pwait(int epfd, int uv__eventfd2(unsigned int count, int flags); int uv__inotify_init(void); int uv__inotify_init1(int flags); -int uv__inotify_add_watch(int fd, const char* path, __u32 mask); -int uv__inotify_rm_watch(int fd, __s32 wd); +int uv__inotify_add_watch(int fd, const char* path, uint32_t mask); +int uv__inotify_rm_watch(int fd, int32_t wd); int uv__pipe2(int pipefd[2], int flags); int uv__recvmmsg(int fd, struct uv__mmsghdr* mmsg, diff --git a/deps/uv/src/unix/udp.c b/deps/uv/src/unix/udp.c index f79b09cd80..8388ba6c23 100644 --- a/deps/uv/src/unix/udp.c +++ b/deps/uv/src/unix/udp.c @@ -542,8 +542,7 @@ int uv_udp_set_membership(uv_udp_t* handle, const char* multicast_addr, optname = IP_DROP_MEMBERSHIP; break; default: - uv__set_sys_error(handle->loop, EFAULT); - return -1; + return uv__set_artificial_error(handle->loop, UV_EINVAL); } if (setsockopt(handle->io_watcher.fd, IPPROTO_IP, optname, (void*) &mreq, sizeof mreq) == -1) { diff --git a/deps/uv/src/uv-common.c b/deps/uv/src/uv-common.c index dd91dbb28d..0b05334945 100644 --- a/deps/uv/src/uv-common.c +++ b/deps/uv/src/uv-common.c @@ -198,7 +198,7 @@ int uv_ip6_name(struct sockaddr_in6* src, char* dst, size_t size) { int uv_tcp_bind(uv_tcp_t* handle, struct sockaddr_in addr) { if (handle->type != UV_TCP || addr.sin_family != AF_INET) { - uv__set_artificial_error(handle->loop, UV_EFAULT); + uv__set_artificial_error(handle->loop, UV_EINVAL); return -1; } @@ -208,7 +208,7 @@ int uv_tcp_bind(uv_tcp_t* handle, struct sockaddr_in addr) { int uv_tcp_bind6(uv_tcp_t* handle, struct sockaddr_in6 addr) { if (handle->type != UV_TCP || addr.sin6_family != AF_INET6) { - uv__set_artificial_error(handle->loop, UV_EFAULT); + uv__set_artificial_error(handle->loop, UV_EINVAL); return -1; } @@ -219,7 +219,7 @@ int uv_tcp_bind6(uv_tcp_t* handle, struct sockaddr_in6 addr) { int uv_udp_bind(uv_udp_t* handle, struct sockaddr_in addr, unsigned int flags) { if (handle->type != UV_UDP || addr.sin_family != AF_INET) { - uv__set_artificial_error(handle->loop, UV_EFAULT); + uv__set_artificial_error(handle->loop, UV_EINVAL); return -1; } @@ -230,7 +230,7 @@ int uv_udp_bind(uv_udp_t* handle, struct sockaddr_in addr, int uv_udp_bind6(uv_udp_t* handle, struct sockaddr_in6 addr, unsigned int flags) { if (handle->type != UV_UDP || addr.sin6_family != AF_INET6) { - uv__set_artificial_error(handle->loop, UV_EFAULT); + uv__set_artificial_error(handle->loop, UV_EINVAL); return -1; } diff --git a/deps/uv/src/win/udp.c b/deps/uv/src/win/udp.c index 56b46239a2..6d2cde30c6 100644 --- a/deps/uv/src/win/udp.c +++ b/deps/uv/src/win/udp.c @@ -615,8 +615,7 @@ int uv_udp_set_membership(uv_udp_t* handle, const char* multicast_addr, optname = IP_DROP_MEMBERSHIP; break; default: - uv__set_artificial_error(handle->loop, UV_EFAULT); - return -1; + return uv__set_artificial_error(handle->loop, UV_EINVAL); } if (setsockopt(handle->socket, diff --git a/deps/uv/test/test-tcp-bind-error.c b/deps/uv/test/test-tcp-bind-error.c index 03cf42eff6..424953568e 100644 --- a/deps/uv/test/test-tcp-bind-error.c +++ b/deps/uv/test/test-tcp-bind-error.c @@ -128,7 +128,7 @@ TEST_IMPL(tcp_bind_error_fault) { r = uv_tcp_bind(&server, *garbage_addr); ASSERT(r == -1); - ASSERT(uv_last_error(uv_default_loop()).code == UV_EFAULT); + ASSERT(uv_last_error(uv_default_loop()).code == UV_EINVAL); uv_close((uv_handle_t*)&server, close_cb); diff --git a/deps/uv/test/test-tcp-bind6-error.c b/deps/uv/test/test-tcp-bind6-error.c index f9f099e1f7..61afc7f19a 100644 --- a/deps/uv/test/test-tcp-bind6-error.c +++ b/deps/uv/test/test-tcp-bind6-error.c @@ -103,7 +103,7 @@ TEST_IMPL(tcp_bind6_error_fault) { r = uv_tcp_bind6(&server, *garbage_addr); ASSERT(r == -1); - ASSERT(uv_last_error(uv_default_loop()).code == UV_EFAULT); + ASSERT(uv_last_error(uv_default_loop()).code == UV_EINVAL); uv_close((uv_handle_t*)&server, close_cb); diff --git a/deps/uv/test/test-threadpool-cancel.c b/deps/uv/test/test-threadpool-cancel.c index 78938f94ce..f000c1a86b 100644 --- a/deps/uv/test/test-threadpool-cancel.c +++ b/deps/uv/test/test-threadpool-cancel.c @@ -195,6 +195,7 @@ TEST_IMPL(threadpool_cancel_getaddrinfo) { cleanup_threadpool(); + MAKE_VALGRIND_HAPPY(); return 0; } @@ -220,6 +221,7 @@ TEST_IMPL(threadpool_cancel_work) { cleanup_threadpool(); + MAKE_VALGRIND_HAPPY(); return 0; } @@ -271,6 +273,7 @@ TEST_IMPL(threadpool_cancel_fs) { cleanup_threadpool(); + MAKE_VALGRIND_HAPPY(); return 0; } @@ -303,5 +306,6 @@ TEST_IMPL(threadpool_cancel_single) { ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT)); ASSERT(req.data != NULL); /* Should have been updated by nop_done_cb(). */ + MAKE_VALGRIND_HAPPY(); return 0; } diff --git a/deps/uv/uv.gyp b/deps/uv/uv.gyp index d7b1963473..6ec5aa2893 100644 --- a/deps/uv/uv.gyp +++ b/deps/uv/uv.gyp @@ -34,14 +34,13 @@ 'defines': [ '_LARGEFILE_SOURCE', '_FILE_OFFSET_BITS=64', - '_POSIX_C_SOURCE=200112', ], }], ['OS == "mac"', { - 'defines': [ - '_DARWIN_USE_64_BIT_INODE=1', - '_DARWIN_C_SOURCE', # _POSIX_C_SOURCE hides SysV definitions. - ], + 'defines': [ '_DARWIN_USE_64_BIT_INODE=1' ], + }], + ['OS == "linux"', { + 'defines': [ '_POSIX_C_SOURCE=200112' ], }], ], },