diff options
Diffstat (limited to 'deps/uv/src/win')
-rw-r--r-- | deps/uv/src/win/fs-event.c | 7 | ||||
-rw-r--r-- | deps/uv/src/win/fs.c | 72 | ||||
-rw-r--r-- | deps/uv/src/win/pipe.c | 9 | ||||
-rw-r--r-- | deps/uv/src/win/thread.c | 6 | ||||
-rw-r--r-- | deps/uv/src/win/tty.c | 9 | ||||
-rw-r--r-- | deps/uv/src/win/util.c | 117 | ||||
-rw-r--r-- | deps/uv/src/win/winapi.c | 4 | ||||
-rw-r--r-- | deps/uv/src/win/winapi.h | 4 |
8 files changed, 147 insertions, 81 deletions
diff --git a/deps/uv/src/win/fs-event.c b/deps/uv/src/win/fs-event.c index 1244967a78..acf8e1107e 100644 --- a/deps/uv/src/win/fs-event.c +++ b/deps/uv/src/win/fs-event.c @@ -230,8 +230,11 @@ int uv_fs_event_start(uv_fs_event_t* handle, */ /* Convert to short path. */ - short_path = short_path_buffer; - if (!GetShortPathNameW(pathw, short_path, ARRAY_SIZE(short_path))) { + if (GetShortPathNameW(pathw, + short_path_buffer, + ARRAY_SIZE(short_path_buffer))) { + short_path = short_path_buffer; + } else { short_path = NULL; } diff --git a/deps/uv/src/win/fs.c b/deps/uv/src/win/fs.c index 0716ecca12..65d936bf08 100644 --- a/deps/uv/src/win/fs.c +++ b/deps/uv/src/win/fs.c @@ -42,8 +42,6 @@ #define UV_FS_FREE_PTR 0x0008 #define UV_FS_CLEANEDUP 0x0010 -#define UV__RENAME_RETRIES 4 -#define UV__RENAME_WAIT 250 #define INIT(subtype) \ do { \ @@ -1360,78 +1358,12 @@ static void fs__fstat(uv_fs_t* req) { static void fs__rename(uv_fs_t* req) { - int tries; - int sys_errno; - int result; - int try_rmdir; - WCHAR* src, *dst; - DWORD src_attrib, dst_attrib; - - src = req->file.pathw; - dst = req->fs.info.new_pathw; - try_rmdir = 0; - - /* Do some checks to fail early. */ - src_attrib = GetFileAttributesW(src); - if (src_attrib == INVALID_FILE_ATTRIBUTES) { + if (!MoveFileExW(req->file.pathw, req->fs.info.new_pathw, MOVEFILE_REPLACE_EXISTING)) { SET_REQ_WIN32_ERROR(req, GetLastError()); return; } - dst_attrib = GetFileAttributesW(dst); - if (dst_attrib != INVALID_FILE_ATTRIBUTES) { - if (dst_attrib & FILE_ATTRIBUTE_READONLY) { - req->result = UV_EPERM; - return; - } - /* Renaming folder to a folder name that already exist will fail on - * Windows. We will try to delete target folder first. - */ - if (src_attrib & FILE_ATTRIBUTE_DIRECTORY && - dst_attrib & FILE_ATTRIBUTE_DIRECTORY) - try_rmdir = 1; - } - - /* Sometimes an antivirus or indexing software can lock the target or the - * source file/directory. This is annoying for users, in such cases we will - * retry couple of times with some delay before failing. - */ - for (tries = 0; tries < UV__RENAME_RETRIES; ++tries) { - if (tries > 0) - Sleep(UV__RENAME_WAIT); - - if (try_rmdir) { - result = _wrmdir(dst) == 0 ? 0 : uv_translate_sys_error(_doserrno); - switch (result) - { - case 0: - case UV_ENOENT: - /* Folder removed or did not exist at all. */ - try_rmdir = 0; - break; - case UV_ENOTEMPTY: - /* Non-empty target folder, fail instantly. */ - SET_REQ_RESULT(req, -1); - return; - default: - /* All other errors - try to move file anyway and handle the error - * there, retrying folder deletion next time around. - */ - break; - } - } - - if (MoveFileExW(src, dst, MOVEFILE_REPLACE_EXISTING) != 0) { - SET_REQ_RESULT(req, 0); - return; - } - sys_errno = GetLastError(); - result = uv_translate_sys_error(sys_errno); - if (result != UV_EBUSY && result != UV_EPERM && result != UV_EACCES) - break; - } - req->sys_errno_ = sys_errno; - req->result = result; + SET_REQ_RESULT(req, 0); } diff --git a/deps/uv/src/win/pipe.c b/deps/uv/src/win/pipe.c index e303cc8a23..277f6497a2 100644 --- a/deps/uv/src/win/pipe.c +++ b/deps/uv/src/win/pipe.c @@ -1310,7 +1310,6 @@ static int uv__pipe_write_data(uv_loop_t* loop, uv_pipe_t* handle, const uv_buf_t bufs[], size_t nbufs, - uv_stream_t* send_handle, uv_write_cb cb, int copy_always) { int err; @@ -1321,7 +1320,7 @@ static int uv__pipe_write_data(uv_loop_t* loop, UV_REQ_INIT(req, UV_WRITE); req->handle = (uv_stream_t*) handle; - req->send_handle = send_handle; + req->send_handle = NULL; req->cb = cb; /* Private fields. */ req->coalesced = 0; @@ -1558,8 +1557,7 @@ int uv__pipe_write_ipc(uv_loop_t* loop, /* Write buffers. We set the `always_copy` flag, so it is not a problem that * some of the written data lives on the stack. */ - err = uv__pipe_write_data( - loop, req, handle, bufs, buf_count, send_handle, cb, 1); + err = uv__pipe_write_data(loop, req, handle, bufs, buf_count, cb, 1); /* If we had to heap-allocate the bufs array, free it now. */ if (bufs != stack_bufs) { @@ -1583,8 +1581,7 @@ int uv__pipe_write(uv_loop_t* loop, } else { /* Non-IPC pipe write: put data on the wire directly. */ assert(send_handle == NULL); - return uv__pipe_write_data( - loop, req, handle, bufs, nbufs, NULL, cb, 0); + return uv__pipe_write_data(loop, req, handle, bufs, nbufs, cb, 0); } } diff --git a/deps/uv/src/win/thread.c b/deps/uv/src/win/thread.c index 56ca41aab0..fd4b7c9868 100644 --- a/deps/uv/src/win/thread.c +++ b/deps/uv/src/win/thread.c @@ -23,6 +23,12 @@ #include <limits.h> #include <stdlib.h> +#if defined(__MINGW64_VERSION_MAJOR) +/* MemoryBarrier expands to __mm_mfence in some cases (x86+sse2), which may + * require this header in some versions of mingw64. */ +#include <intrin.h> +#endif + #include "uv.h" #include "internal.h" diff --git a/deps/uv/src/win/tty.c b/deps/uv/src/win/tty.c index 45bbe9689a..f38e9a8863 100644 --- a/deps/uv/src/win/tty.c +++ b/deps/uv/src/win/tty.c @@ -164,7 +164,7 @@ void uv_console_init(void) { OPEN_EXISTING, 0, 0); - if (uv__tty_console_handle != NULL) { + if (uv__tty_console_handle != INVALID_HANDLE_VALUE) { QueueUserWorkItem(uv__tty_console_resize_message_loop_thread, NULL, WT_EXECUTELONGFUNCTION); @@ -360,6 +360,8 @@ int uv_tty_set_mode(uv_tty_t* tty, uv_tty_mode_t mode) { } } else { was_reading = 0; + alloc_cb = NULL; + read_cb = NULL; } uv_sem_wait(&uv_tty_output_lock); @@ -733,8 +735,9 @@ void uv_process_tty_read_raw_req(uv_loop_t* loop, uv_tty_t* handle, /* Ignore keyup events, unless the left alt key was held and a valid * unicode character was emitted. */ - if (!KEV.bKeyDown && !(((KEV.dwControlKeyState & LEFT_ALT_PRESSED) || - KEV.wVirtualKeyCode==VK_MENU) && KEV.uChar.UnicodeChar != 0)) { + if (!KEV.bKeyDown && + KEV.wVirtualKeyCode != VK_MENU && + KEV.uChar.UnicodeChar != 0) { continue; } diff --git a/deps/uv/src/win/util.c b/deps/uv/src/win/util.c index 6e81c26165..923789129e 100644 --- a/deps/uv/src/win/util.c +++ b/deps/uv/src/win/util.c @@ -1627,3 +1627,120 @@ int uv_os_setpriority(uv_pid_t pid, int priority) { CloseHandle(handle); return r; } + + +int uv_os_uname(uv_utsname_t* buffer) { + /* Implementation loosely based on + https://github.com/gagern/gnulib/blob/master/lib/uname.c */ + OSVERSIONINFOW os_info; + SYSTEM_INFO system_info; + int processor_level; + int r; + + if (buffer == NULL) + return UV_EINVAL; + + uv__once_init(); + os_info.dwOSVersionInfoSize = sizeof(os_info); + os_info.szCSDVersion[0] = L'\0'; + + /* Try calling RtlGetVersion(), and fall back to the deprecated GetVersionEx() + if RtlGetVersion() is not available. */ + if (pRtlGetVersion) { + pRtlGetVersion(&os_info); + } else { + /* Silence GetVersionEx() deprecation warning. */ + #pragma warning(suppress : 4996) + if (GetVersionExW(&os_info) == 0) { + r = uv_translate_sys_error(GetLastError()); + goto error; + } + } + + /* Populate the version field. */ + if (WideCharToMultiByte(CP_UTF8, + 0, + os_info.szCSDVersion, + -1, + buffer->version, + sizeof(buffer->version), + NULL, + NULL) == 0) { + r = uv_translate_sys_error(GetLastError()); + goto error; + } + + /* Populate the sysname field. */ +#ifdef __MINGW32__ + r = snprintf(buffer->sysname, + sizeof(buffer->sysname), + "MINGW32_NT-%u.%u", + (unsigned int) os_info.dwMajorVersion, + (unsigned int) os_info.dwMinorVersion); + assert(r < sizeof(buffer->sysname)); +#else + uv__strscpy(buffer->sysname, "Windows_NT", sizeof(buffer->sysname)); +#endif + + /* Populate the release field. */ + r = snprintf(buffer->release, + sizeof(buffer->release), + "%d.%d.%d", + (unsigned int) os_info.dwMajorVersion, + (unsigned int) os_info.dwMinorVersion, + (unsigned int) os_info.dwBuildNumber); + assert(r < sizeof(buffer->release)); + + /* Populate the machine field. */ + GetSystemInfo(&system_info); + + switch (system_info.wProcessorArchitecture) { + case PROCESSOR_ARCHITECTURE_AMD64: + uv__strscpy(buffer->machine, "x86_64", sizeof(buffer->machine)); + break; + case PROCESSOR_ARCHITECTURE_IA64: + uv__strscpy(buffer->machine, "ia64", sizeof(buffer->machine)); + break; + case PROCESSOR_ARCHITECTURE_INTEL: + uv__strscpy(buffer->machine, "i386", sizeof(buffer->machine)); + + if (system_info.wProcessorLevel > 3) { + processor_level = system_info.wProcessorLevel < 6 ? + system_info.wProcessorLevel : 6; + buffer->machine[1] = '0' + processor_level; + } + + break; + case PROCESSOR_ARCHITECTURE_IA32_ON_WIN64: + uv__strscpy(buffer->machine, "i686", sizeof(buffer->machine)); + break; + case PROCESSOR_ARCHITECTURE_MIPS: + uv__strscpy(buffer->machine, "mips", sizeof(buffer->machine)); + break; + case PROCESSOR_ARCHITECTURE_ALPHA: + case PROCESSOR_ARCHITECTURE_ALPHA64: + uv__strscpy(buffer->machine, "alpha", sizeof(buffer->machine)); + break; + case PROCESSOR_ARCHITECTURE_PPC: + uv__strscpy(buffer->machine, "powerpc", sizeof(buffer->machine)); + break; + case PROCESSOR_ARCHITECTURE_SHX: + uv__strscpy(buffer->machine, "sh", sizeof(buffer->machine)); + break; + case PROCESSOR_ARCHITECTURE_ARM: + uv__strscpy(buffer->machine, "arm", sizeof(buffer->machine)); + break; + default: + uv__strscpy(buffer->machine, "unknown", sizeof(buffer->machine)); + break; + } + + return 0; + +error: + buffer->sysname[0] = '\0'; + buffer->release[0] = '\0'; + buffer->version[0] = '\0'; + buffer->machine[0] = '\0'; + return r; +} diff --git a/deps/uv/src/win/winapi.c b/deps/uv/src/win/winapi.c index 2c09b448a9..fbbbceed95 100644 --- a/deps/uv/src/win/winapi.c +++ b/deps/uv/src/win/winapi.c @@ -26,6 +26,7 @@ /* Ntdll function pointers */ +sRtlGetVersion pRtlGetVersion; sRtlNtStatusToDosError pRtlNtStatusToDosError; sNtDeviceIoControlFile pNtDeviceIoControlFile; sNtQueryInformationFile pNtQueryInformationFile; @@ -55,6 +56,9 @@ void uv_winapi_init(void) { uv_fatal_error(GetLastError(), "GetModuleHandleA"); } + pRtlGetVersion = (sRtlGetVersion) GetProcAddress(ntdll_module, + "RtlGetVersion"); + pRtlNtStatusToDosError = (sRtlNtStatusToDosError) GetProcAddress( ntdll_module, "RtlNtStatusToDosError"); diff --git a/deps/uv/src/win/winapi.h b/deps/uv/src/win/winapi.h index 2a8adf6b26..82c5ed4671 100644 --- a/deps/uv/src/win/winapi.h +++ b/deps/uv/src/win/winapi.h @@ -4519,6 +4519,9 @@ typedef VOID (NTAPI *PIO_APC_ROUTINE) PIO_STATUS_BLOCK IoStatusBlock, ULONG Reserved); +typedef NTSTATUS (NTAPI *sRtlGetVersion) + (PRTL_OSVERSIONINFOW lpVersionInformation); + typedef ULONG (NTAPI *sRtlNtStatusToDosError) (NTSTATUS Status); @@ -4707,6 +4710,7 @@ typedef HWINEVENTHOOK (WINAPI *sSetWinEventHook) /* Ntdll function pointers */ +extern sRtlGetVersion pRtlGetVersion; extern sRtlNtStatusToDosError pRtlNtStatusToDosError; extern sNtDeviceIoControlFile pNtDeviceIoControlFile; extern sNtQueryInformationFile pNtQueryInformationFile; |