uv: upgrade to 58ef43e
This commit is contained in:
parent
de978991d8
commit
554dc63328
2
deps/uv/config-unix.mk
vendored
2
deps/uv/config-unix.mk
vendored
@ -58,7 +58,7 @@ endif
|
||||
ifeq (Linux,$(uname_S))
|
||||
EV_CONFIG=config_linux.h
|
||||
EIO_CONFIG=config_linux.h
|
||||
CSTDFLAG += -D_XOPEN_SOURCE=600
|
||||
CSTDFLAG += -D_GNU_SOURCE
|
||||
CPPFLAGS += -Isrc/ares/config_linux
|
||||
LINKFLAGS+=-lrt
|
||||
OBJS += src/unix/linux.o
|
||||
|
1
deps/uv/include/uv.h
vendored
1
deps/uv/include/uv.h
vendored
@ -172,6 +172,7 @@ typedef enum {
|
||||
UV_ENOTCONN,
|
||||
UV_ENOTSOCK,
|
||||
UV_ENOTSUP,
|
||||
UV_ENOENT,
|
||||
UV_EPIPE,
|
||||
UV_EPROTO,
|
||||
UV_EPROTONOSUPPORT,
|
||||
|
24
deps/uv/src/unix/core.c
vendored
24
deps/uv/src/unix/core.c
vendored
@ -18,10 +18,6 @@
|
||||
* IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE /* O_CLOEXEC, accept4(), etc. */
|
||||
#endif
|
||||
|
||||
#include "uv.h"
|
||||
#include "unix/internal.h"
|
||||
|
||||
@ -42,26 +38,6 @@
|
||||
#include <limits.h> /* PATH_MAX */
|
||||
#include <sys/uio.h> /* writev */
|
||||
|
||||
#if defined(__linux__)
|
||||
|
||||
#include <linux/version.h>
|
||||
#include <features.h>
|
||||
|
||||
#undef HAVE_PIPE2
|
||||
#undef HAVE_ACCEPT4
|
||||
|
||||
/* pipe2() requires linux >= 2.6.27 and glibc >= 2.9 */
|
||||
#if LINUX_VERSION_CODE >= 0x2061B && __GLIBC_PREREQ(2, 9)
|
||||
#define HAVE_PIPE2
|
||||
#endif
|
||||
|
||||
/* accept4() requires linux >= 2.6.28 and glib >= 2.10 */
|
||||
#if LINUX_VERSION_CODE >= 0x2061C && __GLIBC_PREREQ(2, 10)
|
||||
#define HAVE_ACCEPT4
|
||||
#endif
|
||||
|
||||
#endif /* __linux__ */
|
||||
|
||||
#ifdef __sun
|
||||
# include <sys/types.h>
|
||||
# include <sys/wait.h>
|
||||
|
7
deps/uv/src/unix/error.c
vendored
7
deps/uv/src/unix/error.c
vendored
@ -31,6 +31,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
|
||||
/* TODO Expose callback to user to handle fatal error like V8 does. */
|
||||
@ -65,9 +66,10 @@ char* uv_strerror(uv_err_t err) {
|
||||
}
|
||||
|
||||
|
||||
static uv_err_code uv_translate_sys_error(int sys_errno) {
|
||||
uv_err_code uv_translate_sys_error(int sys_errno) {
|
||||
switch (sys_errno) {
|
||||
case 0: return UV_OK;
|
||||
case ENOENT: return UV_ENOENT;
|
||||
case EACCES: return UV_EACCESS;
|
||||
case EBADF: return UV_EBADF;
|
||||
case EPIPE: return UV_EPIPE;
|
||||
@ -83,6 +85,9 @@ static uv_err_code uv_translate_sys_error(int sys_errno) {
|
||||
case ENOTCONN: return UV_ENOTCONN;
|
||||
default: return UV_UNKNOWN;
|
||||
}
|
||||
|
||||
assert(0 && "unreachable");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
|
13
deps/uv/src/unix/fs.c
vendored
13
deps/uv/src/unix/fs.c
vendored
@ -32,6 +32,7 @@
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <utime.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
|
||||
#define ARGS1(a) (a)
|
||||
@ -43,12 +44,12 @@
|
||||
uv_fs_req_init(loop, req, type, path, cb); \
|
||||
if (cb) { \
|
||||
/* async */ \
|
||||
uv_ref(loop); \
|
||||
req->eio = eiofunc(args, EIO_PRI_DEFAULT, uv__fs_after, req); \
|
||||
if (!req->eio) { \
|
||||
uv_err_new(loop, ENOMEM); \
|
||||
return -1; \
|
||||
} \
|
||||
uv_ref(loop); \
|
||||
} else { \
|
||||
/* sync */ \
|
||||
req->result = func(args); \
|
||||
@ -61,7 +62,7 @@
|
||||
|
||||
|
||||
static void uv_fs_req_init(uv_loop_t* loop, uv_fs_t* req, uv_fs_type fs_type,
|
||||
char* path, uv_fs_cb cb) {
|
||||
const char* path, uv_fs_cb cb) {
|
||||
/* Make sure the thread pool is initialized. */
|
||||
uv_eio_init(loop);
|
||||
|
||||
@ -110,7 +111,7 @@ static int uv__fs_after(eio_req* eio) {
|
||||
assert(req->cb);
|
||||
|
||||
req->result = req->eio->result;
|
||||
req->errorno = req->eio->errorno;
|
||||
req->errorno = uv_translate_sys_error(req->eio->errorno);
|
||||
|
||||
switch (req->fs_type) {
|
||||
case UV_FS_READDIR:
|
||||
@ -344,7 +345,7 @@ int uv_fs_readdir(uv_loop_t* loop, uv_fs_t* req, const char* path, int flags,
|
||||
|
||||
|
||||
int uv_fs_stat(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb) {
|
||||
char* pathdup = path;
|
||||
char* pathdup;
|
||||
int pathlen;
|
||||
|
||||
uv_fs_req_init(loop, req, UV_FS_STAT, path, cb);
|
||||
@ -479,7 +480,7 @@ int uv_fs_futime(uv_loop_t* loop, uv_fs_t* req, uv_file file, double atime,
|
||||
|
||||
|
||||
int uv_fs_lstat(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb) {
|
||||
char* pathdup = path;
|
||||
char* pathdup;
|
||||
int pathlen;
|
||||
|
||||
uv_fs_req_init(loop, req, UV_FS_LSTAT, path, cb);
|
||||
@ -538,7 +539,7 @@ int uv_fs_symlink(uv_loop_t* loop, uv_fs_t* req, const char* path,
|
||||
|
||||
int uv_fs_readlink(uv_loop_t* loop, uv_fs_t* req, const char* path,
|
||||
uv_fs_cb cb) {
|
||||
size_t size;
|
||||
ssize_t size;
|
||||
int status;
|
||||
char* buf;
|
||||
|
||||
|
27
deps/uv/src/unix/internal.h
vendored
27
deps/uv/src/unix/internal.h
vendored
@ -25,6 +25,32 @@
|
||||
#include "uv-common.h"
|
||||
#include "uv-eio.h"
|
||||
|
||||
#if defined(__linux__)
|
||||
|
||||
#include <linux/version.h>
|
||||
#include <features.h>
|
||||
|
||||
#undef HAVE_FUTIMES
|
||||
#undef HAVE_PIPE2
|
||||
#undef HAVE_ACCEPT4
|
||||
|
||||
/* futimes() requires linux >= 2.6.22 and glib >= 2.6 */
|
||||
#if LINUX_VERSION_CODE >= 0x20616 && __GLIBC_PREREQ(2, 6)
|
||||
#define HAVE_FUTIMES
|
||||
#endif
|
||||
|
||||
/* pipe2() requires linux >= 2.6.27 and glibc >= 2.9 */
|
||||
#if LINUX_VERSION_CODE >= 0x2061B && __GLIBC_PREREQ(2, 9)
|
||||
#define HAVE_PIPE2
|
||||
#endif
|
||||
|
||||
/* accept4() requires linux >= 2.6.28 and glib >= 2.10 */
|
||||
#if LINUX_VERSION_CODE >= 0x2061C && __GLIBC_PREREQ(2, 10)
|
||||
#define HAVE_ACCEPT4
|
||||
#endif
|
||||
|
||||
#endif /* __linux__ */
|
||||
|
||||
/* flags */
|
||||
enum {
|
||||
UV_CLOSING = 0x00000001, /* uv_close() called but not finished. */
|
||||
@ -48,6 +74,7 @@ int uv__cloexec(int fd, int set) __attribute__((unused));
|
||||
int uv__socket(int domain, int type, int protocol);
|
||||
|
||||
/* error */
|
||||
uv_err_code uv_translate_sys_error(int sys_errno);
|
||||
uv_err_t uv_err_new(uv_loop_t* loop, int sys_error);
|
||||
uv_err_t uv_err_new_artificial(uv_loop_t* loop, int code);
|
||||
void uv_fatal_error(const int errorno, const char* syscall);
|
||||
|
1
deps/uv/src/unix/process.c
vendored
1
deps/uv/src/unix/process.c
vendored
@ -26,6 +26,7 @@
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <sys/wait.h>
|
||||
#include <fcntl.h> /* O_CLOEXEC, O_NONBLOCK */
|
||||
#include <poll.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
|
1
deps/uv/src/uv-common.c
vendored
1
deps/uv/src/uv-common.c
vendored
@ -81,6 +81,7 @@ const char* uv_err_name(uv_err_t err) {
|
||||
case UV_ENOTCONN: return "ENOTCONN";
|
||||
case UV_ENOTSOCK: return "ENOTSOCK";
|
||||
case UV_ENOTSUP: return "ENOTSUP";
|
||||
case UV_ENOENT: return "ENOENT";
|
||||
case UV_EPIPE: return "EPIPE";
|
||||
case UV_EPROTO: return "EPROTO";
|
||||
case UV_EPROTONOSUPPORT: return "EPROTONOSUPPORT";
|
||||
|
6
deps/uv/src/uv-common.h
vendored
6
deps/uv/src/uv-common.h
vendored
@ -32,9 +32,9 @@
|
||||
#define COUNTOF(a) (sizeof(a) / sizeof(a[0]))
|
||||
|
||||
/* Used for the uv_fs_ functions */
|
||||
#define SET_REQ_RESULT(req, result) \
|
||||
req->result = result; \
|
||||
if (result == -1) { \
|
||||
#define SET_REQ_RESULT(req, result_value) \
|
||||
req->result = (result_value); \
|
||||
if (req->result == -1) { \
|
||||
req->errorno = errno; \
|
||||
}
|
||||
|
||||
|
69
deps/uv/src/win/fs.c
vendored
69
deps/uv/src/win/fs.c
vendored
@ -25,6 +25,7 @@
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <io.h>
|
||||
#include <limits.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/utime.h>
|
||||
#include <stdio.h>
|
||||
@ -239,33 +240,77 @@ void fs__close(uv_fs_t* req, uv_file file) {
|
||||
|
||||
void fs__read(uv_fs_t* req, uv_file file, void *buf, size_t length,
|
||||
off_t offset) {
|
||||
int result = 0;
|
||||
HANDLE handle;
|
||||
OVERLAPPED overlapped, *overlapped_ptr;
|
||||
LARGE_INTEGER offset_;
|
||||
DWORD bytes;
|
||||
|
||||
handle = (HANDLE) _get_osfhandle(file);
|
||||
if (handle == INVALID_HANDLE_VALUE) {
|
||||
SET_REQ_RESULT(req, -1);
|
||||
return;
|
||||
}
|
||||
|
||||
if (length > INT_MAX) {
|
||||
SET_REQ_ERROR(req, ERROR_INSUFFICIENT_BUFFER);
|
||||
return;
|
||||
}
|
||||
|
||||
if (offset != -1) {
|
||||
result = _lseek(file, offset, SEEK_SET);
|
||||
memset(&overlapped, 0, sizeof overlapped);
|
||||
|
||||
offset_.QuadPart = offset;
|
||||
overlapped.Offset = offset_.LowPart;
|
||||
overlapped.OffsetHigh = offset_.HighPart;
|
||||
|
||||
overlapped_ptr = &overlapped;
|
||||
} else {
|
||||
overlapped_ptr = NULL;
|
||||
}
|
||||
|
||||
if (result != -1) {
|
||||
result = _read(file, buf, length);
|
||||
if (ReadFile(handle, buf, length, &bytes, overlapped_ptr)) {
|
||||
SET_REQ_RESULT(req, bytes);
|
||||
} else {
|
||||
SET_REQ_ERROR(req, GetLastError());
|
||||
}
|
||||
|
||||
SET_REQ_RESULT(req, result);
|
||||
}
|
||||
|
||||
|
||||
void fs__write(uv_fs_t* req, uv_file file, void *buf, size_t length,
|
||||
off_t offset) {
|
||||
int result = 0;
|
||||
HANDLE handle;
|
||||
OVERLAPPED overlapped, *overlapped_ptr;
|
||||
LARGE_INTEGER offset_;
|
||||
DWORD bytes;
|
||||
|
||||
handle = (HANDLE) _get_osfhandle(file);
|
||||
if (handle == INVALID_HANDLE_VALUE) {
|
||||
SET_REQ_RESULT(req, -1);
|
||||
return;
|
||||
}
|
||||
|
||||
if (length > INT_MAX) {
|
||||
SET_REQ_ERROR(req, ERROR_INSUFFICIENT_BUFFER);
|
||||
return;
|
||||
}
|
||||
|
||||
if (offset != -1) {
|
||||
result = _lseek(file, offset, SEEK_SET);
|
||||
memset(&overlapped, 0, sizeof overlapped);
|
||||
|
||||
offset_.QuadPart = offset;
|
||||
overlapped.Offset = offset_.LowPart;
|
||||
overlapped.OffsetHigh = offset_.HighPart;
|
||||
|
||||
overlapped_ptr = &overlapped;
|
||||
} else {
|
||||
overlapped_ptr = NULL;
|
||||
}
|
||||
|
||||
if (result != -1) {
|
||||
result = _write(file, buf, length);
|
||||
if (WriteFile(handle, buf, length, &bytes, overlapped_ptr)) {
|
||||
SET_REQ_RESULT(req, bytes);
|
||||
} else {
|
||||
SET_REQ_ERROR(req, GetLastError());
|
||||
}
|
||||
|
||||
SET_REQ_RESULT(req, result);
|
||||
}
|
||||
|
||||
|
||||
|
35
deps/uv/test/test-fs.c
vendored
35
deps/uv/test/test-fs.c
vendored
@ -360,6 +360,41 @@ static void sendfile_cb(uv_fs_t* req) {
|
||||
}
|
||||
|
||||
|
||||
static void open_noent_cb(uv_fs_t* req) {
|
||||
ASSERT(req->fs_type == UV_FS_OPEN);
|
||||
ASSERT(req->errorno == UV_ENOENT);
|
||||
ASSERT(req->result == -1);
|
||||
open_cb_count++;
|
||||
uv_fs_req_cleanup(req);
|
||||
}
|
||||
|
||||
|
||||
TEST_IMPL(fs_file_noent) {
|
||||
uv_fs_t req;
|
||||
int r;
|
||||
|
||||
uv_init();
|
||||
loop = uv_default_loop();
|
||||
|
||||
r = uv_fs_open(loop, &req, "does_not_exist", O_RDONLY, 0, NULL);
|
||||
ASSERT(r == -1);
|
||||
ASSERT(req.result == -1);
|
||||
ASSERT(uv_last_error(loop).code == UV_ENOENT);
|
||||
uv_fs_req_cleanup(&req);
|
||||
|
||||
r = uv_fs_open(loop, &req, "does_not_exist", O_RDONLY, 0, open_noent_cb);
|
||||
ASSERT(r == 0);
|
||||
|
||||
ASSERT(open_cb_count == 0);
|
||||
uv_run(loop);
|
||||
ASSERT(open_cb_count == 1);
|
||||
|
||||
/* TODO add EACCES test */
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
TEST_IMPL(fs_file_async) {
|
||||
int r;
|
||||
|
||||
|
2
deps/uv/test/test-list.h
vendored
2
deps/uv/test/test-list.h
vendored
@ -72,6 +72,7 @@ TEST_DECLARE (spawn_exit_code)
|
||||
TEST_DECLARE (spawn_stdout)
|
||||
TEST_DECLARE (spawn_stdin)
|
||||
TEST_DECLARE (spawn_and_kill)
|
||||
TEST_DECLARE (fs_file_noent)
|
||||
TEST_DECLARE (fs_file_async)
|
||||
TEST_DECLARE (fs_file_sync)
|
||||
TEST_DECLARE (fs_async_dir)
|
||||
@ -180,6 +181,7 @@ TASK_LIST_START
|
||||
TEST_ENTRY (environment_creation)
|
||||
#endif
|
||||
|
||||
TEST_ENTRY (fs_file_noent)
|
||||
TEST_ENTRY (fs_file_async)
|
||||
TEST_ENTRY (fs_file_sync)
|
||||
TEST_ENTRY (fs_async_dir)
|
||||
|
Loading…
x
Reference in New Issue
Block a user