From 2d7a7592ecfcad63471ca41048a3498d8294a415 Mon Sep 17 00:00:00 2001 From: cjihrig Date: Wed, 15 Apr 2020 12:41:19 -0400 Subject: [PATCH] deps: upgrade to libuv 1.36.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Notable changes: - gyp support has been removed. - recvmmsg messages are returned in the correct order. - IBMi cmake support has been added. - uv_fs_lutime() has been added. - uv_fs_statfs() on Windows properly handles file paths. PR-URL: https://github.com/nodejs/node/pull/32866 Reviewed-By: James M Snell Reviewed-By: Richard Lau Reviewed-By: Anna Henningsen Reviewed-By: David Carlier Reviewed-By: Santiago Gimeno Reviewed-By: Ben Noordhuis Reviewed-By: Jiawen Geng Reviewed-By: Juan José Arboleda --- deps/uv/.gitignore | 5 - deps/uv/.mailmap | 1 + deps/uv/AUTHORS | 6 + deps/uv/CMakeLists.txt | 68 +++- deps/uv/CONTRIBUTING.md | 1 - deps/uv/ChangeLog | 71 ++++ deps/uv/Makefile.am | 13 +- deps/uv/README.md | 215 +++---------- deps/uv/SUPPORTED_PLATFORMS.md | 5 +- deps/uv/android-configure-arm | 23 -- deps/uv/android-configure-arm64 | 23 -- deps/uv/android-configure-x86 | 23 -- deps/uv/android-configure-x86_64 | 25 -- deps/uv/appveyor.yml | 32 -- deps/uv/configure.ac | 2 +- deps/uv/docs/src/fs.rst | 14 +- deps/uv/docs/src/misc.rst | 10 + deps/uv/docs/src/udp.rst | 17 +- deps/uv/gyp_uv.py | 73 ----- deps/uv/include/uv.h | 34 +- deps/uv/include/uv/version.h | 4 +- deps/uv/src/unix/android-ifaddrs.c | 3 +- deps/uv/src/unix/atomic-ops.h | 2 + deps/uv/src/unix/core.c | 13 +- deps/uv/src/unix/fs.c | 86 +++-- deps/uv/src/unix/openbsd.c | 6 +- deps/uv/src/unix/os390-syscalls.c | 67 +++- deps/uv/src/unix/os390-syscalls.h | 6 + deps/uv/src/unix/os390.c | 2 +- deps/uv/src/unix/posix-poll.c | 2 +- deps/uv/src/unix/tty.c | 35 +- deps/uv/src/unix/udp.c | 13 +- deps/uv/src/uv-common.c | 11 + deps/uv/src/uv-common.h | 1 + deps/uv/src/win/fs.c | 130 +++++++- deps/uv/src/win/process.c | 9 +- deps/uv/src/win/util.c | 10 +- deps/uv/src/win/winapi.c | 12 - deps/uv/src/win/winapi.h | 8 - deps/uv/test/run-benchmarks.c | 3 +- deps/uv/test/run-tests.c | 4 +- deps/uv/test/runner-unix.c | 12 +- deps/uv/test/runner-win.c | 4 +- deps/uv/test/runner.h | 6 +- deps/uv/test/task.h | 114 +++++++ deps/uv/test/test-cwd-and-chdir.c | 3 +- deps/uv/test/test-fs.c | 114 ++++++- deps/uv/test/test-get-currentexe.c | 21 +- deps/uv/test/test-gethostname.c | 2 +- deps/uv/test/test-homedir.c | 2 +- deps/uv/test/test-ipc.c | 321 ++++++++++--------- deps/uv/test/test-list.h | 2 + deps/uv/test/test-process-title-threadsafe.c | 17 +- deps/uv/test/test-spawn.c | 7 +- deps/uv/test/test-tmpdir.c | 2 +- deps/uv/test/test-tty.c | 2 + deps/uv/test/test.gyp | 295 ----------------- deps/uv/vcbuild.bat | 184 ----------- 58 files changed, 997 insertions(+), 1199 deletions(-) delete mode 100755 deps/uv/android-configure-arm delete mode 100755 deps/uv/android-configure-arm64 delete mode 100755 deps/uv/android-configure-x86 delete mode 100755 deps/uv/android-configure-x86_64 delete mode 100644 deps/uv/appveyor.yml delete mode 100755 deps/uv/gyp_uv.py delete mode 100644 deps/uv/test/test.gyp delete mode 100644 deps/uv/vcbuild.bat diff --git a/deps/uv/.gitignore b/deps/uv/.gitignore index b6abc2ab464978..83370a7bb0efcd 100644 --- a/deps/uv/.gitignore +++ b/deps/uv/.gitignore @@ -37,11 +37,6 @@ vgcore.* Makefile Makefile.in -# Generated by gyp for android -*.target.mk -/android-toolchain - -/out/ /build/ /test/.libs/ diff --git a/deps/uv/.mailmap b/deps/uv/.mailmap index 87d63bed0b14d3..2ae2968c83208d 100644 --- a/deps/uv/.mailmap +++ b/deps/uv/.mailmap @@ -17,6 +17,7 @@ Imran Iqbal Isaac Z. Schlueter Jason Williams Jesse Gorzinski +Jesse Gorzinski Justin Venus Keno Fischer Keno Fischer diff --git a/deps/uv/AUTHORS b/deps/uv/AUTHORS index 491eded73d5c94..17d67a64c6ca96 100644 --- a/deps/uv/AUTHORS +++ b/deps/uv/AUTHORS @@ -418,3 +418,9 @@ Dominique Dumont Manuel BACHMANN Marek Vavrusa TK-one +Irek Fakhrutdinov +Lin Zhang +毛毛 +Sk Sajidul Kadir +twosee +Rikard Falkeborn diff --git a/deps/uv/CMakeLists.txt b/deps/uv/CMakeLists.txt index 03d889cf1dd8eb..c82fa2b56d8771 100644 --- a/deps/uv/CMakeLists.txt +++ b/deps/uv/CMakeLists.txt @@ -1,4 +1,3 @@ -# TODO: determine CMAKE_SYSTEM_NAME on OS/390. Currently assumes "OS/390". cmake_minimum_required(VERSION 3.4) project(libuv LANGUAGES C) @@ -114,7 +113,7 @@ if(WIN32) list(APPEND uv_test_sources src/win/snprintf.c test/runner-win.c) else() list(APPEND uv_defines _FILE_OFFSET_BITS=64 _LARGEFILE_SOURCE) - if(NOT CMAKE_SYSTEM_NAME STREQUAL "Android") + if(NOT CMAKE_SYSTEM_NAME MATCHES "Android|OS390") # TODO: This should be replaced with find_package(Threads) if possible # Android has pthread as part of its c library, not as a separate # libpthread.so. @@ -147,9 +146,12 @@ if(CMAKE_SYSTEM_NAME STREQUAL "AIX") _ALL_SOURCE _LINUX_SOURCE_COMPAT _THREAD_SAFE - _XOPEN_SOURCE=500) + _XOPEN_SOURCE=500 + HAVE_SYS_AHAFS_EVPRODS_H) list(APPEND uv_libraries perfstat) - list(APPEND uv_sources src/unix/aix.c) + list(APPEND uv_sources + src/unix/aix.c + src/unix/aix-common.c) endif() if(CMAKE_SYSTEM_NAME STREQUAL "Android") @@ -167,7 +169,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Android") src/unix/sysinfo-loadavg.c) endif() -if(APPLE OR CMAKE_SYSTEM_NAME MATCHES "Android|Linux|OS/390") +if(APPLE OR CMAKE_SYSTEM_NAME MATCHES "Android|Linux|OS390") list(APPEND uv_sources src/unix/proctitle.c) endif() @@ -221,10 +223,11 @@ if(CMAKE_SYSTEM_NAME STREQUAL "OpenBSD") list(APPEND uv_sources src/unix/openbsd.c) endif() -if(CMAKE_SYSTEM_NAME STREQUAL "OS/390") +if(CMAKE_SYSTEM_NAME STREQUAL "OS390") list(APPEND uv_defines PATH_MAX=255) list(APPEND uv_defines _AE_BIMODAL) list(APPEND uv_defines _ALL_SOURCE) + list(APPEND uv_defines _ISOC99_SOURCE) list(APPEND uv_defines _LARGE_TIME_API) list(APPEND uv_defines _OPEN_MSGQ_EXT) list(APPEND uv_defines _OPEN_SYS_FILE_EXT) @@ -237,9 +240,25 @@ if(CMAKE_SYSTEM_NAME STREQUAL "OS/390") list(APPEND uv_defines _XOPEN_SOURCE_EXTENDED) list(APPEND uv_sources src/unix/pthread-fixes.c - src/unix/pthread-barrier.c src/unix/os390.c src/unix/os390-syscalls.c) + list(APPEND uv_cflags -Wc,DLL -Wc,exportall -Wc,xplink) + list(APPEND uv_libraries -Wl,xplink) + list(APPEND uv_test_libraries -Wl,xplink) +endif() + +if(CMAKE_SYSTEM_NAME STREQUAL "OS400") + list(APPEND uv_defines + _ALL_SOURCE + _LINUX_SOURCE_COMPAT + _THREAD_SAFE + _XOPEN_SOURCE=500) + list(APPEND uv_sources + src/unix/aix-common.c + src/unix/ibmi.c + src/unix/no-fsevents.c + src/unix/no-proctitle.c + src/unix/posix-poll.c) endif() if(CMAKE_SYSTEM_NAME STREQUAL "SunOS") @@ -280,6 +299,37 @@ target_include_directories(uv_a target_link_libraries(uv_a ${uv_libraries}) if(LIBUV_BUILD_TESTS) + # Small hack: use ${uv_test_sources} now to get the runner skeleton, + # before the actual tests are added. + add_executable( + uv_run_benchmarks_a + ${uv_test_sources} + test/benchmark-async-pummel.c + test/benchmark-async.c + test/benchmark-fs-stat.c + test/benchmark-getaddrinfo.c + test/benchmark-loop-count.c + test/benchmark-million-async.c + test/benchmark-million-timers.c + test/benchmark-multi-accept.c + test/benchmark-ping-pongs.c + test/benchmark-ping-udp.c + test/benchmark-pound.c + test/benchmark-pump.c + test/benchmark-sizes.c + test/benchmark-spawn.c + test/benchmark-tcp-write-batch.c + test/benchmark-thread.c + test/benchmark-udp-pummel.c + test/blackhole-server.c + test/dns-server.c + test/echo-server.c + test/run-benchmarks.c + test/runner.c) + target_compile_definitions(uv_run_benchmarks_a PRIVATE ${uv_defines}) + target_compile_options(uv_run_benchmarks_a PRIVATE ${uv_cflags}) + target_link_libraries(uv_run_benchmarks_a uv_a ${uv_test_libraries}) + list(APPEND uv_test_sources test/blackhole-server.c test/echo-server.c @@ -447,6 +497,10 @@ if(LIBUV_BUILD_TESTS) add_test(NAME uv_test COMMAND uv_run_tests WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) + if(CMAKE_SYSTEM_NAME STREQUAL "OS390") + set_tests_properties(uv_test PROPERTIES ENVIRONMENT + "LIBPATH=${CMAKE_BINARY_DIR}:$ENV{LIBPATH}") + endif() add_executable(uv_run_tests_a ${uv_test_sources}) target_compile_definitions(uv_run_tests_a PRIVATE ${uv_defines}) target_compile_options(uv_run_tests_a PRIVATE ${uv_cflags}) diff --git a/deps/uv/CONTRIBUTING.md b/deps/uv/CONTRIBUTING.md index 6f8c45affb7545..b0abe3b40eaa25 100644 --- a/deps/uv/CONTRIBUTING.md +++ b/deps/uv/CONTRIBUTING.md @@ -142,7 +142,6 @@ Bug fixes and features should come with tests. Add your tests in the If you add a new test file, it needs to be registered in three places: - `CMakeLists.txt`: add the file's name to the `uv_test_sources` list. - `Makefile.am`: add the file's name to the `test_run_tests_SOURCES` list. -- `uv.gyp`: add the file's name to the `sources` list in the `run-tests` target. Look at other tests to see how they should be structured (license boilerplate, the way entry points are declared, etc.). diff --git a/deps/uv/ChangeLog b/deps/uv/ChangeLog index f45ba985e51cb0..72484155c49039 100644 --- a/deps/uv/ChangeLog +++ b/deps/uv/ChangeLog @@ -1,3 +1,74 @@ +2020.04.16, Version 1.36.0 (Stable), 533b738838ad8407032e14b6772b29ef9af63cfa + +Changes since version 1.35.0: + +* build: add aix-common.c for AIX cmake build (Jesse Gorzinski) + +* zos: explicitly mark message queue events (Irek Fakhrutdinov) + +* zos: move mq check out of loop to save cpu cycles (Irek Fakhrutdinov) + +* zos: add checks to ensure behavior of epoll_wait (Irek Fakhrutdinov) + +* src: add uv__reallocf() (Ben Noordhuis) + +* build: ibmi support for cmake (Jesse Gorzinski) + +* build: fix gyp build for Android API >= 28 (Lin Zhang) + +* udp: return recvmmsg-ed datagrams in order (Saúl Ibarra Corretgé) + +* zos,test: fix spawn_empty_env for shared library build (Richard Lau) + +* zos: fix non-Release builds (Richard Lau) + +* zos: fix return value on expired nanosleep() call (Richard Lau) + +* build: fix z/OS cmake build (Richard Lau) + +* test: add a bunch of ASSERT macros (Santiago Gimeno) + +* test: remove unused extern declaration (Ben Noordhuis) + +* test: canonicalize argv[0] in exepath test (Ben Noordhuis) + +* test: simplify platform_init() (Ben Noordhuis) + +* ibmi: Fix isatty EBADF handling and refactor (Kevin Adler) + +* test: Test EBADF tty handling (Kevin Adler) + +* build: make cmake build benchmarks (Ben Noordhuis) + +* win: use RtlGenRandom from advapi32.dll directly (Ben Noordhuis) + +* android: fix OOB write in uv_interface_addresses() (Lin Zhang) + +* test: pass test when hostname is single character (毛毛) + +* ibmi: set the highest process priority to -10 (Xu Meng) + +* build: remove support for gyp (Ben Noordhuis) + +* doc: add note to README on cross-compiling (Ben Noordhuis) + +* fs: add uv_fs_lutime() (Sk Sajidul Kadir) + +* unix: implement cpu_relax() for arm (David Carlier) + +* linux: fix uv__accept4() (twosee) + +* win: handle file paths in uv_fs_statfs() (erw7) + +* unix: fix uv_os_environ() null pointer check (Rikard Falkeborn) + +* win: fix uv_os_environ() null pointer check (Rikard Falkeborn) + +* unix: fix compilation on macOS 32-bit architectures (Brad King) + +* win: replace alloca() with stack-based array (Ben Noordhuis) + + 2020.03.12, Version 1.35.0 (Stable), e45f1ec38db882f8dc17b51f51a6684027034609 Changes since version 1.34.2: diff --git a/deps/uv/Makefile.am b/deps/uv/Makefile.am index 68bef4c507cf2c..23fa19dc4fc8e7 100644 --- a/deps/uv/Makefile.am +++ b/deps/uv/Makefile.am @@ -123,17 +123,9 @@ EXTRA_DIST = test/fixtures/empty_file \ include \ docs \ img \ - android-configure-arm \ - android-configure-arm64 \ - android-configure-x86 \ - android-configure-x86_64 \ CONTRIBUTING.md \ LICENSE \ - README.md \ - vcbuild.bat \ - common.gypi \ - gyp_uv.py \ - uv.gyp + README.md @@ -346,7 +338,8 @@ test_run_tests_CFLAGS += -D__EXTENSIONS__ \ endif if OS390 -test_run_tests_CFLAGS += -D_UNIX03_THREADS \ +test_run_tests_CFLAGS += -D_ISOC99_SOURCE \ + -D_UNIX03_THREADS \ -D_UNIX03_SOURCE \ -D_OPEN_SYS_IF_EXT=1 \ -D_OPEN_SYS_SOCK_IPV6 \ diff --git a/deps/uv/README.md b/deps/uv/README.md index 9c785da84294db..98007c5e7d21de 100644 --- a/deps/uv/README.md +++ b/deps/uv/README.md @@ -152,47 +152,14 @@ $ gpg --verify libuv-1.7.0.tar.gz.sign ## Build Instructions -For GCC there are two build methods: via autotools 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. +For UNIX-like platforms, including macOS, there are two build methods: +autotools or [CMake][]. -To build with autotools: +For Windows, [CMake][] is the only supported build method and has the +following prerequisites: -```bash -$ sh autogen.sh -$ ./configure -$ make -$ make check -$ make install -``` - -To build with [CMake](https://cmake.org/): - -```bash -$ mkdir -p out/cmake ; cd out/cmake # create build directory -$ cmake ../.. -DBUILD_TESTING=ON # generate project with test -$ cmake --build . # build -$ ctest -C Debug --output-on-failure # run tests +
-# Or manually run tests: -$ ./out/cmake/uv_run_tests # shared library build -$ ./out/cmake/uv_run_tests_a # static library build -``` - -To build with GYP, first run: - -```bash -$ git clone https://chromium.googlesource.com/external/gyp build/gyp -``` - -### Windows - -Prerequisites: - -* [Python 2.6 or 2.7][] as it is required - by [GYP][]. - If python is not in your path, set the environment variable `PYTHON` to its - location. For example: `set PYTHON=C:\Python27\python.exe` * One of: * [Visual C++ Build Tools][] * [Visual Studio 2015 Update 3][], all editions @@ -205,67 +172,44 @@ Prerequisites: [Git for Windows][] includes Git Bash and tools which can be included in the global `PATH`. -To build, launch a git shell (e.g. Cmd or PowerShell), run `vcbuild.bat` -(to build with VS2017 you need to explicitly add a `vs2017` argument), -which will checkout the GYP code into `build/gyp`, generate `uv.sln` -as well as the necesery related project files, and start building. - -```console -> vcbuild -``` - -Or: - -```console -> vcbuild vs2017 -``` - -To run the tests: - -```console -> vcbuild test -``` - -To see all the options that could passed to `vcbuild`: - -```console -> vcbuild help -vcbuild.bat [debug/release] [test/bench] [clean] [noprojgen] [nobuild] [vs2017] [x86/x64] [static/shared] -Examples: - vcbuild.bat : builds debug build - vcbuild.bat test : builds debug build and runs tests - vcbuild.bat release bench: builds release build and runs benchmarks -``` - +
-### Unix - -For Debug builds (recommended) run: +To build with autotools: ```bash -$ ./gyp_uv.py -f make -$ make -C out +$ sh autogen.sh +$ ./configure +$ make +$ make check +$ make install ``` -For Release builds run: +To build with [CMake][]: ```bash -$ ./gyp_uv.py -f make -$ BUILDTYPE=Release make -C out -``` +$ mkdir -p build -Run `./gyp_uv.py -f make -Dtarget_arch=x32` to build [x32][] binaries. +$ (cd build && cmake .. -DBUILD_TESTING=ON) # generate project with tests +$ cmake --build build # add `-j ` with cmake >= 3.12 -### OS X +# Run tests: +$ (cd build && ctest -C Debug --output-on-failure) -Run: +# Or manually run tests: +$ build/uv_run_tests # shared library build +$ build/uv_run_tests_a # static library build +``` + +To cross-compile with [CMake][] (unsupported but generally works): ```bash -$ ./gyp_uv.py -f xcode -$ xcodebuild -ARCHS="x86_64" -project out/uv.xcodeproj -configuration Release -alltargets +$ cmake ../.. \ + -DCMAKE_SYSTEM_NAME=Windows \ + -DCMAKE_SYSTEM_VERSION=6.1 \ + -DCMAKE_C_COMPILER=i686-w64-mingw32-gcc ``` -Using Homebrew: +### Install with Homebrew ```bash $ brew install --HEAD libuv @@ -277,110 +221,48 @@ Make sure that you specify the architecture you wish to build for in the "ARCHS" flag. You can specify more than one by delimiting with a space (e.g. "x86_64 i386"). -### Android - -Run: - -For arm - -```bash -$ source ./android-configure-arm NDK_PATH gyp [API_LEVEL] -$ make -C out -``` - -or for arm64 - -```bash -$ source ./android-configure-arm64 NDK_PATH gyp [API_LEVEL] -$ make -C out -``` - -or for x86 - -```bash -$ source ./android-configure-x86 NDK_PATH gyp [API_LEVEL] -$ make -C out -``` - -or for x86_64 - -```bash -$ source ./android-configure-x86_64 NDK_PATH gyp [API_LEVEL] -$ make -C out -``` - -The default API level is 24, but a different one can be selected as follows: - -```bash -$ source ./android-configure-arm ~/android-ndk-r15b gyp 21 -$ make -C out -``` - -Note for UNIX users: compile your project with `-D_LARGEFILE_SOURCE` and -`-D_FILE_OFFSET_BITS=64`. GYP builds take care of that automatically. - -### Using Ninja - -To use ninja for build on ninja supported platforms, run: - -```bash -$ ./gyp_uv.py -f ninja -$ ninja -C out/Debug #for debug build OR -$ ninja -C out/Release -``` - - ### Running tests -#### Build - -Build (includes tests): - -```bash -$ ./gyp_uv.py -f make -$ make -C out -``` - -#### Run all tests - -```bash -$ ./out/Debug/run-tests -``` - Some tests are timing sensitive. Relaxing test timeouts may be necessary on slow or overloaded machines: ```bash -$ env UV_TEST_TIMEOUT_MULTIPLIER=2 ./out/Debug/run-tests # 10s instead of 5s +$ env UV_TEST_TIMEOUT_MULTIPLIER=2 build/uv_run_tests # 10s instead of 5s ``` #### Run one test The list of all tests is in `test/test-list.h`. -This invocation will cause the `run-tests` driver to fork and execute `TEST_NAME` in a child process: +This invocation will cause the test driver to fork and execute `TEST_NAME` in +a child process: ```bash -$ ./out/Debug/run-tests TEST_NAME +$ build/uv_run_tests_a TEST_NAME ``` -This invocation will cause the `run-tests` driver to execute the test within the `run-tests` process: +This invocation will cause the test driver to execute the test in +the same process: ```bash -$ ./out/Debug/run-tests TEST_NAME TEST_NAME +$ build/uv_run_tests_a TEST_NAME TEST_NAME ``` #### Debugging tools -When running the test from within the `run-tests` process (`run-tests TEST_NAME TEST_NAME`), tools like gdb and valgrind work normally. -When running the test from a child of the `run-tests` process (`run-tests TEST_NAME`), use these tools in a fork-aware manner. +When running the test from within the test driver process +(`build/uv_run_tests_a TEST_NAME TEST_NAME`), tools like gdb and valgrind +work normally. + +When running the test from a child of the test driver process +(`build/uv_run_tests_a TEST_NAME`), use these tools in a fork-aware manner. ##### Fork-aware gdb Use the [follow-fork-mode](https://sourceware.org/gdb/onlinedocs/gdb/Forks.html) setting: ``` -$ gdb --args out/Debug/run-tests TEST_NAME +$ gdb --args build/uv_run_tests_a TEST_NAME (gdb) set follow-fork-mode child ... @@ -391,13 +273,14 @@ $ gdb --args out/Debug/run-tests TEST_NAME Use the `--trace-children=yes` parameter: ```bash -$ valgrind --trace-children=yes -v --tool=memcheck --leak-check=full --track-origins=yes --leak-resolution=high --show-reachable=yes --log-file=memcheck-%p.log out/Debug/run-tests TEST_NAME +$ valgrind --trace-children=yes -v --tool=memcheck --leak-check=full --track-origins=yes --leak-resolution=high --show-reachable=yes --log-file=memcheck-%p.log build/uv_run_tests_a TEST_NAME ``` ### Running benchmarks See the section on running tests. -The benchmark driver is `out/Debug/run-benchmarks` and the benchmarks are listed in `test/benchmark-list.h`. +The benchmark driver is `./uv_run_benchmarks_a` and the benchmarks are +listed in `test/benchmark-list.h`. ## Supported Platforms @@ -413,8 +296,6 @@ that is detected by `autoconf`. [IBM documentation](http://www.ibm.com/developerworks/aix/library/au-aix_event_infrastructure/) describes the package in more detail. -AIX support for filesystem events is not compiled when building with `gyp`. - ### z/OS Notes z/OS creates System V semaphores and message queues. These persist on the system @@ -426,12 +307,10 @@ Use the `ipcrm` command to manually clear up System V resources. See the [guidelines for contributing][]. +[CMake]: https://cmake.org/ [node.js]: http://nodejs.org/ -[GYP]: http://code.google.com/p/gyp/ [guidelines for contributing]: https://github.com/libuv/libuv/blob/master/CONTRIBUTING.md [libuv_banner]: https://raw.githubusercontent.com/libuv/libuv/master/img/banner.png -[x32]: https://en.wikipedia.org/wiki/X32_ABI -[Python 2.6 or 2.7]: https://www.python.org/downloads/ [Visual C++ Build Tools]: https://visualstudio.microsoft.com/visual-cpp-build-tools/ [Visual Studio 2015 Update 3]: https://www.visualstudio.com/vs/older-downloads/ [Visual Studio 2017]: https://www.visualstudio.com/downloads/ diff --git a/deps/uv/SUPPORTED_PLATFORMS.md b/deps/uv/SUPPORTED_PLATFORMS.md index 29e4844ff323d3..72e054eba067ec 100644 --- a/deps/uv/SUPPORTED_PLATFORMS.md +++ b/deps/uv/SUPPORTED_PLATFORMS.md @@ -47,8 +47,9 @@ All functionality related to the new platform must be implemented in its own file inside ``src/unix/`` unless it's already done in a common file, in which case adding an `ifdef` is fine. -Two build systems are supported: autotools and GYP. Ideally both need to be -supported, but if GYP does not support the new platform it can be left out. +Two build systems are supported: autotools and cmake. Ideally both need to be +supported, but if one of the two does not support the new platform it can be +left out. ### Windows diff --git a/deps/uv/android-configure-arm b/deps/uv/android-configure-arm deleted file mode 100755 index 331fdd9ebcf9f9..00000000000000 --- a/deps/uv/android-configure-arm +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash - -export TOOLCHAIN=$PWD/android-toolchain-arm -mkdir -p $TOOLCHAIN -API=${3:-24} -$1/build/tools/make-standalone-toolchain.sh \ - --toolchain=arm-linux-androideabi-4.9 \ - --arch=arm \ - --install-dir=$TOOLCHAIN \ - --platform=android-$API \ - --force -export PATH=$TOOLCHAIN/bin:$PATH -export AR=arm-linux-androideabi-ar -export CC=arm-linux-androideabi-gcc -export CXX=arm-linux-androideabi-g++ -export LINK=arm-linux-androideabi-g++ -export PLATFORM=android -export CFLAGS="-D__ANDROID_API__=$API" - -if [[ $2 == 'gyp' ]] - then - ./gyp_uv.py -Dtarget_arch=arm -DOS=android -f make-android -fi diff --git a/deps/uv/android-configure-arm64 b/deps/uv/android-configure-arm64 deleted file mode 100755 index 1acd905d775fd9..00000000000000 --- a/deps/uv/android-configure-arm64 +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash - -export TOOLCHAIN=$PWD/android-toolchain-arm64 -mkdir -p $TOOLCHAIN -API=${3:-24} -$1/build/tools/make-standalone-toolchain.sh \ - --toolchain=aarch64-linux-android-4.9 \ - --arch=arm64 \ - --install-dir=$TOOLCHAIN \ - --platform=android-$API \ - --force -export PATH=$TOOLCHAIN/bin:$PATH -export AR=aarch64-linux-android-ar -export CC=aarch64-linux-android-gcc -export CXX=aarch64-linux-android-g++ -export LINK=aarch64-linux-android-g++ -export PLATFORM=android -export CFLAGS="-D__ANDROID_API__=$API" - -if [[ $2 == 'gyp' ]] - then - ./gyp_uv.py -Dtarget_arch=arm64 -DOS=android -f make-android -fi diff --git a/deps/uv/android-configure-x86 b/deps/uv/android-configure-x86 deleted file mode 100755 index a149715f37547f..00000000000000 --- a/deps/uv/android-configure-x86 +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash - -export TOOLCHAIN=$PWD/android-toolchain-x86 -mkdir -p $TOOLCHAIN -API=${3:-24} -$1/build/tools/make-standalone-toolchain.sh \ - --toolchain=x86-4.9 \ - --arch=x86 \ - --install-dir=$TOOLCHAIN \ - --platform=android-$API \ - --force -export PATH=$TOOLCHAIN/bin:$PATH -export AR=i686-linux-android-ar -export CC=i686-linux-android-gcc -export CXX=i686-linux-android-g++ -export LINK=i686-linux-android-g++ -export PLATFORM=android -export CFLAGS="-D__ANDROID_API__=$API" - -if [[ $2 == 'gyp' ]] - then - ./gyp_uv.py -Dtarget_arch=x86 -DOS=android -f make-android -fi diff --git a/deps/uv/android-configure-x86_64 b/deps/uv/android-configure-x86_64 deleted file mode 100755 index ff045957f7138d..00000000000000 --- a/deps/uv/android-configure-x86_64 +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/bash - -export TOOLCHAIN=$PWD/android-toolchain-x86_64 -mkdir -p $TOOLCHAIN -API=${3:-24} -$1/build/tools/make-standalone-toolchain.sh \ - --toolchain=x86_64-4.9 \ - --arch=x86_64 \ - --install-dir=$TOOLCHAIN \ - --platform=android-$API \ - --force -export PATH=$TOOLCHAIN/bin:$PATH -export AR=x86_64-linux-android-ar -export CC=x86_64-linux-android-gcc -export CXX=x86_64-linux-android-g++ -export LINK=x86_64-linux-android-g++ -export PLATFORM=android -export CFLAGS="-D__ANDROID_API__=$API -fPIC" -export CXXFLAGS="-D__ANDROID_API__=$API -fPIC" -export LDFLAGS="-fPIC" - -if [[ $2 == 'gyp' ]] - then - ./gyp_uv.py -Dtarget_arch=x86_64 -DOS=android -f make-android -fi diff --git a/deps/uv/appveyor.yml b/deps/uv/appveyor.yml deleted file mode 100644 index 1b018a59cad86c..00000000000000 --- a/deps/uv/appveyor.yml +++ /dev/null @@ -1,32 +0,0 @@ -version: v1.18.0.build{build} - -init: - - git config --global core.autocrlf true - -install: - - cinst -y nsis - -matrix: - fast_finish: true - allow_failures: - - platform: x86 - configuration: Release - - platform: x64 - configuration: Release - -platform: - - x86 - - x64 - -configuration: - - Release - -build_script: - # Fixed tag version number if using a tag. - - cmd: if "%APPVEYOR_REPO_TAG%" == "true" set APPVEYOR_BUILD_VERSION=%APPVEYOR_REPO_TAG_NAME% - # vcbuild overwrites the platform variable. - - cmd: set ARCH=%platform% - - cmd: vcbuild.bat release %ARCH% shared - -cache: - - C:\projects\libuv\build\gyp diff --git a/deps/uv/configure.ac b/deps/uv/configure.ac index d05ec8726bbaff..e2564937b123d9 100644 --- a/deps/uv/configure.ac +++ b/deps/uv/configure.ac @@ -13,7 +13,7 @@ # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. AC_PREREQ(2.57) -AC_INIT([libuv], [1.35.0], [https://github.com/libuv/libuv/issues]) +AC_INIT([libuv], [1.36.0], [https://github.com/libuv/libuv/issues]) AC_CONFIG_MACRO_DIR([m4]) m4_include([m4/libuv-extra-automake-flags.m4]) m4_include([m4/as_case.m4]) diff --git a/deps/uv/docs/src/fs.rst b/deps/uv/docs/src/fs.rst index 2943ead330cc5a..a475a460307898 100644 --- a/deps/uv/docs/src/fs.rst +++ b/deps/uv/docs/src/fs.rst @@ -100,7 +100,8 @@ Data types UV_FS_OPENDIR, UV_FS_READDIR, UV_FS_CLOSEDIR, - UV_FS_MKSTEMP + UV_FS_MKSTEMP, + UV_FS_LUTIME } uv_fs_type; .. c:type:: uv_statfs_t @@ -402,12 +403,17 @@ API .. c:function:: int uv_fs_utime(uv_loop_t* loop, uv_fs_t* req, const char* path, double atime, double mtime, uv_fs_cb cb) .. c:function:: int uv_fs_futime(uv_loop_t* loop, uv_fs_t* req, uv_file file, double atime, double mtime, uv_fs_cb cb) +.. c:function:: int uv_fs_lutime(uv_loop_t* loop, uv_fs_t* req, const char* path, double atime, double mtime, uv_fs_cb cb) - Equivalent to :man:`utime(2)` and :man:`futimes(3)` respectively. + Equivalent to :man:`utime(2)`, :man:`futimes(3)` and :man:`lutimes(3)` respectively. .. note:: - AIX: This function only works for AIX 7.1 and newer. It can still be called on older - versions but will return ``UV_ENOSYS``. + z/OS: `uv_fs_lutime()` is not implemented for z/OS. It can still be called but will return + ``UV_ENOSYS``. + + .. note:: + AIX: `uv_fs_futime()` and `uv_fs_lutime()` functions only work for AIX 7.1 and newer. + They can still be called on older versions but will return ``UV_ENOSYS``. .. versionchanged:: 1.10.0 sub-second precission is supported on Windows diff --git a/deps/uv/docs/src/misc.rst b/deps/uv/docs/src/misc.rst index d9bf3aef01e577..8515cdbc1b040a 100644 --- a/deps/uv/docs/src/misc.rst +++ b/deps/uv/docs/src/misc.rst @@ -649,6 +649,16 @@ API On Windows, setting `PRIORITY_HIGHEST` will only work for elevated user, for others it will be silently reduced to `PRIORITY_HIGH`. + .. note:: + On IBM i PASE, the highest process priority is -10. The constant + `UV_PRIORITY_HIGHEST` is -10, `UV_PRIORITY_HIGH` is -7, + `UV_PRIORITY_ABOVE_NORMAL` is -4, `UV_PRIORITY_NORMAL` is 0, + `UV_PRIORITY_BELOW_NORMAL` is 15 and `UV_PRIORITY_LOW` is 39. + + .. note:: + On IBM i PASE, you are not allowed to change your priority unless you + have the *JOBCTL special authority (even to lower it). + .. versionadded:: 1.23.0 .. c:function:: int uv_os_uname(uv_utsname_t* buffer) diff --git a/deps/uv/docs/src/udp.rst b/deps/uv/docs/src/udp.rst index 2ca0736bc6cebc..786a28b0305849 100644 --- a/deps/uv/docs/src/udp.rst +++ b/deps/uv/docs/src/udp.rst @@ -43,8 +43,7 @@ Data types */ UV_UDP_REUSEADDR = 4 /* - * Indicates that the message was received by recvmmsg and that it's not at - * the beginning of the buffer allocated by alloc_cb - so the buffer provided + * Indicates that the message was received by recvmmsg, so the buffer provided * must not be freed by the recv_cb callback. */ UV_UDP_MMSG_CHUNK = 8 @@ -72,9 +71,13 @@ Data types The callee is responsible for freeing the buffer, libuv does not reuse it. The buffer may be a null buffer (where `buf->base` == NULL and `buf->len` == 0) - on error. Don't free the buffer when the UV_UDP_MMSG_CHUNK flag is set. - The final callback receives the whole buffer (containing the first chunk) - with the UV_UDP_MMSG_CHUNK flag cleared. + on error. + + When using :man:`recvmmsg(2)`, chunks will have the `UV_UDP_MMSG_CHUNK` flag set, + those must not be freed. There will be a final callback with `nread` set to 0, + `addr` set to NULL and the buffer pointing at the initially allocated data with + the `UV_UDP_MMSG_CHUNK` flag cleared. This is a good chance for the callee to + free the provided buffer. .. note:: The receive callback will be called with `nread` == 0 and `addr` == NULL when there is @@ -373,6 +376,10 @@ API :returns: 0 on success, or an error code < 0 on failure. + .. versionchanged:: 1.35.0 added support for :man:`recvmmsg(2)` on supported platforms). + The use of this feature requires a buffer larger than + 2 * 64KB to be passed to `alloc_cb`. + .. c:function:: int uv_udp_recv_stop(uv_udp_t* handle) Stop listening for incoming datagrams. diff --git a/deps/uv/gyp_uv.py b/deps/uv/gyp_uv.py deleted file mode 100755 index c2add5caecc7d3..00000000000000 --- a/deps/uv/gyp_uv.py +++ /dev/null @@ -1,73 +0,0 @@ -#!/usr/bin/env python - -import os -import platform -import sys - -try: - import multiprocessing.synchronize - gyp_parallel_support = True -except ImportError: - gyp_parallel_support = False - - -CC = os.environ.get('CC', 'cc') -script_dir = os.path.dirname(__file__) -uv_root = os.path.normpath(script_dir) -output_dir = os.path.join(os.path.abspath(uv_root), 'out') - -sys.path.insert(0, os.path.join(uv_root, 'build', 'gyp', 'pylib')) -try: - import gyp -except ImportError: - print('You need to install gyp in build/gyp first. See the README.') - sys.exit(42) - - -def host_arch(): - machine = platform.machine() - if machine == 'i386': return 'ia32' - if machine == 'AMD64': return 'x64' - if machine == 'x86_64': return 'x64' - if machine.startswith('arm'): return 'arm' - if machine.startswith('mips'): return 'mips' - return machine # Return as-is and hope for the best. - - -def run_gyp(args): - rc = gyp.main(args) - if rc != 0: - print('Error running GYP') - sys.exit(rc) - - -if __name__ == '__main__': - args = sys.argv[1:] - args.extend('-I common.gypi test/test.gyp'.split(' ')) - args.append('--depth=' + uv_root) - - # There's a bug with windows which doesn't allow this feature. - if sys.platform != 'win32': - if '-f' not in args: - args.extend('-f make'.split()) - if 'eclipse' not in args and 'ninja' not in args: - args.extend(['-Goutput_dir=' + output_dir]) - args.extend(['--generator-output', output_dir]) - - if not any(a.startswith('-Dhost_arch=') for a in args): - args.append('-Dhost_arch=%s' % host_arch()) - - if not any(a.startswith('-Dtarget_arch=') for a in args): - args.append('-Dtarget_arch=%s' % host_arch()) - - if not any(a.startswith('-Duv_library=') for a in args): - args.append('-Duv_library=static_library') - - # Some platforms (OpenBSD for example) don't have multiprocessing.synchronize - # so gyp must be run with --no-parallel - if not gyp_parallel_support: - args.append('--no-parallel') - - gyp_args = list(args) - print(gyp_args) - run_gyp(gyp_args) diff --git a/deps/uv/include/uv.h b/deps/uv/include/uv.h index defc0ac44b180c..2e8072fdaed1f4 100644 --- a/deps/uv/include/uv.h +++ b/deps/uv/include/uv.h @@ -607,8 +607,7 @@ enum uv_udp_flags { */ UV_UDP_REUSEADDR = 4, /* - * Indicates that the message was received by recvmmsg and that it's not at - * the beginning of the buffer allocated by alloc_cb - so the buffer provided + * Indicates that the message was received by recvmmsg, so the buffer provided * must not be freed by the recv_cb callback. */ UV_UDP_MMSG_CHUNK = 8 @@ -1183,12 +1182,22 @@ UV_EXTERN void uv_os_free_passwd(uv_passwd_t* pwd); UV_EXTERN uv_pid_t uv_os_getpid(void); UV_EXTERN uv_pid_t uv_os_getppid(void); -#define UV_PRIORITY_LOW 19 -#define UV_PRIORITY_BELOW_NORMAL 10 -#define UV_PRIORITY_NORMAL 0 -#define UV_PRIORITY_ABOVE_NORMAL -7 -#define UV_PRIORITY_HIGH -14 -#define UV_PRIORITY_HIGHEST -20 +#if defined(__PASE__) +/* On IBM i PASE, the highest process priority is -10 */ +# define UV_PRIORITY_LOW 39 // RUNPTY(99) +# define UV_PRIORITY_BELOW_NORMAL 15 // RUNPTY(50) +# define UV_PRIORITY_NORMAL 0 // RUNPTY(20) +# define UV_PRIORITY_ABOVE_NORMAL -4 // RUNTY(12) +# define UV_PRIORITY_HIGH -7 // RUNPTY(6) +# define UV_PRIORITY_HIGHEST -10 // RUNPTY(1) +#else +# define UV_PRIORITY_LOW 19 +# define UV_PRIORITY_BELOW_NORMAL 10 +# define UV_PRIORITY_NORMAL 0 +# define UV_PRIORITY_ABOVE_NORMAL -7 +# define UV_PRIORITY_HIGH -14 +# define UV_PRIORITY_HIGHEST -20 +#endif UV_EXTERN int uv_os_getpriority(uv_pid_t pid, int* priority); UV_EXTERN int uv_os_setpriority(uv_pid_t pid, int priority); @@ -1265,7 +1274,8 @@ typedef enum { UV_FS_READDIR, UV_FS_CLOSEDIR, UV_FS_STATFS, - UV_FS_MKSTEMP + UV_FS_MKSTEMP, + UV_FS_LUTIME } uv_fs_type; struct uv_dir_s { @@ -1438,6 +1448,12 @@ UV_EXTERN int uv_fs_futime(uv_loop_t* loop, double atime, double mtime, uv_fs_cb cb); +UV_EXTERN int uv_fs_lutime(uv_loop_t* loop, + uv_fs_t* req, + const char* path, + double atime, + double mtime, + uv_fs_cb cb); UV_EXTERN int uv_fs_lstat(uv_loop_t* loop, uv_fs_t* req, const char* path, diff --git a/deps/uv/include/uv/version.h b/deps/uv/include/uv/version.h index 78a2115bb094f9..537835ae1f271a 100644 --- a/deps/uv/include/uv/version.h +++ b/deps/uv/include/uv/version.h @@ -26,12 +26,12 @@ * Versions with the same major number are ABI stable. API is allowed to * evolve between minor releases, but only in a backwards compatible way. * Make sure you update the -soname directives in configure.ac - * and uv.gyp whenever you bump UV_VERSION_MAJOR or UV_VERSION_MINOR (but + * whenever you bump UV_VERSION_MAJOR or UV_VERSION_MINOR (but * not UV_VERSION_PATCH.) */ #define UV_VERSION_MAJOR 1 -#define UV_VERSION_MINOR 35 +#define UV_VERSION_MINOR 36 #define UV_VERSION_PATCH 0 #define UV_VERSION_IS_RELEASE 1 #define UV_VERSION_SUFFIX "" diff --git a/deps/uv/src/unix/android-ifaddrs.c b/deps/uv/src/unix/android-ifaddrs.c index 7d48c6af57ca46..4765cc06b579c4 100644 --- a/deps/uv/src/unix/android-ifaddrs.c +++ b/deps/uv/src/unix/android-ifaddrs.c @@ -470,13 +470,14 @@ static int interpretAddr(struct nlmsghdr *p_hdr, struct ifaddrs **p_resultList, { case IFA_ADDRESS: case IFA_LOCAL: + l_addrSize += NLMSG_ALIGN(calcAddrLen(l_info->ifa_family, l_rtaDataSize)); if((l_info->ifa_family == AF_INET || l_info->ifa_family == AF_INET6) && !l_addedNetmask) { /* Make room for netmask */ l_addrSize += NLMSG_ALIGN(calcAddrLen(l_info->ifa_family, l_rtaDataSize)); l_addedNetmask = 1; } - break; + break; case IFA_BROADCAST: l_addrSize += NLMSG_ALIGN(calcAddrLen(l_info->ifa_family, l_rtaDataSize)); break; diff --git a/deps/uv/src/unix/atomic-ops.h b/deps/uv/src/unix/atomic-ops.h index bc37c0d45d159c..347d19365f7542 100644 --- a/deps/uv/src/unix/atomic-ops.h +++ b/deps/uv/src/unix/atomic-ops.h @@ -53,6 +53,8 @@ UV_UNUSED(static int cmpxchgi(int* ptr, int oldval, int newval)) { UV_UNUSED(static void cpu_relax(void)) { #if defined(__i386__) || defined(__x86_64__) __asm__ __volatile__ ("rep; nop"); /* a.k.a. PAUSE */ +#elif (defined(__arm__) && __ARM_ARCH >= 7) || defined(__aarch64__) + __asm__ volatile("yield"); #endif } diff --git a/deps/uv/src/unix/core.c b/deps/uv/src/unix/core.c index 6d0063513c5020..949eefae339919 100644 --- a/deps/uv/src/unix/core.c +++ b/deps/uv/src/unix/core.c @@ -71,7 +71,7 @@ extern char** environ; # include # include # include -# if defined(__FreeBSD__) || defined(__linux__) +# if defined(__FreeBSD__) # define uv__accept4 accept4 # endif # if defined(__NetBSD__) @@ -88,7 +88,8 @@ extern char** environ; #endif #if defined(__linux__) -#include +# include +# define uv__accept4 accept4 #endif static int uv__run_pending(uv_loop_t* loop); @@ -518,7 +519,7 @@ int uv__close_nocancel(int fd) { #if defined(__APPLE__) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wdollar-in-identifier-extension" -#if defined(__LP64__) || defined(TARGET_OS_IPHONE) +#if defined(__LP64__) || TARGET_OS_IPHONE extern int close$NOCANCEL(int); return close$NOCANCEL(fd); #else @@ -834,8 +835,8 @@ static void maybe_resize(uv_loop_t* loop, unsigned int len) { } nwatchers = next_power_of_two(len + 2) - 2; - watchers = uv__realloc(loop->watchers, - (nwatchers + 2) * sizeof(loop->watchers[0])); + watchers = uv__reallocf(loop->watchers, + (nwatchers + 2) * sizeof(loop->watchers[0])); if (watchers == NULL) abort(); @@ -1257,7 +1258,7 @@ int uv_os_environ(uv_env_item_t** envitems, int* count) { *envitems = uv__calloc(i, sizeof(**envitems)); - if (envitems == NULL) + if (*envitems == NULL) return UV_ENOMEM; for (j = 0, cnt = 0; j < i; j++) { diff --git a/deps/uv/src/unix/fs.c b/deps/uv/src/unix/fs.c index 898bfc45cef46e..bc7fd8509daa1d 100644 --- a/deps/uv/src/unix/fs.c +++ b/deps/uv/src/unix/fs.c @@ -205,6 +205,20 @@ static ssize_t uv__fs_fdatasync(uv_fs_t* req) { } +UV_UNUSED(static struct timespec uv__fs_to_timespec(double time)) { + struct timespec ts; + ts.tv_sec = time; + ts.tv_nsec = (uint64_t)(time * 1000000) % 1000000 * 1000; + return ts; +} + +UV_UNUSED(static struct timeval uv__fs_to_timeval(double time)) { + struct timeval tv; + tv.tv_sec = time; + tv.tv_usec = (uint64_t)(time * 1000000) % 1000000; + return tv; +} + static ssize_t uv__fs_futime(uv_fs_t* req) { #if defined(__linux__) \ || defined(_AIX71) \ @@ -213,10 +227,8 @@ static ssize_t uv__fs_futime(uv_fs_t* req) { * for the sake of consistency with other platforms. */ struct timespec ts[2]; - ts[0].tv_sec = req->atime; - ts[0].tv_nsec = (uint64_t)(req->atime * 1000000) % 1000000 * 1000; - ts[1].tv_sec = req->mtime; - ts[1].tv_nsec = (uint64_t)(req->mtime * 1000000) % 1000000 * 1000; + ts[0] = uv__fs_to_timespec(req->atime); + ts[1] = uv__fs_to_timespec(req->mtime); #if defined(__ANDROID_API__) && __ANDROID_API__ < 21 return utimensat(req->file, NULL, ts, 0); #else @@ -230,10 +242,8 @@ static ssize_t uv__fs_futime(uv_fs_t* req) { || defined(__OpenBSD__) \ || defined(__sun) struct timeval tv[2]; - tv[0].tv_sec = req->atime; - tv[0].tv_usec = (uint64_t)(req->atime * 1000000) % 1000000; - tv[1].tv_sec = req->mtime; - tv[1].tv_usec = (uint64_t)(req->mtime * 1000000) % 1000000; + tv[0] = uv__fs_to_timeval(req->atime); + tv[1] = uv__fs_to_timeval(req->mtime); # if defined(__sun) return futimesat(req->file, NULL, tv); # else @@ -666,7 +676,6 @@ static ssize_t uv__fs_readlink(uv_fs_t* req) { ssize_t maxlen; ssize_t len; char* buf; - char* newbuf; #if defined(_POSIX_PATH_MAX) || defined(PATH_MAX) maxlen = uv__fs_pathmax_size(req->path); @@ -710,14 +719,10 @@ static ssize_t uv__fs_readlink(uv_fs_t* req) { /* Uncommon case: resize to make room for the trailing nul byte. */ if (len == maxlen) { - newbuf = uv__realloc(buf, len + 1); + buf = uv__reallocf(buf, len + 1); - if (newbuf == NULL) { - uv__free(buf); + if (buf == NULL) return -1; - } - - buf = newbuf; } buf[len] = '\0'; @@ -977,10 +982,8 @@ static ssize_t uv__fs_utime(uv_fs_t* req) { * for the sake of consistency with other platforms. */ struct timespec ts[2]; - ts[0].tv_sec = req->atime; - ts[0].tv_nsec = (uint64_t)(req->atime * 1000000) % 1000000 * 1000; - ts[1].tv_sec = req->mtime; - ts[1].tv_nsec = (uint64_t)(req->mtime * 1000000) % 1000000 * 1000; + ts[0] = uv__fs_to_timespec(req->atime); + ts[1] = uv__fs_to_timespec(req->mtime); return utimensat(AT_FDCWD, req->path, ts, 0); #elif defined(__APPLE__) \ || defined(__DragonFly__) \ @@ -989,10 +992,8 @@ static ssize_t uv__fs_utime(uv_fs_t* req) { || defined(__NetBSD__) \ || defined(__OpenBSD__) struct timeval tv[2]; - tv[0].tv_sec = req->atime; - tv[0].tv_usec = (uint64_t)(req->atime * 1000000) % 1000000; - tv[1].tv_sec = req->mtime; - tv[1].tv_usec = (uint64_t)(req->mtime * 1000000) % 1000000; + tv[0] = uv__fs_to_timeval(req->atime); + tv[1] = uv__fs_to_timeval(req->mtime); return utimes(req->path, tv); #elif defined(_AIX) \ && !defined(_AIX71) @@ -1015,6 +1016,31 @@ static ssize_t uv__fs_utime(uv_fs_t* req) { } +static ssize_t uv__fs_lutime(uv_fs_t* req) { +#if defined(__linux__) || \ + defined(_AIX71) || \ + defined(__sun) || \ + defined(__HAIKU__) + struct timespec ts[2]; + ts[0] = uv__fs_to_timespec(req->atime); + ts[1] = uv__fs_to_timespec(req->mtime); + return utimensat(AT_FDCWD, req->path, ts, AT_SYMLINK_NOFOLLOW); +#elif defined(__APPLE__) || \ + defined(__DragonFly__) || \ + defined(__FreeBSD__) || \ + defined(__FreeBSD_kernel__) || \ + defined(__NetBSD__) + struct timeval tv[2]; + tv[0] = uv__fs_to_timeval(req->atime); + tv[1] = uv__fs_to_timeval(req->mtime); + return lutimes(req->path, tv); +#else + errno = ENOSYS; + return -1; +#endif +} + + static ssize_t uv__fs_write(uv_fs_t* req) { #if defined(__linux__) static int no_pwritev; @@ -1528,6 +1554,7 @@ static void uv__fs_work(struct uv__work* w) { X(FSYNC, uv__fs_fsync(req)); X(FTRUNCATE, ftruncate(req->file, req->off)); X(FUTIME, uv__fs_futime(req)); + X(LUTIME, uv__fs_lutime(req)); X(LSTAT, uv__fs_lstat(req->path, &req->statbuf)); X(LINK, link(req->path, req->new_path)); X(MKDIR, mkdir(req->path, req->mode)); @@ -1714,6 +1741,19 @@ int uv_fs_futime(uv_loop_t* loop, POST; } +int uv_fs_lutime(uv_loop_t* loop, + uv_fs_t* req, + const char* path, + double atime, + double mtime, + uv_fs_cb cb) { + INIT(LUTIME); + PATH; + req->atime = atime; + req->mtime = mtime; + POST; +} + int uv_fs_lstat(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb) { INIT(LSTAT); diff --git a/deps/uv/src/unix/openbsd.c b/deps/uv/src/unix/openbsd.c index 713b6c6608a1c8..f32a94df38765f 100644 --- a/deps/uv/src/unix/openbsd.c +++ b/deps/uv/src/unix/openbsd.c @@ -61,7 +61,6 @@ void uv_loadavg(double avg[3]) { int uv_exepath(char* buffer, size_t* size) { int mib[4]; char **argsbuf = NULL; - char **argsbuf_tmp; size_t argsbuf_size = 100U; size_t exepath_size; pid_t mypid; @@ -73,10 +72,9 @@ int uv_exepath(char* buffer, size_t* size) { mypid = getpid(); for (;;) { err = UV_ENOMEM; - argsbuf_tmp = uv__realloc(argsbuf, argsbuf_size); - if (argsbuf_tmp == NULL) + argsbuf = uv__reallocf(argsbuf, argsbuf_size); + if (argsbuf == NULL) goto out; - argsbuf = argsbuf_tmp; mib[0] = CTL_KERN; mib[1] = KERN_PROC_ARGS; mib[2] = mypid; diff --git a/deps/uv/src/unix/os390-syscalls.c b/deps/uv/src/unix/os390-syscalls.c index 4a926c767cc17b..424cc486a86fa3 100644 --- a/deps/uv/src/unix/os390-syscalls.c +++ b/deps/uv/src/unix/os390-syscalls.c @@ -128,7 +128,7 @@ static void maybe_resize(uv__os390_epoll* lst, unsigned int len) { } newsize = next_power_of_two(len); - newlst = uv__realloc(lst->items, newsize * sizeof(lst->items[0])); + newlst = uv__reallocf(lst->items, newsize * sizeof(lst->items[0])); if (newlst == NULL) abort(); @@ -278,6 +278,8 @@ int epoll_ctl(uv__os390_epoll* lst, return 0; } +#define EP_MAX_PFDS (ULONG_MAX / sizeof(struct pollfd)) +#define EP_MAX_EVENTS (INT_MAX / sizeof(struct epoll_event)) int epoll_wait(uv__os390_epoll* lst, struct epoll_event* events, int maxevents, int timeout) { @@ -286,18 +288,41 @@ int epoll_wait(uv__os390_epoll* lst, struct epoll_event* events, int pollret; int reventcount; int nevents; + struct pollfd msg_fd; + int i; - _SET_FDS_MSGS(size, 1, lst->size - 1); + if (!lst || !lst->items || !events) { + errno = EFAULT; + return -1; + } + + if (lst->size > EP_MAX_PFDS) { + errno = EINVAL; + return -1; + } + + if (maxevents <= 0 || maxevents > EP_MAX_EVENTS) { + errno = EINVAL; + return -1; + } + + if (lst->size > 0) + _SET_FDS_MSGS(size, 1, lst->size - 1); + else + _SET_FDS_MSGS(size, 0, 0); pfds = lst->items; pollret = poll(pfds, size, timeout); if (pollret <= 0) return pollret; + assert(lst->size > 0); + pollret = _NFDS(pollret) + _NMSGS(pollret); reventcount = 0; nevents = 0; - for (int i = 0; + msg_fd = pfds[lst->size - 1]; + for (i = 0; i < lst->size && i < maxevents && reventcount < pollret; ++i) { struct epoll_event ev; struct pollfd* pfd; @@ -308,6 +333,7 @@ int epoll_wait(uv__os390_epoll* lst, struct epoll_event* events, ev.fd = pfd->fd; ev.events = pfd->revents; + ev.is_msg = 0; if (pfd->revents & POLLIN && pfd->revents & POLLOUT) reventcount += 2; else if (pfd->revents & (POLLIN | POLLOUT)) @@ -317,6 +343,10 @@ int epoll_wait(uv__os390_epoll* lst, struct epoll_event* events, events[nevents++] = ev; } + if (msg_fd.revents != 0 && msg_fd.fd != -1) + if (i == lst->size) + events[nevents - 1].is_msg = 1; + return nevents; } @@ -378,10 +408,12 @@ int nanosleep(const struct timespec* req, struct timespec* rem) { * Don't leak EAGAIN, that just means the timeout expired. */ if (rv == -1) - if (err != EAGAIN) + if (err == EAGAIN) + rv = 0; + else errno = err; - if (rem != NULL && (rv == 0 || err == EINTR || err == EAGAIN)) { + if (rem != NULL && (rv == 0 || err == EINTR)) { rem->tv_nsec = nanorem; rem->tv_sec = secrem; } @@ -526,3 +558,28 @@ size_t strnlen(const char* str, size_t maxlen) { else return p - str; } + + +int sem_init(UV_PLATFORM_SEM_T* semid, int pshared, unsigned int value) { + UNREACHABLE(); +} + + +int sem_destroy(UV_PLATFORM_SEM_T* semid) { + UNREACHABLE(); +} + + +int sem_post(UV_PLATFORM_SEM_T* semid) { + UNREACHABLE(); +} + + +int sem_trywait(UV_PLATFORM_SEM_T* semid) { + UNREACHABLE(); +} + + +int sem_wait(UV_PLATFORM_SEM_T* semid) { + UNREACHABLE(); +} diff --git a/deps/uv/src/unix/os390-syscalls.h b/deps/uv/src/unix/os390-syscalls.h index ea599107b30281..86416bbc551e19 100644 --- a/deps/uv/src/unix/os390-syscalls.h +++ b/deps/uv/src/unix/os390-syscalls.h @@ -40,6 +40,7 @@ struct epoll_event { int events; int fd; + int is_msg; }; typedef struct { @@ -64,5 +65,10 @@ int scandir(const char* maindir, struct dirent*** namelist, char *mkdtemp(char* path); ssize_t os390_readlink(const char* path, char* buf, size_t len); size_t strnlen(const char* str, size_t maxlen); +int sem_init(UV_PLATFORM_SEM_T* semid, int pshared, unsigned int value); +int sem_destroy(UV_PLATFORM_SEM_T* semid); +int sem_post(UV_PLATFORM_SEM_T* semid); +int sem_trywait(UV_PLATFORM_SEM_T* semid); +int sem_wait(UV_PLATFORM_SEM_T* semid); #endif /* UV_OS390_SYSCALL_H_ */ diff --git a/deps/uv/src/unix/os390.c b/deps/uv/src/unix/os390.c index a7305006c1756d..dce169b9fb4268 100644 --- a/deps/uv/src/unix/os390.c +++ b/deps/uv/src/unix/os390.c @@ -923,7 +923,7 @@ void uv__io_poll(uv_loop_t* loop, int timeout) { continue; ep = loop->ep; - if (fd == ep->msg_queue) { + if (pe->is_msg) { os390_message_queue_handler(ep); continue; } diff --git a/deps/uv/src/unix/posix-poll.c b/deps/uv/src/unix/posix-poll.c index a3b9f2196d5872..766e83205d053f 100644 --- a/deps/uv/src/unix/posix-poll.c +++ b/deps/uv/src/unix/posix-poll.c @@ -61,7 +61,7 @@ static void uv__pollfds_maybe_resize(uv_loop_t* loop) { return; n = loop->poll_fds_size ? loop->poll_fds_size * 2 : 64; - p = uv__realloc(loop->poll_fds, n * sizeof(*loop->poll_fds)); + p = uv__reallocf(loop->poll_fds, n * sizeof(*loop->poll_fds)); if (p == NULL) abort(); diff --git a/deps/uv/src/unix/tty.c b/deps/uv/src/unix/tty.c index ff7d3b17f9303d..6f60abaadb02ef 100644 --- a/deps/uv/src/unix/tty.c +++ b/deps/uv/src/unix/tty.c @@ -34,6 +34,34 @@ #define IMAXBEL 0 #endif +#if defined(__PASE__) +/* On IBM i PASE, for better compatibility with running interactive programs in + * a 5250 environment, isatty() will return true for the stdin/stdout/stderr + * streams created by QSH/QP2TERM. + * + * For more, see docs on PASE_STDIO_ISATTY in + * https://www.ibm.com/support/knowledgecenter/ssw_ibm_i_74/apis/pase_environ.htm + * + * This behavior causes problems for Node as it expects that if isatty() returns + * true that TTY ioctls will be supported by that fd (which is not an + * unreasonable expectation) and when they don't it crashes with assertion + * errors. + * + * Here, we create our own version of isatty() that uses ioctl() to identify + * whether the fd is *really* a TTY or not. + */ +static int isreallyatty(int file) { + int rc; + + rc = !ioctl(file, TXISATTY + 0x81, NULL); + if (!rc && errno != EBADF) + errno = ENOTTY; + + return rc; +} +#define isatty(fd) isreallyatty(fd) +#endif + static int orig_termios_fd = -1; static struct termios orig_termios; static uv_spinlock_t termios_spinlock = UV_SPINLOCK_INITIALIZER; @@ -293,14 +321,7 @@ uv_handle_type uv_guess_handle(uv_file file) { if (file < 0) return UV_UNKNOWN_HANDLE; -#if defined(__PASE__) - /* On IBMi PASE isatty() always returns true for stdin, stdout and stderr. - * Use ioctl() instead to identify whether it's actually a TTY. - */ - if (!ioctl(file, TXISATTY + 0x81, NULL) || errno != ENOTTY) -#else if (isatty(file)) -#endif return UV_TTY; if (fstat(file, &s)) diff --git a/deps/uv/src/unix/udp.c b/deps/uv/src/unix/udp.c index eb4b8f4ce7f13f..f2fcae1760f40c 100644 --- a/deps/uv/src/unix/udp.c +++ b/deps/uv/src/unix/udp.c @@ -214,14 +214,11 @@ static int uv__udp_recvmmsg(uv_udp_t* handle, uv_buf_t* buf) { else handle->recv_cb(handle, UV__ERR(errno), buf, NULL, 0); } else { - /* count to zero, so the buffer base comes last */ - for (k = nread; k > 0 && handle->recv_cb != NULL;) { - k--; - flags = 0; + /* pass each chunk to the application */ + for (k = 0; k < (size_t) nread && handle->recv_cb != NULL; k++) { + flags = UV_UDP_MMSG_CHUNK; if (msgs[k].msg_hdr.msg_flags & MSG_TRUNC) flags |= UV_UDP_PARTIAL; - if (k != 0) - flags |= UV_UDP_MMSG_CHUNK; chunk_buf = uv_buf_init(iov[k].iov_base, iov[k].iov_len); handle->recv_cb(handle, @@ -230,6 +227,10 @@ static int uv__udp_recvmmsg(uv_udp_t* handle, uv_buf_t* buf) { msgs[k].msg_hdr.msg_name, flags); } + + /* one last callback so the original buffer is freed */ + if (handle->recv_cb != NULL) + handle->recv_cb(handle, 0, buf, NULL, 0); } return nread; } diff --git a/deps/uv/src/uv-common.c b/deps/uv/src/uv-common.c index cec4ac6281b91b..5cb1a8c898f7ae 100644 --- a/deps/uv/src/uv-common.c +++ b/deps/uv/src/uv-common.c @@ -100,6 +100,17 @@ void* uv__realloc(void* ptr, size_t size) { return NULL; } +void* uv__reallocf(void* ptr, size_t size) { + void* newptr; + + newptr = uv__realloc(ptr, size); + if (newptr == NULL) + if (size > 0) + uv__free(ptr); + + return newptr; +} + int uv_replace_allocator(uv_malloc_func malloc_func, uv_realloc_func realloc_func, uv_calloc_func calloc_func, diff --git a/deps/uv/src/uv-common.h b/deps/uv/src/uv-common.h index f788161c3955ed..13192c1ebd8814 100644 --- a/deps/uv/src/uv-common.h +++ b/deps/uv/src/uv-common.h @@ -322,5 +322,6 @@ char *uv__strndup(const char* s, size_t n); void* uv__malloc(size_t size); void uv__free(void* ptr); void* uv__realloc(void* ptr, size_t size); +void* uv__reallocf(void* ptr, size_t size); #endif /* UV_COMMON_H_ */ diff --git a/deps/uv/src/win/fs.c b/deps/uv/src/win/fs.c index 8502b072021a9e..834c44a26d44cb 100644 --- a/deps/uv/src/win/fs.c +++ b/deps/uv/src/win/fs.c @@ -2225,34 +2225,68 @@ INLINE static int fs__utime_handle(HANDLE handle, double atime, double mtime) { return 0; } - -static void fs__utime(uv_fs_t* req) { +INLINE static DWORD fs__utime_impl_from_path(WCHAR* path, + double atime, + double mtime, + int do_lutime) { HANDLE handle; + DWORD flags; + DWORD ret; - handle = CreateFileW(req->file.pathw, + flags = FILE_FLAG_BACKUP_SEMANTICS; + if (do_lutime) { + flags |= FILE_FLAG_OPEN_REPARSE_POINT; + } + + handle = CreateFileW(path, FILE_WRITE_ATTRIBUTES, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, NULL, OPEN_EXISTING, - FILE_FLAG_BACKUP_SEMANTICS, + flags, NULL); if (handle == INVALID_HANDLE_VALUE) { - SET_REQ_WIN32_ERROR(req, GetLastError()); - return; + ret = GetLastError(); + } else if (fs__utime_handle(handle, atime, mtime) != 0) { + ret = GetLastError(); + } else { + ret = 0; } - if (fs__utime_handle(handle, req->fs.time.atime, req->fs.time.mtime) != 0) { - SET_REQ_WIN32_ERROR(req, GetLastError()); - CloseHandle(handle); + CloseHandle(handle); + return ret; +} + +INLINE static void fs__utime_impl(uv_fs_t* req, int do_lutime) { + DWORD error; + + error = fs__utime_impl_from_path(req->file.pathw, + req->fs.time.atime, + req->fs.time.mtime, + do_lutime); + + if (error != 0) { + if (do_lutime && + (error == ERROR_SYMLINK_NOT_SUPPORTED || + error == ERROR_NOT_A_REPARSE_POINT)) { + /* Opened file is a reparse point but not a symlink. Try again. */ + fs__utime_impl(req, 0); + } else { + /* utime failed. */ + SET_REQ_WIN32_ERROR(req, error); + } + return; } - CloseHandle(handle); - req->result = 0; } +static void fs__utime(uv_fs_t* req) { + fs__utime_impl(req, /* do_lutime */ 0); +} + static void fs__futime(uv_fs_t* req) { int fd = req->file.fd; @@ -2274,6 +2308,10 @@ static void fs__futime(uv_fs_t* req) { req->result = 0; } +static void fs__lutime(uv_fs_t* req) { + fs__utime_impl(req, /* do_lutime */ 1); +} + static void fs__link(uv_fs_t* req) { DWORD r = CreateHardLinkW(req->fs.info.new_pathw, req->file.pathw, NULL); @@ -2621,14 +2659,62 @@ static void fs__statfs(uv_fs_t* req) { DWORD bytes_per_sector; DWORD free_clusters; DWORD total_clusters; + WCHAR* pathw; - if (0 == GetDiskFreeSpaceW(req->file.pathw, + pathw = req->file.pathw; +retry_get_disk_free_space: + if (0 == GetDiskFreeSpaceW(pathw, §ors_per_cluster, &bytes_per_sector, &free_clusters, &total_clusters)) { - SET_REQ_WIN32_ERROR(req, GetLastError()); - return; + DWORD err; + WCHAR* fpart; + size_t len; + DWORD ret; + BOOL is_second; + + err = GetLastError(); + is_second = pathw != req->file.pathw; + if (err != ERROR_DIRECTORY || is_second) { + if (is_second) + uv__free(pathw); + + SET_REQ_WIN32_ERROR(req, err); + return; + } + + len = MAX_PATH + 1; + pathw = uv__malloc(len * sizeof(*pathw)); + if (pathw == NULL) { + SET_REQ_UV_ERROR(req, UV_ENOMEM, ERROR_OUTOFMEMORY); + return; + } +retry_get_full_path_name: + ret = GetFullPathNameW(req->file.pathw, + len, + pathw, + &fpart); + if (ret == 0) { + uv__free(pathw); + SET_REQ_WIN32_ERROR(req, err); + return; + } else if (ret > len) { + len = ret; + pathw = uv__reallocf(pathw, len * sizeof(*pathw)); + if (pathw == NULL) { + SET_REQ_UV_ERROR(req, UV_ENOMEM, ERROR_OUTOFMEMORY); + return; + } + goto retry_get_full_path_name; + } + if (fpart != 0) + *fpart = L'\0'; + + goto retry_get_disk_free_space; + } + if (pathw != req->file.pathw) { + uv__free(pathw); } stat_fs = uv__malloc(sizeof(*stat_fs)); @@ -2670,6 +2756,7 @@ static void uv__fs_work(struct uv__work* w) { XX(FTRUNCATE, ftruncate) XX(UTIME, utime) XX(FUTIME, futime) + XX(LUTIME, lutime) XX(ACCESS, access) XX(CHMOD, chmod) XX(FCHMOD, fchmod) @@ -3222,6 +3309,21 @@ int uv_fs_futime(uv_loop_t* loop, uv_fs_t* req, uv_file fd, double atime, POST; } +int uv_fs_lutime(uv_loop_t* loop, uv_fs_t* req, const char* path, double atime, + double mtime, uv_fs_cb cb) { + int err; + + INIT(UV_FS_LUTIME); + err = fs__capture_path(req, path, NULL, cb != NULL); + if (err) { + return uv_translate_sys_error(err); + } + + req->fs.time.atime = atime; + req->fs.time.mtime = mtime; + POST; +} + int uv_fs_statfs(uv_loop_t* loop, uv_fs_t* req, diff --git a/deps/uv/src/win/process.c b/deps/uv/src/win/process.c index 9b7fdc1dc1b4e2..73543c6ed987ce 100644 --- a/deps/uv/src/win/process.c +++ b/deps/uv/src/win/process.c @@ -58,7 +58,6 @@ static const env_var_t required_vars[] = { /* keep me sorted */ E_V("USERPROFILE"), E_V("WINDIR"), }; -static size_t n_required_vars = ARRAY_SIZE(required_vars); static HANDLE uv_global_job_handle_; @@ -692,7 +691,7 @@ int make_program_env(char* env_block[], WCHAR** dst_ptr) { WCHAR* dst_copy; WCHAR** ptr_copy; WCHAR** env_copy; - DWORD* required_vars_value_len = alloca(n_required_vars * sizeof(DWORD*)); + DWORD required_vars_value_len[ARRAY_SIZE(required_vars)]; /* first pass: determine size in UTF-16 */ for (env = env_block; *env; env++) { @@ -745,7 +744,7 @@ int make_program_env(char* env_block[], WCHAR** dst_ptr) { qsort(env_copy, env_block_count-1, sizeof(wchar_t*), qsort_wcscmp); /* third pass: check for required variables */ - for (ptr_copy = env_copy, i = 0; i < n_required_vars; ) { + for (ptr_copy = env_copy, i = 0; i < ARRAY_SIZE(required_vars); ) { int cmp; if (!*ptr_copy) { cmp = -1; @@ -778,10 +777,10 @@ int make_program_env(char* env_block[], WCHAR** dst_ptr) { } for (ptr = dst, ptr_copy = env_copy, i = 0; - *ptr_copy || i < n_required_vars; + *ptr_copy || i < ARRAY_SIZE(required_vars); ptr += len) { int cmp; - if (i >= n_required_vars) { + if (i >= ARRAY_SIZE(required_vars)) { cmp = 1; } else if (!*ptr_copy) { cmp = -1; diff --git a/deps/uv/src/win/util.c b/deps/uv/src/win/util.c index 4de638f5971c35..aaa7ba0325b0e5 100644 --- a/deps/uv/src/win/util.c +++ b/deps/uv/src/win/util.c @@ -63,6 +63,9 @@ /* Maximum environment variable size, including the terminating null */ #define MAX_ENV_VAR_LENGTH 32767 +/* A RtlGenRandom() by any other name... */ +extern BOOLEAN NTAPI SystemFunction036(PVOID Buffer, ULONG BufferLength); + /* Cached copy of the process title, plus a mutex guarding it. */ static char *process_title; static CRITICAL_SECTION process_title_lock; @@ -1402,7 +1405,7 @@ int uv_os_environ(uv_env_item_t** envitems, int* count) { for (penv = env, i = 0; *penv != L'\0'; penv += wcslen(penv) + 1, i++); *envitems = uv__calloc(i, sizeof(**envitems)); - if (envitems == NULL) { + if (*envitems == NULL) { FreeEnvironmentStringsW(env); return UV_ENOMEM; } @@ -1862,13 +1865,10 @@ int uv_gettimeofday(uv_timeval64_t* tv) { } int uv__random_rtlgenrandom(void* buf, size_t buflen) { - if (pRtlGenRandom == NULL) - return UV_ENOSYS; - if (buflen == 0) return 0; - if (pRtlGenRandom(buf, buflen) == FALSE) + if (SystemFunction036(buf, buflen) == FALSE) return UV_EIO; return 0; diff --git a/deps/uv/src/win/winapi.c b/deps/uv/src/win/winapi.c index 85a9de8a2295ec..bb86ec8ceac8ba 100644 --- a/deps/uv/src/win/winapi.c +++ b/deps/uv/src/win/winapi.c @@ -36,9 +36,6 @@ sNtQueryDirectoryFile pNtQueryDirectoryFile; sNtQuerySystemInformation pNtQuerySystemInformation; sNtQueryInformationProcess pNtQueryInformationProcess; -/* Advapi32 function pointers */ -sRtlGenRandom pRtlGenRandom; - /* Kernel32 function pointers */ sGetQueuedCompletionStatusEx pGetQueuedCompletionStatusEx; @@ -54,7 +51,6 @@ void uv_winapi_init(void) { HMODULE powrprof_module; HMODULE user32_module; HMODULE kernel32_module; - HMODULE advapi32_module; ntdll_module = GetModuleHandleA("ntdll.dll"); if (ntdll_module == NULL) { @@ -138,12 +134,4 @@ void uv_winapi_init(void) { pSetWinEventHook = (sSetWinEventHook) GetProcAddress(user32_module, "SetWinEventHook"); } - - advapi32_module = GetModuleHandleA("advapi32.dll"); - if (advapi32_module == NULL) { - uv_fatal_error(GetLastError(), "GetModuleHandleA"); - } - - pRtlGenRandom = - (sRtlGenRandom) GetProcAddress(advapi32_module, "SystemFunction036"); } diff --git a/deps/uv/src/win/winapi.h b/deps/uv/src/win/winapi.h index fcc70652a9aedb..322a212dd73c19 100644 --- a/deps/uv/src/win/winapi.h +++ b/deps/uv/src/win/winapi.h @@ -4589,11 +4589,6 @@ typedef NTSTATUS (NTAPI *sNtQueryInformationProcess) ULONG Length, PULONG ReturnLength); -/* - * Advapi32 headers - */ -typedef BOOLEAN (WINAPI *sRtlGenRandom)(PVOID Buffer, ULONG BufferLength); - /* * Kernel32 headers */ @@ -4736,9 +4731,6 @@ extern sNtQueryDirectoryFile pNtQueryDirectoryFile; extern sNtQuerySystemInformation pNtQuerySystemInformation; extern sNtQueryInformationProcess pNtQueryInformationProcess; -/* Advapi32 function pointers */ -extern sRtlGenRandom pRtlGenRandom; - /* Kernel32 function pointers */ extern sGetQueuedCompletionStatusEx pGetQueuedCompletionStatusEx; diff --git a/deps/uv/test/run-benchmarks.c b/deps/uv/test/run-benchmarks.c index 6e42623d54cdec..980c9be8c12aa6 100644 --- a/deps/uv/test/run-benchmarks.c +++ b/deps/uv/test/run-benchmarks.c @@ -33,8 +33,7 @@ static int maybe_run_test(int argc, char **argv); int main(int argc, char **argv) { - if (platform_init(argc, argv)) - return EXIT_FAILURE; + platform_init(argc, argv); switch (argc) { case 1: return run_tests(1); diff --git a/deps/uv/test/run-tests.c b/deps/uv/test/run-tests.c index 3a6452ffdfd067..e5e75e17c87e22 100644 --- a/deps/uv/test/run-tests.c +++ b/deps/uv/test/run-tests.c @@ -59,9 +59,7 @@ int main(int argc, char **argv) { } #endif - if (platform_init(argc, argv)) - return EXIT_FAILURE; - + platform_init(argc, argv); argv = uv_setup_args(argc, argv); switch (argc) { diff --git a/deps/uv/test/runner-unix.c b/deps/uv/test/runner-unix.c index dbb33bfa3edfd2..b7ca1f857ec1e4 100644 --- a/deps/uv/test/runner-unix.c +++ b/deps/uv/test/runner-unix.c @@ -26,7 +26,7 @@ #include /* uintptr_t */ #include -#include /* readlink, usleep */ +#include /* usleep */ #include /* strdup */ #include #include @@ -67,18 +67,12 @@ void notify_parent_process(void) { /* Do platform-specific initialization. */ -int platform_init(int argc, char **argv) { +void platform_init(int argc, char **argv) { /* Disable stdio output buffering. */ setvbuf(stdout, NULL, _IONBF, 0); setvbuf(stderr, NULL, _IONBF, 0); signal(SIGPIPE, SIG_IGN); - - if (realpath(argv[0], executable_path) == NULL) { - perror("realpath"); - return -1; - } - - return 0; + snprintf(executable_path, sizeof(executable_path), "%s", argv[0]); } diff --git a/deps/uv/test/runner-win.c b/deps/uv/test/runner-win.c index e69b7447dcee0c..8c2a00b8a620c2 100644 --- a/deps/uv/test/runner-win.c +++ b/deps/uv/test/runner-win.c @@ -43,7 +43,7 @@ /* Do platform-specific initialization. */ -int platform_init(int argc, char **argv) { +void platform_init(int argc, char **argv) { /* Disable the "application crashed" popup. */ SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX); @@ -67,8 +67,6 @@ int platform_init(int argc, char **argv) { setvbuf(stderr, NULL, _IONBF, 0); strcpy(executable_path, argv[0]); - - return 0; } diff --git a/deps/uv/test/runner.h b/deps/uv/test/runner.h index 1a33950852de15..6801564f961c31 100644 --- a/deps/uv/test/runner.h +++ b/deps/uv/test/runner.h @@ -84,11 +84,7 @@ typedef struct { #define TEST_HELPER HELPER_ENTRY #define BENCHMARK_HELPER HELPER_ENTRY -#ifdef PATH_MAX -extern char executable_path[PATH_MAX]; -#else extern char executable_path[4096]; -#endif /* * Include platform-dependent definitions @@ -136,7 +132,7 @@ void print_lines(const char* buffer, size_t size, FILE* stream); */ /* Do platform-specific initialization. */ -int platform_init(int argc, char** argv); +void platform_init(int argc, char** argv); /* Invoke "argv[0] test-name [test-part]". Store process info in *p. Make sure * that all stdio output of the processes is buffered up. */ diff --git a/deps/uv/test/task.h b/deps/uv/test/task.h index 13105d0bd94a4d..27b731032e10b3 100644 --- a/deps/uv/test/task.h +++ b/deps/uv/test/task.h @@ -27,6 +27,8 @@ #include #include #include +#include +#include #if defined(_MSC_VER) && _MSC_VER < 1600 # include "uv/stdint-msvc2008.h" @@ -109,6 +111,118 @@ typedef enum { } \ } while (0) +#define ASSERT_BASE(expr, a, operator, b, type, conv) \ + do { \ + if (!(expr)) { \ + fprintf(stderr, \ + "Assertion failed in %s on line %d: `%s %s %s` " \ + "(%"conv" %s %"conv")\n", \ + __FILE__, \ + __LINE__, \ + #a, \ + #operator, \ + #b, \ + (type)a, \ + #operator, \ + (type)b); \ + abort(); \ + } \ + } while (0) + +#define ASSERT_BASE_LEN(expr, a, operator, b, conv, len) \ + do { \ + if (!(expr)) { \ + fprintf(stderr, \ + "Assertion failed in %s on line %d: `%s %s %s` " \ + "(%.*"#conv" %s %.*"#conv")\n", \ + __FILE__, \ + __LINE__, \ + #a, \ + #operator, \ + #b, \ + (int)len, \ + a, \ + #operator, \ + (int)len, \ + b); \ + abort(); \ + } \ + } while (0) + +#define ASSERT_BASE_HEX(expr, a, operator, b, size) \ + do { \ + if (!(expr)) { \ + int i; \ + unsigned char* a_ = (unsigned char*)a; \ + unsigned char* b_ = (unsigned char*)b; \ + fprintf(stderr, \ + "Assertion failed in %s on line %d: `%s %s %s` (", \ + __FILE__, \ + __LINE__, \ + #a, \ + #operator, \ + #b); \ + for (i = 0; i < size; ++i) { \ + if (i > 0) fprintf(stderr, ":"); \ + fprintf(stderr, "%02X", a_[i]); \ + } \ + fprintf(stderr, " %s ", #operator); \ + for (i = 0; i < size; ++i) { \ + if (i > 0) fprintf(stderr, ":"); \ + fprintf(stderr, "%02X", b_[i]); \ + } \ + fprintf(stderr, ")\n"); \ + abort(); \ + } \ + } while (0) + +#define ASSERT_INT_BASE(a, operator, b, type, conv) \ + ASSERT_BASE(a operator b, a, operator, b, type, conv) + +#define ASSERT_EQ(a, b) ASSERT_INT_BASE(a, ==, b, int64_t, PRId64) +#define ASSERT_GE(a, b) ASSERT_INT_BASE(a, >=, b, int64_t, PRId64) +#define ASSERT_GT(a, b) ASSERT_INT_BASE(a, >, b, int64_t, PRId64) +#define ASSERT_LE(a, b) ASSERT_INT_BASE(a, <=, b, int64_t, PRId64) +#define ASSERT_LT(a, b) ASSERT_INT_BASE(a, <, b, int64_t, PRId64) +#define ASSERT_NE(a, b) ASSERT_INT_BASE(a, !=, b, int64_t, PRId64) + +#define ASSERT_UINT64_EQ(a, b) ASSERT_INT_BASE(a, ==, b, uint64_t, PRIu64) +#define ASSERT_UINT64_GE(a, b) ASSERT_INT_BASE(a, >=, b, uint64_t, PRIu64) +#define ASSERT_UINT64_GT(a, b) ASSERT_INT_BASE(a, >, b, uint64_t, PRIu64) +#define ASSERT_UINT64_LE(a, b) ASSERT_INT_BASE(a, <=, b, uint64_t, PRIu64) +#define ASSERT_UINT64_LT(a, b) ASSERT_INT_BASE(a, <, b, uint64_t, PRIu64) +#define ASSERT_UINT64_NE(a, b) ASSERT_INT_BASE(a, !=, b, uint64_t, PRIu64) + +#define ASSERT_STR_EQ(a, b) \ + ASSERT_BASE(strcmp(a, b) == 0, a, ==, b, char*, "s") + +#define ASSERT_STR_NE(a, b) \ + ASSERT_BASE(strcmp(a, b) != 0, a, !=, b, char*, "s") + +#define ASSERT_MEM_EQ(a, b, size) \ + ASSERT_BASE_LEN(memcmp(a, b, size) == 0, a, ==, b, s, size) + +#define ASSERT_MEM_NE(a, b, size) \ + ASSERT_BASE_LEN(memcmp(a, b, size) != 0, a, !=, b, s, size) + +#define ASSERT_MEM_HEX_EQ(a, b, size) \ + ASSERT_BASE_HEX(memcmp(a, b, size) == 0, a, ==, b, size) + +#define ASSERT_MEM_HEX_NE(a, b, size) \ + ASSERT_BASE_HEX(memcmp(a, b, size) != 0, a, !=, b, size) + +#define ASSERT_NULL(a) \ + ASSERT_BASE(a == NULL, a, ==, NULL, void*, "p") + +#define ASSERT_NOT_NULL(a) \ + ASSERT_BASE(a != NULL, a, !=, NULL, void*, "p") + +#define ASSERT_PTR_EQ(a, b) \ + ASSERT_BASE((void*)a == (void*)b, a, ==, b, void*, "p") + +#define ASSERT_PTR_NE(a, b) \ + ASSERT_BASE((void*)a != (void*)b, a, !=, b, void*, "p") + /* This macro cleans up the main loop. This is used to avoid valgrind * warnings about memory being "leaked" by the main event loop. */ diff --git a/deps/uv/test/test-cwd-and-chdir.c b/deps/uv/test/test-cwd-and-chdir.c index 5d43524c921cdd..faeed021030e83 100644 --- a/deps/uv/test/test-cwd-and-chdir.c +++ b/deps/uv/test/test-cwd-and-chdir.c @@ -23,8 +23,7 @@ #include "task.h" #include -#define PATHMAX 1024 -extern char executable_path[]; +#define PATHMAX 4096 TEST_IMPL(cwd_and_chdir) { char buffer_orig[PATHMAX]; diff --git a/deps/uv/test/test-fs.c b/deps/uv/test/test-fs.c index b6b2b19981bdd4..2966a53b79d349 100644 --- a/deps/uv/test/test-fs.c +++ b/deps/uv/test/test-fs.c @@ -55,7 +55,7 @@ #endif #define TOO_LONG_NAME_LENGTH 65536 -#define PATHMAX 1024 +#define PATHMAX 4096 typedef struct { const char* path; @@ -95,6 +95,7 @@ static int readlink_cb_count; static int realpath_cb_count; static int utime_cb_count; static int futime_cb_count; +static int lutime_cb_count; static int statfs_cb_count; static uv_loop_t* loop; @@ -806,12 +807,19 @@ TEST_IMPL(fs_file_loop) { return 0; } -static void check_utime(const char* path, double atime, double mtime) { +static void check_utime(const char* path, + double atime, + double mtime, + int test_lutime) { uv_stat_t* s; uv_fs_t req; int r; - r = uv_fs_stat(loop, &req, path, NULL); + if (test_lutime) + r = uv_fs_lstat(loop, &req, path, NULL); + else + r = uv_fs_stat(loop, &req, path, NULL); + ASSERT(r == 0); ASSERT(req.result == 0); @@ -832,7 +840,7 @@ static void utime_cb(uv_fs_t* req) { ASSERT(req->fs_type == UV_FS_UTIME); c = req->data; - check_utime(c->path, c->atime, c->mtime); + check_utime(c->path, c->atime, c->mtime, /* test_lutime */ 0); uv_fs_req_cleanup(req); utime_cb_count++; @@ -847,13 +855,27 @@ static void futime_cb(uv_fs_t* req) { ASSERT(req->fs_type == UV_FS_FUTIME); c = req->data; - check_utime(c->path, c->atime, c->mtime); + check_utime(c->path, c->atime, c->mtime, /* test_lutime */ 0); uv_fs_req_cleanup(req); futime_cb_count++; } +static void lutime_cb(uv_fs_t* req) { + utime_check_t* c; + + ASSERT(req->result == 0); + ASSERT(req->fs_type == UV_FS_LUTIME); + + c = req->data; + check_utime(c->path, c->atime, c->mtime, /* test_lutime */ 1); + + uv_fs_req_cleanup(req); + lutime_cb_count++; +} + + TEST_IMPL(fs_file_async) { int r; @@ -2470,7 +2492,7 @@ TEST_IMPL(fs_utime) { r = uv_fs_stat(NULL, &req, path, NULL); ASSERT(r == 0); ASSERT(req.result == 0); - check_utime(path, atime, mtime); + check_utime(path, atime, mtime, /* test_lutime */ 0); uv_fs_req_cleanup(&req); atime = mtime = 1291404900; /* 2010-12-03 20:35:00 - mees <3 */ @@ -2576,7 +2598,7 @@ TEST_IMPL(fs_futime) { r = uv_fs_stat(NULL, &req, path, NULL); ASSERT(r == 0); ASSERT(req.result == 0); - check_utime(path, atime, mtime); + check_utime(path, atime, mtime, /* test_lutime */ 0); uv_fs_req_cleanup(&req); atime = mtime = 1291404900; /* 2010-12-03 20:35:00 - mees <3 */ @@ -2600,6 +2622,84 @@ TEST_IMPL(fs_futime) { } +TEST_IMPL(fs_lutime) { + utime_check_t checkme; + const char* path = "test_file"; + const char* symlink_path = "test_file_symlink"; + double atime; + double mtime; + uv_fs_t req; + int r, s; + + + /* Setup */ + loop = uv_default_loop(); + unlink(path); + r = uv_fs_open(NULL, &req, path, O_RDWR | O_CREAT, S_IWUSR | S_IRUSR, NULL); + ASSERT(r >= 0); + ASSERT(req.result >= 0); + uv_fs_req_cleanup(&req); + uv_fs_close(loop, &req, r, NULL); + + unlink(symlink_path); + s = uv_fs_symlink(NULL, &req, path, symlink_path, 0, NULL); +#ifdef _WIN32 + if (s == UV_EPERM) { + /* + * Creating a symlink before Windows 10 Creators Update was only allowed + * when running elevated console (with admin rights) + */ + RETURN_SKIP( + "Symlink creation requires elevated console (with admin rights)"); + } +#endif + ASSERT(s == 0); + ASSERT(req.result == 0); + uv_fs_req_cleanup(&req); + + /* Test the synchronous version. */ + atime = mtime = 400497753; /* 1982-09-10 11:22:33 */ + +#ifdef _WIN32 + mtime += 0.444; /* 1982-09-10 11:22:33.444 */ +#endif + + checkme.atime = atime; + checkme.mtime = mtime; + checkme.path = symlink_path; + req.data = &checkme; + + r = uv_fs_lutime(NULL, &req, symlink_path, atime, mtime, NULL); +#if (defined(_AIX) && !defined(_AIX71)) || \ + defined(__MVS__) + ASSERT(r == UV_ENOSYS); + RETURN_SKIP("lutime is not implemented for z/OS and AIX versions below 7.1"); +#endif + ASSERT(r == 0); + lutime_cb(&req); + ASSERT(lutime_cb_count == 1); + + /* Test the asynchronous version. */ + atime = mtime = 1291404900; /* 2010-12-03 20:35:00 */ + + checkme.atime = atime; + checkme.mtime = mtime; + checkme.path = symlink_path; + + r = uv_fs_lutime(loop, &req, symlink_path, atime, mtime, lutime_cb); + ASSERT(r == 0); + uv_run(loop, UV_RUN_DEFAULT); + ASSERT(lutime_cb_count == 2); + + /* Cleanup. */ + unlink(path); + unlink(symlink_path); + + MAKE_VALGRIND_HAPPY(); + return 0; +} + + TEST_IMPL(fs_stat_missing_path) { uv_fs_t req; int r; diff --git a/deps/uv/test/test-get-currentexe.c b/deps/uv/test/test-get-currentexe.c index 0e9d6965402daf..8c730334c205b3 100644 --- a/deps/uv/test/test-get-currentexe.c +++ b/deps/uv/test/test-get-currentexe.c @@ -23,28 +23,29 @@ #include "task.h" #include -#define PATHMAX 1024 +#ifndef _WIN32 +#include +#endif + +#define PATHMAX 4096 extern char executable_path[]; TEST_IMPL(get_currentexe) { char buffer[PATHMAX]; + char path[PATHMAX]; size_t size; char* match; - char* path; int r; size = sizeof(buffer) / sizeof(buffer[0]); r = uv_exepath(buffer, &size); ASSERT(!r); - /* uv_exepath can return an absolute path on darwin, so if the test runner - * was run with a relative prefix of "./", we need to strip that prefix off - * executable_path or we'll fail. */ - if (executable_path[0] == '.' && executable_path[1] == '/') { - path = executable_path + 2; - } else { - path = executable_path; - } +#ifdef _WIN32 + snprintf(path, sizeof(path), "%s", executable_path); +#else + ASSERT(NULL != realpath(executable_path, path)); +#endif match = strstr(buffer, path); /* Verify that the path returned from uv_exepath is a subdirectory of diff --git a/deps/uv/test/test-gethostname.c b/deps/uv/test/test-gethostname.c index ac636f0aba638b..1a9816d43c619e 100644 --- a/deps/uv/test/test-gethostname.c +++ b/deps/uv/test/test-gethostname.c @@ -51,7 +51,7 @@ TEST_IMPL(gethostname) { size = UV_MAXHOSTNAMESIZE; r = uv_os_gethostname(buf, &size); ASSERT(r == 0); - ASSERT(size > 1 && size == strlen(buf)); + ASSERT(size > 0 && size == strlen(buf)); ASSERT(size + 1 == enobufs_size); return 0; diff --git a/deps/uv/test/test-homedir.c b/deps/uv/test/test-homedir.c index 856534a40ceaa9..508351f72c0327 100644 --- a/deps/uv/test/test-homedir.c +++ b/deps/uv/test/test-homedir.c @@ -23,7 +23,7 @@ #include "task.h" #include -#define PATHMAX 1024 +#define PATHMAX 4096 #define SMALLPATH 1 TEST_IMPL(homedir) { diff --git a/deps/uv/test/test-ipc.c b/deps/uv/test/test-ipc.c index 8579a470292d31..39ef4f1175b0d4 100644 --- a/deps/uv/test/test-ipc.c +++ b/deps/uv/test/test-ipc.c @@ -79,16 +79,16 @@ static void on_connection(uv_stream_t* server, int status) { if (!local_conn_accepted) { /* Accept the connection and close it. Also and close the server. */ - ASSERT(status == 0); - ASSERT((uv_stream_t*)&tcp_server == server); + ASSERT_EQ(status, 0); + ASSERT_PTR_EQ(&tcp_server, server); conn = malloc(sizeof(*conn)); - ASSERT(conn); + ASSERT_NOT_NULL(conn); r = uv_tcp_init(server->loop, conn); - ASSERT(r == 0); + ASSERT_EQ(r, 0); r = uv_accept(server, (uv_stream_t*)conn); - ASSERT(r == 0); + ASSERT_EQ(r, 0); uv_close((uv_handle_t*)conn, close_server_conn_cb); uv_close((uv_handle_t*)server, NULL); @@ -102,8 +102,8 @@ static void exit_cb(uv_process_t* process, int term_signal) { printf("exit_cb\n"); exit_cb_called++; - ASSERT(exit_status == 0); - ASSERT(term_signal == 0); + ASSERT_EQ(exit_status, 0); + ASSERT_EQ(term_signal, 0); uv_close((uv_handle_t*)process, NULL); } @@ -134,18 +134,17 @@ static void make_many_connections(void) { for (i = 0; i < CONN_COUNT; i++) { conn = malloc(sizeof(*conn)); - ASSERT(conn); + ASSERT_NOT_NULL(conn); r = uv_tcp_init(uv_default_loop(), &conn->conn); - ASSERT(r == 0); - - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); + ASSERT_EQ(r, 0); + ASSERT_EQ(0, uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); r = uv_tcp_connect(&conn->conn_req, (uv_tcp_t*) &conn->conn, (const struct sockaddr*) &addr, connect_cb); - ASSERT(r == 0); + ASSERT_EQ(r, 0); conn->conn.data = conn; } @@ -182,36 +181,38 @@ static void on_read(uv_stream_t* handle, pending = uv_pipe_pending_type(pipe); if (!tcp_server_listening) { - ASSERT(1 == uv_pipe_pending_count(pipe)); - ASSERT(nread > 0 && buf->base && pending != UV_UNKNOWN_HANDLE); + ASSERT_EQ(1, uv_pipe_pending_count(pipe)); + ASSERT_GT(nread, 0); + ASSERT_NOT_NULL(buf->base); + ASSERT_NE(pending, UV_UNKNOWN_HANDLE); read_cb_called++; /* Accept the pending TCP server, and start listening on it. */ - ASSERT(pending == UV_TCP); + ASSERT_EQ(pending, UV_TCP); r = uv_tcp_init(uv_default_loop(), &tcp_server); - ASSERT(r == 0); + ASSERT_EQ(r, 0); r = uv_accept((uv_stream_t*)pipe, (uv_stream_t*)&tcp_server); - ASSERT(r == 0); + ASSERT_EQ(r, 0); r = uv_listen((uv_stream_t*)&tcp_server, BACKLOG, on_connection); - ASSERT(r == 0); + ASSERT_EQ(r, 0); tcp_server_listening = 1; /* Make sure that the expected data is correctly multiplexed. */ - ASSERT(memcmp("hello\n", buf->base, nread) == 0); + ASSERT_MEM_EQ("hello\n", buf->base, nread); outbuf = uv_buf_init("world\n", 6); r = uv_write(&write_req, (uv_stream_t*)pipe, &outbuf, 1, NULL); - ASSERT(r == 0); + ASSERT_EQ(r, 0); /* Create a bunch of connections to get both servers to accept. */ make_many_connections(); } else if (memcmp("accepted_connection\n", buf->base, nread) == 0) { /* Remote server has accepted a connection. Close the channel. */ - ASSERT(0 == uv_pipe_pending_count(pipe)); - ASSERT(pending == UV_UNKNOWN_HANDLE); + ASSERT_EQ(0, uv_pipe_pending_count(pipe)); + ASSERT_EQ(pending, UV_UNKNOWN_HANDLE); remote_conn_accepted = 1; uv_close((uv_handle_t*)&channel, NULL); } @@ -247,37 +248,39 @@ static void on_read_listen_after_bound_twice(uv_stream_t* handle, fprintf(stderr, "got %d bytes\n", (int)nread); - ASSERT(uv_pipe_pending_count(pipe) > 0); + ASSERT_GT(uv_pipe_pending_count(pipe), 0); pending = uv_pipe_pending_type(pipe); - ASSERT(nread > 0 && buf->base && pending != UV_UNKNOWN_HANDLE); + ASSERT_GT(nread, 0); + ASSERT_NOT_NULL(buf->base); + ASSERT_NE(pending, UV_UNKNOWN_HANDLE); read_cb_called++; if (read_cb_called == 1) { /* Accept the first TCP server, and start listening on it. */ - ASSERT(pending == UV_TCP); + ASSERT_EQ(pending, UV_TCP); r = uv_tcp_init(uv_default_loop(), &tcp_server); - ASSERT(r == 0); + ASSERT_EQ(r, 0); r = uv_accept((uv_stream_t*)pipe, (uv_stream_t*)&tcp_server); - ASSERT(r == 0); + ASSERT_EQ(r, 0); r = uv_listen((uv_stream_t*)&tcp_server, BACKLOG, on_connection); - ASSERT(r == 0); + ASSERT_EQ(r, 0); } else if (read_cb_called == 2) { /* Accept the second TCP server, and start listening on it. */ - ASSERT(pending == UV_TCP); + ASSERT_EQ(pending, UV_TCP); r = uv_tcp_init(uv_default_loop(), &tcp_server2); - ASSERT(r == 0); + ASSERT_EQ(r, 0); r = uv_accept((uv_stream_t*)pipe, (uv_stream_t*)&tcp_server2); - ASSERT(r == 0); + ASSERT_EQ(r, 0); r = uv_listen((uv_stream_t*)&tcp_server2, BACKLOG, on_connection); - ASSERT(r == UV_EADDRINUSE); + ASSERT_EQ(r, UV_EADDRINUSE); uv_close((uv_handle_t*)&tcp_server, NULL); uv_close((uv_handle_t*)&tcp_server2, NULL); - ASSERT(0 == uv_pipe_pending_count(pipe)); + ASSERT_EQ(0, uv_pipe_pending_count(pipe)); uv_close((uv_handle_t*)&channel, NULL); } @@ -296,12 +299,12 @@ void spawn_helper(uv_pipe_t* channel, uv_stdio_container_t stdio[3]; r = uv_pipe_init(uv_default_loop(), channel, 1); - ASSERT(r == 0); - ASSERT(channel->ipc); + ASSERT_EQ(r, 0); + ASSERT_NE(channel->ipc, 0); exepath_size = sizeof(exepath); r = uv_exepath(exepath, &exepath_size); - ASSERT(r == 0); + ASSERT_EQ(r, 0); exepath[exepath_size] = '\0'; args[0] = exepath; @@ -323,13 +326,13 @@ void spawn_helper(uv_pipe_t* channel, stdio[2].data.fd = 2; r = uv_spawn(uv_default_loop(), process, &options); - ASSERT(r == 0); + ASSERT_EQ(r, 0); } static void on_tcp_write(uv_write_t* req, int status) { - ASSERT(status == 0); - ASSERT(req->handle == (uv_stream_t*)&tcp_connection); + ASSERT_EQ(status, 0); + ASSERT_PTR_EQ(req->handle, &tcp_connection); tcp_write_cb_called++; } @@ -343,9 +346,9 @@ static void on_read_alloc(uv_handle_t* handle, static void on_tcp_read(uv_stream_t* tcp, ssize_t nread, const uv_buf_t* buf) { - ASSERT(nread > 0); - ASSERT(memcmp("hello again\n", buf->base, nread) == 0); - ASSERT(tcp == (uv_stream_t*)&tcp_connection); + ASSERT_GT(nread, 0); + ASSERT_MEM_EQ("hello again\n", buf->base, nread); + ASSERT_PTR_EQ(tcp, &tcp_connection); free(buf->base); tcp_read_cb_called++; @@ -382,31 +385,33 @@ static void on_read_connection(uv_stream_t* handle, fprintf(stderr, "got %d bytes\n", (int)nread); - ASSERT(1 == uv_pipe_pending_count(pipe)); + ASSERT_EQ(1, uv_pipe_pending_count(pipe)); pending = uv_pipe_pending_type(pipe); - ASSERT(nread > 0 && buf->base && pending != UV_UNKNOWN_HANDLE); + ASSERT_GT(nread, 0); + ASSERT_NOT_NULL(buf->base); + ASSERT_NE(pending, UV_UNKNOWN_HANDLE); read_cb_called++; /* Accept the pending TCP connection */ - ASSERT(pending == UV_TCP); + ASSERT_EQ(pending, UV_TCP); r = uv_tcp_init(uv_default_loop(), &tcp_connection); - ASSERT(r == 0); + ASSERT_EQ(r, 0); r = uv_accept(handle, (uv_stream_t*)&tcp_connection); - ASSERT(r == 0); + ASSERT_EQ(r, 0); /* Make sure that the expected data is correctly multiplexed. */ - ASSERT(memcmp("hello\n", buf->base, nread) == 0); + ASSERT_MEM_EQ("hello\n", buf->base, nread); /* Write/read to/from the connection */ outbuf = uv_buf_init("world\n", 6); r = uv_write(&write_req, (uv_stream_t*)&tcp_connection, &outbuf, 1, on_tcp_write); - ASSERT(r == 0); + ASSERT_EQ(r, 0); r = uv_read_start((uv_stream_t*)&tcp_connection, on_read_alloc, on_tcp_read); - ASSERT(r == 0); + ASSERT_EQ(r, 0); free(buf->base); } @@ -448,7 +453,7 @@ static int run_ipc_test(const char* helper, uv_read_cb read_cb) { uv_read_start((uv_stream_t*)&channel, on_alloc, read_cb); r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(r == 0); + ASSERT_EQ(r, 0); MAKE_VALGRIND_HAPPY(); return 0; @@ -460,10 +465,10 @@ TEST_IMPL(ipc_listen_before_write) { RETURN_SKIP(NO_SEND_HANDLE_ON_PIPE); #endif int r = run_ipc_test("ipc_helper_listen_before_write", on_read); - ASSERT(local_conn_accepted == 1); - ASSERT(remote_conn_accepted == 1); - ASSERT(read_cb_called == 1); - ASSERT(exit_cb_called == 1); + ASSERT_EQ(local_conn_accepted, 1); + ASSERT_EQ(remote_conn_accepted, 1); + ASSERT_EQ(read_cb_called, 1); + ASSERT_EQ(exit_cb_called, 1); return r; } @@ -473,10 +478,10 @@ TEST_IMPL(ipc_listen_after_write) { RETURN_SKIP(NO_SEND_HANDLE_ON_PIPE); #endif int r = run_ipc_test("ipc_helper_listen_after_write", on_read); - ASSERT(local_conn_accepted == 1); - ASSERT(remote_conn_accepted == 1); - ASSERT(read_cb_called == 1); - ASSERT(exit_cb_called == 1); + ASSERT_EQ(local_conn_accepted, 1); + ASSERT_EQ(remote_conn_accepted, 1); + ASSERT_EQ(read_cb_called, 1); + ASSERT_EQ(exit_cb_called, 1); return r; } @@ -486,10 +491,10 @@ TEST_IMPL(ipc_tcp_connection) { RETURN_SKIP(NO_SEND_HANDLE_ON_PIPE); #endif int r = run_ipc_test("ipc_helper_tcp_connection", on_read_connection); - ASSERT(read_cb_called == 1); - ASSERT(tcp_write_cb_called == 1); - ASSERT(tcp_read_cb_called == 1); - ASSERT(exit_cb_called == 1); + ASSERT_EQ(read_cb_called, 1); + ASSERT_EQ(tcp_write_cb_called, 1); + ASSERT_EQ(tcp_read_cb_called, 1); + ASSERT_EQ(exit_cb_called, 1); return r; } @@ -497,7 +502,7 @@ TEST_IMPL(ipc_tcp_connection) { TEST_IMPL(ipc_closed_handle) { int r; r = run_ipc_test("ipc_helper_closed_handle", on_read_closed_handle); - ASSERT(r == 0); + ASSERT_EQ(r, 0); return 0; } #endif @@ -509,20 +514,20 @@ TEST_IMPL(listen_with_simultaneous_accepts) { int r; struct sockaddr_in addr; - ASSERT(0 == uv_ip4_addr("0.0.0.0", TEST_PORT, &addr)); + ASSERT_EQ(0, uv_ip4_addr("0.0.0.0", TEST_PORT, &addr)); r = uv_tcp_init(uv_default_loop(), &server); - ASSERT(r == 0); + ASSERT_EQ(r, 0); r = uv_tcp_bind(&server, (const struct sockaddr*) &addr, 0); - ASSERT(r == 0); + ASSERT_EQ(r, 0); r = uv_tcp_simultaneous_accepts(&server, 1); - ASSERT(r == 0); + ASSERT_EQ(r, 0); r = uv_listen((uv_stream_t*)&server, SOMAXCONN, NULL); - ASSERT(r == 0); - ASSERT(server.reqs_pending == 32); + ASSERT_EQ(r, 0); + ASSERT_EQ(server.reqs_pending, 32); MAKE_VALGRIND_HAPPY(); return 0; @@ -534,20 +539,20 @@ TEST_IMPL(listen_no_simultaneous_accepts) { int r; struct sockaddr_in addr; - ASSERT(0 == uv_ip4_addr("0.0.0.0", TEST_PORT, &addr)); + ASSERT_EQ(0, uv_ip4_addr("0.0.0.0", TEST_PORT, &addr)); r = uv_tcp_init(uv_default_loop(), &server); - ASSERT(r == 0); + ASSERT_EQ(r, 0); r = uv_tcp_bind(&server, (const struct sockaddr*) &addr, 0); - ASSERT(r == 0); + ASSERT_EQ(r, 0); r = uv_tcp_simultaneous_accepts(&server, 0); - ASSERT(r == 0); + ASSERT_EQ(r, 0); r = uv_listen((uv_stream_t*)&server, SOMAXCONN, NULL); - ASSERT(r == 0); - ASSERT(server.reqs_pending == 1); + ASSERT_EQ(r, 0); + ASSERT_EQ(server.reqs_pending, 1); MAKE_VALGRIND_HAPPY(); return 0; @@ -558,8 +563,8 @@ TEST_IMPL(ipc_listen_after_bind_twice) { RETURN_SKIP(NO_SEND_HANDLE_ON_PIPE); #endif int r = run_ipc_test("ipc_helper_bind_twice", on_read_listen_after_bound_twice); - ASSERT(read_cb_called == 2); - ASSERT(exit_cb_called == 1); + ASSERT_EQ(read_cb_called, 2); + ASSERT_EQ(exit_cb_called, 1); return r; } #endif @@ -567,7 +572,7 @@ TEST_IMPL(ipc_listen_after_bind_twice) { TEST_IMPL(ipc_send_zero) { int r; r = run_ipc_test("ipc_helper_send_zero", on_read_send_zero); - ASSERT(r == 0); + ASSERT_EQ(r, 0); return 0; } @@ -589,7 +594,7 @@ static void conn_notify_write_cb(uv_write_t* req, int status) { static void tcp_connection_write_cb(uv_write_t* req, int status) { - ASSERT((uv_handle_t*)&conn.conn == (uv_handle_t*)req->handle); + ASSERT_PTR_EQ(&conn.conn, req->handle); uv_close((uv_handle_t*)req->handle, close_cb); uv_close((uv_handle_t*)&channel, close_cb); uv_close((uv_handle_t*)&tcp_server, close_cb); @@ -598,7 +603,7 @@ static void tcp_connection_write_cb(uv_write_t* req, int status) { static void closed_handle_large_write_cb(uv_write_t* req, int status) { - ASSERT(status == 0); + ASSERT_EQ(status, 0); ASSERT(closed_handle_data_read = LARGE_SIZE); if (++write_reqs_completed == ARRAY_SIZE(write_reqs)) { write_reqs_completed = 0; @@ -609,13 +614,13 @@ static void closed_handle_large_write_cb(uv_write_t* req, int status) { static void closed_handle_write_cb(uv_write_t* req, int status) { - ASSERT(status == UV_EBADF); + ASSERT_EQ(status, UV_EBADF); closed_handle_write = 1; } static void send_zero_write_cb(uv_write_t* req, int status) { - ASSERT(status == 0); + ASSERT_EQ(status, 0); send_zero_write++; } @@ -635,15 +640,15 @@ static void on_tcp_child_process_read(uv_stream_t* tcp, abort(); } - ASSERT(nread > 0); - ASSERT(memcmp("world\n", buf->base, nread) == 0); + ASSERT_GT(nread, 0); + ASSERT_MEM_EQ("world\n", buf->base, nread); on_pipe_read_called++; free(buf->base); /* Write to the socket */ outbuf = uv_buf_init("hello again\n", 12); r = uv_write(&conn.tcp_write_req, tcp, &outbuf, 1, tcp_connection_write_cb); - ASSERT(r == 0); + ASSERT_EQ(r, 0); tcp_conn_read_cb_called++; } @@ -652,9 +657,9 @@ static void on_tcp_child_process_read(uv_stream_t* tcp, static void connect_child_process_cb(uv_connect_t* req, int status) { int r; - ASSERT(status == 0); + ASSERT_EQ(status, 0); r = uv_read_start(req->handle, on_read_alloc, on_tcp_child_process_read); - ASSERT(r == 0); + ASSERT_EQ(r, 0); } @@ -667,21 +672,21 @@ static void ipc_on_connection(uv_stream_t* server, int status) { * Accept the connection and close it. Also let the other * side know. */ - ASSERT(status == 0); - ASSERT((uv_stream_t*)&tcp_server == server); + ASSERT_EQ(status, 0); + ASSERT_PTR_EQ(&tcp_server, server); r = uv_tcp_init(server->loop, &conn.conn); - ASSERT(r == 0); + ASSERT_EQ(r, 0); r = uv_accept(server, (uv_stream_t*)&conn.conn); - ASSERT(r == 0); + ASSERT_EQ(r, 0); uv_close((uv_handle_t*)&conn.conn, close_cb); buf = uv_buf_init("accepted_connection\n", 20); r = uv_write2(&conn_notify_req, (uv_stream_t*)&channel, &buf, 1, NULL, conn_notify_write_cb); - ASSERT(r == 0); + ASSERT_EQ(r, 0); connection_accepted = 1; } @@ -693,28 +698,28 @@ static void ipc_on_connection_tcp_conn(uv_stream_t* server, int status) { uv_buf_t buf; uv_tcp_t* conn; - ASSERT(status == 0); - ASSERT((uv_stream_t*)&tcp_server == server); + ASSERT_EQ(status, 0); + ASSERT_PTR_EQ(&tcp_server, server); conn = malloc(sizeof(*conn)); - ASSERT(conn); + ASSERT_NOT_NULL(conn); r = uv_tcp_init(server->loop, conn); - ASSERT(r == 0); + ASSERT_EQ(r, 0); r = uv_accept(server, (uv_stream_t*)conn); - ASSERT(r == 0); + ASSERT_EQ(r, 0); /* Send the accepted connection to the other process */ buf = uv_buf_init("hello\n", 6); r = uv_write2(&conn_notify_req, (uv_stream_t*)&channel, &buf, 1, (uv_stream_t*)conn, NULL); - ASSERT(r == 0); + ASSERT_EQ(r, 0); r = uv_read_start((uv_stream_t*) conn, on_read_alloc, on_tcp_child_process_read); - ASSERT(r == 0); + ASSERT_EQ(r, 0); uv_close((uv_handle_t*)conn, close_cb); } @@ -729,44 +734,44 @@ int ipc_helper(int listen_after_write) { int r; uv_buf_t buf; - ASSERT(0 == uv_ip4_addr("0.0.0.0", TEST_PORT, &addr)); + ASSERT_EQ(0, uv_ip4_addr("0.0.0.0", TEST_PORT, &addr)); r = uv_pipe_init(uv_default_loop(), &channel, 1); - ASSERT(r == 0); + ASSERT_EQ(r, 0); uv_pipe_open(&channel, 0); - ASSERT(1 == uv_is_readable((uv_stream_t*) &channel)); - ASSERT(1 == uv_is_writable((uv_stream_t*) &channel)); - ASSERT(0 == uv_is_closing((uv_handle_t*) &channel)); + ASSERT_EQ(1, uv_is_readable((uv_stream_t*) &channel)); + ASSERT_EQ(1, uv_is_writable((uv_stream_t*) &channel)); + ASSERT_EQ(0, uv_is_closing((uv_handle_t*) &channel)); r = uv_tcp_init(uv_default_loop(), &tcp_server); - ASSERT(r == 0); + ASSERT_EQ(r, 0); r = uv_tcp_bind(&tcp_server, (const struct sockaddr*) &addr, 0); - ASSERT(r == 0); + ASSERT_EQ(r, 0); if (!listen_after_write) { r = uv_listen((uv_stream_t*)&tcp_server, BACKLOG, ipc_on_connection); - ASSERT(r == 0); + ASSERT_EQ(r, 0); } buf = uv_buf_init("hello\n", 6); r = uv_write2(&write_req, (uv_stream_t*)&channel, &buf, 1, (uv_stream_t*)&tcp_server, NULL); - ASSERT(r == 0); + ASSERT_EQ(r, 0); if (listen_after_write) { r = uv_listen((uv_stream_t*)&tcp_server, BACKLOG, ipc_on_connection); - ASSERT(r == 0); + ASSERT_EQ(r, 0); } notify_parent_process(); r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(r == 0); + ASSERT_EQ(r, 0); - ASSERT(connection_accepted == 1); - ASSERT(close_cb_called == 3); + ASSERT_EQ(connection_accepted, 1); + ASSERT_EQ(close_cb_called, 3); MAKE_VALGRIND_HAPPY(); return 0; @@ -783,43 +788,43 @@ int ipc_helper_tcp_connection(void) { struct sockaddr_in addr; r = uv_pipe_init(uv_default_loop(), &channel, 1); - ASSERT(r == 0); + ASSERT_EQ(r, 0); uv_pipe_open(&channel, 0); - ASSERT(1 == uv_is_readable((uv_stream_t*) &channel)); - ASSERT(1 == uv_is_writable((uv_stream_t*) &channel)); - ASSERT(0 == uv_is_closing((uv_handle_t*) &channel)); + ASSERT_EQ(1, uv_is_readable((uv_stream_t*) &channel)); + ASSERT_EQ(1, uv_is_writable((uv_stream_t*) &channel)); + ASSERT_EQ(0, uv_is_closing((uv_handle_t*) &channel)); r = uv_tcp_init(uv_default_loop(), &tcp_server); - ASSERT(r == 0); + ASSERT_EQ(r, 0); - ASSERT(0 == uv_ip4_addr("0.0.0.0", TEST_PORT, &addr)); + ASSERT_EQ(0, uv_ip4_addr("0.0.0.0", TEST_PORT, &addr)); r = uv_tcp_bind(&tcp_server, (const struct sockaddr*) &addr, 0); - ASSERT(r == 0); + ASSERT_EQ(r, 0); r = uv_listen((uv_stream_t*)&tcp_server, BACKLOG, ipc_on_connection_tcp_conn); - ASSERT(r == 0); + ASSERT_EQ(r, 0); /* Make a connection to the server */ r = uv_tcp_init(uv_default_loop(), &conn.conn); - ASSERT(r == 0); + ASSERT_EQ(r, 0); - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); + ASSERT_EQ(0, uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); r = uv_tcp_connect(&conn.conn_req, (uv_tcp_t*) &conn.conn, (const struct sockaddr*) &addr, connect_child_process_cb); - ASSERT(r == 0); + ASSERT_EQ(r, 0); r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(r == 0); + ASSERT_EQ(r, 0); - ASSERT(tcp_conn_read_cb_called == 1); - ASSERT(tcp_conn_write_cb_called == 1); - ASSERT(close_cb_called == 4); + ASSERT_EQ(tcp_conn_read_cb_called, 1); + ASSERT_EQ(tcp_conn_write_cb_called, 1); + ASSERT_EQ(close_cb_called, 4); MAKE_VALGRIND_HAPPY(); return 0; @@ -836,7 +841,7 @@ static unsigned int write_until_data_queued() { &large_buf, 1, closed_handle_large_write_cb); - ASSERT(r == 0); + ASSERT_EQ(r, 0); i++; } while (channel.write_queue_size == 0 && i < ARRAY_SIZE(write_reqs)); @@ -849,12 +854,12 @@ static void send_handle_and_close() { struct sockaddr_in addr; r = uv_tcp_init(uv_default_loop(), &tcp_server); - ASSERT(r == 0); + ASSERT_EQ(r, 0); - ASSERT(0 == uv_ip4_addr("0.0.0.0", TEST_PORT, &addr)); + ASSERT_EQ(0, uv_ip4_addr("0.0.0.0", TEST_PORT, &addr)); r = uv_tcp_bind(&tcp_server, (const struct sockaddr*) &addr, 0); - ASSERT(r == 0); + ASSERT_EQ(r, 0); r = uv_write2(&write_req, (uv_stream_t*)&channel, @@ -862,7 +867,7 @@ static void send_handle_and_close() { 1, (uv_stream_t*)&tcp_server, closed_handle_write_cb); - ASSERT(r == 0); + ASSERT_EQ(r, 0); uv_close((uv_handle_t*)&tcp_server, NULL); } @@ -874,21 +879,21 @@ int ipc_helper_closed_handle(void) { large_buf = uv_buf_init(buffer, LARGE_SIZE); r = uv_pipe_init(uv_default_loop(), &channel, 1); - ASSERT(r == 0); + ASSERT_EQ(r, 0); uv_pipe_open(&channel, 0); - ASSERT(1 == uv_is_readable((uv_stream_t*) &channel)); - ASSERT(1 == uv_is_writable((uv_stream_t*) &channel)); - ASSERT(0 == uv_is_closing((uv_handle_t*) &channel)); + ASSERT_EQ(1, uv_is_readable((uv_stream_t*) &channel)); + ASSERT_EQ(1, uv_is_writable((uv_stream_t*) &channel)); + ASSERT_EQ(0, uv_is_closing((uv_handle_t*) &channel)); if (write_until_data_queued() > 0) send_handle_and_close(); r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(r == 0); + ASSERT_EQ(r, 0); - ASSERT(closed_handle_write == 1); + ASSERT_EQ(closed_handle_write, 1); MAKE_VALGRIND_HAPPY(); return 0; @@ -904,38 +909,38 @@ int ipc_helper_bind_twice(void) { int r; uv_buf_t buf; - ASSERT(0 == uv_ip4_addr("0.0.0.0", TEST_PORT, &addr)); + ASSERT_EQ(0, uv_ip4_addr("0.0.0.0", TEST_PORT, &addr)); r = uv_pipe_init(uv_default_loop(), &channel, 1); - ASSERT(r == 0); + ASSERT_EQ(r, 0); uv_pipe_open(&channel, 0); - ASSERT(1 == uv_is_readable((uv_stream_t*) &channel)); - ASSERT(1 == uv_is_writable((uv_stream_t*) &channel)); - ASSERT(0 == uv_is_closing((uv_handle_t*) &channel)); + ASSERT_EQ(1, uv_is_readable((uv_stream_t*) &channel)); + ASSERT_EQ(1, uv_is_writable((uv_stream_t*) &channel)); + ASSERT_EQ(0, uv_is_closing((uv_handle_t*) &channel)); buf = uv_buf_init("hello\n", 6); r = uv_tcp_init(uv_default_loop(), &tcp_server); - ASSERT(r == 0); + ASSERT_EQ(r, 0); r = uv_tcp_init(uv_default_loop(), &tcp_server2); - ASSERT(r == 0); + ASSERT_EQ(r, 0); r = uv_tcp_bind(&tcp_server, (const struct sockaddr*) &addr, 0); - ASSERT(r == 0); + ASSERT_EQ(r, 0); r = uv_tcp_bind(&tcp_server2, (const struct sockaddr*) &addr, 0); - ASSERT(r == 0); + ASSERT_EQ(r, 0); r = uv_write2(&write_req, (uv_stream_t*)&channel, &buf, 1, (uv_stream_t*)&tcp_server, NULL); - ASSERT(r == 0); + ASSERT_EQ(r, 0); r = uv_write2(&write_req2, (uv_stream_t*)&channel, &buf, 1, (uv_stream_t*)&tcp_server2, NULL); - ASSERT(r == 0); + ASSERT_EQ(r, 0); r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(r == 0); + ASSERT_EQ(r, 0); MAKE_VALGRIND_HAPPY(); return 0; @@ -948,13 +953,13 @@ int ipc_helper_send_zero(void) { zero_buf = uv_buf_init(0, 0); r = uv_pipe_init(uv_default_loop(), &channel, 0); - ASSERT(r == 0); + ASSERT_EQ(r, 0); uv_pipe_open(&channel, 0); - ASSERT(1 == uv_is_readable((uv_stream_t*) &channel)); - ASSERT(1 == uv_is_writable((uv_stream_t*) &channel)); - ASSERT(0 == uv_is_closing((uv_handle_t*) &channel)); + ASSERT_EQ(1, uv_is_readable((uv_stream_t*) &channel)); + ASSERT_EQ(1, uv_is_writable((uv_stream_t*) &channel)); + ASSERT_EQ(0, uv_is_closing((uv_handle_t*) &channel)); r = uv_write(&write_req, (uv_stream_t*)&channel, @@ -962,12 +967,12 @@ int ipc_helper_send_zero(void) { 1, send_zero_write_cb); - ASSERT(r == 0); + ASSERT_EQ(r, 0); r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(r == 0); + ASSERT_EQ(r, 0); - ASSERT(send_zero_write == 1); + ASSERT_EQ(send_zero_write, 1); MAKE_VALGRIND_HAPPY(); return 0; diff --git a/deps/uv/test/test-list.h b/deps/uv/test/test-list.h index 003b8d26517570..eb6665716f0718 100644 --- a/deps/uv/test/test-list.h +++ b/deps/uv/test/test-list.h @@ -353,6 +353,7 @@ TEST_DECLARE (fs_fd_hash) #endif TEST_DECLARE (fs_utime) TEST_DECLARE (fs_futime) +TEST_DECLARE (fs_lutime) TEST_DECLARE (fs_file_open_append) TEST_DECLARE (fs_statfs) TEST_DECLARE (fs_stat_missing_path) @@ -969,6 +970,7 @@ TASK_LIST_START TEST_ENTRY (fs_chown) TEST_ENTRY (fs_utime) TEST_ENTRY (fs_futime) + TEST_ENTRY (fs_lutime) TEST_ENTRY (fs_readlink) TEST_ENTRY (fs_realpath) TEST_ENTRY (fs_symlink) diff --git a/deps/uv/test/test-process-title-threadsafe.c b/deps/uv/test/test-process-title-threadsafe.c index 2f12b74e14f96f..3b4168be84c6b4 100644 --- a/deps/uv/test/test-process-title-threadsafe.c +++ b/deps/uv/test/test-process-title-threadsafe.c @@ -40,14 +40,23 @@ static const char* titles[] = { static void getter_thread_body(void* arg) { char buffer[512]; + size_t len; for (;;) { ASSERT(0 == uv_get_process_title(buffer, sizeof(buffer))); + + /* The maximum size of the process title on some platforms depends on + * the total size of the argv vector. It's therefore possible to read + * back a title that's shorter than what we submitted. + */ + len = strlen(buffer); + ASSERT_GT(len, 0); + ASSERT( - 0 == strcmp(buffer, titles[0]) || - 0 == strcmp(buffer, titles[1]) || - 0 == strcmp(buffer, titles[2]) || - 0 == strcmp(buffer, titles[3])); + 0 == strncmp(buffer, titles[0], len) || + 0 == strncmp(buffer, titles[1], len) || + 0 == strncmp(buffer, titles[2], len) || + 0 == strncmp(buffer, titles[3], len)); uv_sleep(0); } diff --git a/deps/uv/test/test-spawn.c b/deps/uv/test/test-spawn.c index 2b7f5d56d24fd2..314a3562b02034 100644 --- a/deps/uv/test/test-spawn.c +++ b/deps/uv/test/test-spawn.c @@ -236,13 +236,14 @@ TEST_IMPL(spawn_empty_env) { char* env[1]; /* The autotools dynamic library build requires the presence of - * DYLD_LIBARY_PATH (macOS) or LD_LIBRARY_PATH (other Unices) + * DYLD_LIBARY_PATH (macOS) or LD_LIBRARY_PATH/LIBPATH (other Unices) * in the environment, but of course that doesn't work with * the empty environment that we're testing here. */ if (NULL != getenv("DYLD_LIBRARY_PATH") || - NULL != getenv("LD_LIBRARY_PATH")) { - RETURN_SKIP("doesn't work with DYLD_LIBRARY_PATH/LD_LIBRARY_PATH"); + NULL != getenv("LD_LIBRARY_PATH") || + NULL != getenv("LIBPATH")) { + RETURN_SKIP("doesn't work with DYLD_LIBRARY_PATH/LD_LIBRARY_PATH/LIBPATH"); } init_process_options("spawn_helper1", exit_cb); diff --git a/deps/uv/test/test-tmpdir.c b/deps/uv/test/test-tmpdir.c index dac488d05804e0..86f72e25431a15 100644 --- a/deps/uv/test/test-tmpdir.c +++ b/deps/uv/test/test-tmpdir.c @@ -23,7 +23,7 @@ #include "task.h" #include -#define PATHMAX 1024 +#define PATHMAX 4096 #define SMALLPATH 1 TEST_IMPL(tmpdir) { diff --git a/deps/uv/test/test-tty.c b/deps/uv/test/test-tty.c index 688711e5082116..0c6548f95f38c8 100644 --- a/deps/uv/test/test-tty.c +++ b/deps/uv/test/test-tty.c @@ -360,6 +360,8 @@ TEST_IMPL(tty_file) { if (fd != -1) { ASSERT(UV_EINVAL == uv_tty_init(&loop, &tty, fd, 1)); ASSERT(0 == close(fd)); + /* test EBADF handling */ + ASSERT(UV_EINVAL == uv_tty_init(&loop, &tty, fd, 1)); } /* Bug on AIX where '/dev/random' returns 1 from isatty() */ diff --git a/deps/uv/test/test.gyp b/deps/uv/test/test.gyp deleted file mode 100644 index 48fc5eaf8e3f8d..00000000000000 --- a/deps/uv/test/test.gyp +++ /dev/null @@ -1,295 +0,0 @@ -{ - 'targets': [ - { - 'target_name': 'run-tests', - 'type': 'executable', - 'dependencies': [ '../uv.gyp:libuv' ], - 'sources': [ - 'blackhole-server.c', - 'echo-server.c', - 'run-tests.c', - 'runner.c', - 'runner.h', - 'test-get-loadavg.c', - 'task.h', - 'test-active.c', - 'test-async.c', - 'test-async-null-cb.c', - 'test-callback-stack.c', - 'test-callback-order.c', - 'test-close-fd.c', - 'test-close-order.c', - 'test-connect-unspecified.c', - 'test-connection-fail.c', - 'test-cwd-and-chdir.c', - 'test-default-loop-close.c', - 'test-delayed-accept.c', - 'test-eintr-handling.c', - 'test-error.c', - 'test-embed.c', - 'test-emfile.c', - 'test-env-vars.c', - 'test-fail-always.c', - 'test-fork.c', - 'test-fs.c', - 'test-fs-readdir.c', - 'test-fs-copyfile.c', - 'test-fs-event.c', - 'test-fs-fd-hash.c', - 'test-fs-open-flags.c', - 'test-fs-poll.c', - 'test-getters-setters.c', - 'test-get-currentexe.c', - 'test-get-memory.c', - 'test-get-passwd.c', - 'test-getaddrinfo.c', - 'test-gethostname.c', - 'test-getnameinfo.c', - 'test-getsockname.c', - 'test-gettimeofday.c', - 'test-handle-fileno.c', - 'test-homedir.c', - 'test-hrtime.c', - 'test-idle.c', - 'test-idna.c', - 'test-ip4-addr.c', - 'test-ip6-addr.c', - 'test-ipc-heavy-traffic-deadlock-bug.c', - 'test-ipc-send-recv.c', - 'test-ipc.c', - 'test-list.h', - 'test-loop-handles.c', - 'test-loop-alive.c', - 'test-loop-close.c', - 'test-loop-stop.c', - 'test-loop-time.c', - 'test-loop-configure.c', - 'test-walk-handles.c', - 'test-watcher-cross-stop.c', - 'test-multiple-listen.c', - 'test-osx-select.c', - 'test-pass-always.c', - 'test-ping-pong.c', - 'test-pipe-bind-error.c', - 'test-pipe-connect-error.c', - 'test-pipe-connect-multiple.c', - 'test-pipe-connect-prepare.c', - 'test-pipe-getsockname.c', - 'test-pipe-pending-instances.c', - 'test-pipe-sendmsg.c', - 'test-pipe-server-close.c', - 'test-pipe-close-stdout-read-stdin.c', - 'test-pipe-set-non-blocking.c', - 'test-pipe-set-fchmod.c', - 'test-platform-output.c', - 'test-poll.c', - 'test-poll-close.c', - 'test-poll-close-doesnt-corrupt-stack.c', - 'test-poll-closesocket.c', - 'test-poll-oob.c', - 'test-process-priority.c', - 'test-process-title.c', - 'test-process-title-threadsafe.c', - 'test-queue-foreach-delete.c', - 'test-random.c', - 'test-ref.c', - 'test-run-nowait.c', - 'test-run-once.c', - 'test-semaphore.c', - 'test-shutdown-close.c', - 'test-shutdown-eof.c', - 'test-shutdown-twice.c', - 'test-signal.c', - 'test-signal-multiple-loops.c', - 'test-signal-pending-on-close.c', - 'test-socket-buffer-size.c', - 'test-spawn.c', - 'test-strscpy.c', - 'test-stdio-over-pipes.c', - 'test-tcp-alloc-cb-fail.c', - 'test-tcp-bind-error.c', - 'test-tcp-bind6-error.c', - 'test-tcp-close.c', - 'test-tcp-close-accept.c', - 'test-tcp-close-reset.c', - 'test-tcp-close-while-connecting.c', - 'test-tcp-create-socket-early.c', - 'test-tcp-connect-error-after-write.c', - 'test-tcp-shutdown-after-write.c', - 'test-tcp-flags.c', - 'test-tcp-connect-error.c', - 'test-tcp-connect-timeout.c', - 'test-tcp-connect6-error.c', - 'test-tcp-open.c', - 'test-tcp-write-to-half-open-connection.c', - 'test-tcp-write-after-connect.c', - 'test-tcp-writealot.c', - 'test-tcp-write-fail.c', - 'test-tcp-try-write.c', - 'test-tcp-try-write-error.c', - 'test-tcp-unexpected-read.c', - 'test-tcp-oob.c', - 'test-tcp-read-stop.c', - 'test-tcp-write-queue-order.c', - 'test-threadpool.c', - 'test-threadpool-cancel.c', - 'test-thread-equal.c', - 'test-tmpdir.c', - 'test-mutexes.c', - 'test-thread.c', - 'test-barrier.c', - 'test-condvar.c', - 'test-timer-again.c', - 'test-timer-from-check.c', - 'test-timer.c', - 'test-tty-duplicate-key.c', - 'test-tty-escape-sequence-processing.c', - 'test-tty.c', - 'test-udp-alloc-cb-fail.c', - 'test-udp-bind.c', - 'test-udp-connect.c', - 'test-udp-create-socket-early.c', - 'test-udp-dgram-too-big.c', - 'test-udp-ipv6.c', - 'test-udp-open.c', - 'test-udp-options.c', - 'test-udp-send-and-recv.c', - 'test-udp-send-hang-loop.c', - 'test-udp-send-immediate.c', - 'test-udp-send-unreachable.c', - 'test-udp-multicast-join.c', - 'test-udp-multicast-join6.c', - 'test-dlerror.c', - 'test-udp-multicast-ttl.c', - 'test-udp-multicast-interface.c', - 'test-udp-multicast-interface6.c', - 'test-udp-try-send.c', - 'test-uname.c', - ], - 'conditions': [ - [ 'OS=="win"', { - 'sources': [ - 'runner-win.c', - 'runner-win.h', - '../src/win/snprintf.c', - ], - 'libraries': [ '-lws2_32' ] - }, { # POSIX - 'sources': [ - 'runner-unix.c', - 'runner-unix.h', - ], - 'conditions': [ - [ 'OS != "zos"', { - 'defines': [ '_GNU_SOURCE' ], - 'cflags': [ '-Wno-long-long' ], - 'xcode_settings': { - 'WARNING_CFLAGS': [ '-Wno-long-long' ] - } - }], - ]}, - ], - [ 'OS in "mac dragonflybsd freebsd linux netbsd openbsd".split()', { - 'link_settings': { - 'libraries': [ '-lutil' ], - }, - }], - [ 'OS=="solaris"', { # make test-fs.c compile, needs _POSIX_C_SOURCE - 'defines': [ - '__EXTENSIONS__', - '_XOPEN_SOURCE=500', - ], - }], - [ 'OS=="aix"', { # make test-fs.c compile, needs _POSIX_C_SOURCE - 'defines': [ - '_ALL_SOURCE', - '_XOPEN_SOURCE=500', - ], - }], - [ 'OS == "zos"', { - 'cflags': [ '-qxplink' ], - 'ldflags': [ '-qxplink' ], - }], - ['uv_library=="shared_library"', { - 'defines': [ 'USING_UV_SHARED=1' ], - 'conditions': [ - [ 'OS == "zos"', { - 'cflags': [ '-Wc,DLL' ], - }], - ], - }], - ], - 'msvs-settings': { - 'VCLinkerTool': { - 'SubSystem': 1, # /subsystem:console - }, - }, - }, - - { - 'target_name': 'run-benchmarks', - 'type': 'executable', - 'dependencies': [ '../uv.gyp:libuv' ], - 'sources': [ - 'benchmark-async.c', - 'benchmark-async-pummel.c', - 'benchmark-fs-stat.c', - 'benchmark-getaddrinfo.c', - 'benchmark-list.h', - 'benchmark-loop-count.c', - 'benchmark-million-async.c', - 'benchmark-million-timers.c', - 'benchmark-multi-accept.c', - 'benchmark-ping-pongs.c', - 'benchmark-ping-udp.c', - 'benchmark-pound.c', - 'benchmark-pump.c', - 'benchmark-sizes.c', - 'benchmark-spawn.c', - 'benchmark-thread.c', - 'benchmark-tcp-write-batch.c', - 'benchmark-udp-pummel.c', - 'dns-server.c', - 'echo-server.c', - 'blackhole-server.c', - 'run-benchmarks.c', - 'runner.c', - 'runner.h', - 'task.h', - ], - 'conditions': [ - [ 'OS=="win"', { - 'sources': [ - 'runner-win.c', - 'runner-win.h', - '../src/win/snprintf.c', - ], - 'libraries': [ '-lws2_32' ] - }, { # POSIX - 'defines': [ '_GNU_SOURCE' ], - 'sources': [ - 'runner-unix.c', - 'runner-unix.h', - ] - }], - [ 'OS == "zos"', { - 'cflags': [ '-qxplink' ], - 'ldflags': [ '-qxplink' ], - }], - ['uv_library=="shared_library"', { - 'defines': [ 'USING_UV_SHARED=1' ], - 'conditions': [ - [ 'OS == "zos"', { - 'cflags': [ '-Wc,DLL' ], - }], - ], - }], - ], - 'msvs-settings': { - 'VCLinkerTool': { - 'SubSystem': 1, # /subsystem:console - }, - }, - }, - ], -} diff --git a/deps/uv/vcbuild.bat b/deps/uv/vcbuild.bat deleted file mode 100644 index c195394f37ea0b..00000000000000 --- a/deps/uv/vcbuild.bat +++ /dev/null @@ -1,184 +0,0 @@ -@echo off - -cd %~dp0 - -if /i "%1"=="help" goto help -if /i "%1"=="--help" goto help -if /i "%1"=="-help" goto help -if /i "%1"=="/help" goto help -if /i "%1"=="?" goto help -if /i "%1"=="-?" goto help -if /i "%1"=="--?" goto help -if /i "%1"=="/?" goto help - -@rem Process arguments. -set config= -set target=Build -set target_arch=ia32 -set target_env= -set noprojgen= -set nobuild= -set run= -set vs_toolset=x86 -set msbuild_platform=WIN32 -set library=static_library - -:next-arg -if "%1"=="" goto args-done -if /i "%1"=="debug" set config=Debug&goto arg-ok -if /i "%1"=="release" set config=Release&goto arg-ok -if /i "%1"=="test" set run=run-tests.exe&goto arg-ok -if /i "%1"=="bench" set run=run-benchmarks.exe&goto arg-ok -if /i "%1"=="clean" set target=Clean&goto arg-ok -if /i "%1"=="vs2017" set target_env=vs2017&goto arg-ok -if /i "%1"=="noprojgen" set noprojgen=1&goto arg-ok -if /i "%1"=="nobuild" set nobuild=1&goto arg-ok -if /i "%1"=="x86" set target_arch=ia32&set msbuild_platform=WIN32&set vs_toolset=x86&goto arg-ok -if /i "%1"=="ia32" set target_arch=ia32&set msbuild_platform=WIN32&set vs_toolset=x86&goto arg-ok -if /i "%1"=="x64" set target_arch=x64&set msbuild_platform=x64&set vs_toolset=x64&goto arg-ok -if /i "%1"=="shared" set library=shared_library&goto arg-ok -if /i "%1"=="static" set library=static_library&goto arg-ok -:arg-ok -shift -goto next-arg -:args-done - -if defined WindowsSDKDir goto select-target -if defined VCINSTALLDIR goto select-target - -@rem Look for Visual Studio 2017 only if explicitly requested. -if "%target_env%" NEQ "vs2017" goto vs-set-2015 -echo Looking for Visual Studio 2017 -@rem Check if VS2017 is already setup, and for the requested arch. -if "_%VisualStudioVersion%_" == "_15.0_" if "_%VSCMD_ARG_TGT_ARCH%_"=="_%vs_toolset%_" goto found_vs2017 -set "VSINSTALLDIR=" -call tools\vswhere_usability_wrapper.cmd -if "_%VCINSTALLDIR%_" == "__" goto vs-set-2015 -@rem Need to clear VSINSTALLDIR for vcvarsall to work as expected. -@rem Keep current working directory after call to vcvarsall -set "VSCMD_START_DIR=%CD%" -set vcvars_call="%VCINSTALLDIR%\Auxiliary\Build\vcvarsall.bat" %vs_toolset% -echo calling: %vcvars_call% -call %vcvars_call% - -:found_vs2017 -echo Found MSVS version %VisualStudioVersion% -if %VSCMD_ARG_TGT_ARCH%==x64 set target_arch=x64&set msbuild_platform=x64&set vs_toolset=x64 -set GYP_MSVS_VERSION=2017 -goto select-target - - -@rem Look for Visual Studio 2015 -:vs-set-2015 -if not defined VS140COMNTOOLS goto vc-set-2013 -if not exist "%VS140COMNTOOLS%\..\..\vc\vcvarsall.bat" goto vc-set-2013 -call "%VS140COMNTOOLS%\..\..\vc\vcvarsall.bat" %vs_toolset% -set GYP_MSVS_VERSION=2015 -echo Using Visual Studio 2015 -goto select-target - -:vc-set-2013 -@rem Look for Visual Studio 2013 -if not defined VS120COMNTOOLS goto vc-set-2012 -if not exist "%VS120COMNTOOLS%\..\..\vc\vcvarsall.bat" goto vc-set-2012 -call "%VS120COMNTOOLS%\..\..\vc\vcvarsall.bat" %vs_toolset% -set GYP_MSVS_VERSION=2013 -echo Using Visual Studio 2013 -goto select-target - -:vc-set-2012 -@rem Look for Visual Studio 2012 -if not defined VS110COMNTOOLS goto vc-set-2010 -if not exist "%VS110COMNTOOLS%\..\..\vc\vcvarsall.bat" goto vc-set-2010 -call "%VS110COMNTOOLS%\..\..\vc\vcvarsall.bat" %vs_toolset% -set GYP_MSVS_VERSION=2012 -echo Using Visual Studio 2012 -goto select-target - -:vc-set-2010 -@rem Look for Visual Studio 2010 -if not defined VS100COMNTOOLS goto vc-set-2008 -if not exist "%VS100COMNTOOLS%\..\..\vc\vcvarsall.bat" goto vc-set-2008 -call "%VS100COMNTOOLS%\..\..\vc\vcvarsall.bat" %vs_toolset% -set GYP_MSVS_VERSION=2010 -echo Using Visual Studio 2010 -goto select-target - -:vc-set-2008 -@rem Look for Visual Studio 2008 -if not defined VS90COMNTOOLS goto vc-set-notfound -if not exist "%VS90COMNTOOLS%\..\..\vc\vcvarsall.bat" goto vc-set-notfound -call "%VS90COMNTOOLS%\..\..\vc\vcvarsall.bat" %vs_toolset% -set GYP_MSVS_VERSION=2008 -echo Using Visual Studio 2008 -goto select-target - -:vc-set-notfound -echo Warning: Visual Studio not found - -:select-target -if not "%config%"=="" goto project-gen -if "%run%"=="run-tests.exe" set config=Debug& goto project-gen -if "%run%"=="run-benchmarks.exe" set config=Release& goto project-gen -set config=Debug - -:project-gen -@rem Skip project generation if requested. -if defined noprojgen goto msbuild - -@rem Generate the VS project. -if exist build\gyp goto have_gyp -echo git clone https://chromium.googlesource.com/external/gyp build/gyp -git clone https://chromium.googlesource.com/external/gyp build/gyp -if errorlevel 1 goto gyp_install_failed -goto have_gyp - -:gyp_install_failed -echo Failed to download gyp. Make sure you have git installed, or -echo manually install gyp into %~dp0build\gyp. -exit /b 1 - -:have_gyp -if not defined PYTHON set PYTHON=python -"%PYTHON%" gyp_uv.py -Dtarget_arch=%target_arch% -Duv_library=%library% -if errorlevel 1 goto create-msvs-files-failed -if not exist uv.sln goto create-msvs-files-failed -echo Project files generated. - -:msbuild -@rem Skip project generation if requested. -if defined nobuild goto run - -@rem Check if VS build env is available -if defined VCINSTALLDIR goto msbuild-found -if defined WindowsSDKDir goto msbuild-found -echo Build skipped. To build, this file needs to run from VS cmd prompt. -goto run - -@rem Build the sln with msbuild. -:msbuild-found -msbuild uv.sln /t:%target% /p:Configuration=%config% /p:Platform="%msbuild_platform%" /clp:NoSummary;NoItemAndPropertyList;Verbosity=minimal /nologo -if errorlevel 1 exit /b 1 -msbuild test\test.sln /t:%target% /p:Configuration=%config% /p:Platform="%msbuild_platform%" /clp:NoSummary;NoItemAndPropertyList;Verbosity=minimal /nologo -if errorlevel 1 exit /b 1 - -:run -@rem Run tests if requested. -if "%run%"=="" goto exit -echo running 'test\%config%\%run%' -test\%config%\%run% -goto exit - -:create-msvs-files-failed -echo Failed to create vc project files. -exit /b 1 - -:help -echo vcbuild.bat [debug/release] [test/bench] [clean] [noprojgen] [nobuild] [vs2017] [x86/x64] [static/shared] -echo Examples: -echo vcbuild.bat : builds debug build -echo vcbuild.bat test : builds debug build and runs tests -echo vcbuild.bat release bench: builds release build and runs benchmarks -goto exit - -:exit