diff --git a/upstream_utils/libuv.py b/upstream_utils/libuv.py index 97f0959c254..6cf89cb957a 100755 --- a/upstream_utils/libuv.py +++ b/upstream_utils/libuv.py @@ -56,7 +56,7 @@ def copy_upstream_src(wpilib_root): def main(): name = "libuv" url = "https://github.com/libuv/libuv" - tag = "v1.49.0" + tag = "v1.48.0" libuv = Lib(name, url, tag, copy_upstream_src) libuv.main() diff --git a/upstream_utils/libuv_patches/0001-Revert-win-process-write-minidumps-when-sending-SIGQ.patch b/upstream_utils/libuv_patches/0001-Revert-win-process-write-minidumps-when-sending-SIGQ.patch index ca17c36d868..8db5c3cd0c6 100644 --- a/upstream_utils/libuv_patches/0001-Revert-win-process-write-minidumps-when-sending-SIGQ.patch +++ b/upstream_utils/libuv_patches/0001-Revert-win-process-write-minidumps-when-sending-SIGQ.patch @@ -1,8 +1,8 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Tyler Veness Date: Fri, 14 Jul 2023 17:33:08 -0700 -Subject: [PATCH 1/9] Revert "win,process: write minidumps when sending SIGQUIT - (#3840)" +Subject: [PATCH 01/10] Revert "win,process: write minidumps when sending + SIGQUIT (#3840)" This reverts commit 748d894e82abcdfff7429cf745003e182c47f163. --- @@ -13,10 +13,10 @@ This reverts commit 748d894e82abcdfff7429cf745003e182c47f163. 4 files changed, 2 insertions(+), 131 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt -index 28c6df2566696785383716bf463c37cf2d07f987..36fef0fdff5090bb3a56d7e231c3bfe390772318 100644 +index 5e8e0166d743bc23f446b180fdbe6843492c754b..4b6ff2477e494dde7a876d8b5bd3e8985c93f0e8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt -@@ -193,10 +193,7 @@ if(WIN32) +@@ -188,10 +188,7 @@ if(WIN32) advapi32 iphlpapi userenv @@ -29,7 +29,7 @@ index 28c6df2566696785383716bf463c37cf2d07f987..36fef0fdff5090bb3a56d7e231c3bfe3 src/win/async.c src/win/core.c diff --git a/configure.ac b/configure.ac -index b7981d6194969b74751b97747cfc7bc1d679536b..0ad8026905453e27fff8f720913fdda2544baef2 100644 +index d4cc003e34388de77fe1cfe2ebf12ab25b00b9b8..b215638506223e1c9edb1847bbcfccb7404be33f 100644 --- a/configure.ac +++ b/configure.ac @@ -74,7 +74,7 @@ AM_CONDITIONAL([OS400], [AS_CASE([$host_os],[os400], [true], [false]) @@ -42,7 +42,7 @@ index b7981d6194969b74751b97747cfc7bc1d679536b..0ad8026905453e27fff8f720913fdda2 AS_CASE([$host_os], [solaris2.10], [ CFLAGS="$CFLAGS -DSUNOS_NO_IFADDRS" diff --git a/include/uv/win.h b/include/uv/win.h -index 12ac53b4f217d212d1b5c32cfe090800f8770a09..d4c271d4d856a5ec847439825cace5bafb0d4acd 100644 +index f4adaa216c6f0c17437ed42ca594acbf1b8c2c56..518b17606c3b0c114845594e6be9c3c4d95f1776 100644 --- a/include/uv/win.h +++ b/include/uv/win.h @@ -91,7 +91,6 @@ typedef struct pollfd { @@ -54,10 +54,10 @@ index 12ac53b4f217d212d1b5c32cfe090800f8770a09..d4c271d4d856a5ec847439825cace5ba #define SIGWINCH 28 diff --git a/src/win/process.c b/src/win/process.c -index 9d48ddc6f84d6f8c425a8f6f8a344f39d3deb5cc..79bec0090cc94bfe20dab722cf2d8135ddd03cb8 100644 +index 4e94dee90e13eede63d8e97ddc9992726f874ea9..4f0af83e83442bb905762361775abe05ab6beb4e 100644 --- a/src/win/process.c +++ b/src/win/process.c -@@ -31,9 +31,6 @@ +@@ -32,9 +32,6 @@ #include "internal.h" #include "handle-inl.h" #include "req-inl.h" @@ -67,7 +67,7 @@ index 9d48ddc6f84d6f8c425a8f6f8a344f39d3deb5cc..79bec0090cc94bfe20dab722cf2d8135 #define SIGKILL 9 -@@ -1160,129 +1157,7 @@ static int uv__kill(HANDLE process_handle, int signum) { +@@ -1179,129 +1176,7 @@ static int uv__kill(HANDLE process_handle, int signum) { return UV_EINVAL; } diff --git a/upstream_utils/libuv_patches/0002-Fix-missing-casts.patch b/upstream_utils/libuv_patches/0002-Fix-missing-casts.patch index c8da12bf728..2c9355b4402 100644 --- a/upstream_utils/libuv_patches/0002-Fix-missing-casts.patch +++ b/upstream_utils/libuv_patches/0002-Fix-missing-casts.patch @@ -1,10 +1,10 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Tue, 26 Apr 2022 15:01:25 -0400 -Subject: [PATCH 2/9] Fix missing casts +Subject: [PATCH 02/10] Fix missing casts --- - src/fs-poll.c | 10 +++---- + src/fs-poll.c | 10 ++++---- src/idna.c | 2 +- src/inet.c | 11 ++++---- src/strscpy.c | 2 +- @@ -15,22 +15,22 @@ Subject: [PATCH 2/9] Fix missing casts src/unix/darwin-proctitle.c | 5 ++-- src/unix/darwin.c | 2 +- src/unix/freebsd.c | 4 +-- - src/unix/fs.c | 22 ++++++++-------- - src/unix/fsevents.c | 34 ++++++++++++------------ + src/unix/fs.c | 20 +++++++-------- + src/unix/fsevents.c | 34 ++++++++++++------------- src/unix/getaddrinfo.c | 8 +++--- src/unix/ibmi.c | 2 +- src/unix/kqueue.c | 6 ++--- - src/unix/linux.c | 48 +++++++++++++++++----------------- + src/unix/linux.c | 46 +++++++++++++++++----------------- src/unix/loop.c | 2 +- src/unix/netbsd.c | 4 +-- src/unix/openbsd.c | 4 +-- - src/unix/pipe.c | 8 +++--- + src/unix/pipe.c | 6 ++--- src/unix/poll.c | 4 +-- src/unix/posix-poll.c | 2 +- src/unix/process.c | 4 +-- src/unix/proctitle.c | 2 +- src/unix/random-sysctl-linux.c | 2 +- - src/unix/stream.c | 33 +++++++++++------------ + src/unix/stream.c | 31 ++++++++++++----------- src/unix/tcp.c | 2 +- src/unix/thread.c | 5 ++-- src/unix/udp.c | 8 +++--- @@ -39,15 +39,15 @@ Subject: [PATCH 2/9] Fix missing casts src/win/dl.c | 2 +- src/win/fs-event.c | 4 +-- src/win/fs-fd-hash-inl.h | 2 +- - src/win/fs.c | 38 +++++++++++++-------------- - src/win/getaddrinfo.c | 10 +++---- + src/win/fs.c | 38 ++++++++++++++-------------- + src/win/getaddrinfo.c | 12 ++++----- src/win/pipe.c | 12 ++++----- - src/win/process.c | 20 +++++++------- + src/win/process.c | 22 ++++++++-------- src/win/tcp.c | 2 +- - src/win/thread.c | 6 ++--- + src/win/thread.c | 4 +-- src/win/tty.c | 6 ++--- - src/win/util.c | 35 +++++++++++++------------ - 43 files changed, 213 insertions(+), 208 deletions(-) + src/win/util.c | 35 +++++++++++++------------- + 43 files changed, 210 insertions(+), 205 deletions(-) diff --git a/src/fs-poll.c b/src/fs-poll.c index 1bac1c568e36cadd0b68451926c6f045f88342d2..5a39daed095502b2db34f23fcaf0ab04f31f96ff 100644 @@ -177,7 +177,7 @@ index c67c0a7dd7279af6c67b7d5d4a623c47bdf3fff2..c0e39b543df229dd8cb8492bb695e61e return UV_ENOMEM; #endif diff --git a/src/threadpool.c b/src/threadpool.c -index 45af50dcd04ea6ab1d0cfd7ed48ced3aac9c562a..ccb5249893df2733fc607fec6e8d3037ebe2e212 100644 +index dbef67f2f10f1df498f228c21eba2a71ceceee29..f572de5aaf1a1b150e58c7b989949441cac279c4 100644 --- a/src/threadpool.c +++ b/src/threadpool.c @@ -207,7 +207,7 @@ static void init_threads(void) { @@ -203,10 +203,10 @@ index 11ca95591fc38244e931fecd9dd4038d3968af7a..c3dd71a1889bfae08cfdf95acda61e6c if (*addresses == NULL) { freeifaddrs(addrs); diff --git a/src/unix/core.c b/src/unix/core.c -index 1935ba87381db2616326188eed075dfee9bf70e9..d8c09f5e41ff96dae4d0df9982f227eaac3c8576 100644 +index 965e7f775250cf9899266bc3aaf62eda69367264..8c08d607884335a2da5cb49f35e3108cb833da32 100644 --- a/src/unix/core.c +++ b/src/unix/core.c -@@ -866,7 +866,7 @@ static unsigned int next_power_of_two(unsigned int val) { +@@ -856,7 +856,7 @@ static unsigned int next_power_of_two(unsigned int val) { } static void maybe_resize(uv_loop_t* loop, unsigned int len) { @@ -215,7 +215,7 @@ index 1935ba87381db2616326188eed075dfee9bf70e9..d8c09f5e41ff96dae4d0df9982f227ea void* fake_watcher_list; void* fake_watcher_count; unsigned int nwatchers; -@@ -885,8 +885,8 @@ static void maybe_resize(uv_loop_t* loop, unsigned int len) { +@@ -875,8 +875,8 @@ static void maybe_resize(uv_loop_t* loop, unsigned int len) { } nwatchers = next_power_of_two(len + 2) - 2; @@ -226,7 +226,7 @@ index 1935ba87381db2616326188eed075dfee9bf70e9..d8c09f5e41ff96dae4d0df9982f227ea if (watchers == NULL) abort(); -@@ -895,7 +895,7 @@ static void maybe_resize(uv_loop_t* loop, unsigned int len) { +@@ -885,7 +885,7 @@ static void maybe_resize(uv_loop_t* loop, unsigned int len) { watchers[nwatchers] = fake_watcher_list; watchers[nwatchers + 1] = fake_watcher_count; @@ -235,7 +235,7 @@ index 1935ba87381db2616326188eed075dfee9bf70e9..d8c09f5e41ff96dae4d0df9982f227ea loop->nwatchers = nwatchers; } -@@ -1227,7 +1227,7 @@ static int uv__getpwuid_r(uv_passwd_t *pwd, uid_t uid) { +@@ -1217,7 +1217,7 @@ static int uv__getpwuid_r(uv_passwd_t *pwd, uid_t uid) { * is frequently 1024 or 4096, so we can just use that directly. The pwent * will not usually be large. */ for (bufsize = 2000;; bufsize *= 2) { @@ -244,7 +244,7 @@ index 1935ba87381db2616326188eed075dfee9bf70e9..d8c09f5e41ff96dae4d0df9982f227ea if (buf == NULL) return UV_ENOMEM; -@@ -1253,7 +1253,7 @@ static int uv__getpwuid_r(uv_passwd_t *pwd, uid_t uid) { +@@ -1243,7 +1243,7 @@ static int uv__getpwuid_r(uv_passwd_t *pwd, uid_t uid) { name_size = strlen(pw.pw_name) + 1; homedir_size = strlen(pw.pw_dir) + 1; shell_size = strlen(pw.pw_shell) + 1; @@ -253,7 +253,7 @@ index 1935ba87381db2616326188eed075dfee9bf70e9..d8c09f5e41ff96dae4d0df9982f227ea if (pwd->username == NULL) { uv__free(buf); -@@ -1303,7 +1303,7 @@ int uv_os_get_group(uv_group_t* grp, uv_uid_t gid) { +@@ -1293,7 +1293,7 @@ int uv_os_get_group(uv_group_t* grp, uv_uid_t gid) { * is frequently 1024 or 4096, so we can just use that directly. The pwent * will not usually be large. */ for (bufsize = 2000;; bufsize *= 2) { @@ -262,7 +262,7 @@ index 1935ba87381db2616326188eed075dfee9bf70e9..d8c09f5e41ff96dae4d0df9982f227ea if (buf == NULL) return UV_ENOMEM; -@@ -1334,7 +1334,7 @@ int uv_os_get_group(uv_group_t* grp, uv_uid_t gid) { +@@ -1324,7 +1324,7 @@ int uv_os_get_group(uv_group_t* grp, uv_uid_t gid) { members++; } @@ -271,7 +271,7 @@ index 1935ba87381db2616326188eed075dfee9bf70e9..d8c09f5e41ff96dae4d0df9982f227ea if (gr_mem == NULL) { uv__free(buf); return UV_ENOMEM; -@@ -1391,7 +1391,7 @@ int uv_os_environ(uv_env_item_t** envitems, int* count) { +@@ -1381,7 +1381,7 @@ int uv_os_environ(uv_env_item_t** envitems, int* count) { for (i = 0; environ[i] != NULL; i++); @@ -297,10 +297,10 @@ index 5288083ef04fd78d90c34071cc76281adbc310d8..9bd55dd764b845cf8ea441d525b4e136 if (display_name_key == NULL || *display_name_key == NULL) goto out; diff --git a/src/unix/darwin.c b/src/unix/darwin.c -index 009efbefaa70ee1e552cf6177893bd412201e276..b1657a2ffdab4e41c7900d6dda92f23bd8d137c2 100644 +index 5e764a65ee4c71efd61876c70b0e999420f24f61..dc93d236b6b7c6da62dc7aa66cb42ddc125575a2 100644 --- a/src/unix/darwin.c +++ b/src/unix/darwin.c -@@ -211,7 +211,7 @@ int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) { +@@ -217,7 +217,7 @@ int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) { return UV_EINVAL; /* FIXME(bnoordhuis) Translate error. */ } @@ -310,10 +310,10 @@ index 009efbefaa70ee1e552cf6177893bd412201e276..b1657a2ffdab4e41c7900d6dda92f23b vm_deallocate(mach_task_self(), (vm_address_t)info, msg_type); return UV_ENOMEM; diff --git a/src/unix/freebsd.c b/src/unix/freebsd.c -index a6de29c558cde45dacc5bba7d75950fe6e57e857..8fb03c7803cd6d8e3c65558bee0be21f7ad07a3c 100644 +index 191bc8bc213ffddb15c5e04baa66e2a0a8d69a3d..1bd63886b823be6451ac013d94e29885795375b7 100644 --- a/src/unix/freebsd.c +++ b/src/unix/freebsd.c -@@ -225,7 +225,7 @@ int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) { +@@ -220,7 +220,7 @@ int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) { if (sysctlbyname("hw.ncpu", &numcpus, &size, NULL, 0)) return UV__ERR(errno); @@ -322,7 +322,7 @@ index a6de29c558cde45dacc5bba7d75950fe6e57e857..8fb03c7803cd6d8e3c65558bee0be21f if (!(*cpu_infos)) return UV_ENOMEM; -@@ -242,7 +242,7 @@ int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) { +@@ -237,7 +237,7 @@ int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) { size = maxcpus * CPUSTATES * sizeof(long); @@ -332,10 +332,10 @@ index a6de29c558cde45dacc5bba7d75950fe6e57e857..8fb03c7803cd6d8e3c65558bee0be21f uv__free(*cpu_infos); return UV_ENOMEM; diff --git a/src/unix/fs.c b/src/unix/fs.c -index 6d810debf5d469ec3d67420062eeb9b6810137dd..77f3a17ad3d102f0aa2860eaf88602fe9555bc4e 100644 +index 3a74350f0e5ab6b268b9fb72eda2a4da909f3f5d..22f31f7285c995c981aca0fa5125bc70aeedc151 100644 --- a/src/unix/fs.c +++ b/src/unix/fs.c -@@ -126,7 +126,7 @@ extern char *mkdtemp(char *template); /* See issue #740 on AIX < 7 */ +@@ -136,7 +136,7 @@ extern char *mkdtemp(char *template); /* See issue #740 on AIX < 7 */ size_t new_path_len; \ path_len = strlen(path) + 1; \ new_path_len = strlen(new_path) + 1; \ @@ -344,16 +344,7 @@ index 6d810debf5d469ec3d67420062eeb9b6810137dd..77f3a17ad3d102f0aa2860eaf88602fe if (req->path == NULL) \ return UV_ENOMEM; \ req->new_path = req->path + path_len; \ -@@ -478,7 +478,7 @@ static ssize_t uv__preadv_or_pwritev(int fd, - dlerror(); /* Clear errors. */ - #endif /* RTLD_DEFAULT */ - if (p == NULL) -- p = is_pread ? uv__preadv_emul : uv__pwritev_emul; -+ p = (void*)(is_pread ? uv__preadv_emul : uv__pwritev_emul); - atomic_store_explicit(cache, (uintptr_t) p, memory_order_relaxed); - } - -@@ -600,7 +600,7 @@ static ssize_t uv__fs_scandir(uv_fs_t* req) { +@@ -498,7 +498,7 @@ static ssize_t uv__fs_scandir(uv_fs_t* req) { static int uv__fs_opendir(uv_fs_t* req) { uv_dir_t* dir; @@ -362,7 +353,7 @@ index 6d810debf5d469ec3d67420062eeb9b6810137dd..77f3a17ad3d102f0aa2860eaf88602fe if (dir == NULL) goto error; -@@ -624,7 +624,7 @@ static int uv__fs_readdir(uv_fs_t* req) { +@@ -522,7 +522,7 @@ static int uv__fs_readdir(uv_fs_t* req) { unsigned int dirent_idx; unsigned int i; @@ -371,7 +362,7 @@ index 6d810debf5d469ec3d67420062eeb9b6810137dd..77f3a17ad3d102f0aa2860eaf88602fe dirent_idx = 0; while (dirent_idx < dir->nentries) { -@@ -666,7 +666,7 @@ error: +@@ -564,7 +564,7 @@ error: static int uv__fs_closedir(uv_fs_t* req) { uv_dir_t* dir; @@ -380,7 +371,7 @@ index 6d810debf5d469ec3d67420062eeb9b6810137dd..77f3a17ad3d102f0aa2860eaf88602fe if (dir->dir != NULL) { closedir(dir->dir); -@@ -695,7 +695,7 @@ static int uv__fs_statfs(uv_fs_t* req) { +@@ -593,7 +593,7 @@ static int uv__fs_statfs(uv_fs_t* req) { #endif /* defined(__sun) */ return -1; @@ -389,7 +380,7 @@ index 6d810debf5d469ec3d67420062eeb9b6810137dd..77f3a17ad3d102f0aa2860eaf88602fe if (stat_fs == NULL) { errno = ENOMEM; return -1; -@@ -759,7 +759,7 @@ static ssize_t uv__fs_readlink(uv_fs_t* req) { +@@ -657,7 +657,7 @@ static ssize_t uv__fs_readlink(uv_fs_t* req) { maxlen = uv__fs_pathmax_size(req->path); #endif @@ -398,7 +389,7 @@ index 6d810debf5d469ec3d67420062eeb9b6810137dd..77f3a17ad3d102f0aa2860eaf88602fe if (buf == NULL) { errno = ENOMEM; -@@ -779,7 +779,7 @@ static ssize_t uv__fs_readlink(uv_fs_t* req) { +@@ -677,7 +677,7 @@ static ssize_t uv__fs_readlink(uv_fs_t* req) { /* Uncommon case: resize to make room for the trailing nul byte. */ if (len == maxlen) { @@ -407,8 +398,8 @@ index 6d810debf5d469ec3d67420062eeb9b6810137dd..77f3a17ad3d102f0aa2860eaf88602fe if (buf == NULL) return -1; -@@ -811,7 +811,7 @@ static ssize_t uv__fs_realpath(uv_fs_t* req) { - (void)tmp; +@@ -700,7 +700,7 @@ static ssize_t uv__fs_realpath(uv_fs_t* req) { + ssize_t len; len = uv__fs_pathmax_size(req->path); - buf = uv__malloc(len + 1); @@ -416,7 +407,7 @@ index 6d810debf5d469ec3d67420062eeb9b6810137dd..77f3a17ad3d102f0aa2860eaf88602fe if (buf == NULL) { errno = ENOMEM; -@@ -2042,7 +2042,7 @@ int uv_fs_read(uv_loop_t* loop, uv_fs_t* req, +@@ -1898,7 +1898,7 @@ int uv_fs_read(uv_loop_t* loop, uv_fs_t* req, req->bufs = req->bufsml; if (nbufs > ARRAY_SIZE(req->bufsml)) @@ -425,7 +416,7 @@ index 6d810debf5d469ec3d67420062eeb9b6810137dd..77f3a17ad3d102f0aa2860eaf88602fe if (req->bufs == NULL) return UV_ENOMEM; -@@ -2227,7 +2227,7 @@ int uv_fs_write(uv_loop_t* loop, +@@ -2083,7 +2083,7 @@ int uv_fs_write(uv_loop_t* loop, req->nbufs = nbufs; req->bufs = req->bufsml; if (nbufs > ARRAY_SIZE(req->bufsml)) @@ -435,7 +426,7 @@ index 6d810debf5d469ec3d67420062eeb9b6810137dd..77f3a17ad3d102f0aa2860eaf88602fe if (req->bufs == NULL) return UV_ENOMEM; diff --git a/src/unix/fsevents.c b/src/unix/fsevents.c -index 7fb6bb2ec36ae0b1584a43a2fc0101db54c42f97..0d1c9ebad6f490f3f890d81a66496ff31417e213 100644 +index df703f3635fc95bab21debc9697dba06a2a44827..c31d08ba37cfd10672ab6a7a8fd38a1c79b952fe 100644 --- a/src/unix/fsevents.c +++ b/src/unix/fsevents.c @@ -183,7 +183,7 @@ static void (*pFSEventStreamStop)(FSEventStreamRef); @@ -461,7 +452,7 @@ index 7fb6bb2ec36ae0b1584a43a2fc0101db54c42f97..0d1c9ebad6f490f3f890d81a66496ff3 /* For each handle */ uv_mutex_lock(&state->fsevent_mutex); -@@ -300,7 +300,7 @@ static void uv__fsevents_event_cb(const FSEventStreamRef streamRef, +@@ -304,7 +304,7 @@ static void uv__fsevents_event_cb(const FSEventStreamRef streamRef, continue; } @@ -470,7 +461,7 @@ index 7fb6bb2ec36ae0b1584a43a2fc0101db54c42f97..0d1c9ebad6f490f3f890d81a66496ff3 if (event == NULL) break; -@@ -434,7 +434,7 @@ static void uv__fsevents_reschedule(uv__cf_loop_state_t* state, +@@ -438,7 +438,7 @@ static void uv__fsevents_reschedule(uv__cf_loop_state_t* state, uv_mutex_lock(&state->fsevent_mutex); path_count = state->fsevent_handle_count; if (path_count != 0) { @@ -479,7 +470,7 @@ index 7fb6bb2ec36ae0b1584a43a2fc0101db54c42f97..0d1c9ebad6f490f3f890d81a66496ff3 if (paths == NULL) { uv_mutex_unlock(&state->fsevent_mutex); goto final; -@@ -590,7 +590,7 @@ static int uv__fsevents_loop_init(uv_loop_t* loop) { +@@ -594,7 +594,7 @@ static int uv__fsevents_loop_init(uv_loop_t* loop) { if (err) return err; @@ -488,7 +479,7 @@ index 7fb6bb2ec36ae0b1584a43a2fc0101db54c42f97..0d1c9ebad6f490f3f890d81a66496ff3 if (state == NULL) return UV_ENOMEM; -@@ -692,7 +692,7 @@ void uv__fsevents_loop_delete(uv_loop_t* loop) { +@@ -696,7 +696,7 @@ void uv__fsevents_loop_delete(uv_loop_t* loop) { } /* Destroy state */ @@ -497,7 +488,7 @@ index 7fb6bb2ec36ae0b1584a43a2fc0101db54c42f97..0d1c9ebad6f490f3f890d81a66496ff3 uv_sem_destroy(&state->fsevent_sem); uv_mutex_destroy(&state->fsevent_mutex); pCFRelease(state->signal_source); -@@ -706,8 +706,8 @@ static void* uv__cf_loop_runner(void* arg) { +@@ -710,8 +710,8 @@ static void* uv__cf_loop_runner(void* arg) { uv_loop_t* loop; uv__cf_loop_state_t* state; @@ -508,7 +499,7 @@ index 7fb6bb2ec36ae0b1584a43a2fc0101db54c42f97..0d1c9ebad6f490f3f890d81a66496ff3 state->loop = pCFRunLoopGetCurrent(); pCFRunLoopAddSource(state->loop, -@@ -735,8 +735,8 @@ static void uv__cf_loop_cb(void* arg) { +@@ -739,8 +739,8 @@ static void uv__cf_loop_cb(void* arg) { struct uv__queue split_head; uv__cf_loop_signal_t* s; @@ -519,7 +510,7 @@ index 7fb6bb2ec36ae0b1584a43a2fc0101db54c42f97..0d1c9ebad6f490f3f890d81a66496ff3 uv_mutex_lock(&loop->cf_mutex); uv__queue_move(&loop->cf_signals, &split_head); -@@ -766,7 +766,7 @@ int uv__cf_loop_signal(uv_loop_t* loop, +@@ -770,7 +770,7 @@ int uv__cf_loop_signal(uv_loop_t* loop, uv__cf_loop_signal_t* item; uv__cf_loop_state_t* state; @@ -528,7 +519,7 @@ index 7fb6bb2ec36ae0b1584a43a2fc0101db54c42f97..0d1c9ebad6f490f3f890d81a66496ff3 if (item == NULL) return UV_ENOMEM; -@@ -776,7 +776,7 @@ int uv__cf_loop_signal(uv_loop_t* loop, +@@ -780,7 +780,7 @@ int uv__cf_loop_signal(uv_loop_t* loop, uv_mutex_lock(&loop->cf_mutex); uv__queue_insert_tail(&loop->cf_signals, &item->member); @@ -537,7 +528,7 @@ index 7fb6bb2ec36ae0b1584a43a2fc0101db54c42f97..0d1c9ebad6f490f3f890d81a66496ff3 assert(state != NULL); pCFRunLoopSourceSignal(state->signal_source); pCFRunLoopWakeUp(state->loop); -@@ -815,7 +815,7 @@ int uv__fsevents_init(uv_fs_event_t* handle) { +@@ -814,7 +814,7 @@ int uv__fsevents_init(uv_fs_event_t* handle) { * Events will occur in other thread. * Initialize callback for getting them back into event loop's thread */ @@ -546,7 +537,7 @@ index 7fb6bb2ec36ae0b1584a43a2fc0101db54c42f97..0d1c9ebad6f490f3f890d81a66496ff3 if (handle->cf_cb == NULL) { err = UV_ENOMEM; goto fail_cf_cb_malloc; -@@ -831,7 +831,7 @@ int uv__fsevents_init(uv_fs_event_t* handle) { +@@ -830,7 +830,7 @@ int uv__fsevents_init(uv_fs_event_t* handle) { goto fail_cf_mutex_init; /* Insert handle into the list */ @@ -555,7 +546,7 @@ index 7fb6bb2ec36ae0b1584a43a2fc0101db54c42f97..0d1c9ebad6f490f3f890d81a66496ff3 uv_mutex_lock(&state->fsevent_mutex); uv__queue_insert_tail(&state->fsevent_handles, &handle->cf_member); state->fsevent_handle_count++; -@@ -871,7 +871,7 @@ int uv__fsevents_close(uv_fs_event_t* handle) { +@@ -870,7 +870,7 @@ int uv__fsevents_close(uv_fs_event_t* handle) { return UV_EINVAL; /* Remove handle from the list */ @@ -565,7 +556,7 @@ index 7fb6bb2ec36ae0b1584a43a2fc0101db54c42f97..0d1c9ebad6f490f3f890d81a66496ff3 uv__queue_remove(&handle->cf_member); state->fsevent_handle_count--; diff --git a/src/unix/getaddrinfo.c b/src/unix/getaddrinfo.c -index b70753436665901c5fc8a4126b9537d01a47ffa0..5a205d0ebd89009472d6062f5173aac1be2f8a87 100644 +index 77337ace9454e032a392c97cb9aa311f15518956..41dc3909969a643e129847ae3a3252d51feadb27 100644 --- a/src/unix/getaddrinfo.c +++ b/src/unix/getaddrinfo.c @@ -172,7 +172,7 @@ int uv_getaddrinfo(uv_loop_t* loop, @@ -612,10 +603,10 @@ index 837bba6e2fef7b834a8d104d263bef47eaed0950..5e0fa98d104428534e5264a1c6358e3f return UV_ENOMEM; } diff --git a/src/unix/kqueue.c b/src/unix/kqueue.c -index 876b717086c6098dda97461ccc50292065d8137d..2dd3b2156f363c73e4ba3ebc7e52367c85f654a8 100644 +index 4d09edc06a0972a32ef66a91100404d95e006e60..c307e6631eefb1effb0e0c304eb400e0cb8d984e 100644 --- a/src/unix/kqueue.c +++ b/src/unix/kqueue.c -@@ -336,8 +336,8 @@ void uv__io_poll(uv_loop_t* loop, int timeout) { +@@ -303,8 +303,8 @@ void uv__io_poll(uv_loop_t* loop, int timeout) { nevents = 0; assert(loop->watchers != NULL); @@ -626,7 +617,7 @@ index 876b717086c6098dda97461ccc50292065d8137d..2dd3b2156f363c73e4ba3ebc7e52367c for (i = 0; i < nfds; i++) { ev = events + i; fd = ev->ident; -@@ -359,7 +359,7 @@ void uv__io_poll(uv_loop_t* loop, int timeout) { +@@ -326,7 +326,7 @@ void uv__io_poll(uv_loop_t* loop, int timeout) { /* Skip invalidated events, see uv__platform_invalidate_fd */ if (fd == -1) continue; @@ -636,7 +627,7 @@ index 876b717086c6098dda97461ccc50292065d8137d..2dd3b2156f363c73e4ba3ebc7e52367c if (w == NULL) { /* File descriptor that we've stopped watching, disarm it. */ diff --git a/src/unix/linux.c b/src/unix/linux.c -index a5f74e8901600412267ce25bc4e739da482423d0..96c8b1dfe060e896f768493448ec20cfb9203592 100644 +index 4164e90dbb0a39457d565a35be2d7890f66a7d71..09b02cd5df6c32a954cbed817111cf3c1874c3db 100644 --- a/src/unix/linux.c +++ b/src/unix/linux.c @@ -514,8 +514,8 @@ static void uv__iou_init(int epollfd, @@ -667,7 +658,7 @@ index a5f74e8901600412267ce25bc4e739da482423d0..96c8b1dfe060e896f768493448ec20cf sqelen, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_POPULATE, -@@ -700,7 +700,7 @@ void uv__platform_invalidate_fd(uv_loop_t* loop, int fd) { +@@ -701,7 +701,7 @@ void uv__platform_invalidate_fd(uv_loop_t* loop, int fd) { int i; lfields = uv__get_internal_fields(loop); @@ -676,7 +667,7 @@ index a5f74e8901600412267ce25bc4e739da482423d0..96c8b1dfe060e896f768493448ec20cf /* Invalidate events with same file descriptor */ if (inv != NULL) -@@ -786,7 +786,7 @@ static struct uv__io_uring_sqe* uv__iou_get_sqe(struct uv__iou* iou, +@@ -776,7 +776,7 @@ static struct uv__io_uring_sqe* uv__iou_get_sqe(struct uv__iou* iou, return NULL; /* No room in ring buffer. TODO(bnoordhuis) maybe flush it? */ slot = tail & mask; @@ -685,7 +676,7 @@ index a5f74e8901600412267ce25bc4e739da482423d0..96c8b1dfe060e896f768493448ec20cf sqe = &sqe[slot]; memset(sqe, 0, sizeof(*sqe)); sqe->user_data = (uintptr_t) req; -@@ -1063,7 +1063,7 @@ int uv__iou_fs_statx(uv_loop_t* loop, +@@ -1053,7 +1053,7 @@ int uv__iou_fs_statx(uv_loop_t* loop, struct uv__statx* statxbuf; struct uv__iou* iou; @@ -694,7 +685,7 @@ index a5f74e8901600412267ce25bc4e739da482423d0..96c8b1dfe060e896f768493448ec20cf if (statxbuf == NULL) return 0; -@@ -1127,7 +1127,7 @@ static void uv__iou_fs_statx_post(uv_fs_t* req) { +@@ -1117,7 +1117,7 @@ static void uv__iou_fs_statx_post(uv_fs_t* req) { uv_stat_t* buf; buf = &req->statbuf; @@ -703,7 +694,7 @@ index a5f74e8901600412267ce25bc4e739da482423d0..96c8b1dfe060e896f768493448ec20cf req->ptr = NULL; if (req->result == 0) { -@@ -1156,7 +1156,7 @@ static void uv__poll_io_uring(uv_loop_t* loop, struct uv__iou* iou) { +@@ -1146,7 +1146,7 @@ static void uv__poll_io_uring(uv_loop_t* loop, struct uv__iou* iou) { tail = atomic_load_explicit((_Atomic uint32_t*) iou->cqtail, memory_order_acquire); mask = iou->cqmask; @@ -712,16 +703,16 @@ index a5f74e8901600412267ce25bc4e739da482423d0..96c8b1dfe060e896f768493448ec20cf nevents = 0; for (i = head; i != tail; i++) { -@@ -1241,7 +1241,7 @@ static void uv__epoll_ctl_prep(int epollfd, - pe = &(*events)[slot]; - *pe = *e; +@@ -1243,7 +1243,7 @@ static void uv__epoll_ctl_prep(int epollfd, + pe = &(*events)[slot]; + *pe = *e; -- sqe = ctl->sqe; -+ sqe = (uv__io_uring_sqe*)ctl->sqe; - sqe = &sqe[slot]; +- sqe = ctl->sqe; ++ sqe = (uv__io_uring_sqe*)ctl->sqe; + sqe = &sqe[slot]; - memset(sqe, 0, sizeof(*sqe)); -@@ -1296,7 +1296,7 @@ static void uv__epoll_ctl_flush(int epollfd, + memset(sqe, 0, sizeof(*sqe)); +@@ -1299,7 +1299,7 @@ static void uv__epoll_ctl_flush(int epollfd, while (*ctl->cqhead != *ctl->cqtail) { slot = (*ctl->cqhead)++ & ctl->cqmask; @@ -802,16 +793,7 @@ index a5f74e8901600412267ce25bc4e739da482423d0..96c8b1dfe060e896f768493448ec20cf if (!(*addresses)) { freeifaddrs(addrs); return UV_ENOMEM; -@@ -2321,7 +2321,7 @@ static int uv__get_cgroupv2_constrained_cpu(const char* cgroup, - static char* uv__cgroup1_find_cpu_controller(const char* cgroup, - int* cgroup_size) { - /* Seek to the cpu controller line. */ -- char* cgroup_cpu = strstr(cgroup, ":cpu,"); -+ char* cgroup_cpu = (char*)strstr(cgroup, ":cpu,"); - - if (cgroup_cpu != NULL) { - /* Skip the controller prefix to the start of the cgroup path. */ -@@ -2647,12 +2647,12 @@ int uv_fs_event_start(uv_fs_event_t* handle, +@@ -2517,12 +2517,12 @@ int uv_fs_event_start(uv_fs_event_t* handle, goto no_insert; len = strlen(path) + 1; @@ -827,7 +809,7 @@ index a5f74e8901600412267ce25bc4e739da482423d0..96c8b1dfe060e896f768493448ec20cf w->iterating = 0; RB_INSERT(watcher_root, uv__inotify_watchers(loop), w); diff --git a/src/unix/loop.c b/src/unix/loop.c -index 179ee999d8052e779dc692aeb5b673d210aaa997..006db94d0080507bf3d52bf206bffbbc812cc375 100644 +index a9468e8e19cbede795032980c47eb83aee1e0c68..3babe4d701949ebc69d74f7dedee33c777d89892 100644 --- a/src/unix/loop.c +++ b/src/unix/loop.c @@ -148,7 +148,7 @@ int uv_loop_fork(uv_loop_t* loop) { @@ -883,10 +865,10 @@ index 9c863b6c90dad9864cb8341c2b6203c1390a9487..2aa61e2ee3321d91ba84887c7ed6dcfa return UV_ENOMEM; diff --git a/src/unix/pipe.c b/src/unix/pipe.c -index 1f9acfac41e9c561cbd823c27863d9a3dc52f7b8..7627ee39c1be869d4d2bbf93dbae0bbd52a4464f 100644 +index fca364426f809e2085a3e6c4d984cfb88de548d3..ea26ce45c9b4c298528ab45cd4e8a21917f4be0e 100644 --- a/src/unix/pipe.c +++ b/src/unix/pipe.c -@@ -109,7 +109,7 @@ int uv_pipe_bind2(uv_pipe_t* handle, +@@ -104,7 +104,7 @@ int uv_pipe_bind2(uv_pipe_t* handle, if (*name == '\0') { addrlen = offsetof(struct sockaddr_un, sun_path) + namelen; } else { @@ -895,16 +877,7 @@ index 1f9acfac41e9c561cbd823c27863d9a3dc52f7b8..7627ee39c1be869d4d2bbf93dbae0bbd if (pipe_fname == NULL) return UV_ENOMEM; memcpy(pipe_fname, name, namelen); -@@ -377,7 +377,7 @@ static int uv__pipe_getsockpeername(const uv_pipe_t* handle, - slop = 0; - addrlen -= offsetof(struct sockaddr_un, sun_path); - } else { -- p = memchr(sa.sun_path, '\0', sizeof(sa.sun_path)); -+ p = (char*)memchr(sa.sun_path, '\0', sizeof(sa.sun_path)); - if (p == NULL) - p = ARRAY_END(sa.sun_path); - addrlen = p - sa.sun_path; -@@ -425,7 +425,7 @@ int uv_pipe_pending_count(uv_pipe_t* handle) { +@@ -410,7 +410,7 @@ int uv_pipe_pending_count(uv_pipe_t* handle) { if (handle->queued_fds == NULL) return 1; @@ -913,7 +886,7 @@ index 1f9acfac41e9c561cbd823c27863d9a3dc52f7b8..7627ee39c1be869d4d2bbf93dbae0bbd return queued_fds->offset + 1; } -@@ -462,7 +462,7 @@ int uv_pipe_chmod(uv_pipe_t* handle, int mode) { +@@ -447,7 +447,7 @@ int uv_pipe_chmod(uv_pipe_t* handle, int mode) { if (r != UV_ENOBUFS) return r; @@ -958,10 +931,10 @@ index 2e016c2fbaed2eeccd78080969a86aff821a4251..b71eee3f01a3f30b3b5efef539194139 abort(); diff --git a/src/unix/process.c b/src/unix/process.c -index f2038f2c0e823e1d5ebf3331b1d93c12fe23e83e..e1349689065b4593a929509a3daafa5a48916768 100644 +index 4812a90f2f5047fc18ddb9b6f70e3f380641ddde..8271d513b15588a3a73401cc2df3be160940ab10 100644 --- a/src/unix/process.c +++ b/src/unix/process.c -@@ -420,7 +420,7 @@ static int posix_spawn_can_use_setsid; +@@ -423,7 +423,7 @@ static int posix_spawn_can_use_setsid; static void uv__spawn_init_posix_spawn_fncs(void) { /* Try to locate all non-portable functions at runtime */ posix_spawn_fncs.file_actions.addchdir_np = @@ -970,7 +943,7 @@ index f2038f2c0e823e1d5ebf3331b1d93c12fe23e83e..e1349689065b4593a929509a3daafa5a } -@@ -986,7 +986,7 @@ int uv_spawn(uv_loop_t* loop, +@@ -989,7 +989,7 @@ int uv_spawn(uv_loop_t* loop, err = UV_ENOMEM; pipes = pipes_storage; if (stdio_count > (int) ARRAY_SIZE(pipes_storage)) @@ -1006,7 +979,7 @@ index 66ba8d74ec22b72d318b91d82365f5b9693feb3c..9ef18df01a51aa6a26ae6d1d9660a819 while (p < pe) { diff --git a/src/unix/stream.c b/src/unix/stream.c -index 18763b4744c30a93f067a911b8059984bf36eb86..2d2b5d2f45e673d495ac814fbc1c6a877950ab9b 100644 +index 28c4d5463c4622725a433b8807e5e7bde580dadd..265ddade7aec129eb9dbf07cde2a16a0e341d1a7 100644 --- a/src/unix/stream.c +++ b/src/unix/stream.c @@ -123,7 +123,7 @@ static void uv__stream_osx_interrupt_select(uv_stream_t* stream) { @@ -1047,7 +1020,7 @@ index 18763b4744c30a93f067a911b8059984bf36eb86..2d2b5d2f45e673d495ac814fbc1c6a87 /* Read first */ server->accepted_fd = queued_fds->fds[0]; -@@ -943,11 +943,12 @@ static int uv__stream_queue_fd(uv_stream_t* stream, int fd) { +@@ -942,11 +942,12 @@ static int uv__stream_queue_fd(uv_stream_t* stream, int fd) { uv__stream_queued_fds_t* queued_fds; unsigned int queue_size; @@ -1063,7 +1036,7 @@ index 18763b4744c30a93f067a911b8059984bf36eb86..2d2b5d2f45e673d495ac814fbc1c6a87 if (queued_fds == NULL) return UV_ENOMEM; queued_fds->size = queue_size; -@@ -957,9 +958,9 @@ static int uv__stream_queue_fd(uv_stream_t* stream, int fd) { +@@ -956,9 +957,9 @@ static int uv__stream_queue_fd(uv_stream_t* stream, int fd) { /* Grow */ } else if (queued_fds->size == queued_fds->offset) { queue_size = queued_fds->size + 8; @@ -1076,16 +1049,7 @@ index 18763b4744c30a93f067a911b8059984bf36eb86..2d2b5d2f45e673d495ac814fbc1c6a87 /* * Allocation failure, report back. -@@ -999,7 +1000,7 @@ static int uv__stream_recv_cmsg(uv_stream_t* stream, struct msghdr* msg) { - assert(count % sizeof(fd) == 0); - count /= sizeof(fd); - -- p = (void*) CMSG_DATA(cmsg); -+ p = (char*) CMSG_DATA(cmsg); - pe = p + count * sizeof(fd); - - while (p < pe) { -@@ -1361,7 +1362,7 @@ int uv_write2(uv_write_t* req, +@@ -1356,7 +1357,7 @@ int uv_write2(uv_write_t* req, req->bufs = req->bufsml; if (nbufs > ARRAY_SIZE(req->bufsml)) @@ -1094,7 +1058,7 @@ index 18763b4744c30a93f067a911b8059984bf36eb86..2d2b5d2f45e673d495ac814fbc1c6a87 if (req->bufs == NULL) return UV_ENOMEM; -@@ -1495,7 +1496,7 @@ int uv___stream_fd(const uv_stream_t* handle) { +@@ -1490,7 +1491,7 @@ int uv___stream_fd(const uv_stream_t* handle) { handle->type == UV_TTY || handle->type == UV_NAMED_PIPE); @@ -1103,7 +1067,7 @@ index 18763b4744c30a93f067a911b8059984bf36eb86..2d2b5d2f45e673d495ac814fbc1c6a87 if (s != NULL) return s->fd; -@@ -1513,7 +1514,7 @@ void uv__stream_close(uv_stream_t* handle) { +@@ -1508,7 +1509,7 @@ void uv__stream_close(uv_stream_t* handle) { if (handle->select != NULL) { uv__stream_select_t* s; @@ -1112,7 +1076,7 @@ index 18763b4744c30a93f067a911b8059984bf36eb86..2d2b5d2f45e673d495ac814fbc1c6a87 uv_sem_post(&s->close_sem); uv_sem_post(&s->async_sem); -@@ -1548,7 +1549,7 @@ void uv__stream_close(uv_stream_t* handle) { +@@ -1543,7 +1544,7 @@ void uv__stream_close(uv_stream_t* handle) { /* Close all queued fds */ if (handle->queued_fds != NULL) { @@ -1122,10 +1086,10 @@ index 18763b4744c30a93f067a911b8059984bf36eb86..2d2b5d2f45e673d495ac814fbc1c6a87 uv__close(queued_fds->fds[i]); uv__free(handle->queued_fds); diff --git a/src/unix/tcp.c b/src/unix/tcp.c -index 98970d75278e312578facdfd06e349fdf51c0ba3..018ec144c78e9dcc7cbebcdaa432b31832f6e902 100644 +index 799fca77aa53920e86c128336f19903f522c3b6a..6fe6361c81e39133b605edfedd88da840ba9ba20 100644 --- a/src/unix/tcp.c +++ b/src/unix/tcp.c -@@ -301,7 +301,7 @@ int uv__tcp_connect(uv_connect_t* req, +@@ -295,7 +295,7 @@ int uv__tcp_connect(uv_connect_t* req, memcpy(&tmp6, addr, sizeof(tmp6)); if (tmp6.sin6_scope_id == 0) { tmp6.sin6_scope_id = uv__ipv6_link_local_scope_id(); @@ -1158,10 +1122,10 @@ index f05e6fe0f7dd5ac579f6a9d6f93bffb99e1bcbc2..20409541de3cb300504b823472a73bc9 return UV_ENOMEM; diff --git a/src/unix/udp.c b/src/unix/udp.c -index f6640fc72318635d9c1aba6015646cf241747774..50506752d0b168aec9507cd36ac81586bb912981 100644 +index c2814512a5f507ceb9e764cdb7c6ff3d36e77974..cbee16b22a36b1c82e74f6a81c3811052e9b8482 100644 --- a/src/unix/udp.c +++ b/src/unix/udp.c -@@ -198,11 +198,11 @@ static int uv__udp_recvmmsg(uv_udp_t* handle, uv_buf_t* buf) { +@@ -191,11 +191,11 @@ static int uv__udp_recvmmsg(uv_udp_t* handle, uv_buf_t* buf) { if (msgs[k].msg_hdr.msg_flags & MSG_TRUNC) flags |= UV_UDP_PARTIAL; @@ -1175,7 +1139,7 @@ index f6640fc72318635d9c1aba6015646cf241747774..50506752d0b168aec9507cd36ac81586 flags); } -@@ -252,7 +252,7 @@ static void uv__udp_recvmsg(uv_udp_t* handle) { +@@ -245,7 +245,7 @@ static void uv__udp_recvmsg(uv_udp_t* handle) { memset(&peer, 0, sizeof(peer)); h.msg_name = &peer; h.msg_namelen = sizeof(peer); @@ -1184,7 +1148,7 @@ index f6640fc72318635d9c1aba6015646cf241747774..50506752d0b168aec9507cd36ac81586 h.msg_iovlen = 1; do { -@@ -754,7 +754,7 @@ int uv__udp_send(uv_udp_send_t* req, +@@ -719,7 +719,7 @@ int uv__udp_send(uv_udp_send_t* req, req->bufs = req->bufsml; if (nbufs > ARRAY_SIZE(req->bufsml)) @@ -1192,7 +1156,7 @@ index f6640fc72318635d9c1aba6015646cf241747774..50506752d0b168aec9507cd36ac81586 + req->bufs = (uv_buf_t*)uv__malloc(nbufs * sizeof(bufs[0])); if (req->bufs == NULL) { - uv__req_unregister(handle->loop); + uv__req_unregister(handle->loop, req); diff --git a/src/uv-common.c b/src/uv-common.c index 2200fe3f0a41e295acb426f39ccc9f0133994675..69e95801a18104ea910abf86db236d85f62afb66 100644 --- a/src/uv-common.c @@ -1307,7 +1271,7 @@ index 7880c9595be1f66ea0dcbdbcc4a91ce40577587f..d88400f0e819d74998e13f60f13c67a6 lib->handle = LoadLibraryExW(filename_w, NULL, LOAD_WITH_ALTERED_SEARCH_PATH); if (lib->handle == NULL) { diff --git a/src/win/fs-event.c b/src/win/fs-event.c -index 7ab407e05345f96a2c5f577e51dc9b21b2f610b9..3754437b4989d67f688153e066ef047268911708 100644 +index fce411813e937018f636aefd6b8c172eebc7532b..dba981c68821ece88e0beb80422b214b77e84b79 100644 --- a/src/win/fs-event.c +++ b/src/win/fs-event.c @@ -73,7 +73,7 @@ static void uv__relative_path(const WCHAR* filename, @@ -1342,10 +1306,10 @@ index 0b532af12d4371c2311bd50a66913287a0716f43..703a8d8f87de1089ac8b18bd817d416d uv_fatal_error(ERROR_OUTOFMEMORY, "uv__malloc"); } diff --git a/src/win/fs.c b/src/win/fs.c -index d87246e0ff34aae2c1e456e2530aa089d3031b29..b90d2368aa769cb66f9367e97f004fa8bd4da3c0 100644 +index b73c17d8c1c831c29aef6454cb0525bb0b951071..7e2367e8c1c6ad96af55a2cc370142104cc0de77 100644 --- a/src/win/fs.c +++ b/src/win/fs.c -@@ -302,7 +302,7 @@ INLINE static int fs__readlink_handle(HANDLE handle, +@@ -280,7 +280,7 @@ INLINE static int fs__readlink_handle(HANDLE handle, } assert(target_ptr == NULL || *target_ptr == NULL); @@ -1354,7 +1318,7 @@ index d87246e0ff34aae2c1e456e2530aa089d3031b29..b90d2368aa769cb66f9367e97f004fa8 } -@@ -345,7 +345,7 @@ INLINE static int fs__capture_path(uv_fs_t* req, const char* path, +@@ -323,7 +323,7 @@ INLINE static int fs__capture_path(uv_fs_t* req, const char* path, return 0; } @@ -1363,7 +1327,7 @@ index d87246e0ff34aae2c1e456e2530aa089d3031b29..b90d2368aa769cb66f9367e97f004fa8 if (buf == NULL) { return ERROR_OUTOFMEMORY; } -@@ -353,7 +353,7 @@ INLINE static int fs__capture_path(uv_fs_t* req, const char* path, +@@ -331,7 +331,7 @@ INLINE static int fs__capture_path(uv_fs_t* req, const char* path, pos = buf; if (path != NULL) { @@ -1372,7 +1336,7 @@ index d87246e0ff34aae2c1e456e2530aa089d3031b29..b90d2368aa769cb66f9367e97f004fa8 req->file.pathw = pos; pos += pathw_len; } else { -@@ -361,7 +361,7 @@ INLINE static int fs__capture_path(uv_fs_t* req, const char* path, +@@ -339,7 +339,7 @@ INLINE static int fs__capture_path(uv_fs_t* req, const char* path, } if (new_path != NULL) { @@ -1381,7 +1345,7 @@ index d87246e0ff34aae2c1e456e2530aa089d3031b29..b90d2368aa769cb66f9367e97f004fa8 req->fs.info.new_pathw = pos; pos += new_pathw_len; } else { -@@ -1447,13 +1447,13 @@ void fs__scandir(uv_fs_t* req) { +@@ -1390,13 +1390,13 @@ void fs__scandir(uv_fs_t* req) { continue; /* Compute the space required to store the filename as WTF-8. */ @@ -1397,7 +1361,7 @@ index d87246e0ff34aae2c1e456e2530aa089d3031b29..b90d2368aa769cb66f9367e97f004fa8 uv__realloc(dirents, new_dirents_size * sizeof *dirents); if (new_dirents == NULL) -@@ -1467,7 +1467,7 @@ void fs__scandir(uv_fs_t* req) { +@@ -1410,7 +1410,7 @@ void fs__scandir(uv_fs_t* req) { * includes room for the first character of the filename, but `utf8_len` * doesn't count the NULL terminator at this point. */ @@ -1406,7 +1370,7 @@ index d87246e0ff34aae2c1e456e2530aa089d3031b29..b90d2368aa769cb66f9367e97f004fa8 if (dirent == NULL) goto out_of_memory_error; -@@ -1475,7 +1475,7 @@ void fs__scandir(uv_fs_t* req) { +@@ -1418,7 +1418,7 @@ void fs__scandir(uv_fs_t* req) { /* Convert file name to UTF-8. */ wtf8 = &dirent->d_name[0]; @@ -1415,7 +1379,7 @@ index d87246e0ff34aae2c1e456e2530aa089d3031b29..b90d2368aa769cb66f9367e97f004fa8 goto out_of_memory_error; /* Fill out the type field. */ -@@ -1569,7 +1569,7 @@ void fs__opendir(uv_fs_t* req) { +@@ -1512,7 +1512,7 @@ void fs__opendir(uv_fs_t* req) { goto error; } @@ -1424,7 +1388,7 @@ index d87246e0ff34aae2c1e456e2530aa089d3031b29..b90d2368aa769cb66f9367e97f004fa8 if (dir == NULL) { SET_REQ_UV_ERROR(req, UV_ENOMEM, ERROR_OUTOFMEMORY); goto error; -@@ -1584,7 +1584,7 @@ void fs__opendir(uv_fs_t* req) { +@@ -1527,7 +1527,7 @@ void fs__opendir(uv_fs_t* req) { else fmt = L"%s\\*"; @@ -1433,7 +1397,7 @@ index d87246e0ff34aae2c1e456e2530aa089d3031b29..b90d2368aa769cb66f9367e97f004fa8 if (find_path == NULL) { SET_REQ_UV_ERROR(req, UV_ENOMEM, ERROR_OUTOFMEMORY); goto error; -@@ -1621,7 +1621,7 @@ void fs__readdir(uv_fs_t* req) { +@@ -1564,7 +1564,7 @@ void fs__readdir(uv_fs_t* req) { int r; req->flags |= UV_FS_FREE_PTR; @@ -1442,7 +1406,7 @@ index d87246e0ff34aae2c1e456e2530aa089d3031b29..b90d2368aa769cb66f9367e97f004fa8 dirents = dir->dirents; memset(dirents, 0, dir->nentries * sizeof(*dir->dirents)); find_data = &dir->find_data; -@@ -1678,7 +1678,7 @@ error: +@@ -1621,7 +1621,7 @@ error: void fs__closedir(uv_fs_t* req) { uv_dir_t* dir; @@ -1451,7 +1415,7 @@ index d87246e0ff34aae2c1e456e2530aa089d3031b29..b90d2368aa769cb66f9367e97f004fa8 FindClose(dir->dir_handle); uv__free(req->ptr); SET_REQ_RESULT(req, 0); -@@ -2754,7 +2754,7 @@ static ssize_t fs__realpath_handle(HANDLE handle, char** realpath_ptr) { +@@ -2612,7 +2612,7 @@ static ssize_t fs__realpath_handle(HANDLE handle, char** realpath_ptr) { return -1; } @@ -1460,7 +1424,7 @@ index d87246e0ff34aae2c1e456e2530aa089d3031b29..b90d2368aa769cb66f9367e97f004fa8 if (w_realpath_buf == NULL) { SetLastError(ERROR_OUTOFMEMORY); return -1; -@@ -2787,7 +2787,7 @@ static ssize_t fs__realpath_handle(HANDLE handle, char** realpath_ptr) { +@@ -2645,7 +2645,7 @@ static ssize_t fs__realpath_handle(HANDLE handle, char** realpath_ptr) { } assert(*realpath_ptr == NULL); @@ -1469,7 +1433,7 @@ index d87246e0ff34aae2c1e456e2530aa089d3031b29..b90d2368aa769cb66f9367e97f004fa8 uv__free(w_realpath_buf); return r; } -@@ -2867,7 +2867,7 @@ retry_get_disk_free_space: +@@ -2725,7 +2725,7 @@ retry_get_disk_free_space: } len = MAX_PATH + 1; @@ -1478,7 +1442,7 @@ index d87246e0ff34aae2c1e456e2530aa089d3031b29..b90d2368aa769cb66f9367e97f004fa8 if (pathw == NULL) { SET_REQ_UV_ERROR(req, UV_ENOMEM, ERROR_OUTOFMEMORY); return; -@@ -2883,7 +2883,7 @@ retry_get_full_path_name: +@@ -2741,7 +2741,7 @@ retry_get_full_path_name: return; } else if (ret > len) { len = ret; @@ -1487,7 +1451,7 @@ index d87246e0ff34aae2c1e456e2530aa089d3031b29..b90d2368aa769cb66f9367e97f004fa8 if (pathw == NULL) { SET_REQ_UV_ERROR(req, UV_ENOMEM, ERROR_OUTOFMEMORY); return; -@@ -2899,7 +2899,7 @@ retry_get_full_path_name: +@@ -2757,7 +2757,7 @@ retry_get_full_path_name: uv__free(pathw); } @@ -1496,7 +1460,7 @@ index d87246e0ff34aae2c1e456e2530aa089d3031b29..b90d2368aa769cb66f9367e97f004fa8 if (stat_fs == NULL) { SET_REQ_UV_ERROR(req, UV_ENOMEM, ERROR_OUTOFMEMORY); return; -@@ -3058,7 +3058,7 @@ int uv_fs_read(uv_loop_t* loop, +@@ -2916,7 +2916,7 @@ int uv_fs_read(uv_loop_t* loop, req->fs.info.nbufs = nbufs; req->fs.info.bufs = req->fs.info.bufsml; if (nbufs > ARRAY_SIZE(req->fs.info.bufsml)) @@ -1505,7 +1469,7 @@ index d87246e0ff34aae2c1e456e2530aa089d3031b29..b90d2368aa769cb66f9367e97f004fa8 if (req->fs.info.bufs == NULL) { SET_REQ_UV_ERROR(req, UV_ENOMEM, ERROR_OUTOFMEMORY); -@@ -3091,7 +3091,7 @@ int uv_fs_write(uv_loop_t* loop, +@@ -2949,7 +2949,7 @@ int uv_fs_write(uv_loop_t* loop, req->fs.info.nbufs = nbufs; req->fs.info.bufs = req->fs.info.bufsml; if (nbufs > ARRAY_SIZE(req->fs.info.bufsml)) @@ -1515,56 +1479,51 @@ index d87246e0ff34aae2c1e456e2530aa089d3031b29..b90d2368aa769cb66f9367e97f004fa8 if (req->fs.info.bufs == NULL) { SET_REQ_UV_ERROR(req, UV_ENOMEM, ERROR_OUTOFMEMORY); diff --git a/src/win/getaddrinfo.c b/src/win/getaddrinfo.c -index f20e10d49d974ac547f44ea7a9c3e9a0a84fcfa5..1181695550d3ed3f4cad9ff059a53d9af1fd854a 100644 +index 8b8406ada8e7434e291b2e50caf4ed7f36613fa0..5bc63d8e19411b967a2acf5c24b34b9b17323ccc 100644 --- a/src/win/getaddrinfo.c +++ b/src/win/getaddrinfo.c -@@ -129,7 +129,7 @@ static void uv__getaddrinfo_done(struct uv__work* w, int status) { - cur_off += addrinfow_ptr->ai_addrlen; +@@ -132,7 +132,7 @@ static void uv__getaddrinfo_done(struct uv__work* w, int status) { + addrinfo_len += addrinfo_struct_len + + ALIGNED_SIZE(addrinfow_ptr->ai_addrlen); if (addrinfow_ptr->ai_canonname != NULL) { - ssize_t name_len = -- uv_utf16_length_as_wtf8(addrinfow_ptr->ai_canonname, -1); -+ uv_utf16_length_as_wtf8((const uint16_t*)addrinfow_ptr->ai_canonname, -1); +- name_len = uv_utf16_length_as_wtf8(addrinfow_ptr->ai_canonname, -1); ++ name_len = uv_utf16_length_as_wtf8((const uint16_t*)addrinfow_ptr->ai_canonname, -1); if (name_len < 0) { req->retcode = name_len; goto complete; -@@ -141,7 +141,7 @@ static void uv__getaddrinfo_done(struct uv__work* w, int status) { - - /* allocate memory for addrinfo results */ - addrinfo_len = cur_off; -- alloc_ptr = uv__malloc(addrinfo_len); -+ alloc_ptr = (char*)uv__malloc(addrinfo_len); - - /* do conversions */ - if (alloc_ptr != NULL) { -@@ -292,7 +292,7 @@ int uv_getaddrinfo(uv_loop_t* loop, +@@ -281,9 +281,9 @@ int uv_getaddrinfo(uv_loop_t* loop, } /* allocate memory for inputs, and partition it as needed */ -- req->alloc = uv__malloc(off); -+ req->alloc = (char*)uv__malloc(off); - if (!req->alloc) +- alloc_ptr = uv__malloc(ALIGNED_SIZE(nodesize * sizeof(WCHAR)) + +- ALIGNED_SIZE(servicesize * sizeof(WCHAR)) + +- hintssize); ++ alloc_ptr = (char*)uv__malloc(ALIGNED_SIZE(nodesize * sizeof(WCHAR)) + ++ ALIGNED_SIZE(servicesize * sizeof(WCHAR)) + ++ hintssize); + if (!alloc_ptr) return UV_ENOMEM; -@@ -300,7 +300,7 @@ int uv_getaddrinfo(uv_loop_t* loop, +@@ -294,7 +294,7 @@ int uv_getaddrinfo(uv_loop_t* loop, * request. The node here has been converted to ascii. */ if (node != NULL) { - req->node = (WCHAR*) req->alloc; -- uv_wtf8_to_utf16(node, req->node, nodesize); -+ uv_wtf8_to_utf16(node, (uint16_t*)req->node, nodesize); + req->node = (WCHAR*) alloc_ptr; +- uv_wtf8_to_utf16(node, (WCHAR*) alloc_ptr, nodesize); ++ uv_wtf8_to_utf16(node, (uint16_t*) alloc_ptr, nodesize); + alloc_ptr += ALIGNED_SIZE(nodesize * sizeof(WCHAR)); } else { req->node = NULL; - } -@@ -309,7 +309,7 @@ int uv_getaddrinfo(uv_loop_t* loop, +@@ -304,7 +304,7 @@ int uv_getaddrinfo(uv_loop_t* loop, * the req. */ if (service != NULL) { - req->service = (WCHAR*) ((char*) req->alloc + serviceoff); -- uv_wtf8_to_utf16(service, req->service, servicesize); -+ uv_wtf8_to_utf16(service, (uint16_t*)req->service, servicesize); + req->service = (WCHAR*) alloc_ptr; +- uv_wtf8_to_utf16(service, (WCHAR*) alloc_ptr, servicesize); ++ uv_wtf8_to_utf16(service, (uint16_t*) alloc_ptr, servicesize); + alloc_ptr += ALIGNED_SIZE(servicesize * sizeof(WCHAR)); } else { req->service = NULL; - } diff --git a/src/win/pipe.c b/src/win/pipe.c -index 76ea169e19ff0a3fc92e8b3be981b21b39b03e94..8226369294299fd2a9d7d05a91d3d711015b7fd0 100644 +index 3c8abe1c28ce369dc9fbc91936f6a97b0c178fdc..27868221455dcbb90c00066fd8b716d2c0a4d371 100644 --- a/src/win/pipe.c +++ b/src/win/pipe.c @@ -739,7 +739,7 @@ int uv_pipe_bind2(uv_pipe_t* handle, @@ -1594,7 +1553,7 @@ index 76ea169e19ff0a3fc92e8b3be981b21b39b03e94..8226369294299fd2a9d7d05a91d3d711 if (!req->u.connect.name) { uv_fatal_error(ERROR_OUTOFMEMORY, "uv__malloc"); } -@@ -1547,7 +1547,7 @@ static int uv__build_coalesced_write_req(uv_write_t* user_req, +@@ -1548,7 +1548,7 @@ static int uv__build_coalesced_write_req(uv_write_t* user_req, data_length; /* (c) */ /* Allocate buffer. */ @@ -1603,7 +1562,7 @@ index 76ea169e19ff0a3fc92e8b3be981b21b39b03e94..8226369294299fd2a9d7d05a91d3d711 if (heap_buffer == NULL) return ERROR_NOT_ENOUGH_MEMORY; /* Maps to UV_ENOMEM. */ -@@ -1796,7 +1796,7 @@ int uv__pipe_write_ipc(uv_loop_t* loop, +@@ -1797,7 +1797,7 @@ int uv__pipe_write_ipc(uv_loop_t* loop, bufs = stack_bufs; } else { /* Use heap-allocated buffer array. */ @@ -1612,7 +1571,7 @@ index 76ea169e19ff0a3fc92e8b3be981b21b39b03e94..8226369294299fd2a9d7d05a91d3d711 if (bufs == NULL) return ERROR_NOT_ENOUGH_MEMORY; /* Maps to UV_ENOMEM. */ } -@@ -2545,7 +2545,7 @@ static int uv__pipe_getname(const uv_pipe_t* handle, char* buffer, size_t* size) +@@ -2494,7 +2494,7 @@ static int uv__pipe_getname(const uv_pipe_t* handle, char* buffer, size_t* size) FileNameInformation); if (nt_status == STATUS_BUFFER_OVERFLOW) { name_size = sizeof(*name_info) + tmp_name_info.FileNameLength; @@ -1622,10 +1581,10 @@ index 76ea169e19ff0a3fc92e8b3be981b21b39b03e94..8226369294299fd2a9d7d05a91d3d711 *size = 0; return UV_ENOMEM; diff --git a/src/win/process.c b/src/win/process.c -index 79bec0090cc94bfe20dab722cf2d8135ddd03cb8..5a648494ae03688f6a56705f2c3d65b026605818 100644 +index 4f0af83e83442bb905762361775abe05ab6beb4e..25f1075745267785cdd7d7de83d9c62750305852 100644 --- a/src/win/process.c +++ b/src/win/process.c -@@ -546,14 +546,14 @@ int make_program_args(char** args, int verbatim_arguments, WCHAR** dst_ptr) { +@@ -547,14 +547,14 @@ int make_program_args(char** args, int verbatim_arguments, WCHAR** dst_ptr) { dst_len = dst_len * 2 + arg_count * 2; /* Allocate buffer for the final command line. */ @@ -1642,7 +1601,7 @@ index 79bec0090cc94bfe20dab722cf2d8135ddd03cb8..5a648494ae03688f6a56705f2c3d65b0 if (temp_buffer == NULL) { err = UV_ENOMEM; goto error; -@@ -567,7 +567,7 @@ int make_program_args(char** args, int verbatim_arguments, WCHAR** dst_ptr) { +@@ -568,7 +568,7 @@ int make_program_args(char** args, int verbatim_arguments, WCHAR** dst_ptr) { arg_len = uv_wtf8_length_as_utf16(*arg); assert(arg_len > 0); assert(temp_buffer_len >= (size_t) arg_len); @@ -1651,34 +1610,43 @@ index 79bec0090cc94bfe20dab722cf2d8135ddd03cb8..5a648494ae03688f6a56705f2c3d65b0 if (verbatim_arguments) { /* Copy verbatim. */ -@@ -595,8 +595,8 @@ error: +@@ -596,8 +596,8 @@ error: - static int env_strncmp(const wchar_t* a, int na, const wchar_t* b) { + int env_strncmp(const wchar_t* a, int na, const wchar_t* b) { - wchar_t* a_eq; - wchar_t* b_eq; + const wchar_t* a_eq; + const wchar_t* b_eq; + wchar_t* A; + wchar_t* B; int nb; - int r; - -@@ -668,12 +668,12 @@ int make_program_env(char* env_block[], WCHAR** dst_ptr) { +@@ -614,8 +614,8 @@ int env_strncmp(const wchar_t* a, int na, const wchar_t* b) { + assert(b_eq); + nb = b_eq - b; + +- A = _alloca((na+1) * sizeof(wchar_t)); +- B = _alloca((nb+1) * sizeof(wchar_t)); ++ A = (wchar_t*)_alloca((na+1) * sizeof(wchar_t)); ++ B = (wchar_t*)_alloca((nb+1) * sizeof(wchar_t)); + + r = LCMapStringW(LOCALE_INVARIANT, LCMAP_UPPERCASE, a, na, A, na); + assert(r==na); +@@ -688,11 +688,11 @@ int make_program_env(char* env_block[], WCHAR** dst_ptr) { + } /* second pass: copy to UTF-16 environment block */ - len = env_block_count * sizeof(WCHAR*); -- p = uv__malloc(len + env_len * sizeof(WCHAR)); -+ p = (char*)uv__malloc(len + env_len * sizeof(WCHAR)); - if (p == NULL) { +- dst_copy = uv__malloc(env_len * sizeof(WCHAR)); ++ dst_copy = (WCHAR*)uv__malloc(env_len * sizeof(WCHAR)); + if (dst_copy == NULL && env_len > 0) { return UV_ENOMEM; } -- env_copy = (void*) &p[0]; -- dst_copy = (void*) &p[len]; -+ env_copy = (WCHAR**) &p[0]; -+ dst_copy = (WCHAR*) &p[len]; +- env_copy = _alloca(env_block_count * sizeof(WCHAR*)); ++ env_copy = (WCHAR**)_alloca(env_block_count * sizeof(WCHAR*)); ptr = dst_copy; ptr_copy = env_copy; -@@ -683,7 +683,7 @@ int make_program_env(char* env_block[], WCHAR** dst_ptr) { +@@ -702,7 +702,7 @@ int make_program_env(char* env_block[], WCHAR** dst_ptr) { len = uv_wtf8_length_as_utf16(*env); assert(len > 0); assert((size_t) len <= env_len - (ptr - dst_copy)); @@ -1687,20 +1655,20 @@ index 79bec0090cc94bfe20dab722cf2d8135ddd03cb8..5a648494ae03688f6a56705f2c3d65b0 *ptr_copy++ = ptr; ptr += len; } -@@ -721,7 +721,7 @@ int make_program_env(char* env_block[], WCHAR** dst_ptr) { +@@ -740,7 +740,7 @@ int make_program_env(char* env_block[], WCHAR** dst_ptr) { } /* final pass: copy, in sort order, and inserting required variables */ - dst = uv__malloc((1+env_len) * sizeof(WCHAR)); + dst = (WCHAR*)uv__malloc((1+env_len) * sizeof(WCHAR)); if (!dst) { - uv__free(p); + uv__free(dst_copy); return UV_ENOMEM; diff --git a/src/win/tcp.c b/src/win/tcp.c -index c452c12e8f06f13e519a198f786eec63faebe2bf..2b43d03ea227b87a717b128ed0d8f0767c8233fd 100644 +index 187f36e2a61c870b0d16e17e9d4a9e1161ba8851..d8da4d941a51b0625fc0c072342ec4edf74c0ea3 100644 --- a/src/win/tcp.c +++ b/src/win/tcp.c -@@ -597,7 +597,7 @@ int uv__tcp_listen(uv_tcp_t* handle, int backlog, uv_connection_cb cb) { +@@ -585,7 +585,7 @@ int uv__tcp_listen(uv_tcp_t* handle, int backlog, uv_connection_cb cb) { if (handle->tcp.serv.accept_reqs == NULL) { handle->tcp.serv.accept_reqs = @@ -1710,19 +1678,10 @@ index c452c12e8f06f13e519a198f786eec63faebe2bf..2b43d03ea227b87a717b128ed0d8f076 uv_fatal_error(ERROR_OUTOFMEMORY, "uv__malloc"); } diff --git a/src/win/thread.c b/src/win/thread.c -index bf39b88633b0d87de02b56579121d384aa5f2d3e..dd958ccd782772869d5448d788a563c1526a89f6 100644 +index 57c25e8f5a861c9d8a4c402c260d3ac235200423..57f1698f595e2410a51044f7f228b5a235206819 100644 --- a/src/win/thread.c +++ b/src/win/thread.c -@@ -39,7 +39,7 @@ typedef struct { - } uv__once_data_t; - - static BOOL WINAPI uv__once_inner(INIT_ONCE *once, void* param, void** context) { -- uv__once_data_t* data = param; -+ uv__once_data_t* data = (uv__once_data_t*)param; - - data->callback(); - -@@ -76,7 +76,7 @@ static UINT __stdcall uv__thread_start(void* arg) { +@@ -98,7 +98,7 @@ static UINT __stdcall uv__thread_start(void* arg) { struct thread_ctx *ctx_p; struct thread_ctx ctx; @@ -1731,7 +1690,7 @@ index bf39b88633b0d87de02b56579121d384aa5f2d3e..dd958ccd782772869d5448d788a563c1 ctx = *ctx_p; uv__free(ctx_p); -@@ -119,7 +119,7 @@ int uv_thread_create_ex(uv_thread_t* tid, +@@ -141,7 +141,7 @@ int uv_thread_create_ex(uv_thread_t* tid, return UV_EINVAL; } @@ -1741,7 +1700,7 @@ index bf39b88633b0d87de02b56579121d384aa5f2d3e..dd958ccd782772869d5448d788a563c1 return UV_ENOMEM; diff --git a/src/win/tty.c b/src/win/tty.c -index c0339ded2e4b763c3b09331e3acd58bf43dccc28..145706e27a7b596dc003d43d94b54f6ceb0eabee 100644 +index 9f8dd698d761248a994e66c4039b35cb216f1d82..0b51b6c82fad711480c28ad6cee7125ddb72ca87 100644 --- a/src/win/tty.c +++ b/src/win/tty.c @@ -528,7 +528,7 @@ static DWORD CALLBACK uv_tty_line_read_thread(void* data) { @@ -1772,7 +1731,7 @@ index c0339ded2e4b763c3b09331e3acd58bf43dccc28..145706e27a7b596dc003d43d94b54f6c &last_key_buf, &char_len)) diff --git a/src/win/util.c b/src/win/util.c -index e0dba1aaa94e285a6e10f57d3b923b53126767d8..1aca4e9a081cd7e4481503d59f39872acbbc6a9c 100644 +index a96cb915930a30a49ba55fd7d15ea48f0b471f89..924d878e89260c2d3cf9a30b7151abeaf735b8be 100644 --- a/src/win/util.c +++ b/src/win/util.c @@ -124,7 +124,7 @@ int uv_exepath(char* buffer, size_t* size_ptr) { @@ -1793,7 +1752,7 @@ index e0dba1aaa94e285a6e10f57d3b923b53126767d8..1aca4e9a081cd7e4481503d59f39872a if (p == NULL) return UV_ENOMEM; -@@ -546,14 +546,14 @@ int uv_cpu_info(uv_cpu_info_t** cpu_infos_ptr, int* cpu_count_ptr) { +@@ -548,14 +548,14 @@ int uv_cpu_info(uv_cpu_info_t** cpu_infos_ptr, int* cpu_count_ptr) { GetSystemInfo(&system_info); cpu_count = system_info.dwNumberOfProcessors; @@ -1810,7 +1769,7 @@ index e0dba1aaa94e285a6e10f57d3b923b53126767d8..1aca4e9a081cd7e4481503d59f39872a if (sppi == NULL) { err = ERROR_OUTOFMEMORY; goto error; -@@ -697,7 +697,8 @@ int uv_interface_addresses(uv_interface_address_t** addresses_ptr, +@@ -699,7 +699,8 @@ int uv_interface_addresses(uv_interface_address_t** addresses_ptr, case ERROR_BUFFER_OVERFLOW: /* This happens when win_address_buf is NULL or too small to hold all * adapters. */ @@ -1820,7 +1779,7 @@ index e0dba1aaa94e285a6e10f57d3b923b53126767d8..1aca4e9a081cd7e4481503d59f39872a if (win_address_buf == NULL) return UV_ENOMEM; -@@ -705,7 +706,7 @@ int uv_interface_addresses(uv_interface_address_t** addresses_ptr, +@@ -707,7 +708,7 @@ int uv_interface_addresses(uv_interface_address_t** addresses_ptr, case ERROR_NO_DATA: { /* No adapters were found. */ @@ -1829,7 +1788,7 @@ index e0dba1aaa94e285a6e10f57d3b923b53126767d8..1aca4e9a081cd7e4481503d59f39872a if (uv_address_buf == NULL) return UV_ENOMEM; -@@ -756,7 +757,7 @@ int uv_interface_addresses(uv_interface_address_t** addresses_ptr, +@@ -758,7 +759,7 @@ int uv_interface_addresses(uv_interface_address_t** addresses_ptr, continue; /* Compute the size of the interface name. */ @@ -1838,7 +1797,7 @@ index e0dba1aaa94e285a6e10f57d3b923b53126767d8..1aca4e9a081cd7e4481503d59f39872a uv_address_buf_size += name_size + 1; /* Count the number of addresses associated with this interface, and -@@ -771,7 +772,7 @@ int uv_interface_addresses(uv_interface_address_t** addresses_ptr, +@@ -773,7 +774,7 @@ int uv_interface_addresses(uv_interface_address_t** addresses_ptr, } /* Allocate space to store interface data plus adapter names. */ @@ -1847,8 +1806,8 @@ index e0dba1aaa94e285a6e10f57d3b923b53126767d8..1aca4e9a081cd7e4481503d59f39872a if (uv_address_buf == NULL) { uv__free(win_address_buf); return UV_ENOMEM; -@@ -991,7 +992,7 @@ int uv_os_tmpdir(char* buffer, size_t* size) { - +@@ -982,7 +983,7 @@ int uv_os_tmpdir(char* buffer, size_t* size) { + } /* Include space for terminating null char. */ len += 1; - path = uv__malloc(len * sizeof(wchar_t)); @@ -1856,7 +1815,7 @@ index e0dba1aaa94e285a6e10f57d3b923b53126767d8..1aca4e9a081cd7e4481503d59f39872a if (path == NULL) { return UV_ENOMEM; } -@@ -1028,7 +1029,7 @@ int uv__convert_utf16_to_utf8(const WCHAR* utf16, size_t utf16len, char** utf8) +@@ -1019,7 +1020,7 @@ int uv__convert_utf16_to_utf8(const WCHAR* utf16, size_t utf16len, char** utf8) return UV_EINVAL; *utf8 = NULL; @@ -1865,7 +1824,7 @@ index e0dba1aaa94e285a6e10f57d3b923b53126767d8..1aca4e9a081cd7e4481503d59f39872a } -@@ -1048,13 +1049,13 @@ int uv__convert_utf8_to_utf16(const char* utf8, WCHAR** utf16) { +@@ -1039,13 +1040,13 @@ int uv__convert_utf8_to_utf16(const char* utf8, WCHAR** utf16) { return UV__EINVAL; /* Allocate the destination buffer. */ @@ -1881,7 +1840,7 @@ index e0dba1aaa94e285a6e10f57d3b923b53126767d8..1aca4e9a081cd7e4481503d59f39872a return 0; } -@@ -1074,11 +1075,11 @@ int uv__copy_utf16_to_utf8(const WCHAR* utf16buffer, size_t utf16len, char* utf8 +@@ -1065,11 +1066,11 @@ int uv__copy_utf16_to_utf8(const WCHAR* utf16buffer, size_t utf16len, char* utf8 return UV_EINVAL; if (*size == 0) { @@ -1895,7 +1854,7 @@ index e0dba1aaa94e285a6e10f57d3b923b53126767d8..1aca4e9a081cd7e4481503d59f39872a } if (r == UV_ENOBUFS) *size += 1; /* Add space for NUL. */ -@@ -1108,7 +1109,7 @@ static int uv__getpwuid_r(uv_passwd_t* pwd) { +@@ -1099,7 +1100,7 @@ static int uv__getpwuid_r(uv_passwd_t* pwd) { return uv_translate_sys_error(r); } @@ -1904,7 +1863,7 @@ index e0dba1aaa94e285a6e10f57d3b923b53126767d8..1aca4e9a081cd7e4481503d59f39872a if (path == NULL) { CloseHandle(token); return UV_ENOMEM; -@@ -1189,7 +1190,7 @@ int uv_os_environ(uv_env_item_t** envitems, int* count) { +@@ -1180,7 +1181,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++); @@ -1913,7 +1872,7 @@ index e0dba1aaa94e285a6e10f57d3b923b53126767d8..1aca4e9a081cd7e4481503d59f39872a if (*envitems == NULL) { FreeEnvironmentStringsW(env); return UV_ENOMEM; -@@ -1281,7 +1282,7 @@ int uv_os_getenv(const char* name, char* buffer, size_t* size) { +@@ -1269,7 +1270,7 @@ int uv_os_getenv(const char* name, char* buffer, size_t* size) { uv__free(var); varlen = 1 + len; diff --git a/upstream_utils/libuv_patches/0003-Fix-warnings.patch b/upstream_utils/libuv_patches/0003-Fix-warnings.patch index 3e367612ab6..03d0127af32 100644 --- a/upstream_utils/libuv_patches/0003-Fix-warnings.patch +++ b/upstream_utils/libuv_patches/0003-Fix-warnings.patch @@ -1,7 +1,7 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Tue, 26 Apr 2022 15:09:43 -0400 -Subject: [PATCH 3/9] Fix warnings +Subject: [PATCH 03/10] Fix warnings --- include/uv/win.h | 5 +++++ @@ -10,7 +10,6 @@ Subject: [PATCH 3/9] Fix warnings src/threadpool.c | 4 ++++ src/unix/core.c | 12 ++++++++++-- src/unix/internal.h | 4 ++-- - src/unix/linux.c | 2 +- src/unix/thread.c | 6 ------ src/uv-common.c | 8 ++++++++ src/win/fs-event.c | 2 ++ @@ -19,10 +18,10 @@ Subject: [PATCH 3/9] Fix warnings src/win/process.c | 2 ++ src/win/thread.c | 4 ++-- src/win/tty.c | 2 ++ - 15 files changed, 48 insertions(+), 15 deletions(-) + 14 files changed, 47 insertions(+), 14 deletions(-) diff --git a/include/uv/win.h b/include/uv/win.h -index d4c271d4d856a5ec847439825cace5bafb0d4acd..48e1402d155ceb80e35a904815cb5739cab2fbe8 100644 +index 518b17606c3b0c114845594e6be9c3c4d95f1776..9a8c990c1b182633f23890cb5f4532b6bee2b22c 100644 --- a/include/uv/win.h +++ b/include/uv/win.h @@ -201,11 +201,16 @@ typedef int (WSAAPI* LPFN_WSARECVFROM) @@ -80,7 +79,7 @@ index dd94bea3886ca37945fcad7909d765e3700e3c21..71c9e5b774d64d505e6c6d6ed2637178 #define UV__INET6_ADDRSTRLEN 46 diff --git a/src/threadpool.c b/src/threadpool.c -index ccb5249893df2733fc607fec6e8d3037ebe2e212..a08832cd4c292f9e7c83b2e8b6c326f542e49cd8 100644 +index f572de5aaf1a1b150e58c7b989949441cac279c4..aa282af468935b680140295a175e503ca82d8fa4 100644 --- a/src/threadpool.c +++ b/src/threadpool.c @@ -27,6 +27,10 @@ @@ -95,10 +94,10 @@ index ccb5249893df2733fc607fec6e8d3037ebe2e212..a08832cd4c292f9e7c83b2e8b6c326f5 static uv_once_t once = UV_ONCE_INIT; diff --git a/src/unix/core.c b/src/unix/core.c -index d8c09f5e41ff96dae4d0df9982f227eaac3c8576..d9f868b13b4fa2c340c542fe567b4193cf079748 100644 +index 8c08d607884335a2da5cb49f35e3108cb833da32..4bc870214afa1e08da2f7b335c031d67d221fdd6 100644 --- a/src/unix/core.c +++ b/src/unix/core.c -@@ -586,6 +586,16 @@ int uv__accept(int sockfd) { +@@ -576,6 +576,16 @@ int uv__accept(int sockfd) { return peerfd; } @@ -115,7 +114,7 @@ index d8c09f5e41ff96dae4d0df9982f227eaac3c8576..d9f868b13b4fa2c340c542fe567b4193 /* close() on macos has the "interesting" quirk that it fails with EINTR * without closing the file descriptor when a thread is in the cancel state. -@@ -600,10 +610,8 @@ int uv__close_nocancel(int fd) { +@@ -590,10 +600,8 @@ int uv__close_nocancel(int fd) { #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wdollar-in-identifier-extension" #if defined(__LP64__) || TARGET_OS_IPHONE @@ -127,10 +126,10 @@ index d8c09f5e41ff96dae4d0df9982f227eaac3c8576..d9f868b13b4fa2c340c542fe567b4193 #endif #pragma GCC diagnostic pop diff --git a/src/unix/internal.h b/src/unix/internal.h -index 529c783e6e93200e52dab98ea9a3c1e0aea557ce..0bf3736cd682e43beedcf4c701a147787f1329fc 100644 +index bcb3be577e584925d4bf4a20d2429ce13aad0584..4c167f5e529cb38a7418fc35dbbafc2a2cea626c 100644 --- a/src/unix/internal.h +++ b/src/unix/internal.h -@@ -396,8 +396,8 @@ UV_UNUSED(static void uv__update_time(uv_loop_t* loop)) { +@@ -384,8 +384,8 @@ UV_UNUSED(static void uv__update_time(uv_loop_t* loop)) { loop->time = uv__hrtime(UV_CLOCK_FAST) / 1000000; } @@ -141,19 +140,6 @@ index 529c783e6e93200e52dab98ea9a3c1e0aea557ce..0bf3736cd682e43beedcf4c701a14778 s = strrchr(path, '/'); if (s == NULL) -diff --git a/src/unix/linux.c b/src/unix/linux.c -index 96c8b1dfe060e896f768493448ec20cfb9203592..cfb0c6eebf2fb231f610020be35187a488127477 100644 ---- a/src/unix/linux.c -+++ b/src/unix/linux.c -@@ -2294,7 +2294,7 @@ static int uv__get_cgroupv2_constrained_cpu(const char* cgroup, - if (uv__slurp(path, buf, sizeof(buf)) < 0) - return UV_EIO; - -- if (sscanf(buf, "%15s %llu", quota_buf, &constraint->period_length) != 2) -+ if (sscanf(buf, "%15s %lld", quota_buf, &constraint->period_length) != 2) - return UV_EINVAL; - - if (strncmp(quota_buf, "max", 3) == 0) diff --git a/src/unix/thread.c b/src/unix/thread.c index 20409541de3cb300504b823472a73bc95fa38f62..688c042e1aedf379264900c29758c8b01a4a90ed 100644 --- a/src/unix/thread.c @@ -198,7 +184,7 @@ index 69e95801a18104ea910abf86db236d85f62afb66..49126e50f07bac16d198775454b731f4 static uv_loop_t default_loop_struct; static uv_loop_t* default_loop_ptr; diff --git a/src/win/fs-event.c b/src/win/fs-event.c -index 3754437b4989d67f688153e066ef047268911708..2fdcbcb73a9ee29dd282b366011a6878fc431a47 100644 +index dba981c68821ece88e0beb80422b214b77e84b79..2f566f796a55c68329d5aed19bd5bb392d0082fa 100644 --- a/src/win/fs-event.c +++ b/src/win/fs-event.c @@ -19,6 +19,8 @@ @@ -211,7 +197,7 @@ index 3754437b4989d67f688153e066ef047268911708..2fdcbcb73a9ee29dd282b366011a6878 #include #include diff --git a/src/win/fs.c b/src/win/fs.c -index b90d2368aa769cb66f9367e97f004fa8bd4da3c0..a4b47fe5ec4135059b8e08be6a232ddd7798bebe 100644 +index 7e2367e8c1c6ad96af55a2cc370142104cc0de77..b812293048e60264f3e849367b7a129c306f8502 100644 --- a/src/win/fs.c +++ b/src/win/fs.c @@ -19,6 +19,8 @@ @@ -224,7 +210,7 @@ index b90d2368aa769cb66f9367e97f004fa8bd4da3c0..a4b47fe5ec4135059b8e08be6a232ddd #include #include diff --git a/src/win/pipe.c b/src/win/pipe.c -index 8226369294299fd2a9d7d05a91d3d711015b7fd0..43ea270e618fd9fd0c0cb30981a3425967b6dbcd 100644 +index 27868221455dcbb90c00066fd8b716d2c0a4d371..d747dc72362a0b21077fa7b9beb57234ca62baad 100644 --- a/src/win/pipe.c +++ b/src/win/pipe.c @@ -19,6 +19,8 @@ @@ -237,7 +223,7 @@ index 8226369294299fd2a9d7d05a91d3d711015b7fd0..43ea270e618fd9fd0c0cb30981a34259 #include #include diff --git a/src/win/process.c b/src/win/process.c -index 5a648494ae03688f6a56705f2c3d65b026605818..d6b61c14015b8d72d8a9aca71bd0483c06a16820 100644 +index 25f1075745267785cdd7d7de83d9c62750305852..e4bf93d707da3d22b747300775e8c96a34039ddb 100644 --- a/src/win/process.c +++ b/src/win/process.c @@ -19,6 +19,8 @@ @@ -250,10 +236,10 @@ index 5a648494ae03688f6a56705f2c3d65b026605818..d6b61c14015b8d72d8a9aca71bd0483c #include #include diff --git a/src/win/thread.c b/src/win/thread.c -index dd958ccd782772869d5448d788a563c1526a89f6..6a4d4498577b0abaa8408052051b0472dde5afec 100644 +index 57f1698f595e2410a51044f7f228b5a235206819..03b33e9b4de6fe2532095d717a8639e8df454cce 100644 --- a/src/win/thread.c +++ b/src/win/thread.c -@@ -182,8 +182,8 @@ int uv_thread_setaffinity(uv_thread_t* tid, +@@ -204,8 +204,8 @@ int uv_thread_setaffinity(uv_thread_t* tid, threadmask = 0; for (i = 0; i < cpumasksize; i++) { if (cpumask[i]) { @@ -265,7 +251,7 @@ index dd958ccd782772869d5448d788a563c1526a89f6..6a4d4498577b0abaa8408052051b0472 return UV_EINVAL; } diff --git a/src/win/tty.c b/src/win/tty.c -index 145706e27a7b596dc003d43d94b54f6ceb0eabee..62ddf32f0fbd29664dd05c6ba426532a2faf4668 100644 +index 0b51b6c82fad711480c28ad6cee7125ddb72ca87..67df01396ab50260b986fc9e7aff0368f6ceb308 100644 --- a/src/win/tty.c +++ b/src/win/tty.c @@ -19,6 +19,8 @@ diff --git a/upstream_utils/libuv_patches/0004-Preprocessor-cleanup.patch b/upstream_utils/libuv_patches/0004-Preprocessor-cleanup.patch index 310d5047e98..7d7a6c89e40 100644 --- a/upstream_utils/libuv_patches/0004-Preprocessor-cleanup.patch +++ b/upstream_utils/libuv_patches/0004-Preprocessor-cleanup.patch @@ -1,21 +1,20 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Tue, 26 Apr 2022 15:19:14 -0400 -Subject: [PATCH 4/9] Preprocessor cleanup +Subject: [PATCH 04/10] Preprocessor cleanup --- - include/uv.h | 12 ------------ - include/uv/unix.h | 8 -------- - src/unix/darwin-syscalls.h | 2 ++ - src/unix/internal.h | 2 ++ - src/win/fs.c | 1 + - src/win/tty.c | 2 ++ - src/win/util.c | 8 ++++++++ - src/win/winsock.c | 1 + - 8 files changed, 16 insertions(+), 20 deletions(-) + include/uv.h | 12 ------------ + include/uv/unix.h | 8 -------- + src/unix/internal.h | 2 ++ + src/win/fs.c | 1 + + src/win/tty.c | 2 ++ + src/win/util.c | 8 ++++++++ + src/win/winsock.c | 1 + + 7 files changed, 14 insertions(+), 20 deletions(-) diff --git a/include/uv.h b/include/uv.h -index 9e450c5110fe57117b686bf683cc6631f37efaeb..d8d59a03512eff879d9688c09fb4a9a57a82ffb7 100644 +index a62b3fa69b1087847f37c7093954e19a07959b74..931c96262b33090422cc1f6c519f8eb4bfc4f9b3 100644 --- a/include/uv.h +++ b/include/uv.h @@ -23,9 +23,6 @@ @@ -28,7 +27,7 @@ index 9e450c5110fe57117b686bf683cc6631f37efaeb..d8d59a03512eff879d9688c09fb4a9a5 #if defined(BUILDING_UV_SHARED) && defined(USING_UV_SHARED) #error "Define either BUILDING_UV_SHARED or USING_UV_SHARED, not both." -@@ -824,16 +821,10 @@ UV_EXTERN int uv_tty_get_winsize(uv_tty_t*, int* width, int* height); +@@ -796,16 +793,10 @@ UV_EXTERN int uv_tty_get_winsize(uv_tty_t*, int* width, int* height); UV_EXTERN void uv_tty_set_vterm_state(uv_tty_vtermstate_t state); UV_EXTERN int uv_tty_get_vterm_state(uv_tty_vtermstate_t* state); @@ -45,7 +44,7 @@ index 9e450c5110fe57117b686bf683cc6631f37efaeb..d8d59a03512eff879d9688c09fb4a9a5 UV_EXTERN uv_handle_type uv_guess_handle(uv_file file); enum { -@@ -1964,7 +1955,4 @@ UV_EXTERN void uv_wtf8_to_utf16(const char* wtf8, +@@ -1936,7 +1927,4 @@ void uv_wtf8_to_utf16(const char* wtf8, #undef UV_LOOP_PRIVATE_PLATFORM_FIELDS #undef UV__ERR @@ -72,25 +71,11 @@ index 538f98b6c5d657169e2750a549dd82bf0b948542..2073fe61a569386cc850d733a6c94cbb #elif defined(__APPLE__) # include "uv/darwin.h" #elif defined(__DragonFly__) || \ -diff --git a/src/unix/darwin-syscalls.h b/src/unix/darwin-syscalls.h -index dc2d1bd234b1f12e39b7e76d6e290c15b19a3735..851af81c74e5b5d62f5f7e72da84703c15eace90 100644 ---- a/src/unix/darwin-syscalls.h -+++ b/src/unix/darwin-syscalls.h -@@ -11,7 +11,9 @@ struct mmsghdr { - size_t msg_len; - }; - -+extern "C" { - ssize_t recvmsg_x(int s, const struct mmsghdr* msgp, u_int cnt, int flags); - ssize_t sendmsg_x(int s, const struct mmsghdr* msgp, u_int cnt, int flags); -+} - - #endif /* UV_DARWIN_SYSCALLS_H_ */ diff --git a/src/unix/internal.h b/src/unix/internal.h -index 0bf3736cd682e43beedcf4c701a147787f1329fc..c1ead096f7d43b9e7a0daf8de2b65cc82bec7eaf 100644 +index 4c167f5e529cb38a7418fc35dbbafc2a2cea626c..35ac6d1f6da75522d4bd69dcde696a8d0fd42bce 100644 --- a/src/unix/internal.h +++ b/src/unix/internal.h -@@ -241,6 +241,8 @@ struct uv__statx { +@@ -233,6 +233,8 @@ struct uv__statx { #if defined(__linux__) && O_NDELAY != O_NONBLOCK #undef uv__nonblock #define uv__nonblock uv__nonblock_fcntl @@ -100,7 +85,7 @@ index 0bf3736cd682e43beedcf4c701a147787f1329fc..c1ead096f7d43b9e7a0daf8de2b65cc8 /* core */ diff --git a/src/win/fs.c b/src/win/fs.c -index a4b47fe5ec4135059b8e08be6a232ddd7798bebe..af07d092a65909ac4948c679b95468eef549ccca 100644 +index b812293048e60264f3e849367b7a129c306f8502..05488e5d67101adba611f882ded4f6dc5a462d9a 100644 --- a/src/win/fs.c +++ b/src/win/fs.c @@ -43,6 +43,7 @@ @@ -112,7 +97,7 @@ index a4b47fe5ec4135059b8e08be6a232ddd7798bebe..af07d092a65909ac4948c679b95468ee #define UV_FS_FREE_PATHS 0x0002 #define UV_FS_FREE_PTR 0x0008 diff --git a/src/win/tty.c b/src/win/tty.c -index 62ddf32f0fbd29664dd05c6ba426532a2faf4668..9a4252d9d89d82fdd316312cc4550dd3c0fe798d 100644 +index 67df01396ab50260b986fc9e7aff0368f6ceb308..7294f311e17d5d02e5873e60f8f0cdd551f6d34d 100644 --- a/src/win/tty.c +++ b/src/win/tty.c @@ -37,6 +37,8 @@ @@ -125,7 +110,7 @@ index 62ddf32f0fbd29664dd05c6ba426532a2faf4668..9a4252d9d89d82fdd316312cc4550dd3 # define InterlockedOr _InterlockedOr #endif diff --git a/src/win/util.c b/src/win/util.c -index 1aca4e9a081cd7e4481503d59f39872acbbc6a9c..1239831dcc0c5fdb8e267d4dd8e73cb73fdc88c9 100644 +index 924d878e89260c2d3cf9a30b7151abeaf735b8be..5767c66c988c67edaf17155d5cb299a1936870ee 100644 --- a/src/win/util.c +++ b/src/win/util.c @@ -64,12 +64,20 @@ diff --git a/upstream_utils/libuv_patches/0005-Cleanup-problematic-language.patch b/upstream_utils/libuv_patches/0005-Cleanup-problematic-language.patch index 60bd213023f..e016c2ee1c4 100644 --- a/upstream_utils/libuv_patches/0005-Cleanup-problematic-language.patch +++ b/upstream_utils/libuv_patches/0005-Cleanup-problematic-language.patch @@ -1,14 +1,14 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Tue, 26 Apr 2022 15:24:47 -0400 -Subject: [PATCH 5/9] Cleanup problematic language +Subject: [PATCH 05/10] Cleanup problematic language --- src/unix/tty.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/unix/tty.c b/src/unix/tty.c -index 793054ba5a9bffe4e2db9040ca09a7fff0ec6b23..699a092da2dea77277557211065f6594bcad4e0b 100644 +index d099bdb3b677212d21e06ac7bb1031c8e5386499..1bd217b5a15eed13a8349c479b53471dd36ca216 100644 --- a/src/unix/tty.c +++ b/src/unix/tty.c @@ -79,7 +79,7 @@ int uv__tcsetattr(int fd, int how, const struct termios *term) { diff --git a/upstream_utils/libuv_patches/0006-Fix-Win32-warning-suppression-pragma.patch b/upstream_utils/libuv_patches/0006-Fix-Win32-warning-suppression-pragma.patch new file mode 100644 index 00000000000..90355bb98da --- /dev/null +++ b/upstream_utils/libuv_patches/0006-Fix-Win32-warning-suppression-pragma.patch @@ -0,0 +1,22 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Tyler Veness +Date: Sat, 21 May 2022 22:58:06 -0700 +Subject: [PATCH 06/10] Fix Win32 warning suppression pragma + +--- + src/win/util.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/win/util.c b/src/win/util.c +index 5767c66c988c67edaf17155d5cb299a1936870ee..52c31979589e4ed7fe12af200f7e8daab9e02797 100644 +--- a/src/win/util.c ++++ b/src/win/util.c +@@ -1544,7 +1544,7 @@ int uv_os_uname(uv_utsname_t* buffer) { + } else { + /* Silence GetVersionEx() deprecation warning. */ + #ifdef _MSC_VER +- #pragma warning(suppress : 4996) ++ #pragma warning(disable : 4996) + #endif + if (GetVersionExW(&os_info) == 0) { + r = uv_translate_sys_error(GetLastError()); diff --git a/upstream_utils/libuv_patches/0006-Use-C-atomics.patch b/upstream_utils/libuv_patches/0007-Use-C-atomics.patch similarity index 75% rename from upstream_utils/libuv_patches/0006-Use-C-atomics.patch rename to upstream_utils/libuv_patches/0007-Use-C-atomics.patch index 2e68b27d0a1..26b488bb68a 100644 --- a/upstream_utils/libuv_patches/0006-Use-C-atomics.patch +++ b/upstream_utils/libuv_patches/0007-Use-C-atomics.patch @@ -1,21 +1,21 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Tyler Veness Date: Thu, 13 Jul 2023 22:13:47 -0700 -Subject: [PATCH 6/9] Use C++ atomics +Subject: [PATCH 07/10] Use C++ atomics --- src/unix/async.c | 25 +++++++++++++------------ src/unix/core.c | 3 ++- - src/unix/fs.c | 33 +++++++++++++++++---------------- + src/unix/fs.c | 20 +++++++++++--------- src/unix/kqueue.c | 10 ++++++---- src/unix/linux.c | 45 +++++++++++++++++++++++---------------------- src/unix/tty.c | 5 +++-- src/uv-common.c | 2 +- src/uv-common.h | 8 +++----- - 8 files changed, 68 insertions(+), 63 deletions(-) + 8 files changed, 62 insertions(+), 56 deletions(-) diff --git a/src/unix/async.c b/src/unix/async.c -index bc97ec54c4fcc60ec51583b5f8b87582265d4ff6..ce63d0ac8c4d761a8765ffcaa7ce1516c9d2485a 100644 +index 0ff2669e30a628dbb2df9e28ba14b38cf14114e5..fef4ae93343edc0341179a1c4739dcd831ef6e26 100644 --- a/src/unix/async.c +++ b/src/unix/async.c @@ -26,7 +26,6 @@ @@ -32,10 +32,10 @@ index bc97ec54c4fcc60ec51583b5f8b87582265d4ff6..ce63d0ac8c4d761a8765ffcaa7ce1516 +#include + - #if UV__KQUEUE_EVFILT_USER - static uv_once_t kqueue_runtime_detection_guard = UV_ONCE_INIT; - static int kqueue_evfilt_user_support = 1; -@@ -91,14 +92,14 @@ int uv_async_init(uv_loop_t* loop, uv_async_t* handle, uv_async_cb async_cb) { + static void uv__async_send(uv_loop_t* loop); + static int uv__async_start(uv_loop_t* loop); + static void uv__cpu_relax(void); +@@ -63,14 +64,14 @@ int uv_async_init(uv_loop_t* loop, uv_async_t* handle, uv_async_cb async_cb) { int uv_async_send(uv_async_t* handle) { @@ -55,7 +55,7 @@ index bc97ec54c4fcc60ec51583b5f8b87582265d4ff6..ce63d0ac8c4d761a8765ffcaa7ce1516 return 0; /* Set the loop to busy. */ -@@ -118,12 +119,12 @@ int uv_async_send(uv_async_t* handle) { +@@ -90,12 +91,12 @@ int uv_async_send(uv_async_t* handle) { /* Wait for the busy flag to clear before closing. * Only call this from the event loop thread. */ static void uv__async_spin(uv_async_t* handle) { @@ -72,7 +72,7 @@ index bc97ec54c4fcc60ec51583b5f8b87582265d4ff6..ce63d0ac8c4d761a8765ffcaa7ce1516 /* Set the pending flag first, so no new events will be added by other * threads after this function returns. */ -@@ -165,7 +166,7 @@ static void uv__async_io(uv_loop_t* loop, uv__io_t* w, unsigned int events) { +@@ -135,7 +136,7 @@ static void uv__async_io(uv_loop_t* loop, uv__io_t* w, unsigned int events) { struct uv__queue queue; struct uv__queue* q; uv_async_t* h; @@ -81,7 +81,7 @@ index bc97ec54c4fcc60ec51583b5f8b87582265d4ff6..ce63d0ac8c4d761a8765ffcaa7ce1516 assert(w == &loop->async_io_watcher); -@@ -202,7 +203,7 @@ static void uv__async_io(uv_loop_t* loop, uv__io_t* w, unsigned int events) { +@@ -166,7 +167,7 @@ static void uv__async_io(uv_loop_t* loop, uv__io_t* w, unsigned int events) { uv__queue_insert_tail(&loop->async_handles, q); /* Atomically fetch and clear pending flag */ @@ -91,7 +91,7 @@ index bc97ec54c4fcc60ec51583b5f8b87582265d4ff6..ce63d0ac8c4d761a8765ffcaa7ce1516 continue; diff --git a/src/unix/core.c b/src/unix/core.c -index d9f868b13b4fa2c340c542fe567b4193cf079748..6c701c0c5a89bc851c709b1a13f1a79210ac0a00 100644 +index 4bc870214afa1e08da2f7b335c031d67d221fdd6..f13ffd1714af26dede3d4d5f6f01efa39fc78959 100644 --- a/src/unix/core.c +++ b/src/unix/core.c @@ -45,6 +45,7 @@ @@ -102,7 +102,7 @@ index d9f868b13b4fa2c340c542fe567b4193cf079748..6c701c0c5a89bc851c709b1a13f1a792 #ifdef __sun # include -@@ -274,7 +275,7 @@ int uv__getiovmax(void) { +@@ -264,7 +265,7 @@ int uv__getiovmax(void) { #if defined(IOV_MAX) return IOV_MAX; #elif defined(_SC_IOV_MAX) @@ -112,18 +112,10 @@ index d9f868b13b4fa2c340c542fe567b4193cf079748..6c701c0c5a89bc851c709b1a13f1a792 iovmax = atomic_load_explicit(&iovmax_cached, memory_order_relaxed); diff --git a/src/unix/fs.c b/src/unix/fs.c -index 77f3a17ad3d102f0aa2860eaf88602fe9555bc4e..49a7d52b5651e0c73a147da2167d8acb6bfbc940 100644 +index 22f31f7285c995c981aca0fa5125bc70aeedc151..75c3093cb7cd6998637c31348265e9299404f91f 100644 --- a/src/unix/fs.c +++ b/src/unix/fs.c -@@ -31,7 +31,6 @@ - - #include - #include --#include - #include - #include - #include -@@ -46,6 +45,8 @@ +@@ -45,6 +45,8 @@ #include #include @@ -132,7 +124,7 @@ index 77f3a17ad3d102f0aa2860eaf88602fe9555bc4e..49a7d52b5651e0c73a147da2167d8acb #if defined(__linux__) # include #endif -@@ -299,7 +300,7 @@ static int uv__fs_mkstemp(uv_fs_t* req) { +@@ -309,7 +311,7 @@ static int uv__fs_mkstemp(uv_fs_t* req) { static uv_once_t once = UV_ONCE_INIT; int r; #ifdef O_CLOEXEC @@ -141,7 +133,7 @@ index 77f3a17ad3d102f0aa2860eaf88602fe9555bc4e..49a7d52b5651e0c73a147da2167d8acb #endif static const char pattern[] = "XXXXXX"; static const size_t pattern_size = sizeof(pattern) - 1; -@@ -324,7 +325,7 @@ static int uv__fs_mkstemp(uv_fs_t* req) { +@@ -334,7 +336,7 @@ static int uv__fs_mkstemp(uv_fs_t* req) { uv_once(&once, uv__mkostemp_initonce); #ifdef O_CLOEXEC @@ -150,7 +142,7 @@ index 77f3a17ad3d102f0aa2860eaf88602fe9555bc4e..49a7d52b5651e0c73a147da2167d8acb uv__mkostemp != NULL) { r = uv__mkostemp(path, O_CLOEXEC); -@@ -338,7 +339,7 @@ static int uv__fs_mkstemp(uv_fs_t* req) { +@@ -348,7 +350,7 @@ static int uv__fs_mkstemp(uv_fs_t* req) { /* We set the static variable so that next calls don't even try to use mkostemp. */ @@ -159,57 +151,7 @@ index 77f3a17ad3d102f0aa2860eaf88602fe9555bc4e..49a7d52b5651e0c73a147da2167d8acb } #endif /* O_CLOEXEC */ -@@ -459,19 +460,19 @@ static ssize_t uv__pwritev_emul(int fd, - } - - --/* The function pointer cache is an uintptr_t because _Atomic void* -+/* The function pointer cache is an uintptr_t because std::atomic* - * doesn't work on macos/ios/etc... - */ - static ssize_t uv__preadv_or_pwritev(int fd, - const struct iovec* bufs, - size_t nbufs, - off_t off, -- _Atomic uintptr_t* cache, -+ std::atomic* cache, - int is_pread) { - ssize_t (*f)(int, const struct iovec*, uv__iovcnt, off_t); - void* p; - -- p = (void*) atomic_load_explicit(cache, memory_order_relaxed); -+ p = (void*) atomic_load_explicit(cache, std::memory_order_relaxed); - if (p == NULL) { - #ifdef RTLD_DEFAULT - p = dlsym(RTLD_DEFAULT, is_pread ? "preadv" : "pwritev"); -@@ -479,7 +480,7 @@ static ssize_t uv__preadv_or_pwritev(int fd, - #endif /* RTLD_DEFAULT */ - if (p == NULL) - p = (void*)(is_pread ? uv__preadv_emul : uv__pwritev_emul); -- atomic_store_explicit(cache, (uintptr_t) p, memory_order_relaxed); -+ atomic_store_explicit(cache, (uintptr_t) p, std::memory_order_relaxed); - } - - /* Use memcpy instead of `f = p` to work around a compiler bug, -@@ -494,7 +495,7 @@ static ssize_t uv__preadv(int fd, - const struct iovec* bufs, - size_t nbufs, - off_t off) { -- static _Atomic uintptr_t cache; -+ static std::atomic cache; - return uv__preadv_or_pwritev(fd, bufs, nbufs, off, &cache, /*is_pread*/1); - } - -@@ -503,7 +504,7 @@ static ssize_t uv__pwritev(int fd, - const struct iovec* bufs, - size_t nbufs, - off_t off) { -- static _Atomic uintptr_t cache; -+ static std::atomic cache; - return uv__preadv_or_pwritev(fd, bufs, nbufs, off, &cache, /*is_pread*/0); - } - -@@ -980,10 +981,10 @@ static int uv__is_cifs_or_smb(int fd) { +@@ -869,10 +871,10 @@ static int uv__is_cifs_or_smb(int fd) { static ssize_t uv__fs_try_copy_file_range(int in_fd, off_t* off, int out_fd, size_t len) { @@ -222,7 +164,7 @@ index 77f3a17ad3d102f0aa2860eaf88602fe9555bc4e..49a7d52b5651e0c73a147da2167d8acb errno = ENOSYS; return -1; } -@@ -1002,7 +1003,7 @@ static ssize_t uv__fs_try_copy_file_range(int in_fd, off_t* off, +@@ -891,7 +893,7 @@ static ssize_t uv__fs_try_copy_file_range(int in_fd, off_t* off, errno = ENOSYS; /* Use fallback. */ break; case ENOSYS: @@ -231,7 +173,7 @@ index 77f3a17ad3d102f0aa2860eaf88602fe9555bc4e..49a7d52b5651e0c73a147da2167d8acb break; case EPERM: /* It's been reported that CIFS spuriously fails. -@@ -1526,14 +1527,14 @@ static int uv__fs_statx(int fd, +@@ -1382,14 +1384,14 @@ static int uv__fs_statx(int fd, uv_stat_t* buf) { STATIC_ASSERT(UV_ENOSYS != -1); #ifdef __linux__ @@ -248,7 +190,7 @@ index 77f3a17ad3d102f0aa2860eaf88602fe9555bc4e..49a7d52b5651e0c73a147da2167d8acb return UV_ENOSYS; dirfd = AT_FDCWD; -@@ -1567,7 +1568,7 @@ static int uv__fs_statx(int fd, +@@ -1423,7 +1425,7 @@ static int uv__fs_statx(int fd, * implemented, rc might return 1 with 0 set as the error code in which * case we return ENOSYS. */ @@ -258,7 +200,7 @@ index 77f3a17ad3d102f0aa2860eaf88602fe9555bc4e..49a7d52b5651e0c73a147da2167d8acb } diff --git a/src/unix/kqueue.c b/src/unix/kqueue.c -index 2dd3b2156f363c73e4ba3ebc7e52367c85f654a8..6f0e06476a65f0d9ed92b28c1b932d17d98dfaa2 100644 +index c307e6631eefb1effb0e0c304eb400e0cb8d984e..bd09ac39dda916dd5a7d664979ce5735586fd7e3 100644 --- a/src/unix/kqueue.c +++ b/src/unix/kqueue.c @@ -37,6 +37,8 @@ @@ -288,7 +230,7 @@ index 2dd3b2156f363c73e4ba3ebc7e52367c85f654a8..6f0e06476a65f0d9ed92b28c1b932d17 uv__free(loop->cf_state); loop->cf_state = NULL; } -@@ -609,7 +611,7 @@ int uv_fs_event_start(uv_fs_event_t* handle, +@@ -565,7 +567,7 @@ int uv_fs_event_start(uv_fs_event_t* handle, goto fallback; if (0 == atomic_load_explicit(&uv__has_forked_with_cfrunloop, @@ -297,7 +239,7 @@ index 2dd3b2156f363c73e4ba3ebc7e52367c85f654a8..6f0e06476a65f0d9ed92b28c1b932d17 int r; /* The fallback fd is no longer needed */ uv__close_nocheckstdio(fd); -@@ -645,7 +647,7 @@ int uv_fs_event_stop(uv_fs_event_t* handle) { +@@ -601,7 +603,7 @@ int uv_fs_event_stop(uv_fs_event_t* handle) { #if defined(__APPLE__) && MAC_OS_X_VERSION_MAX_ALLOWED >= 1070 if (0 == atomic_load_explicit(&uv__has_forked_with_cfrunloop, @@ -307,7 +249,7 @@ index 2dd3b2156f363c73e4ba3ebc7e52367c85f654a8..6f0e06476a65f0d9ed92b28c1b932d17 r = uv__fsevents_close(handle); #endif diff --git a/src/unix/linux.c b/src/unix/linux.c -index cfb0c6eebf2fb231f610020be35187a488127477..be72054ab6513dce8099caeb4dca5083dfbef9df 100644 +index 09b02cd5df6c32a954cbed817111cf3c1874c3db..e0c4902385edac10ac31bc5075a85a45025615f9 100644 --- a/src/unix/linux.c +++ b/src/unix/linux.c @@ -27,7 +27,6 @@ @@ -377,7 +319,7 @@ index cfb0c6eebf2fb231f610020be35187a488127477..be72054ab6513dce8099caeb4dca5083 } return use > 0; -@@ -777,8 +778,8 @@ static struct uv__io_uring_sqe* uv__iou_get_sqe(struct uv__iou* iou, +@@ -767,8 +768,8 @@ static struct uv__io_uring_sqe* uv__iou_get_sqe(struct uv__iou* iou, if (iou->ringfd == -1) return NULL; @@ -388,7 +330,7 @@ index cfb0c6eebf2fb231f610020be35187a488127477..be72054ab6513dce8099caeb4dca5083 tail = *iou->sqtail; mask = iou->sqmask; -@@ -807,12 +808,12 @@ static struct uv__io_uring_sqe* uv__iou_get_sqe(struct uv__iou* iou, +@@ -797,12 +798,12 @@ static struct uv__io_uring_sqe* uv__iou_get_sqe(struct uv__iou* iou, static void uv__iou_submit(struct uv__iou* iou) { uint32_t flags; @@ -405,7 +347,7 @@ index cfb0c6eebf2fb231f610020be35187a488127477..be72054ab6513dce8099caeb4dca5083 if (flags & UV__IORING_SQ_NEED_WAKEUP) if (uv__io_uring_enter(iou->ringfd, 0, 0, UV__IORING_ENTER_SQ_WAKEUP)) -@@ -1153,8 +1154,8 @@ static void uv__poll_io_uring(uv_loop_t* loop, struct uv__iou* iou) { +@@ -1143,8 +1144,8 @@ static void uv__poll_io_uring(uv_loop_t* loop, struct uv__iou* iou) { int rc; head = *iou->cqhead; @@ -416,7 +358,7 @@ index cfb0c6eebf2fb231f610020be35187a488127477..be72054ab6513dce8099caeb4dca5083 mask = iou->cqmask; cqe = (uv__io_uring_cqe*)iou->cqe; nevents = 0; -@@ -1192,15 +1193,15 @@ static void uv__poll_io_uring(uv_loop_t* loop, struct uv__iou* iou) { +@@ -1182,15 +1183,15 @@ static void uv__poll_io_uring(uv_loop_t* loop, struct uv__iou* iou) { nevents++; } @@ -436,7 +378,7 @@ index cfb0c6eebf2fb231f610020be35187a488127477..be72054ab6513dce8099caeb4dca5083 if (flags & UV__IORING_SQ_CQ_OVERFLOW) { do -@@ -1604,7 +1605,7 @@ update_timeout: +@@ -1583,7 +1584,7 @@ update_timeout: } uint64_t uv__hrtime(uv_clocktype_t type) { @@ -445,7 +387,7 @@ index cfb0c6eebf2fb231f610020be35187a488127477..be72054ab6513dce8099caeb4dca5083 struct timespec t; clock_t clock_id; -@@ -1620,7 +1621,7 @@ uint64_t uv__hrtime(uv_clocktype_t type) { +@@ -1599,7 +1600,7 @@ uint64_t uv__hrtime(uv_clocktype_t type) { if (type != UV_CLOCK_FAST) goto done; @@ -454,7 +396,7 @@ index cfb0c6eebf2fb231f610020be35187a488127477..be72054ab6513dce8099caeb4dca5083 if (clock_id != -1) goto done; -@@ -1629,7 +1630,7 @@ uint64_t uv__hrtime(uv_clocktype_t type) { +@@ -1608,7 +1609,7 @@ uint64_t uv__hrtime(uv_clocktype_t type) { if (t.tv_nsec <= 1 * 1000 * 1000) clock_id = CLOCK_MONOTONIC_COARSE; @@ -464,7 +406,7 @@ index cfb0c6eebf2fb231f610020be35187a488127477..be72054ab6513dce8099caeb4dca5083 done: diff --git a/src/unix/tty.c b/src/unix/tty.c -index 699a092da2dea77277557211065f6594bcad4e0b..5ca2105848fc07d312455c336ac7303e61679213 100644 +index 1bd217b5a15eed13a8349c479b53471dd36ca216..1304c6d8685cfd122cffea066dc668d1dfc9ae02 100644 --- a/src/unix/tty.c +++ b/src/unix/tty.c @@ -22,7 +22,6 @@ @@ -507,7 +449,7 @@ index 49126e50f07bac16d198775454b731f40630d1d1..1ce25c24d6c046f7aaeaa52dcfc4fafa if (uv__exchange_int_relaxed(&was_shutdown, 1)) return; diff --git a/src/uv-common.h b/src/uv-common.h -index 339e5f37323ce3819bea555ee3bb5fa7216d016d..50bbc874c115b552851d9b12b807332aeefcd3ee 100644 +index cd57e5a35153d0557351b60cce0c5be7a4468b60..5dce8eaf2705b47935b218181f6dd69af0d5b61b 100644 --- a/src/uv-common.h +++ b/src/uv-common.h @@ -32,15 +32,13 @@ diff --git a/upstream_utils/libuv_patches/0007-Remove-static-from-array-indices.patch b/upstream_utils/libuv_patches/0008-Remove-static-from-array-indices.patch similarity index 94% rename from upstream_utils/libuv_patches/0007-Remove-static-from-array-indices.patch rename to upstream_utils/libuv_patches/0008-Remove-static-from-array-indices.patch index 9538caed85b..7fd97eabcc4 100644 --- a/upstream_utils/libuv_patches/0007-Remove-static-from-array-indices.patch +++ b/upstream_utils/libuv_patches/0008-Remove-static-from-array-indices.patch @@ -1,14 +1,14 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Tyler Veness Date: Thu, 13 Jul 2023 23:30:58 -0700 -Subject: [PATCH 7/9] Remove static from array indices +Subject: [PATCH 08/10] Remove static from array indices --- src/unix/linux.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/unix/linux.c b/src/unix/linux.c -index be72054ab6513dce8099caeb4dca5083dfbef9df..322873f6f0e8954d2c5b572ef87fcbc74d7b12c1 100644 +index e0c4902385edac10ac31bc5075a85a45025615f9..091c0474cfe37de4eb55dbf6c20144aa78e896a5 100644 --- a/src/unix/linux.c +++ b/src/unix/linux.c @@ -2098,7 +2098,7 @@ static uint64_t uv__read_uint64(const char* filename) { diff --git a/upstream_utils/libuv_patches/0008-Add-pragmas-for-missing-libraries-and-set-_WIN32_WIN.patch b/upstream_utils/libuv_patches/0009-Add-pragmas-for-missing-libraries-and-set-_WIN32_WIN.patch similarity index 79% rename from upstream_utils/libuv_patches/0008-Add-pragmas-for-missing-libraries-and-set-_WIN32_WIN.patch rename to upstream_utils/libuv_patches/0009-Add-pragmas-for-missing-libraries-and-set-_WIN32_WIN.patch index 1062c1322f5..4bbcf846cfe 100644 --- a/upstream_utils/libuv_patches/0008-Add-pragmas-for-missing-libraries-and-set-_WIN32_WIN.patch +++ b/upstream_utils/libuv_patches/0009-Add-pragmas-for-missing-libraries-and-set-_WIN32_WIN.patch @@ -1,8 +1,8 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Tyler Veness Date: Fri, 14 Jul 2023 16:40:18 -0700 -Subject: [PATCH 8/9] Add pragmas for missing libraries and set _WIN32_WINNT to - Windows 10 +Subject: [PATCH 09/10] Add pragmas for missing libraries and set _WIN32_WINNT + to Windows 10 This makes GetSystemTimePreciseAsFileTime() available. @@ -14,7 +14,7 @@ https://learn.microsoft.com/en-us/cpp/porting/modifying-winver-and-win32-winnt. 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/include/uv/win.h b/include/uv/win.h -index 48e1402d155ceb80e35a904815cb5739cab2fbe8..576f0fa52b60524711e04e94c740ae9b85fb36a9 100644 +index 9a8c990c1b182633f23890cb5f4532b6bee2b22c..f17abc1f92681971da8ec603f7a20204fd53e5d1 100644 --- a/include/uv/win.h +++ b/include/uv/win.h @@ -20,7 +20,7 @@ @@ -27,7 +27,7 @@ index 48e1402d155ceb80e35a904815cb5739cab2fbe8..576f0fa52b60524711e04e94c740ae9b #if !defined(_SSIZE_T_) && !defined(_SSIZE_T_DEFINED) diff --git a/src/win/util.c b/src/win/util.c -index 1239831dcc0c5fdb8e267d4dd8e73cb73fdc88c9..907a09840931b37ec74b8011aedaee3100b5c643 100644 +index 52c31979589e4ed7fe12af200f7e8daab9e02797..6529aa36f32eab1114488b7445a6bd872975b97b 100644 --- a/src/win/util.c +++ b/src/win/util.c @@ -73,7 +73,9 @@ static char *process_title; diff --git a/upstream_utils/libuv_patches/0009-Remove-swearing.patch b/upstream_utils/libuv_patches/0010-Remove-swearing.patch similarity index 78% rename from upstream_utils/libuv_patches/0009-Remove-swearing.patch rename to upstream_utils/libuv_patches/0010-Remove-swearing.patch index 5f712d17dc3..fabd4a8c19b 100644 --- a/upstream_utils/libuv_patches/0009-Remove-swearing.patch +++ b/upstream_utils/libuv_patches/0010-Remove-swearing.patch @@ -1,7 +1,7 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Jade Turner Date: Wed, 26 Jun 2024 11:40:37 +0800 -Subject: [PATCH 9/9] Remove swearing +Subject: [PATCH 10/10] Remove swearing --- src/win/fs.c | 2 +- @@ -9,10 +9,10 @@ Subject: [PATCH 9/9] Remove swearing 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/win/fs.c b/src/win/fs.c -index af07d092a65909ac4948c679b95468eef549ccca..69a413eab4caa2aee4137411d17f630eea138975 100644 +index 05488e5d67101adba611f882ded4f6dc5a462d9a..d6b2b3f1d08d846fa941942f4bb33ae2fa30e320 100644 --- a/src/win/fs.c +++ b/src/win/fs.c -@@ -1844,7 +1844,7 @@ INLINE static void fs__stat_assign_statbuf(uv_stat_t* statbuf, +@@ -1704,7 +1704,7 @@ INLINE static int fs__stat_handle(HANDLE handle, uv_stat_t* statbuf, * impossible to delete the file afterwards, since read-only files can't be * deleted. * @@ -22,7 +22,7 @@ index af07d092a65909ac4948c679b95468eef549ccca..69a413eab4caa2aee4137411d17f630e * * And uv_fs_chmod should probably just fail on windows or be a total no-op. diff --git a/src/win/tty.c b/src/win/tty.c -index 9a4252d9d89d82fdd316312cc4550dd3c0fe798d..f1acef2c64e5a7397c86729d81d1f15ee74b7a43 100644 +index 7294f311e17d5d02e5873e60f8f0cdd551f6d34d..f7d5ef6c29f97a979fb1df993b66e31830af55c4 100644 --- a/src/win/tty.c +++ b/src/win/tty.c @@ -1055,7 +1055,7 @@ int uv__tty_read_stop(uv_tty_t* handle) { diff --git a/wpinet/src/main/native/thirdparty/libuv/include/uv.h b/wpinet/src/main/native/thirdparty/libuv/include/uv.h index d8d59a03512..931c96262b3 100644 --- a/wpinet/src/main/native/thirdparty/libuv/include/uv.h +++ b/wpinet/src/main/native/thirdparty/libuv/include/uv.h @@ -257,9 +257,7 @@ typedef struct uv_metrics_s uv_metrics_t; typedef enum { UV_LOOP_BLOCK_SIGNAL = 0, - UV_METRICS_IDLE_TIME, - UV_LOOP_USE_IO_URING_SQPOLL -#define UV_LOOP_USE_IO_URING_SQPOLL UV_LOOP_USE_IO_URING_SQPOLL + UV_METRICS_IDLE_TIME } uv_loop_option; typedef enum { @@ -603,18 +601,7 @@ UV_EXTERN int uv_tcp_simultaneous_accepts(uv_tcp_t* handle, int enable); enum uv_tcp_flags { /* Used with uv_tcp_bind, when an IPv6 address is used. */ - UV_TCP_IPV6ONLY = 1, - - /* Enable SO_REUSEPORT socket option when binding the handle. - * This allows completely duplicate bindings by multiple processes - * or threads if they all set SO_REUSEPORT before binding the port. - * Incoming connections are distributed across the participating - * listener sockets. - * - * This flag is available only on Linux 3.9+, DragonFlyBSD 3.6+, - * FreeBSD 12.0+, Solaris 11.4, and AIX 7.2.5+ for now. - */ - UV_TCP_REUSEPORT = 2, + UV_TCP_IPV6ONLY = 1 }; UV_EXTERN int uv_tcp_bind(uv_tcp_t* handle, @@ -655,13 +642,10 @@ enum uv_udp_flags { UV_UDP_PARTIAL = 2, /* * Indicates if SO_REUSEADDR will be set when binding the handle. - * This sets the SO_REUSEPORT socket flag on the BSDs (except for - * DragonFlyBSD), OS X, and other platforms where SO_REUSEPORTs don't - * have the capability of load balancing, as the opposite of what - * UV_UDP_REUSEPORT would do. On other Unix platforms, it sets the - * SO_REUSEADDR flag. What that means is that multiple threads or - * processes can bind to the same address without error (provided - * they all set the flag) but only the last one to bind will receive + * This sets the SO_REUSEPORT socket flag on the BSDs and OS X. On other + * Unix platforms, it sets the SO_REUSEADDR flag. What that means is that + * multiple threads or processes can bind to the same address without error + * (provided they all set the flag) but only the last one to bind will receive * any traffic, in effect "stealing" the port from the previous listener. */ UV_UDP_REUSEADDR = 4, @@ -684,18 +668,6 @@ enum uv_udp_flags { * This flag is no-op on platforms other than Linux. */ UV_UDP_LINUX_RECVERR = 32, - /* - * Indicates if SO_REUSEPORT will be set when binding the handle. - * This sets the SO_REUSEPORT socket option on supported platforms. - * Unlike UV_UDP_REUSEADDR, this flag will make multiple threads or - * processes that are binding to the same address and port "share" - * the port, which means incoming datagrams are distributed across - * the receiving sockets among threads or processes. - * - * This flag is available only on Linux 3.9+, DragonFlyBSD 3.6+, - * FreeBSD 12.0+, Solaris 11.4, and AIX 7.2.5+ for now. - */ - UV_UDP_REUSEPORT = 64, /* * Indicates that recvmmsg should be used, if available. */ @@ -1922,17 +1894,17 @@ struct uv_loop_s { UV_EXTERN void* uv_loop_get_data(const uv_loop_t*); UV_EXTERN void uv_loop_set_data(uv_loop_t*, void* data); -/* Unicode utilities needed for dealing with Windows. */ -UV_EXTERN size_t uv_utf16_length_as_wtf8(const uint16_t* utf16, - ssize_t utf16_len); -UV_EXTERN int uv_utf16_to_wtf8(const uint16_t* utf16, - ssize_t utf16_len, - char** wtf8_ptr, - size_t* wtf8_len_ptr); -UV_EXTERN ssize_t uv_wtf8_length_as_utf16(const char* wtf8); -UV_EXTERN void uv_wtf8_to_utf16(const char* wtf8, - uint16_t* utf16, - size_t utf16_len); +/* String utilities needed internally for dealing with Windows. */ +size_t uv_utf16_length_as_wtf8(const uint16_t* utf16, + ssize_t utf16_len); +int uv_utf16_to_wtf8(const uint16_t* utf16, + ssize_t utf16_len, + char** wtf8_ptr, + size_t* wtf8_len_ptr); +ssize_t uv_wtf8_length_as_utf16(const char* wtf8); +void uv_wtf8_to_utf16(const char* wtf8, + uint16_t* utf16, + size_t utf16_len); /* Don't export the private CPP symbols. */ #undef UV_HANDLE_TYPE_PRIVATE diff --git a/wpinet/src/main/native/thirdparty/libuv/include/uv/tree.h b/wpinet/src/main/native/thirdparty/libuv/include/uv/tree.h index 06bba084f38..2b28835fded 100644 --- a/wpinet/src/main/native/thirdparty/libuv/include/uv/tree.h +++ b/wpinet/src/main/native/thirdparty/libuv/include/uv/tree.h @@ -35,7 +35,21 @@ #endif /* - * This file defines data structures for red-black trees. + * This file defines data structures for different types of trees: + * splay trees and red-black trees. + * + * A splay tree is a self-organizing data structure. Every operation + * on the tree causes a splay to happen. The splay moves the requested + * node to the root of the tree and partly rebalances it. + * + * This has the benefit that request locality causes faster lookups as + * the requested nodes move to the top of the tree. On the other hand, + * every lookup causes memory writes. + * + * The Balance Theorem bounds the total access time for m operations + * and n inserts on an initially empty tree as O((m + n)lg n). The + * amortized cost for a sequence of m accesses to a splay tree is O(lg n); + * * A red-black tree is a binary search tree with the node color as an * extra attribute. It fulfills a set of conditions: * - every search path from the root to a leaf consists of the @@ -47,6 +61,239 @@ * The maximum height of a red-black tree is 2lg (n+1). */ +#define SPLAY_HEAD(name, type) \ +struct name { \ + struct type *sph_root; /* root of the tree */ \ +} + +#define SPLAY_INITIALIZER(root) \ + { NULL } + +#define SPLAY_INIT(root) do { \ + (root)->sph_root = NULL; \ +} while (/*CONSTCOND*/ 0) + +#define SPLAY_ENTRY(type) \ +struct { \ + struct type *spe_left; /* left element */ \ + struct type *spe_right; /* right element */ \ +} + +#define SPLAY_LEFT(elm, field) (elm)->field.spe_left +#define SPLAY_RIGHT(elm, field) (elm)->field.spe_right +#define SPLAY_ROOT(head) (head)->sph_root +#define SPLAY_EMPTY(head) (SPLAY_ROOT(head) == NULL) + +/* SPLAY_ROTATE_{LEFT,RIGHT} expect that tmp hold SPLAY_{RIGHT,LEFT} */ +#define SPLAY_ROTATE_RIGHT(head, tmp, field) do { \ + SPLAY_LEFT((head)->sph_root, field) = SPLAY_RIGHT(tmp, field); \ + SPLAY_RIGHT(tmp, field) = (head)->sph_root; \ + (head)->sph_root = tmp; \ +} while (/*CONSTCOND*/ 0) + +#define SPLAY_ROTATE_LEFT(head, tmp, field) do { \ + SPLAY_RIGHT((head)->sph_root, field) = SPLAY_LEFT(tmp, field); \ + SPLAY_LEFT(tmp, field) = (head)->sph_root; \ + (head)->sph_root = tmp; \ +} while (/*CONSTCOND*/ 0) + +#define SPLAY_LINKLEFT(head, tmp, field) do { \ + SPLAY_LEFT(tmp, field) = (head)->sph_root; \ + tmp = (head)->sph_root; \ + (head)->sph_root = SPLAY_LEFT((head)->sph_root, field); \ +} while (/*CONSTCOND*/ 0) + +#define SPLAY_LINKRIGHT(head, tmp, field) do { \ + SPLAY_RIGHT(tmp, field) = (head)->sph_root; \ + tmp = (head)->sph_root; \ + (head)->sph_root = SPLAY_RIGHT((head)->sph_root, field); \ +} while (/*CONSTCOND*/ 0) + +#define SPLAY_ASSEMBLE(head, node, left, right, field) do { \ + SPLAY_RIGHT(left, field) = SPLAY_LEFT((head)->sph_root, field); \ + SPLAY_LEFT(right, field) = SPLAY_RIGHT((head)->sph_root, field); \ + SPLAY_LEFT((head)->sph_root, field) = SPLAY_RIGHT(node, field); \ + SPLAY_RIGHT((head)->sph_root, field) = SPLAY_LEFT(node, field); \ +} while (/*CONSTCOND*/ 0) + +/* Generates prototypes and inline functions */ + +#define SPLAY_PROTOTYPE(name, type, field, cmp) \ +void name##_SPLAY(struct name *, struct type *); \ +void name##_SPLAY_MINMAX(struct name *, int); \ +struct type *name##_SPLAY_INSERT(struct name *, struct type *); \ +struct type *name##_SPLAY_REMOVE(struct name *, struct type *); \ + \ +/* Finds the node with the same key as elm */ \ +static __inline struct type * \ +name##_SPLAY_FIND(struct name *head, struct type *elm) \ +{ \ + if (SPLAY_EMPTY(head)) \ + return(NULL); \ + name##_SPLAY(head, elm); \ + if ((cmp)(elm, (head)->sph_root) == 0) \ + return (head->sph_root); \ + return (NULL); \ +} \ + \ +static __inline struct type * \ +name##_SPLAY_NEXT(struct name *head, struct type *elm) \ +{ \ + name##_SPLAY(head, elm); \ + if (SPLAY_RIGHT(elm, field) != NULL) { \ + elm = SPLAY_RIGHT(elm, field); \ + while (SPLAY_LEFT(elm, field) != NULL) { \ + elm = SPLAY_LEFT(elm, field); \ + } \ + } else \ + elm = NULL; \ + return (elm); \ +} \ + \ +static __inline struct type * \ +name##_SPLAY_MIN_MAX(struct name *head, int val) \ +{ \ + name##_SPLAY_MINMAX(head, val); \ + return (SPLAY_ROOT(head)); \ +} + +/* Main splay operation. + * Moves node close to the key of elm to top + */ +#define SPLAY_GENERATE(name, type, field, cmp) \ +struct type * \ +name##_SPLAY_INSERT(struct name *head, struct type *elm) \ +{ \ + if (SPLAY_EMPTY(head)) { \ + SPLAY_LEFT(elm, field) = SPLAY_RIGHT(elm, field) = NULL; \ + } else { \ + int __comp; \ + name##_SPLAY(head, elm); \ + __comp = (cmp)(elm, (head)->sph_root); \ + if(__comp < 0) { \ + SPLAY_LEFT(elm, field) = SPLAY_LEFT((head)->sph_root, field); \ + SPLAY_RIGHT(elm, field) = (head)->sph_root; \ + SPLAY_LEFT((head)->sph_root, field) = NULL; \ + } else if (__comp > 0) { \ + SPLAY_RIGHT(elm, field) = SPLAY_RIGHT((head)->sph_root, field); \ + SPLAY_LEFT(elm, field) = (head)->sph_root; \ + SPLAY_RIGHT((head)->sph_root, field) = NULL; \ + } else \ + return ((head)->sph_root); \ + } \ + (head)->sph_root = (elm); \ + return (NULL); \ +} \ + \ +struct type * \ +name##_SPLAY_REMOVE(struct name *head, struct type *elm) \ +{ \ + struct type *__tmp; \ + if (SPLAY_EMPTY(head)) \ + return (NULL); \ + name##_SPLAY(head, elm); \ + if ((cmp)(elm, (head)->sph_root) == 0) { \ + if (SPLAY_LEFT((head)->sph_root, field) == NULL) { \ + (head)->sph_root = SPLAY_RIGHT((head)->sph_root, field); \ + } else { \ + __tmp = SPLAY_RIGHT((head)->sph_root, field); \ + (head)->sph_root = SPLAY_LEFT((head)->sph_root, field); \ + name##_SPLAY(head, elm); \ + SPLAY_RIGHT((head)->sph_root, field) = __tmp; \ + } \ + return (elm); \ + } \ + return (NULL); \ +} \ + \ +void \ +name##_SPLAY(struct name *head, struct type *elm) \ +{ \ + struct type __node, *__left, *__right, *__tmp; \ + int __comp; \ + \ + SPLAY_LEFT(&__node, field) = SPLAY_RIGHT(&__node, field) = NULL; \ + __left = __right = &__node; \ + \ + while ((__comp = (cmp)(elm, (head)->sph_root)) != 0) { \ + if (__comp < 0) { \ + __tmp = SPLAY_LEFT((head)->sph_root, field); \ + if (__tmp == NULL) \ + break; \ + if ((cmp)(elm, __tmp) < 0){ \ + SPLAY_ROTATE_RIGHT(head, __tmp, field); \ + if (SPLAY_LEFT((head)->sph_root, field) == NULL) \ + break; \ + } \ + SPLAY_LINKLEFT(head, __right, field); \ + } else if (__comp > 0) { \ + __tmp = SPLAY_RIGHT((head)->sph_root, field); \ + if (__tmp == NULL) \ + break; \ + if ((cmp)(elm, __tmp) > 0){ \ + SPLAY_ROTATE_LEFT(head, __tmp, field); \ + if (SPLAY_RIGHT((head)->sph_root, field) == NULL) \ + break; \ + } \ + SPLAY_LINKRIGHT(head, __left, field); \ + } \ + } \ + SPLAY_ASSEMBLE(head, &__node, __left, __right, field); \ +} \ + \ +/* Splay with either the minimum or the maximum element \ + * Used to find minimum or maximum element in tree. \ + */ \ +void name##_SPLAY_MINMAX(struct name *head, int __comp) \ +{ \ + struct type __node, *__left, *__right, *__tmp; \ + \ + SPLAY_LEFT(&__node, field) = SPLAY_RIGHT(&__node, field) = NULL; \ + __left = __right = &__node; \ + \ + for (;;) { \ + if (__comp < 0) { \ + __tmp = SPLAY_LEFT((head)->sph_root, field); \ + if (__tmp == NULL) \ + break; \ + if (__comp < 0){ \ + SPLAY_ROTATE_RIGHT(head, __tmp, field); \ + if (SPLAY_LEFT((head)->sph_root, field) == NULL) \ + break; \ + } \ + SPLAY_LINKLEFT(head, __right, field); \ + } else if (__comp > 0) { \ + __tmp = SPLAY_RIGHT((head)->sph_root, field); \ + if (__tmp == NULL) \ + break; \ + if (__comp > 0) { \ + SPLAY_ROTATE_LEFT(head, __tmp, field); \ + if (SPLAY_RIGHT((head)->sph_root, field) == NULL) \ + break; \ + } \ + SPLAY_LINKRIGHT(head, __left, field); \ + } \ + } \ + SPLAY_ASSEMBLE(head, &__node, __left, __right, field); \ +} + +#define SPLAY_NEGINF -1 +#define SPLAY_INF 1 + +#define SPLAY_INSERT(name, x, y) name##_SPLAY_INSERT(x, y) +#define SPLAY_REMOVE(name, x, y) name##_SPLAY_REMOVE(x, y) +#define SPLAY_FIND(name, x, y) name##_SPLAY_FIND(x, y) +#define SPLAY_NEXT(name, x, y) name##_SPLAY_NEXT(x, y) +#define SPLAY_MIN(name, x) (SPLAY_EMPTY(x) ? NULL \ + : name##_SPLAY_MIN_MAX(x, SPLAY_NEGINF)) +#define SPLAY_MAX(name, x) (SPLAY_EMPTY(x) ? NULL \ + : name##_SPLAY_MIN_MAX(x, SPLAY_INF)) + +#define SPLAY_FOREACH(x, name, head) \ + for ((x) = SPLAY_MIN(name, head); \ + (x) != NULL; \ + (x) = SPLAY_NEXT(name, head, x)) + /* Macros that define a red-black tree */ #define RB_HEAD(name, type) \ struct name { \ @@ -483,8 +730,8 @@ name##_RB_MINMAX(struct name *head, int val) \ #define RB_REMOVE(name, x, y) name##_RB_REMOVE(x, y) #define RB_FIND(name, x, y) name##_RB_FIND(x, y) #define RB_NFIND(name, x, y) name##_RB_NFIND(x, y) -#define RB_NEXT(name, x) name##_RB_NEXT(x) -#define RB_PREV(name, x) name##_RB_PREV(x) +#define RB_NEXT(name, x, y) name##_RB_NEXT(y) +#define RB_PREV(name, x, y) name##_RB_PREV(y) #define RB_MIN(name, x) name##_RB_MINMAX(x, RB_NEGINF) #define RB_MAX(name, x) name##_RB_MINMAX(x, RB_INF) diff --git a/wpinet/src/main/native/thirdparty/libuv/include/uv/version.h b/wpinet/src/main/native/thirdparty/libuv/include/uv/version.h index 43db019867e..d6a61a10f7c 100644 --- a/wpinet/src/main/native/thirdparty/libuv/include/uv/version.h +++ b/wpinet/src/main/native/thirdparty/libuv/include/uv/version.h @@ -31,7 +31,7 @@ */ #define UV_VERSION_MAJOR 1 -#define UV_VERSION_MINOR 49 +#define UV_VERSION_MINOR 48 #define UV_VERSION_PATCH 0 #define UV_VERSION_IS_RELEASE 1 #define UV_VERSION_SUFFIX "" diff --git a/wpinet/src/main/native/thirdparty/libuv/include/uv/win.h b/wpinet/src/main/native/thirdparty/libuv/include/uv/win.h index 576f0fa52b6..f17abc1f926 100644 --- a/wpinet/src/main/native/thirdparty/libuv/include/uv/win.h +++ b/wpinet/src/main/native/thirdparty/libuv/include/uv/win.h @@ -294,8 +294,8 @@ typedef struct { #define UV_ONCE_INIT { 0, NULL } typedef struct uv_once_s { - unsigned char unused; - INIT_ONCE init_once; + unsigned char ran; + HANDLE event; } uv_once_t; /* Platform-specific definitions for uv_spawn support. */ diff --git a/wpinet/src/main/native/thirdparty/libuv/src/random.cpp b/wpinet/src/main/native/thirdparty/libuv/src/random.cpp index 57fc0d911da..e75f77deb2b 100644 --- a/wpinet/src/main/native/thirdparty/libuv/src/random.cpp +++ b/wpinet/src/main/native/thirdparty/libuv/src/random.cpp @@ -82,7 +82,7 @@ static void uv__random_done(struct uv__work* w, int status) { uv_random_t* req; req = container_of(w, uv_random_t, work_req); - uv__req_unregister(req->loop); + uv__req_unregister(req->loop, req); if (status == 0) status = req->status; diff --git a/wpinet/src/main/native/thirdparty/libuv/src/threadpool.cpp b/wpinet/src/main/native/thirdparty/libuv/src/threadpool.cpp index a08832cd4c2..aa282af4689 100644 --- a/wpinet/src/main/native/thirdparty/libuv/src/threadpool.cpp +++ b/wpinet/src/main/native/thirdparty/libuv/src/threadpool.cpp @@ -360,7 +360,7 @@ static void uv__queue_done(struct uv__work* w, int err) { uv_work_t* req; req = container_of(w, uv_work_t, work_req); - uv__req_unregister(req->loop); + uv__req_unregister(req->loop, req); if (req->after_work_cb == NULL) return; diff --git a/wpinet/src/main/native/thirdparty/libuv/src/unix/async.cpp b/wpinet/src/main/native/thirdparty/libuv/src/unix/async.cpp index ce63d0ac8c4..fef4ae93343 100644 --- a/wpinet/src/main/native/thirdparty/libuv/src/unix/async.cpp +++ b/wpinet/src/main/native/thirdparty/libuv/src/unix/async.cpp @@ -39,34 +39,6 @@ #include -#if UV__KQUEUE_EVFILT_USER -static uv_once_t kqueue_runtime_detection_guard = UV_ONCE_INIT; -static int kqueue_evfilt_user_support = 1; - - -static void uv__kqueue_runtime_detection(void) { - int kq; - struct kevent ev[2]; - struct timespec timeout = {0, 0}; - - /* Perform the runtime detection to ensure that kqueue with - * EVFILT_USER actually works. */ - kq = kqueue(); - EV_SET(ev, UV__KQUEUE_EVFILT_USER_IDENT, EVFILT_USER, - EV_ADD | EV_CLEAR, 0, 0, 0); - EV_SET(ev + 1, UV__KQUEUE_EVFILT_USER_IDENT, EVFILT_USER, - 0, NOTE_TRIGGER, 0, 0); - if (kevent(kq, ev, 2, ev, 1, &timeout) < 1 || - ev[0].filter != EVFILT_USER || - ev[0].ident != UV__KQUEUE_EVFILT_USER_IDENT || - ev[0].flags & EV_ERROR) - /* If we wind up here, we can assume that EVFILT_USER is defined but - * broken on the current system. */ - kqueue_evfilt_user_support = 0; - uv__close(kq); -} -#endif - static void uv__async_send(uv_loop_t* loop); static int uv__async_start(uv_loop_t* loop); static void uv__cpu_relax(void); @@ -159,10 +131,8 @@ void uv__async_close(uv_async_t* handle) { static void uv__async_io(uv_loop_t* loop, uv__io_t* w, unsigned int events) { -#ifndef __linux__ char buf[1024]; ssize_t r; -#endif struct uv__queue queue; struct uv__queue* q; uv_async_t* h; @@ -170,12 +140,7 @@ static void uv__async_io(uv_loop_t* loop, uv__io_t* w, unsigned int events) { assert(w == &loop->async_io_watcher); -#ifndef __linux__ -#if UV__KQUEUE_EVFILT_USER - for (;!kqueue_evfilt_user_support;) { -#else for (;;) { -#endif r = read(w->fd, buf, sizeof(buf)); if (r == sizeof(buf)) @@ -192,7 +157,6 @@ static void uv__async_io(uv_loop_t* loop, uv__io_t* w, unsigned int events) { abort(); } -#endif /* !__linux__ */ uv__queue_move(&loop->async_handles, &queue); while (!uv__queue_empty(&queue)) { @@ -216,58 +180,34 @@ static void uv__async_io(uv_loop_t* loop, uv__io_t* w, unsigned int events) { static void uv__async_send(uv_loop_t* loop) { + const void* buf; + ssize_t len; int fd; - ssize_t r; -#ifdef __linux__ - uint64_t val; - - fd = loop->async_io_watcher.fd; /* eventfd */ - for (val = 1; /* empty */; val = 1) { - r = write(fd, &val, sizeof(uint64_t)); - if (r < 0) { - /* When EAGAIN occurs, the eventfd counter hits the maximum value of the unsigned 64-bit. - * We need to first drain the eventfd and then write again. - * - * Check out https://man7.org/linux/man-pages/man2/eventfd.2.html for details. - */ - if (errno == EAGAIN) { - /* It's ready to retry. */ - if (read(fd, &val, sizeof(uint64_t)) > 0 || errno == EAGAIN) { - continue; - } - } - /* Unknown error occurs. */ - break; - } - return; - } -#else -#if UV__KQUEUE_EVFILT_USER - struct kevent ev; - - if (kqueue_evfilt_user_support) { - fd = loop->async_io_watcher.fd; /* magic number for EVFILT_USER */ - EV_SET(&ev, fd, EVFILT_USER, 0, NOTE_TRIGGER, 0, 0); - r = kevent(loop->backend_fd, &ev, 1, NULL, 0, NULL); - if (r == 0) - return; - else - abort(); + int r; + + buf = ""; + len = 1; + fd = loop->async_wfd; + +#if defined(__linux__) + if (fd == -1) { + static const uint64_t val = 1; + buf = &val; + len = sizeof(val); + fd = loop->async_io_watcher.fd; /* eventfd */ } #endif - fd = loop->async_wfd; /* write end of the pipe */ do - r = write(fd, "x", 1); + r = write(fd, buf, len); while (r == -1 && errno == EINTR); - if (r == 1) + if (r == len) return; if (r == -1) if (errno == EAGAIN || errno == EWOULDBLOCK) return; -#endif abort(); } @@ -276,9 +216,6 @@ static void uv__async_send(uv_loop_t* loop) { static int uv__async_start(uv_loop_t* loop) { int pipefd[2]; int err; -#if UV__KQUEUE_EVFILT_USER - struct kevent ev; -#endif if (loop->async_io_watcher.fd != -1) return 0; @@ -290,36 +227,6 @@ static int uv__async_start(uv_loop_t* loop) { pipefd[0] = err; pipefd[1] = -1; -#elif UV__KQUEUE_EVFILT_USER - uv_once(&kqueue_runtime_detection_guard, uv__kqueue_runtime_detection); - if (kqueue_evfilt_user_support) { - /* In order not to break the generic pattern of I/O polling, a valid - * file descriptor is required to take up a room in loop->watchers, - * thus we create one for that, but this fd will not be actually used, - * it's just a placeholder and magic number which is going to be closed - * during the cleanup, as other FDs. */ - err = uv__open_cloexec("/dev/null", O_RDONLY); - if (err < 0) - return err; - - pipefd[0] = err; - pipefd[1] = -1; - - /* When using EVFILT_USER event to wake up the kqueue, this event must be - * registered beforehand. Otherwise, calling kevent() to issue an - * unregistered EVFILT_USER event will get an ENOENT. - * Since uv__async_send() may happen before uv__io_poll() with multi-threads, - * we can't defer this registration of EVFILT_USER event as we did for other - * events, but must perform it right away. */ - EV_SET(&ev, err, EVFILT_USER, EV_ADD | EV_CLEAR, 0, 0, 0); - err = kevent(loop->backend_fd, &ev, 1, NULL, 0, NULL); - if (err < 0) - return UV__ERR(errno); - } else { - err = uv__make_pipe(pipefd, UV_NONBLOCK_PIPE); - if (err < 0) - return err; - } #else err = uv__make_pipe(pipefd, UV_NONBLOCK_PIPE); if (err < 0) @@ -330,13 +237,6 @@ static int uv__async_start(uv_loop_t* loop) { uv__io_start(loop, &loop->async_io_watcher, POLLIN); loop->async_wfd = pipefd[1]; -#if UV__KQUEUE_EVFILT_USER - /* Prevent the EVFILT_USER event from being added to kqueue redundantly - * and mistakenly later in uv__io_poll(). */ - if (kqueue_evfilt_user_support) - loop->async_io_watcher.events = loop->async_io_watcher.pevents; -#endif - return 0; } diff --git a/wpinet/src/main/native/thirdparty/libuv/src/unix/core.cpp b/wpinet/src/main/native/thirdparty/libuv/src/unix/core.cpp index 6c701c0c5a8..f13ffd1714a 100644 --- a/wpinet/src/main/native/thirdparty/libuv/src/unix/core.cpp +++ b/wpinet/src/main/native/thirdparty/libuv/src/unix/core.cpp @@ -54,8 +54,7 @@ #if defined(__APPLE__) # include -# include -#endif /* defined(__APPLE__) */ +# endif /* defined(__APPLE__) */ #if defined(__APPLE__) && !TARGET_OS_IPHONE @@ -96,15 +95,6 @@ extern char** environ; # define uv__accept4 accept4 #endif -#if defined(__FreeBSD__) -# include -# include -#endif - -#if defined(__NetBSD__) -# include -#endif - #if defined(__linux__) && defined(__SANITIZE_THREAD__) && defined(__clang__) # include #endif @@ -167,7 +157,7 @@ void uv_close(uv_handle_t* handle, uv_close_cb close_cb) { break; case UV_TTY: - uv__tty_close((uv_tty_t*)handle); + uv__stream_close((uv_stream_t*)handle); break; case UV_TCP: @@ -1635,7 +1625,6 @@ static int set_nice_for_calling_thread(int priority) { * If the function fails, the return value is non-zero. */ int uv_thread_setpriority(uv_thread_t tid, int priority) { -#if !defined(__GNU__) int r; int min; int max; @@ -1697,14 +1686,10 @@ int uv_thread_setpriority(uv_thread_t tid, int priority) { param.sched_priority = prio; r = pthread_setschedparam(tid, policy, ¶m); if (r != 0) - return UV__ERR(errno); + return UV__ERR(errno); } return 0; -#else /* !defined(__GNU__) */ - /* Simulate success on systems where thread priority is not implemented. */ - return 0; -#endif /* !defined(__GNU__) */ } int uv_os_uname(uv_utsname_t* buffer) { @@ -1888,31 +1873,11 @@ int uv__search_path(const char* prog, char* buf, size_t* buflen) { return UV_EINVAL; } -#if defined(__linux__) || defined (__FreeBSD__) -# define uv__cpu_count(cpuset) CPU_COUNT(cpuset) -#elif defined(__NetBSD__) -static int uv__cpu_count(cpuset_t *cpuset) { - int rc; - cpuid_t i; - - rc = 0; - for (i = 0;; i++) { - int r = cpuset_isset(cpu, set); - if (r < 0) - break; - if (r) - rc++; - } - - return rc; -} -#endif /* __NetBSD__ */ unsigned int uv_available_parallelism(void) { - long rc = -1; - #ifdef __linux__ cpu_set_t set; + long rc; memset(&set, 0, sizeof(set)); @@ -1921,127 +1886,29 @@ unsigned int uv_available_parallelism(void) { * before falling back to sysconf(_SC_NPROCESSORS_ONLN). */ if (0 == sched_getaffinity(0, sizeof(set), &set)) - rc = uv__cpu_count(&set); -#elif defined(__MVS__) - rc = __get_num_online_cpus(); + rc = CPU_COUNT(&set); + else + rc = sysconf(_SC_NPROCESSORS_ONLN); + if (rc < 1) rc = 1; return (unsigned) rc; -#elif defined(__FreeBSD__) - cpuset_t set; - - memset(&set, 0, sizeof(set)); - - if (0 == cpuset_getaffinity(CPU_LEVEL_WHICH, CPU_WHICH_PID, -1, sizeof(set), &set)) - rc = uv__cpu_count(&set); -#elif defined(__NetBSD__) - cpuset_t* set = cpuset_create(); - if (set != NULL) { - if (0 == sched_getaffinity_np(getpid(), sizeof(set), &set)) - rc = uv__cpu_count(&set); - cpuset_destroy(set); - } -#elif defined(__APPLE__) - int nprocs; - size_t i; - size_t len = sizeof(nprocs); - static const char *mib[] = { - "hw.activecpu", - "hw.logicalcpu", - "hw.ncpu" - }; - - for (i = 0; i < ARRAY_SIZE(mib); i++) { - if (0 == sysctlbyname(mib[i], &nprocs, &len, NULL, 0) && - len == sizeof(nprocs) && - nprocs > 0) { - rc = nprocs; - break; - } - } -#elif defined(__OpenBSD__) - int nprocs; - size_t i; - size_t len = sizeof(nprocs); - static int mib[][2] = { -# ifdef HW_NCPUONLINE - { CTL_HW, HW_NCPUONLINE }, -# endif - { CTL_HW, HW_NCPU } - }; - - for (i = 0; i < ARRAY_SIZE(mib); i++) { - if (0 == sysctl(mib[i], ARRAY_SIZE(mib[i]), &nprocs, &len, NULL, 0) && - len == sizeof(nprocs) && - nprocs > 0) { - rc = nprocs; - break; - } - } -#endif /* __linux__ */ - - if (rc < 0) - rc = sysconf(_SC_NPROCESSORS_ONLN); - -#ifdef __linux__ - { - double rc_with_cgroup; - uv__cpu_constraint c = {0, 0, 0.0}; - - if (uv__get_constrained_cpu(&c) == 0 && c.period_length > 0) { - rc_with_cgroup = (double)c.quota_per_period / c.period_length * c.proportions; - if (rc_with_cgroup < rc) - rc = (long)rc_with_cgroup; /* Casting is safe since rc_with_cgroup < rc < LONG_MAX */ - } - } -#endif /* __linux__ */ +#elif defined(__MVS__) + int rc; + rc = __get_num_online_cpus(); if (rc < 1) rc = 1; return (unsigned) rc; -} +#else /* __linux__ */ + long rc; -int uv__sock_reuseport(int fd) { - int on = 1; -#if defined(__FreeBSD__) && __FreeBSD__ >= 12 && defined(SO_REUSEPORT_LB) - /* FreeBSD 12 introduced a new socket option named SO_REUSEPORT_LB - * with the capability of load balancing, it's the substitution of - * the SO_REUSEPORTs on Linux and DragonFlyBSD. */ - if (setsockopt(fd, SOL_SOCKET, SO_REUSEPORT_LB, &on, sizeof(on))) - return UV__ERR(errno); -#elif (defined(__linux__) || \ - defined(_AIX73) || \ - (defined(__DragonFly__) && __DragonFly_version >= 300600) || \ - (defined(UV__SOLARIS_11_4) && UV__SOLARIS_11_4)) && \ - defined(SO_REUSEPORT) - /* On Linux 3.9+, the SO_REUSEPORT implementation distributes connections - * evenly across all of the threads (or processes) that are blocked in - * accept() on the same port. As with TCP, SO_REUSEPORT distributes datagrams - * evenly across all of the receiving threads (or process). - * - * DragonFlyBSD 3.6.0 extended SO_REUSEPORT to distribute workload to - * available sockets, which made it the equivalent of Linux's SO_REUSEPORT. - * - * AIX 7.2.5 added the feature that would add the capability to distribute - * incoming connections or datagrams across all listening ports for SO_REUSEPORT. - * - * Solaris 11 supported SO_REUSEPORT, but it's implemented only for - * binding to the same address and port, without load balancing. - * Solaris 11.4 extended SO_REUSEPORT with the capability of load balancing. - */ - if (setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, &on, sizeof(on))) - return UV__ERR(errno); -#else - (void) (fd); - (void) (on); - /* SO_REUSEPORTs do not have the capability of load balancing on platforms - * other than those mentioned above. The semantics are completely different, - * therefore we shouldn't enable it, but fail this operation to indicate that - * UV_[TCP/UDP]_REUSEPORT is not supported on these platforms. */ - return UV_ENOTSUP; -#endif + rc = sysconf(_SC_NPROCESSORS_ONLN); + if (rc < 1) + rc = 1; - return 0; + return (unsigned) rc; +#endif /* __linux__ */ } diff --git a/wpinet/src/main/native/thirdparty/libuv/src/unix/cygwin.cpp b/wpinet/src/main/native/thirdparty/libuv/src/unix/cygwin.cpp index 4913108223f..4e5413963d6 100644 --- a/wpinet/src/main/native/thirdparty/libuv/src/unix/cygwin.cpp +++ b/wpinet/src/main/native/thirdparty/libuv/src/unix/cygwin.cpp @@ -36,45 +36,9 @@ int uv_uptime(double* uptime) { } int uv_resident_set_memory(size_t* rss) { - char buf[1024]; - const char* s; - long val; - int rc; - int i; - struct sysinfo si; - - /* rss: 24th element */ - rc = uv__slurp("/proc/self/stat", buf, sizeof(buf)); - if (rc < 0) - return rc; - - /* find the last ')' */ - s = strrchr(buf, ')'); - if (s == NULL) - goto err; - - for (i = 1; i <= 22; i++) { - s = strchr(s + 1, ' '); - if (s == NULL) - goto err; - } - - errno = 0; - val = strtol(s, NULL, 10); - if (val < 0 || errno != 0) - goto err; - - do - rc = sysinfo(&si); - while (rc == -1 && errno == EINTR); - if (rc == -1) - return UV__ERR(errno); - - *rss = val * si.mem_unit; + /* FIXME: read /proc/meminfo? */ + *rss = 0; return 0; - -err: - return UV_EINVAL; } int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) { diff --git a/wpinet/src/main/native/thirdparty/libuv/src/unix/darwin-syscalls.h b/wpinet/src/main/native/thirdparty/libuv/src/unix/darwin-syscalls.h deleted file mode 100644 index 851af81c74e..00000000000 --- a/wpinet/src/main/native/thirdparty/libuv/src/unix/darwin-syscalls.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef UV_DARWIN_SYSCALLS_H_ -#define UV_DARWIN_SYSCALLS_H_ - -#include -#include - -/* https://github.com/apple/darwin-xnu/blob/master/bsd/sys/socket.h */ - -struct mmsghdr { - struct msghdr msg_hdr; - size_t msg_len; -}; - -extern "C" { -ssize_t recvmsg_x(int s, const struct mmsghdr* msgp, u_int cnt, int flags); -ssize_t sendmsg_x(int s, const struct mmsghdr* msgp, u_int cnt, int flags); -} - -#endif /* UV_DARWIN_SYSCALLS_H_ */ diff --git a/wpinet/src/main/native/thirdparty/libuv/src/unix/darwin.cpp b/wpinet/src/main/native/thirdparty/libuv/src/unix/darwin.cpp index b1657a2ffda..dc93d236b6b 100644 --- a/wpinet/src/main/native/thirdparty/libuv/src/unix/darwin.cpp +++ b/wpinet/src/main/native/thirdparty/libuv/src/unix/darwin.cpp @@ -25,6 +25,7 @@ #include #include +#include #include #include #include /* _NSGetExecutablePath */ @@ -33,6 +34,7 @@ #include /* sysconf */ static uv_once_t once = UV_ONCE_INIT; +static uint64_t (*time_func)(void); static mach_timebase_info_data_t timebase; @@ -54,12 +56,16 @@ void uv__platform_loop_delete(uv_loop_t* loop) { static void uv__hrtime_init_once(void) { if (KERN_SUCCESS != mach_timebase_info(&timebase)) abort(); + + time_func = (uint64_t (*)(void)) dlsym(RTLD_DEFAULT, "mach_continuous_time"); + if (time_func == NULL) + time_func = mach_absolute_time; } uint64_t uv__hrtime(uv_clocktype_t type) { uv_once(&once, uv__hrtime_init_once); - return mach_continuous_time() * timebase.numer / timebase.denom; + return time_func() * timebase.numer / timebase.denom; } diff --git a/wpinet/src/main/native/thirdparty/libuv/src/unix/freebsd.cpp b/wpinet/src/main/native/thirdparty/libuv/src/unix/freebsd.cpp index 8fb03c7803c..1bd63886b82 100644 --- a/wpinet/src/main/native/thirdparty/libuv/src/unix/freebsd.cpp +++ b/wpinet/src/main/native/thirdparty/libuv/src/unix/freebsd.cpp @@ -26,12 +26,7 @@ #include #include -#if defined(__DragonFly__) -# include -# include -#else -# include -#endif +#include #include #include #include diff --git a/wpinet/src/main/native/thirdparty/libuv/src/unix/fs.cpp b/wpinet/src/main/native/thirdparty/libuv/src/unix/fs.cpp index 49a7d52b565..75c3093cb7c 100644 --- a/wpinet/src/main/native/thirdparty/libuv/src/unix/fs.cpp +++ b/wpinet/src/main/native/thirdparty/libuv/src/unix/fs.cpp @@ -84,6 +84,17 @@ # include #endif +#if defined(__CYGWIN__) || \ + (defined(__HAIKU__) && B_HAIKU_VERSION < B_HAIKU_VERSION_1_PRE_BETA_5) || \ + (defined(__sun) && !defined(__illumos__)) || \ + (defined(__APPLE__) && !TARGET_OS_IPHONE && \ + MAC_OS_X_VERSION_MIN_REQUIRED < 110000) +#define preadv(fd, bufs, nbufs, off) \ + pread(fd, (bufs)->iov_base, (bufs)->iov_len, off) +#define pwritev(fd, bufs, nbufs, off) \ + pwrite(fd, (bufs)->iov_base, (bufs)->iov_len, off) +#endif + #if defined(_AIX) && _XOPEN_SOURCE <= 600 extern char *mkdtemp(char *template); /* See issue #740 on AIX < 7 */ #endif @@ -140,7 +151,7 @@ extern char *mkdtemp(char *template); /* See issue #740 on AIX < 7 */ #define POST \ do { \ if (cb != NULL) { \ - uv__req_register(loop); \ + uv__req_register(loop, req); \ uv__work_submit(loop, \ &req->work_req, \ UV__WORK_FAST_IO, \ @@ -397,118 +408,6 @@ static ssize_t uv__fs_open(uv_fs_t* req) { } -static ssize_t uv__preadv_or_pwritev_emul(int fd, - const struct iovec* bufs, - size_t nbufs, - off_t off, - int is_pread) { - ssize_t total; - ssize_t r; - size_t i; - size_t n; - void* p; - - total = 0; - for (i = 0; i < (size_t) nbufs; i++) { - p = bufs[i].iov_base; - n = bufs[i].iov_len; - - do - if (is_pread) - r = pread(fd, p, n, off); - else - r = pwrite(fd, p, n, off); - while (r == -1 && errno == EINTR); - - if (r == -1) { - if (total > 0) - return total; - return -1; - } - - off += r; - total += r; - - if ((size_t) r < n) - return total; - } - - return total; -} - - -#ifdef __linux__ -typedef int uv__iovcnt; -#else -typedef size_t uv__iovcnt; -#endif - - -static ssize_t uv__preadv_emul(int fd, - const struct iovec* bufs, - uv__iovcnt nbufs, - off_t off) { - return uv__preadv_or_pwritev_emul(fd, bufs, nbufs, off, /*is_pread*/1); -} - - -static ssize_t uv__pwritev_emul(int fd, - const struct iovec* bufs, - uv__iovcnt nbufs, - off_t off) { - return uv__preadv_or_pwritev_emul(fd, bufs, nbufs, off, /*is_pread*/0); -} - - -/* The function pointer cache is an uintptr_t because std::atomic* - * doesn't work on macos/ios/etc... - */ -static ssize_t uv__preadv_or_pwritev(int fd, - const struct iovec* bufs, - size_t nbufs, - off_t off, - std::atomic* cache, - int is_pread) { - ssize_t (*f)(int, const struct iovec*, uv__iovcnt, off_t); - void* p; - - p = (void*) atomic_load_explicit(cache, std::memory_order_relaxed); - if (p == NULL) { -#ifdef RTLD_DEFAULT - p = dlsym(RTLD_DEFAULT, is_pread ? "preadv" : "pwritev"); - dlerror(); /* Clear errors. */ -#endif /* RTLD_DEFAULT */ - if (p == NULL) - p = (void*)(is_pread ? uv__preadv_emul : uv__pwritev_emul); - atomic_store_explicit(cache, (uintptr_t) p, std::memory_order_relaxed); - } - - /* Use memcpy instead of `f = p` to work around a compiler bug, - * see https://github.com/libuv/libuv/issues/4532 - */ - memcpy(&f, &p, sizeof(p)); - return f(fd, bufs, nbufs, off); -} - - -static ssize_t uv__preadv(int fd, - const struct iovec* bufs, - size_t nbufs, - off_t off) { - static std::atomic cache; - return uv__preadv_or_pwritev(fd, bufs, nbufs, off, &cache, /*is_pread*/1); -} - - -static ssize_t uv__pwritev(int fd, - const struct iovec* bufs, - size_t nbufs, - off_t off) { - static std::atomic cache; - return uv__preadv_or_pwritev(fd, bufs, nbufs, off, &cache, /*is_pread*/0); -} - - static ssize_t uv__fs_read(uv_fs_t* req) { const struct iovec* bufs; unsigned int iovmax; @@ -536,7 +435,7 @@ static ssize_t uv__fs_read(uv_fs_t* req) { if (nbufs == 1) r = pread(fd, bufs->iov_base, bufs->iov_len, off); else if (nbufs > 1) - r = uv__preadv(fd, bufs, nbufs, off); + r = preadv(fd, bufs, nbufs, off); } #ifdef __PASE__ @@ -794,23 +693,14 @@ static ssize_t uv__fs_readlink(uv_fs_t* req) { static ssize_t uv__fs_realpath(uv_fs_t* req) { char* buf; - char* tmp; #if defined(_POSIX_VERSION) && _POSIX_VERSION >= 200809L - tmp = realpath(req->path, NULL); - if (tmp == NULL) + buf = realpath(req->path, NULL); + if (buf == NULL) return -1; - buf = uv__strdup(tmp); - free(tmp); /* _Not_ uv__free. */ - if (buf == NULL) { - errno = ENOMEM; - return -1; - } #else ssize_t len; - (void)tmp; - len = uv__fs_pathmax_size(req->path); buf = (char*)uv__malloc(len + 1); @@ -1074,10 +964,7 @@ static ssize_t uv__fs_sendfile(uv_fs_t* req) { return -1; } -/* sendfile() on iOS(arm64) will throw SIGSYS signal cause crash. */ -#elif (defined(__APPLE__) && !TARGET_OS_IPHONE) \ - || defined(__DragonFly__) \ - || defined(__FreeBSD__) +#elif defined(__APPLE__) || defined(__DragonFly__) || defined(__FreeBSD__) { off_t len; ssize_t r; @@ -1227,7 +1114,7 @@ static ssize_t uv__fs_write(uv_fs_t* req) { if (nbufs == 1) r = pwrite(fd, bufs->iov_base, bufs->iov_len, off); else if (nbufs > 1) - r = uv__pwritev(fd, bufs, nbufs, off); + r = pwritev(fd, bufs, nbufs, off); } return r; @@ -1240,7 +1127,6 @@ static ssize_t uv__fs_copyfile(uv_fs_t* req) { uv_file dstfd; struct stat src_statsbuf; struct stat dst_statsbuf; - struct timespec times[2]; int dst_flags; int result; int err; @@ -1318,35 +1204,6 @@ static ssize_t uv__fs_copyfile(uv_fs_t* req) { } } - /** - * Change the timestamps of the destination file to match the source file. - */ -#if defined(__APPLE__) - times[0] = src_statsbuf.st_atimespec; - times[1] = src_statsbuf.st_mtimespec; -#elif defined(_AIX) - times[0].tv_sec = src_statsbuf.st_atime; - times[0].tv_nsec = src_statsbuf.st_atime_n; - times[1].tv_sec = src_statsbuf.st_mtime; - times[1].tv_nsec = src_statsbuf.st_mtime_n; -#else - times[0] = src_statsbuf.st_atim; - times[1] = src_statsbuf.st_mtim; -#endif - - if (futimens(dstfd, times) == -1) { - err = UV__ERR(errno); - goto out; - } - - /* - * Change the ownership and permissions of the destination file to match the - * source file. - * `cp -p` does not care about errors here, so we don't either. Reuse the - * `result` variable to silence a -Wunused-result warning. - */ - result = fchown(dstfd, src_statsbuf.st_uid, src_statsbuf.st_gid); - if (fchmod(dstfd, src_statsbuf.st_mode) == -1) { err = UV__ERR(errno); #ifdef __linux__ @@ -1764,7 +1621,7 @@ static void uv__fs_done(struct uv__work* w, int status) { uv_fs_t* req; req = container_of(w, uv_fs_t, work_req); - uv__req_unregister(req->loop); + uv__req_unregister(req->loop, req); if (status == UV_ECANCELED) { assert(req->result == 0); @@ -1776,7 +1633,7 @@ static void uv__fs_done(struct uv__work* w, int status) { void uv__fs_post(uv_loop_t* loop, uv_fs_t* req) { - uv__req_register(loop); + uv__req_register(loop, req); uv__work_submit(loop, &req->work_req, UV__WORK_FAST_IO, diff --git a/wpinet/src/main/native/thirdparty/libuv/src/unix/fsevents.cpp b/wpinet/src/main/native/thirdparty/libuv/src/unix/fsevents.cpp index 0d1c9ebad6f..c31d08ba37c 100644 --- a/wpinet/src/main/native/thirdparty/libuv/src/unix/fsevents.cpp +++ b/wpinet/src/main/native/thirdparty/libuv/src/unix/fsevents.cpp @@ -276,6 +276,10 @@ static void uv__fsevents_event_cb(const FSEventStreamRef streamRef, path += handle->realpath_len; len -= handle->realpath_len; + /* Ignore events with path equal to directory itself */ + if (len <= 1 && (flags & kFSEventStreamEventFlagItemIsDir)) + continue; + if (len == 0) { /* Since we're using fsevents to watch the file itself, * realpath == path, and we now need to get the basename of the file back @@ -789,7 +793,6 @@ int uv__cf_loop_signal(uv_loop_t* loop, /* Runs in UV loop to initialize handle */ int uv__fsevents_init(uv_fs_event_t* handle) { - char* buf; int err; uv__cf_loop_state_t* state; @@ -798,13 +801,9 @@ int uv__fsevents_init(uv_fs_event_t* handle) { return err; /* Get absolute path to file */ - buf = realpath(handle->path, NULL); - if (buf == NULL) - return UV__ERR(errno); - handle->realpath = uv__strdup(buf); - free(buf); /* _Not_ uv__free. */ + handle->realpath = realpath(handle->path, NULL); if (handle->realpath == NULL) - return UV_ENOMEM; + return UV__ERR(errno); handle->realpath_len = strlen(handle->realpath); /* Initialize event queue */ diff --git a/wpinet/src/main/native/thirdparty/libuv/src/unix/getaddrinfo.cpp b/wpinet/src/main/native/thirdparty/libuv/src/unix/getaddrinfo.cpp index 5a205d0ebd8..41dc3909969 100644 --- a/wpinet/src/main/native/thirdparty/libuv/src/unix/getaddrinfo.cpp +++ b/wpinet/src/main/native/thirdparty/libuv/src/unix/getaddrinfo.cpp @@ -109,7 +109,7 @@ static void uv__getaddrinfo_done(struct uv__work* w, int status) { uv_getaddrinfo_t* req; req = container_of(w, uv_getaddrinfo_t, work_req); - uv__req_unregister(req->loop); + uv__req_unregister(req->loop, req); /* See initialization in uv_getaddrinfo(). */ if (req->hints) diff --git a/wpinet/src/main/native/thirdparty/libuv/src/unix/getnameinfo.cpp b/wpinet/src/main/native/thirdparty/libuv/src/unix/getnameinfo.cpp index 959b4c6a821..991002a67d7 100644 --- a/wpinet/src/main/native/thirdparty/libuv/src/unix/getnameinfo.cpp +++ b/wpinet/src/main/native/thirdparty/libuv/src/unix/getnameinfo.cpp @@ -58,7 +58,7 @@ static void uv__getnameinfo_done(struct uv__work* w, int status) { char* service; req = container_of(w, uv_getnameinfo_t, work_req); - uv__req_unregister(req->loop); + uv__req_unregister(req->loop, req); host = service = NULL; if (status == UV_ECANCELED) { diff --git a/wpinet/src/main/native/thirdparty/libuv/src/unix/internal.h b/wpinet/src/main/native/thirdparty/libuv/src/unix/internal.h index c1ead096f7d..35ac6d1f6da 100644 --- a/wpinet/src/main/native/thirdparty/libuv/src/unix/internal.h +++ b/wpinet/src/main/native/thirdparty/libuv/src/unix/internal.h @@ -35,10 +35,6 @@ #include #include #include -#if defined(__APPLE__) || defined(__DragonFly__) || \ - defined(__FreeBSD__) || defined(__NetBSD__) -#include -#endif #define uv__msan_unpoison(p, n) \ do { \ @@ -75,11 +71,8 @@ # include #endif /* _AIX */ -#if defined(__APPLE__) -# include "darwin-syscalls.h" -# if !TARGET_OS_IPHONE -# include -# endif +#if defined(__APPLE__) && !TARGET_OS_IPHONE +# include #endif /* @@ -164,8 +157,7 @@ typedef struct uv__stream_queued_fds_s uv__stream_queued_fds_t; /* loop flags */ enum { UV_LOOP_BLOCK_SIGPROF = 0x1, - UV_LOOP_REAP_CHILDREN = 0x2, - UV_LOOP_ENABLE_IO_URING_SQPOLL = 0x4 + UV_LOOP_REAP_CHILDREN = 0x2 }; /* flags of excluding ifaddr */ @@ -253,7 +245,6 @@ int uv__close(int fd); /* preserves errno */ int uv__close_nocheckstdio(int fd); int uv__close_nocancel(int fd); int uv__socket(int domain, int type, int protocol); -int uv__sock_reuseport(int fd); ssize_t uv__recvmsg(int fd, struct msghdr *msg, int flags); void uv__make_close_pending(uv_handle_t* handle); int uv__getiovmax(void); @@ -298,9 +289,6 @@ int uv__tcp_listen(uv_tcp_t* tcp, int backlog, uv_connection_cb cb); int uv__tcp_nodelay(int fd, int on); int uv__tcp_keepalive(int fd, int on, unsigned int delay); -/* tty */ -void uv__tty_close(uv_tty_t* handle); - /* pipe */ int uv__pipe_listen(uv_pipe_t* handle, int backlog, uv_connection_cb cb); @@ -486,44 +474,4 @@ uv__fs_copy_file_range(int fd_in, #define UV__CPU_AFFINITY_SUPPORTED 0 #endif -#ifdef __linux__ -typedef struct { - long long quota_per_period; - long long period_length; - double proportions; -} uv__cpu_constraint; - -int uv__get_constrained_cpu(uv__cpu_constraint* constraint); -#endif - -#ifdef __sun -#ifdef SO_FLOW_NAME -/* Since it's impossible to detect the Solaris 11.4 version via OS macros, - * so we check the presence of the socket option SO_FLOW_NAME that was first - * introduced to Solaris 11.4 and define a custom macro for determining 11.4. - */ -#define UV__SOLARIS_11_4 (1) -#else -#define UV__SOLARIS_11_4 (0) -#endif -#endif - -#if defined(EVFILT_USER) && defined(NOTE_TRIGGER) -/* EVFILT_USER is available since OS X 10.6, DragonFlyBSD 4.0, - * FreeBSD 8.1, and NetBSD 10.0. - * - * Note that even though EVFILT_USER is defined on the current system, - * it may still fail to work at runtime somehow. In that case, we fall - * back to pipe-based signaling. - */ -#define UV__KQUEUE_EVFILT_USER 1 -/* Magic number of identifier used for EVFILT_USER during runtime detection. - * There are no Google hits for this number when I create it. That way, - * people will be directed here if this number gets printed due to some - * kqueue error and they google for help. */ -#define UV__KQUEUE_EVFILT_USER_IDENT 0x1e7e7711 -#else -#define UV__KQUEUE_EVFILT_USER 0 -#endif - #endif /* UV_UNIX_INTERNAL_H_ */ diff --git a/wpinet/src/main/native/thirdparty/libuv/src/unix/kqueue.cpp b/wpinet/src/main/native/thirdparty/libuv/src/unix/kqueue.cpp index 6f0e06476a6..bd09ac39dda 100644 --- a/wpinet/src/main/native/thirdparty/libuv/src/unix/kqueue.cpp +++ b/wpinet/src/main/native/thirdparty/libuv/src/unix/kqueue.cpp @@ -101,39 +101,6 @@ int uv__io_fork(uv_loop_t* loop) { int uv__io_check_fd(uv_loop_t* loop, int fd) { struct kevent ev; int rc; - struct stat sb; -#ifdef __APPLE__ - char path[MAXPATHLEN]; -#endif - - if (uv__fstat(fd, &sb)) - return UV__ERR(errno); - - /* On FreeBSD, kqueue only supports EVFILT_READ notification for regular files - * and always reports ready events for writing, resulting in busy-looping. - * - * On Darwin, DragonFlyBSD, NetBSD and OpenBSD, kqueue reports ready events for - * regular files as readable and writable only once, acting like an EV_ONESHOT. - * - * Neither of the above cases should be added to the kqueue. - */ - if (S_ISREG(sb.st_mode) || S_ISDIR(sb.st_mode)) - return UV_EINVAL; - -#ifdef __APPLE__ - /* On Darwin (both macOS and iOS), in addition to regular files, FIFOs also don't - * work properly with kqueue: the disconnection from the last writer won't trigger - * an event for kqueue in spite of what the man pages say. Thus, we also disallow - * the case of S_IFIFO. */ - if (S_ISFIFO(sb.st_mode)) { - /* File descriptors of FIFO, pipe and kqueue share the same type of file, - * therefore there is no way to tell them apart via stat.st_mode&S_IFMT. - * Fortunately, FIFO is the only one that has a persisted file on filesystem, - * from which we're able to make the distinction for it. */ - if (!fcntl(fd, F_GETPATH, path)) - return UV_EINVAL; - } -#endif rc = 0; EV_SET(&ev, fd, EVFILT_READ, EV_ADD, 0, 0, 0); @@ -369,17 +336,6 @@ void uv__io_poll(uv_loop_t* loop, int timeout) { continue; } -#if UV__KQUEUE_EVFILT_USER - if (ev->filter == EVFILT_USER) { - w = &loop->async_io_watcher; - assert(fd == w->fd); - uv__metrics_update_idle_time(loop); - w->cb(loop, w, w->events); - nevents++; - continue; - } -#endif - if (ev->filter == EVFILT_VNODE) { assert(w->events == POLLIN); assert(w->pevents == POLLIN); diff --git a/wpinet/src/main/native/thirdparty/libuv/src/unix/linux.cpp b/wpinet/src/main/native/thirdparty/libuv/src/unix/linux.cpp index 322873f6f0e..091c0474cfe 100644 --- a/wpinet/src/main/native/thirdparty/libuv/src/unix/linux.cpp +++ b/wpinet/src/main/native/thirdparty/libuv/src/unix/linux.cpp @@ -623,7 +623,7 @@ static void uv__iou_init(int epollfd, static void uv__iou_delete(struct uv__iou* iou) { - if (iou->ringfd > -1) { + if (iou->ringfd != -1) { munmap(iou->sq, iou->maxlen); munmap(iou->sqe, iou->sqelen); uv__close(iou->ringfd); @@ -637,7 +637,7 @@ int uv__platform_loop_init(uv_loop_t* loop) { lfields = uv__get_internal_fields(loop); lfields->ctl.ringfd = -1; - lfields->iou.ringfd = -2; /* "uninitialized" */ + lfields->iou.ringfd = -1; loop->inotify_watchers = NULL; loop->inotify_fd = -1; @@ -646,6 +646,7 @@ int uv__platform_loop_init(uv_loop_t* loop) { if (loop->backend_fd == -1) return UV__ERR(errno); + uv__iou_init(loop->backend_fd, &lfields->iou, 64, UV__IORING_SETUP_SQPOLL); uv__iou_init(loop->backend_fd, &lfields->ctl, 256, 0); return 0; @@ -713,17 +714,23 @@ void uv__platform_invalidate_fd(uv_loop_t* loop, int fd) { * This avoids a problem where the same file description remains open * in another process, causing repeated junk epoll events. * - * Perform EPOLL_CTL_DEL immediately instead of going through - * io_uring's submit queue, otherwise the file descriptor may - * be closed by the time the kernel starts the operation. - * * We pass in a dummy epoll_event, to work around a bug in old kernels. * * Work around a bug in kernels 3.10 to 3.19 where passing a struct that * has the EPOLLWAKEUP flag set generates spurious audit syslog warnings. */ memset(&dummy, 0, sizeof(dummy)); - epoll_ctl(loop->backend_fd, EPOLL_CTL_DEL, fd, &dummy); + + if (inv == NULL) { + epoll_ctl(loop->backend_fd, EPOLL_CTL_DEL, fd, &dummy); + } else { + uv__epoll_ctl_prep(loop->backend_fd, + &lfields->ctl, + inv->prep, + EPOLL_CTL_DEL, + fd, + &dummy); + } } @@ -758,23 +765,6 @@ static struct uv__io_uring_sqe* uv__iou_get_sqe(struct uv__iou* iou, uint32_t mask; uint32_t slot; - /* Lazily create the ring. State machine: -2 means uninitialized, -1 means - * initialization failed. Anything else is a valid ring file descriptor. - */ - if (iou->ringfd == -2) { - /* By default, the SQPOLL is not created. Enable only if the loop is - * configured with UV_LOOP_USE_IO_URING_SQPOLL. - */ - if ((loop->flags & UV_LOOP_ENABLE_IO_URING_SQPOLL) == 0) { - iou->ringfd = -1; - return NULL; - } - - uv__iou_init(loop->backend_fd, iou, 64, UV__IORING_SETUP_SQPOLL); - if (iou->ringfd == -2) - iou->ringfd = -1; /* "failed" */ - } - if (iou->ringfd == -1) return NULL; @@ -798,7 +788,7 @@ static struct uv__io_uring_sqe* uv__iou_get_sqe(struct uv__iou* iou, req->work_req.done = NULL; uv__queue_init(&req->work_req.wq); - uv__req_register(loop); + uv__req_register(loop, req); iou->in_flight++; return sqe; @@ -1166,7 +1156,7 @@ static void uv__poll_io_uring(uv_loop_t* loop, struct uv__iou* iou) { req = (uv_fs_t*) (uintptr_t) e->user_data; assert(req->type == UV_FS); - uv__req_unregister(loop); + uv__req_unregister(loop, req); iou->in_flight--; /* If the op is not supported by the kernel retry using the thread pool */ @@ -1218,10 +1208,6 @@ static void uv__poll_io_uring(uv_loop_t* loop, struct uv__iou* iou) { } -/* Only for EPOLL_CTL_ADD and EPOLL_CTL_MOD. EPOLL_CTL_DEL should always be - * executed immediately, otherwise the file descriptor may have been closed - * by the time the kernel starts the operation. - */ static void uv__epoll_ctl_prep(int epollfd, struct uv__iou* ctl, struct epoll_event (*events)[256], @@ -1233,28 +1219,45 @@ static void uv__epoll_ctl_prep(int epollfd, uint32_t mask; uint32_t slot; - assert(op == EPOLL_CTL_ADD || op == EPOLL_CTL_MOD); - assert(ctl->ringfd != -1); + if (ctl->ringfd == -1) { + if (!epoll_ctl(epollfd, op, fd, e)) + return; - mask = ctl->sqmask; - slot = (*ctl->sqtail)++ & mask; + if (op == EPOLL_CTL_DEL) + return; /* Ignore errors, may be racing with another thread. */ - pe = &(*events)[slot]; - *pe = *e; + if (op != EPOLL_CTL_ADD) + abort(); - sqe = (uv__io_uring_sqe*)ctl->sqe; - sqe = &sqe[slot]; + if (errno != EEXIST) + abort(); - memset(sqe, 0, sizeof(*sqe)); - sqe->addr = (uintptr_t) pe; - sqe->fd = epollfd; - sqe->len = op; - sqe->off = fd; - sqe->opcode = UV__IORING_OP_EPOLL_CTL; - sqe->user_data = op | slot << 2 | (int64_t) fd << 32; + /* File descriptor that's been watched before, update event mask. */ + if (!epoll_ctl(epollfd, EPOLL_CTL_MOD, fd, e)) + return; + + abort(); + } else { + mask = ctl->sqmask; + slot = (*ctl->sqtail)++ & mask; + + pe = &(*events)[slot]; + *pe = *e; - if ((*ctl->sqhead & mask) == (*ctl->sqtail & mask)) - uv__epoll_ctl_flush(epollfd, ctl, events); + sqe = (uv__io_uring_sqe*)ctl->sqe; + sqe = &sqe[slot]; + + memset(sqe, 0, sizeof(*sqe)); + sqe->addr = (uintptr_t) pe; + sqe->fd = epollfd; + sqe->len = op; + sqe->off = fd; + sqe->opcode = UV__IORING_OP_EPOLL_CTL; + sqe->user_data = op | slot << 2 | (int64_t) fd << 32; + + if ((*ctl->sqhead & mask) == (*ctl->sqtail & mask)) + uv__epoll_ctl_flush(epollfd, ctl, events); + } } @@ -1394,29 +1397,9 @@ void uv__io_poll(uv_loop_t* loop, int timeout) { w->events = w->pevents; e.events = w->pevents; - if (w == &loop->async_io_watcher) - /* Enable edge-triggered mode on async_io_watcher(eventfd), - * so that we're able to eliminate the overhead of reading - * the eventfd via system call on each event loop wakeup. - */ - e.events |= EPOLLET; e.data.fd = w->fd; - fd = w->fd; - - if (ctl->ringfd != -1) { - uv__epoll_ctl_prep(epollfd, ctl, &prep, op, fd, &e); - continue; - } - if (!epoll_ctl(epollfd, op, fd, &e)) - continue; - - assert(op == EPOLL_CTL_ADD); - assert(errno == EEXIST); - - /* File descriptor that's been watched before, update event mask. */ - if (epoll_ctl(epollfd, EPOLL_CTL_MOD, fd, &e)) - abort(); + uv__epoll_ctl_prep(epollfd, ctl, &prep, op, w->fd, &e); } inv.events = events; @@ -1504,12 +1487,8 @@ void uv__io_poll(uv_loop_t* loop, int timeout) { * * Ignore all errors because we may be racing with another thread * when the file descriptor is closed. - * - * Perform EPOLL_CTL_DEL immediately instead of going through - * io_uring's submit queue, otherwise the file descriptor may - * be closed by the time the kernel starts the operation. */ - epoll_ctl(epollfd, EPOLL_CTL_DEL, fd, pe); + uv__epoll_ctl_prep(epollfd, ctl, &prep, EPOLL_CTL_DEL, fd, pe); continue; } @@ -1644,17 +1623,36 @@ uint64_t uv__hrtime(uv_clocktype_t type) { int uv_resident_set_memory(size_t* rss) { char buf[1024]; const char* s; + ssize_t n; long val; - int rc; + int fd; int i; - /* rss: 24th element */ - rc = uv__slurp("/proc/self/stat", buf, sizeof(buf)); - if (rc < 0) - return rc; + do + fd = open("/proc/self/stat", O_RDONLY); + while (fd == -1 && errno == EINTR); + + if (fd == -1) + return UV__ERR(errno); + + do + n = read(fd, buf, sizeof(buf) - 1); + while (n == -1 && errno == EINTR); + + uv__close(fd); + if (n == -1) + return UV__ERR(errno); + buf[n] = '\0'; + + s = strchr(buf, ' '); + if (s == NULL) + goto err; + + s += 1; + if (*s != '(') + goto err; - /* find the last ')' */ - s = strrchr(buf, ')'); + s = strchr(s, ')'); if (s == NULL) goto err; @@ -1666,7 +1664,9 @@ int uv_resident_set_memory(size_t* rss) { errno = 0; val = strtol(s, NULL, 10); - if (val < 0 || errno != 0) + if (errno != 0) + goto err; + if (val < 0) goto err; *rss = val * getpagesize(); @@ -2271,136 +2271,6 @@ uint64_t uv_get_available_memory(void) { } -static int uv__get_cgroupv2_constrained_cpu(const char* cgroup, - uv__cpu_constraint* constraint) { - char path[256]; - char buf[1024]; - unsigned int weight; - int cgroup_size; - const char* cgroup_trimmed; - char quota_buf[16]; - - if (strncmp(cgroup, "0::/", 4) != 0) - return UV_EINVAL; - - /* Trim ending \n by replacing it with a 0 */ - cgroup_trimmed = cgroup + sizeof("0::/") - 1; /* Skip the prefix "0::/" */ - cgroup_size = (int)strcspn(cgroup_trimmed, "\n"); /* Find the first slash */ - - /* Construct the path to the cpu.max file */ - snprintf(path, sizeof(path), "/sys/fs/cgroup/%.*s/cpu.max", cgroup_size, - cgroup_trimmed); - - /* Read cpu.max */ - if (uv__slurp(path, buf, sizeof(buf)) < 0) - return UV_EIO; - - if (sscanf(buf, "%15s %lld", quota_buf, &constraint->period_length) != 2) - return UV_EINVAL; - - if (strncmp(quota_buf, "max", 3) == 0) - constraint->quota_per_period = LLONG_MAX; - else if (sscanf(quota_buf, "%lld", &constraint->quota_per_period) != 1) - return UV_EINVAL; // conversion failed - - /* Construct the path to the cpu.weight file */ - snprintf(path, sizeof(path), "/sys/fs/cgroup/%.*s/cpu.weight", cgroup_size, - cgroup_trimmed); - - /* Read cpu.weight */ - if (uv__slurp(path, buf, sizeof(buf)) < 0) - return UV_EIO; - - if (sscanf(buf, "%u", &weight) != 1) - return UV_EINVAL; - - constraint->proportions = (double)weight / 100.0; - - return 0; -} - -static char* uv__cgroup1_find_cpu_controller(const char* cgroup, - int* cgroup_size) { - /* Seek to the cpu controller line. */ - char* cgroup_cpu = (char*)strstr(cgroup, ":cpu,"); - - if (cgroup_cpu != NULL) { - /* Skip the controller prefix to the start of the cgroup path. */ - cgroup_cpu += sizeof(":cpu,") - 1; - /* Determine the length of the cgroup path, excluding the newline. */ - *cgroup_size = (int)strcspn(cgroup_cpu, "\n"); - } - - return cgroup_cpu; -} - -static int uv__get_cgroupv1_constrained_cpu(const char* cgroup, - uv__cpu_constraint* constraint) { - char path[256]; - char buf[1024]; - unsigned int shares; - int cgroup_size; - char* cgroup_cpu; - - cgroup_cpu = uv__cgroup1_find_cpu_controller(cgroup, &cgroup_size); - - if (cgroup_cpu == NULL) - return UV_EIO; - - /* Construct the path to the cpu.cfs_quota_us file */ - snprintf(path, sizeof(path), "/sys/fs/cgroup/%.*s/cpu.cfs_quota_us", - cgroup_size, cgroup_cpu); - - if (uv__slurp(path, buf, sizeof(buf)) < 0) - return UV_EIO; - - if (sscanf(buf, "%lld", &constraint->quota_per_period) != 1) - return UV_EINVAL; - - /* Construct the path to the cpu.cfs_period_us file */ - snprintf(path, sizeof(path), "/sys/fs/cgroup/%.*s/cpu.cfs_period_us", - cgroup_size, cgroup_cpu); - - /* Read cpu.cfs_period_us */ - if (uv__slurp(path, buf, sizeof(buf)) < 0) - return UV_EIO; - - if (sscanf(buf, "%lld", &constraint->period_length) != 1) - return UV_EINVAL; - - /* Construct the path to the cpu.shares file */ - snprintf(path, sizeof(path), "/sys/fs/cgroup/%.*s/cpu.shares", cgroup_size, - cgroup_cpu); - - /* Read cpu.shares */ - if (uv__slurp(path, buf, sizeof(buf)) < 0) - return UV_EIO; - - if (sscanf(buf, "%u", &shares) != 1) - return UV_EINVAL; - - constraint->proportions = (double)shares / 1024.0; - - return 0; -} - -int uv__get_constrained_cpu(uv__cpu_constraint* constraint) { - char cgroup[1024]; - - /* Read the cgroup from /proc/self/cgroup */ - if (uv__slurp("/proc/self/cgroup", cgroup, sizeof(cgroup)) < 0) - return UV_EIO; - - /* Check if the system is using cgroup v2 by examining /proc/self/cgroup - * The entry for cgroup v2 is always in the format "0::$PATH" - * see https://docs.kernel.org/admin-guide/cgroup-v2.html */ - if (strncmp(cgroup, "0::/", 4) == 0) - return uv__get_cgroupv2_constrained_cpu(cgroup, constraint); - else - return uv__get_cgroupv1_constrained_cpu(cgroup, constraint); -} - - void uv_loadavg(double avg[3]) { struct sysinfo info; char buf[128]; /* Large enough to hold all of /proc/loadavg. */ diff --git a/wpinet/src/main/native/thirdparty/libuv/src/unix/loop.cpp b/wpinet/src/main/native/thirdparty/libuv/src/unix/loop.cpp index 006db94d008..3babe4d7019 100644 --- a/wpinet/src/main/native/thirdparty/libuv/src/unix/loop.cpp +++ b/wpinet/src/main/native/thirdparty/libuv/src/unix/loop.cpp @@ -217,14 +217,6 @@ int uv__loop_configure(uv_loop_t* loop, uv_loop_option option, va_list ap) { return 0; } -#if defined(__linux__) - if (option == UV_LOOP_USE_IO_URING_SQPOLL) { - loop->flags |= UV_LOOP_ENABLE_IO_URING_SQPOLL; - return 0; - } -#endif - - if (option != UV_LOOP_BLOCK_SIGNAL) return UV_ENOSYS; diff --git a/wpinet/src/main/native/thirdparty/libuv/src/unix/pipe.cpp b/wpinet/src/main/native/thirdparty/libuv/src/unix/pipe.cpp index 7627ee39c1b..ea26ce45c9b 100644 --- a/wpinet/src/main/native/thirdparty/libuv/src/unix/pipe.cpp +++ b/wpinet/src/main/native/thirdparty/libuv/src/unix/pipe.cpp @@ -76,13 +76,8 @@ int uv_pipe_bind2(uv_pipe_t* handle, if (name == NULL) return UV_EINVAL; - /* namelen==0 on Linux means autobind the listen socket in the abstract - * socket namespace, see `man 7 unix` for details. - */ -#if !defined(__linux__) if (namelen == 0) return UV_EINVAL; -#endif if (includes_nul(name, namelen)) return UV_EINVAL; @@ -349,15 +344,8 @@ static int uv__pipe_getsockpeername(const uv_pipe_t* handle, uv__peersockfunc func, char* buffer, size_t* size) { -#if defined(__linux__) - static const int is_linux = 1; -#else - static const int is_linux = 0; -#endif struct sockaddr_un sa; socklen_t addrlen; - size_t slop; - char* p; int err; addrlen = sizeof(sa); @@ -371,20 +359,17 @@ static int uv__pipe_getsockpeername(const uv_pipe_t* handle, return err; } - slop = 1; - if (is_linux && sa.sun_path[0] == '\0') { - /* Linux abstract namespace. Not zero-terminated. */ - slop = 0; +#if defined(__linux__) + if (sa.sun_path[0] == 0) + /* Linux abstract namespace */ addrlen -= offsetof(struct sockaddr_un, sun_path); - } else { - p = (char*)memchr(sa.sun_path, '\0', sizeof(sa.sun_path)); - if (p == NULL) - p = ARRAY_END(sa.sun_path); - addrlen = p - sa.sun_path; - } + else +#endif + addrlen = strlen(sa.sun_path); + - if ((size_t)addrlen + slop > *size) { - *size = addrlen + slop; + if ((size_t)addrlen >= *size) { + *size = addrlen + 1; return UV_ENOBUFS; } @@ -502,11 +487,7 @@ int uv_pipe_chmod(uv_pipe_t* handle, int mode) { int uv_pipe(uv_os_fd_t fds[2], int read_flags, int write_flags) { uv_os_fd_t temp[2]; int err; -#if defined(__linux__) || \ - defined(__FreeBSD__) || \ - defined(__OpenBSD__) || \ - defined(__DragonFly__) || \ - defined(__NetBSD__) +#if defined(__FreeBSD__) || defined(__linux__) int flags = O_CLOEXEC; if ((read_flags & UV_NONBLOCK_PIPE) && (write_flags & UV_NONBLOCK_PIPE)) diff --git a/wpinet/src/main/native/thirdparty/libuv/src/unix/process.cpp b/wpinet/src/main/native/thirdparty/libuv/src/unix/process.cpp index e1349689065..8271d513b15 100644 --- a/wpinet/src/main/native/thirdparty/libuv/src/unix/process.cpp +++ b/wpinet/src/main/native/thirdparty/libuv/src/unix/process.cpp @@ -55,8 +55,7 @@ extern char **environ; #endif -#if defined(__linux__) || \ - defined(__GNU__) +#if defined(__linux__) # include #endif @@ -64,7 +63,11 @@ extern char **environ; # include "zos-base.h" #endif -#ifdef UV_HAVE_KQUEUE +#if defined(__APPLE__) || \ + defined(__DragonFly__) || \ + defined(__FreeBSD__) || \ + defined(__NetBSD__) || \ + defined(__OpenBSD__) #include #else #define UV_USE_SIGCHLD diff --git a/wpinet/src/main/native/thirdparty/libuv/src/unix/signal.cpp b/wpinet/src/main/native/thirdparty/libuv/src/unix/signal.cpp index f23c887d0d6..bc4206e6d86 100644 --- a/wpinet/src/main/native/thirdparty/libuv/src/unix/signal.cpp +++ b/wpinet/src/main/native/thirdparty/libuv/src/unix/signal.cpp @@ -195,7 +195,7 @@ static void uv__signal_handler(int signum) { for (handle = uv__signal_first_handle(signum); handle != NULL && handle->signum == signum; - handle = RB_NEXT(uv__signal_tree_s, handle)) { + handle = RB_NEXT(uv__signal_tree_s, &uv__signal_tree, handle)) { int r; msg.signum = signum; diff --git a/wpinet/src/main/native/thirdparty/libuv/src/unix/stream.cpp b/wpinet/src/main/native/thirdparty/libuv/src/unix/stream.cpp index 2d2b5d2f45e..265ddade7ae 100644 --- a/wpinet/src/main/native/thirdparty/libuv/src/unix/stream.cpp +++ b/wpinet/src/main/native/thirdparty/libuv/src/unix/stream.cpp @@ -457,7 +457,7 @@ void uv__stream_destroy(uv_stream_t* stream) { assert(stream->flags & UV_HANDLE_CLOSED); if (stream->connect_req) { - uv__req_unregister(stream->loop); + uv__req_unregister(stream->loop, stream->connect_req); stream->connect_req->cb(stream->connect_req, UV_ECANCELED); stream->connect_req = NULL; } @@ -642,7 +642,7 @@ static void uv__drain(uv_stream_t* stream) { if ((stream->flags & UV_HANDLE_CLOSING) || !(stream->flags & UV_HANDLE_SHUT)) { stream->shutdown_req = NULL; - uv__req_unregister(stream->loop); + uv__req_unregister(stream->loop, req); err = 0; if (stream->flags & UV_HANDLE_CLOSING) @@ -698,8 +698,7 @@ static int uv__write_req_update(uv_stream_t* stream, do { len = n < buf->len ? n : buf->len; - if (buf->len != 0) - buf->base += len; + buf->base += len; buf->len -= len; buf += (buf->len == 0); /* Advance to next buffer if this one is empty. */ n -= len; @@ -913,7 +912,7 @@ static void uv__write_callbacks(uv_stream_t* stream) { q = uv__queue_head(&pq); req = uv__queue_data(q, uv_write_t, queue); uv__queue_remove(q); - uv__req_unregister(stream->loop); + uv__req_unregister(stream->loop, req); if (req->bufs != NULL) { stream->write_queue_size -= uv__write_req_size(req); @@ -981,13 +980,11 @@ static int uv__stream_queue_fd(uv_stream_t* stream, int fd) { static int uv__stream_recv_cmsg(uv_stream_t* stream, struct msghdr* msg) { struct cmsghdr* cmsg; - char* p; - char* pe; int fd; int err; + size_t i; size_t count; - err = 0; for (cmsg = CMSG_FIRSTHDR(msg); cmsg != NULL; cmsg = CMSG_NXTHDR(msg, cmsg)) { if (cmsg->cmsg_type != SCM_RIGHTS) { fprintf(stderr, "ignoring non-SCM_RIGHTS ancillary data: %d\n", @@ -1000,26 +997,24 @@ static int uv__stream_recv_cmsg(uv_stream_t* stream, struct msghdr* msg) { assert(count % sizeof(fd) == 0); count /= sizeof(fd); - p = (char*) CMSG_DATA(cmsg); - pe = p + count * sizeof(fd); - - while (p < pe) { - memcpy(&fd, p, sizeof(fd)); - p += sizeof(fd); - - if (err == 0) { - if (stream->accepted_fd == -1) - stream->accepted_fd = fd; - else - err = uv__stream_queue_fd(stream, fd); + for (i = 0; i < count; i++) { + memcpy(&fd, (char*) CMSG_DATA(cmsg) + i * sizeof(fd), sizeof(fd)); + /* Already has accepted fd, queue now */ + if (stream->accepted_fd != -1) { + err = uv__stream_queue_fd(stream, fd); + if (err != 0) { + /* Close rest */ + for (; i < count; i++) + uv__close(fd); + return err; + } + } else { + stream->accepted_fd = fd; } - - if (err != 0) - uv__close(fd); } } - return err; + return 0; } @@ -1274,7 +1269,7 @@ static void uv__stream_connect(uv_stream_t* stream) { return; stream->connect_req = NULL; - uv__req_unregister(stream->loop); + uv__req_unregister(stream->loop, req); if (error < 0 || uv__queue_empty(&stream->write_queue)) { uv__io_stop(stream->loop, &stream->io_watcher, POLLOUT); diff --git a/wpinet/src/main/native/thirdparty/libuv/src/unix/tcp.cpp b/wpinet/src/main/native/thirdparty/libuv/src/unix/tcp.cpp index 018ec144c78..6fe6361c81e 100644 --- a/wpinet/src/main/native/thirdparty/libuv/src/unix/tcp.cpp +++ b/wpinet/src/main/native/thirdparty/libuv/src/unix/tcp.cpp @@ -167,12 +167,6 @@ int uv__tcp_bind(uv_tcp_t* tcp, if (setsockopt(tcp->io_watcher.fd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on))) return UV__ERR(errno); - if (flags & UV_TCP_REUSEPORT) { - err = uv__sock_reuseport(tcp->io_watcher.fd); - if (err) - return err; - } - #ifndef __OpenBSD__ #ifdef IPV6_V6ONLY if (addr->sa_family == AF_INET6) { @@ -458,14 +452,6 @@ int uv__tcp_nodelay(int fd, int on) { } -#if (defined(UV__SOLARIS_11_4) && !UV__SOLARIS_11_4) || \ - (defined(__DragonFly__) && __DragonFly_version < 500702) -/* DragonFlyBSD <500702 and Solaris <11.4 require millisecond units - * for TCP keepalive options. */ -#define UV_KEEPALIVE_FACTOR(x) (x *= 1000) -#else -#define UV_KEEPALIVE_FACTOR(x) -#endif int uv__tcp_keepalive(int fd, int on, unsigned int delay) { int idle; int intvl; @@ -481,8 +467,8 @@ int uv__tcp_keepalive(int fd, int on, unsigned int delay) { if (!on) return 0; - if (delay < 1) - return UV_EINVAL; + if (delay == 0) + return -1; #ifdef __sun /* The implementation of TCP keep-alive on Solaris/SmartOS is a bit unusual @@ -515,53 +501,49 @@ int uv__tcp_keepalive(int fd, int on, unsigned int delay) { if (idle > 10*24*60*60) idle = 10*24*60*60; - UV_KEEPALIVE_FACTOR(idle); - /* `TCP_KEEPIDLE`, `TCP_KEEPINTVL`, and `TCP_KEEPCNT` were not available on Solaris * until version 11.4, but let's take a chance here. */ #if defined(TCP_KEEPIDLE) && defined(TCP_KEEPINTVL) && defined(TCP_KEEPCNT) if (setsockopt(fd, IPPROTO_TCP, TCP_KEEPIDLE, &idle, sizeof(idle))) return UV__ERR(errno); - intvl = 10; /* required at least 10 seconds */ - UV_KEEPALIVE_FACTOR(intvl); + intvl = idle/3; if (setsockopt(fd, IPPROTO_TCP, TCP_KEEPINTVL, &intvl, sizeof(intvl))) return UV__ERR(errno); - cnt = 1; /* 1 retry, ensure (TCP_KEEPINTVL * TCP_KEEPCNT) is 10 seconds */ + cnt = 3; if (setsockopt(fd, IPPROTO_TCP, TCP_KEEPCNT, &cnt, sizeof(cnt))) return UV__ERR(errno); #else /* Fall back to the first implementation of tcp-alive mechanism for older Solaris, * simulate the tcp-alive mechanism on other platforms via `TCP_KEEPALIVE_THRESHOLD` + `TCP_KEEPALIVE_ABORT_THRESHOLD`. */ + idle *= 1000; /* kernel expects milliseconds */ if (setsockopt(fd, IPPROTO_TCP, TCP_KEEPALIVE_THRESHOLD, &idle, sizeof(idle))) return UV__ERR(errno); /* Note that the consequent probes will not be sent at equal intervals on Solaris, * but will be sent using the exponential backoff algorithm. */ - int time_to_abort = 10; /* 10 seconds */ - UV_KEEPALIVE_FACTOR(time_to_abort); + intvl = idle/3; + cnt = 3; + int time_to_abort = intvl * cnt; if (setsockopt(fd, IPPROTO_TCP, TCP_KEEPALIVE_ABORT_THRESHOLD, &time_to_abort, sizeof(time_to_abort))) return UV__ERR(errno); #endif #else /* !defined(__sun) */ - idle = delay; - UV_KEEPALIVE_FACTOR(idle); #ifdef TCP_KEEPIDLE - if (setsockopt(fd, IPPROTO_TCP, TCP_KEEPIDLE, &idle, sizeof(idle))) + if (setsockopt(fd, IPPROTO_TCP, TCP_KEEPIDLE, &delay, sizeof(delay))) return UV__ERR(errno); #elif defined(TCP_KEEPALIVE) /* Darwin/macOS uses TCP_KEEPALIVE in place of TCP_KEEPIDLE. */ - if (setsockopt(fd, IPPROTO_TCP, TCP_KEEPALIVE, &idle, sizeof(idle))) + if (setsockopt(fd, IPPROTO_TCP, TCP_KEEPALIVE, &delay, sizeof(delay))) return UV__ERR(errno); #endif #ifdef TCP_KEEPINTVL - intvl = 1; /* 1 second; same as default on Win32 */ - UV_KEEPALIVE_FACTOR(intvl); + intvl = 1; /* 1 second; same as default on Win32 */ if (setsockopt(fd, IPPROTO_TCP, TCP_KEEPINTVL, &intvl, sizeof(intvl))) return UV__ERR(errno); #endif @@ -630,7 +612,7 @@ void uv__tcp_close(uv_tcp_t* handle) { int uv_socketpair(int type, int protocol, uv_os_sock_t fds[2], int flags0, int flags1) { uv_os_sock_t temp[2]; int err; -#if defined(SOCK_NONBLOCK) && defined(SOCK_CLOEXEC) +#if defined(__FreeBSD__) || defined(__linux__) int flags; flags = type | SOCK_CLOEXEC; diff --git a/wpinet/src/main/native/thirdparty/libuv/src/unix/tty.cpp b/wpinet/src/main/native/thirdparty/libuv/src/unix/tty.cpp index 5ca2105848f..1304c6d8685 100644 --- a/wpinet/src/main/native/thirdparty/libuv/src/unix/tty.cpp +++ b/wpinet/src/main/native/thirdparty/libuv/src/unix/tty.cpp @@ -337,37 +337,6 @@ int uv_tty_set_mode(uv_tty_t* tty, uv_tty_mode_t mode) { } -void uv__tty_close(uv_tty_t* handle) { - int expected; - int fd; - - fd = handle->io_watcher.fd; - if (fd == -1) - goto done; - - /* This is used for uv_tty_reset_mode() */ - do - expected = 0; - while (!atomic_compare_exchange_strong(&termios_spinlock, &expected, 1)); - - if (fd == orig_termios_fd) { - /* XXX(bnoordhuis) the tcsetattr is probably wrong when there are still - * other uv_tty_t handles active that refer to the same tty/pty but it's - * hard to recognize that particular situation without maintaining some - * kind of process-global data structure, and that still won't work in a - * multi-process setup. - */ - uv__tcsetattr(fd, TCSANOW, &orig_termios); - orig_termios_fd = -1; - } - - atomic_store(&termios_spinlock, 0); - -done: - uv__stream_close((uv_stream_t*) handle); -} - - int uv_tty_get_winsize(uv_tty_t* tty, int* width, int* height) { struct winsize ws; int err; @@ -485,7 +454,7 @@ int uv_tty_reset_mode(void) { saved_errno = errno; if (atomic_exchange(&termios_spinlock, 1)) - return UV_EBUSY; /* In uv_tty_set_mode() or uv__tty_close(). */ + return UV_EBUSY; /* In uv_tty_set_mode(). */ err = 0; if (orig_termios_fd != -1) diff --git a/wpinet/src/main/native/thirdparty/libuv/src/unix/udp.cpp b/wpinet/src/main/native/thirdparty/libuv/src/unix/udp.cpp index 50506752d0b..cbee16b22a3 100644 --- a/wpinet/src/main/native/thirdparty/libuv/src/unix/udp.cpp +++ b/wpinet/src/main/native/thirdparty/libuv/src/unix/udp.cpp @@ -100,7 +100,7 @@ static void uv__udp_run_completed(uv_udp_t* handle) { uv__queue_remove(q); req = uv__queue_data(q, uv_udp_send_t, queue); - uv__req_unregister(handle->loop); + uv__req_unregister(handle->loop, req); handle->send_queue_size -= uv__count_bufs(req->bufs, req->nbufs); handle->send_queue_count--; @@ -141,14 +141,14 @@ static void uv__udp_io(uv_loop_t* loop, uv__io_t* w, unsigned int revents) { if (revents & POLLIN) uv__udp_recvmsg(handle); - if (revents & POLLOUT && !uv__is_closing(handle)) { + if (revents & POLLOUT) { uv__udp_sendmsg(handle); uv__udp_run_completed(handle); } } static int uv__udp_recvmmsg(uv_udp_t* handle, uv_buf_t* buf) { -#if defined(__linux__) || defined(__FreeBSD__) || defined(__APPLE__) +#if defined(__linux__) || defined(__FreeBSD__) struct sockaddr_in6 peers[20]; struct iovec iov[ARRAY_SIZE(peers)]; struct mmsghdr msgs[ARRAY_SIZE(peers)]; @@ -173,18 +173,11 @@ static int uv__udp_recvmmsg(uv_udp_t* handle, uv_buf_t* buf) { msgs[k].msg_hdr.msg_control = NULL; msgs[k].msg_hdr.msg_controllen = 0; msgs[k].msg_hdr.msg_flags = 0; - msgs[k].msg_len = 0; } -#if defined(__APPLE__) - do - nread = recvmsg_x(handle->io_watcher.fd, msgs, chunks, MSG_DONTWAIT); - while (nread == -1 && errno == EINTR); -#else do nread = recvmmsg(handle->io_watcher.fd, msgs, chunks, 0, NULL); while (nread == -1 && errno == EINTR); -#endif if (nread < 1) { if (nread == 0 || errno == EAGAIN || errno == EWOULDBLOCK) @@ -211,9 +204,9 @@ static int uv__udp_recvmmsg(uv_udp_t* handle, uv_buf_t* buf) { handle->recv_cb(handle, 0, buf, NULL, UV_UDP_MMSG_FREE); } return nread; -#else /* __linux__ || ____FreeBSD__ || __APPLE__ */ +#else /* __linux__ || ____FreeBSD__ */ return UV_ENOSYS; -#endif /* __linux__ || ____FreeBSD__ || __APPLE__ */ +#endif /* __linux__ || ____FreeBSD__ */ } static void uv__udp_recvmsg(uv_udp_t* handle) { @@ -282,61 +275,8 @@ static void uv__udp_recvmsg(uv_udp_t* handle) { && handle->recv_cb != NULL); } -static void uv__udp_sendmsg_one(uv_udp_t* handle, uv_udp_send_t* req) { - struct uv__queue* q; - struct msghdr h; - ssize_t size; - - for (;;) { - memset(&h, 0, sizeof h); - if (req->addr.ss_family == AF_UNSPEC) { - h.msg_name = NULL; - h.msg_namelen = 0; - } else { - h.msg_name = &req->addr; - if (req->addr.ss_family == AF_INET6) - h.msg_namelen = sizeof(struct sockaddr_in6); - else if (req->addr.ss_family == AF_INET) - h.msg_namelen = sizeof(struct sockaddr_in); - else if (req->addr.ss_family == AF_UNIX) - h.msg_namelen = sizeof(struct sockaddr_un); - else { - assert(0 && "unsupported address family"); - abort(); - } - } - h.msg_iov = (struct iovec*) req->bufs; - h.msg_iovlen = req->nbufs; - - do - size = sendmsg(handle->io_watcher.fd, &h, 0); - while (size == -1 && errno == EINTR); - - if (size == -1) - if (errno == EAGAIN || errno == EWOULDBLOCK || errno == ENOBUFS) - return; - - req->status = (size == -1 ? UV__ERR(errno) : size); - - /* Sending a datagram is an atomic operation: either all data - * is written or nothing is (and EMSGSIZE is raised). That is - * why we don't handle partial writes. Just pop the request - * off the write queue and onto the completed queue, done. - */ - uv__queue_remove(&req->queue); - uv__queue_insert_tail(&handle->write_completed_queue, &req->queue); - uv__io_feed(handle->loop, &handle->io_watcher); - - if (uv__queue_empty(&handle->write_queue)) - return; - - q = uv__queue_head(&handle->write_queue); - req = uv__queue_data(q, uv_udp_send_t, queue); - } -} - -#if defined(__linux__) || defined(__FreeBSD__) || defined(__APPLE__) -static void uv__udp_sendmsg_many(uv_udp_t* handle) { +static void uv__udp_sendmsg(uv_udp_t* handle) { +#if defined(__linux__) || defined(__FreeBSD__) uv_udp_send_t* req; struct mmsghdr h[20]; struct mmsghdr* p; @@ -345,11 +285,16 @@ static void uv__udp_sendmsg_many(uv_udp_t* handle) { size_t pkts; size_t i; + if (uv__queue_empty(&handle->write_queue)) + return; + write_queue_drain: for (pkts = 0, q = uv__queue_head(&handle->write_queue); pkts < ARRAY_SIZE(h) && q != &handle->write_queue; ++pkts, q = uv__queue_head(q)) { + assert(q != NULL); req = uv__queue_data(q, uv_udp_send_t, queue); + assert(req != NULL); p = &h[pkts]; memset(p, 0, sizeof(*p)); @@ -373,15 +318,9 @@ static void uv__udp_sendmsg_many(uv_udp_t* handle) { h[pkts].msg_hdr.msg_iovlen = req->nbufs; } -#if defined(__APPLE__) - do - npkts = sendmsg_x(handle->io_watcher.fd, h, pkts, MSG_DONTWAIT); - while (npkts == -1 && errno == EINTR); -#else do npkts = sendmmsg(handle->io_watcher.fd, h, pkts, 0); while (npkts == -1 && errno == EINTR); -#endif if (npkts < 1) { if (errno == EAGAIN || errno == EWOULDBLOCK || errno == ENOBUFS) @@ -389,7 +328,10 @@ static void uv__udp_sendmsg_many(uv_udp_t* handle) { for (i = 0, q = uv__queue_head(&handle->write_queue); i < pkts && q != &handle->write_queue; ++i, q = uv__queue_head(&handle->write_queue)) { + assert(q != NULL); req = uv__queue_data(q, uv_udp_send_t, queue); + assert(req != NULL); + req->status = UV__ERR(errno); uv__queue_remove(&req->queue); uv__queue_insert_tail(&handle->write_completed_queue, &req->queue); @@ -404,7 +346,10 @@ static void uv__udp_sendmsg_many(uv_udp_t* handle) { for (i = 0, q = uv__queue_head(&handle->write_queue); i < (size_t)npkts && q != &handle->write_queue; ++i, q = uv__queue_head(&handle->write_queue)) { + assert(q != NULL); req = uv__queue_data(q, uv_udp_send_t, queue); + assert(req != NULL); + req->status = req->bufs[0].len; /* Sending a datagram is an atomic operation: either all data @@ -419,48 +364,75 @@ static void uv__udp_sendmsg_many(uv_udp_t* handle) { /* couldn't batch everything, continue sending (jump to avoid stack growth) */ if (!uv__queue_empty(&handle->write_queue)) goto write_queue_drain; - uv__io_feed(handle->loop, &handle->io_watcher); -} -#endif /* __linux__ || ____FreeBSD__ || __APPLE__ */ - -static void uv__udp_sendmsg(uv_udp_t* handle) { - struct uv__queue* q; +#else /* __linux__ || ____FreeBSD__ */ uv_udp_send_t* req; + struct msghdr h; + struct uv__queue* q; + ssize_t size; - if (uv__queue_empty(&handle->write_queue)) - return; + while (!uv__queue_empty(&handle->write_queue)) { + q = uv__queue_head(&handle->write_queue); + assert(q != NULL); - q = uv__queue_head(&handle->write_queue); - req = uv__queue_data(q, uv_udp_send_t, queue); + req = uv__queue_data(q, uv_udp_send_t, queue); + assert(req != NULL); -#if defined(__linux__) || defined(__FreeBSD__) || defined(__APPLE__) - /* Use sendmmsg() if this send request contains more than one datagram OR - * there is more than one send request (because that automatically implies - * there is more than one datagram.) - */ - if (req->nbufs != 1 || &handle->write_queue != uv__queue_next(&req->queue)) - return uv__udp_sendmsg_many(handle); -#endif + memset(&h, 0, sizeof h); + if (req->addr.ss_family == AF_UNSPEC) { + h.msg_name = NULL; + h.msg_namelen = 0; + } else { + h.msg_name = &req->addr; + if (req->addr.ss_family == AF_INET6) + h.msg_namelen = sizeof(struct sockaddr_in6); + else if (req->addr.ss_family == AF_INET) + h.msg_namelen = sizeof(struct sockaddr_in); + else if (req->addr.ss_family == AF_UNIX) + h.msg_namelen = sizeof(struct sockaddr_un); + else { + assert(0 && "unsupported address family"); + abort(); + } + } + h.msg_iov = (struct iovec*) req->bufs; + h.msg_iovlen = req->nbufs; + + do { + size = sendmsg(handle->io_watcher.fd, &h, 0); + } while (size == -1 && errno == EINTR); + + if (size == -1) { + if (errno == EAGAIN || errno == EWOULDBLOCK || errno == ENOBUFS) + break; + } + + req->status = (size == -1 ? UV__ERR(errno) : size); - return uv__udp_sendmsg_one(handle, req); + /* Sending a datagram is an atomic operation: either all data + * is written or nothing is (and EMSGSIZE is raised). That is + * why we don't handle partial writes. Just pop the request + * off the write queue and onto the completed queue, done. + */ + uv__queue_remove(&req->queue); + uv__queue_insert_tail(&handle->write_completed_queue, &req->queue); + uv__io_feed(handle->loop, &handle->io_watcher); + } +#endif /* __linux__ || ____FreeBSD__ */ } /* On the BSDs, SO_REUSEPORT implies SO_REUSEADDR but with some additional - * refinements for programs that use multicast. Therefore we preferentially - * set SO_REUSEPORT over SO_REUSEADDR here, but we set SO_REUSEPORT only - * when that socket option doesn't have the capability of load balancing. - * Otherwise, we fall back to SO_REUSEADDR. + * refinements for programs that use multicast. * - * Linux as of 3.9, DragonflyBSD 3.6, AIX 7.2.5 have the SO_REUSEPORT socket - * option but with semantics that are different from the BSDs: it _shares_ - * the port rather than steals it from the current listener. While useful, - * it's not something we can emulate on other platforms so we don't enable it. + * Linux as of 3.9 has a SO_REUSEPORT socket option but with semantics that + * are different from the BSDs: it _shares_ the port rather than steal it + * from the current listener. While useful, it's not something we can emulate + * on other platforms so we don't enable it. * * zOS does not support getsockname with SO_REUSEPORT option when using * AF_UNIX. */ -static int uv__sock_reuseaddr(int fd) { +static int uv__set_reuse(int fd) { int yes; yes = 1; @@ -477,7 +449,7 @@ static int uv__sock_reuseaddr(int fd) { return UV__ERR(errno); } #elif defined(SO_REUSEPORT) && !defined(__linux__) && !defined(__GNU__) && \ - !defined(__sun__) && !defined(__DragonFly__) && !defined(_AIX73) + !defined(__sun__) if (setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, &yes, sizeof(yes))) return UV__ERR(errno); #else @@ -520,8 +492,7 @@ int uv__udp_bind(uv_udp_t* handle, int fd; /* Check for bad flags. */ - if (flags & ~(UV_UDP_IPV6ONLY | UV_UDP_REUSEADDR | - UV_UDP_REUSEPORT | UV_UDP_LINUX_RECVERR)) + if (flags & ~(UV_UDP_IPV6ONLY | UV_UDP_REUSEADDR | UV_UDP_LINUX_RECVERR)) return UV_EINVAL; /* Cannot set IPv6-only mode on non-IPv6 socket. */ @@ -544,13 +515,7 @@ int uv__udp_bind(uv_udp_t* handle, } if (flags & UV_UDP_REUSEADDR) { - err = uv__sock_reuseaddr(fd); - if (err) - return err; - } - - if (flags & UV_UDP_REUSEPORT) { - err = uv__sock_reuseport(fd); + err = uv__set_reuse(fd); if (err) return err; } @@ -757,7 +722,7 @@ int uv__udp_send(uv_udp_send_t* req, req->bufs = (uv_buf_t*)uv__malloc(nbufs * sizeof(bufs[0])); if (req->bufs == NULL) { - uv__req_unregister(handle->loop); + uv__req_unregister(handle->loop, req); return UV_ENOMEM; } @@ -1050,7 +1015,7 @@ int uv__udp_init_ex(uv_loop_t* loop, int uv_udp_using_recvmmsg(const uv_udp_t* handle) { -#if defined(__linux__) || defined(__FreeBSD__) || defined(__APPLE__) +#if defined(__linux__) || defined(__FreeBSD__) if (handle->flags & UV_HANDLE_UDP_RECVMMSG) return 1; #endif @@ -1072,7 +1037,7 @@ int uv_udp_open(uv_udp_t* handle, uv_os_sock_t sock) { if (err) return err; - err = uv__sock_reuseaddr(sock); + err = uv__set_reuse(sock); if (err) return err; diff --git a/wpinet/src/main/native/thirdparty/libuv/src/uv-common.h b/wpinet/src/main/native/thirdparty/libuv/src/uv-common.h index 50bbc874c11..5dce8eaf270 100644 --- a/wpinet/src/main/native/thirdparty/libuv/src/uv-common.h +++ b/wpinet/src/main/native/thirdparty/libuv/src/uv-common.h @@ -231,13 +231,13 @@ void uv__threadpool_cleanup(void); #define uv__has_active_reqs(loop) \ ((loop)->active_reqs.count > 0) -#define uv__req_register(loop) \ +#define uv__req_register(loop, req) \ do { \ (loop)->active_reqs.count++; \ } \ while (0) -#define uv__req_unregister(loop) \ +#define uv__req_unregister(loop, req) \ do { \ assert(uv__has_active_reqs(loop)); \ (loop)->active_reqs.count--; \ @@ -347,7 +347,7 @@ void uv__threadpool_cleanup(void); #define uv__req_init(loop, req, typ) \ do { \ UV_REQ_INIT(req, typ); \ - uv__req_register(loop); \ + uv__req_register(loop, req); \ } \ while (0) diff --git a/wpinet/src/main/native/thirdparty/libuv/src/win/error.cpp b/wpinet/src/main/native/thirdparty/libuv/src/win/error.cpp index 5cc264fea86..3a269da87a9 100644 --- a/wpinet/src/main/native/thirdparty/libuv/src/win/error.cpp +++ b/wpinet/src/main/native/thirdparty/libuv/src/win/error.cpp @@ -78,7 +78,6 @@ int uv_translate_sys_error(int sys_errno) { case WSAEADDRNOTAVAIL: return UV_EADDRNOTAVAIL; case WSAEAFNOSUPPORT: return UV_EAFNOSUPPORT; case WSAEWOULDBLOCK: return UV_EAGAIN; - case ERROR_NO_DATA: return UV_EAGAIN; case WSAEALREADY: return UV_EALREADY; case ERROR_INVALID_FLAGS: return UV_EBADF; case ERROR_INVALID_HANDLE: return UV_EBADF; @@ -158,6 +157,7 @@ int uv_translate_sys_error(int sys_errno) { case ERROR_ACCESS_DENIED: return UV_EPERM; case ERROR_PRIVILEGE_NOT_HELD: return UV_EPERM; case ERROR_BAD_PIPE: return UV_EPIPE; + case ERROR_NO_DATA: return UV_EPIPE; case ERROR_PIPE_NOT_CONNECTED: return UV_EPIPE; case WSAESHUTDOWN: return UV_EPIPE; case WSAEPROTONOSUPPORT: return UV_EPROTONOSUPPORT; @@ -168,7 +168,6 @@ int uv_translate_sys_error(int sys_errno) { case ERROR_INVALID_FUNCTION: return UV_EISDIR; case ERROR_META_EXPANSION_TOO_LONG: return UV_E2BIG; case WSAESOCKTNOSUPPORT: return UV_ESOCKTNOSUPPORT; - case ERROR_BAD_EXE_FORMAT: return UV_EFTYPE; default: return UV_UNKNOWN; } } diff --git a/wpinet/src/main/native/thirdparty/libuv/src/win/fs-event.cpp b/wpinet/src/main/native/thirdparty/libuv/src/win/fs-event.cpp index 2fdcbcb73a9..2f566f796a5 100644 --- a/wpinet/src/main/native/thirdparty/libuv/src/win/fs-event.cpp +++ b/wpinet/src/main/native/thirdparty/libuv/src/win/fs-event.cpp @@ -563,25 +563,7 @@ void uv__process_fs_event_req(uv_loop_t* loop, uv_req_t* req, } } else { err = GET_REQ_ERROR(req); - /* - * Check whether the ERROR_ACCESS_DENIED is caused by the watched directory - * being actually deleted (not an actual error) or a legit error. Retrieve - * FileStandardInfo to check whether the directory is pending deletion. - */ - FILE_STANDARD_INFO info; - if (err == ERROR_ACCESS_DENIED && - handle->dirw != NULL && - GetFileInformationByHandleEx(handle->dir_handle, - FileStandardInfo, - &info, - sizeof(info)) && - info.Directory && - info.DeletePending) { - uv__convert_utf16_to_utf8(handle->dirw, -1, &filename); - handle->cb(handle, filename, UV_RENAME, 0); - } else { - handle->cb(handle, NULL, 0, uv_translate_sys_error(err)); - } + handle->cb(handle, NULL, 0, uv_translate_sys_error(err)); } if (handle->flags & UV_HANDLE_CLOSING) { diff --git a/wpinet/src/main/native/thirdparty/libuv/src/win/fs.cpp b/wpinet/src/main/native/thirdparty/libuv/src/win/fs.cpp index 69a413eab4c..d6b2b3f1d08 100644 --- a/wpinet/src/main/native/thirdparty/libuv/src/win/fs.cpp +++ b/wpinet/src/main/native/thirdparty/libuv/src/win/fs.cpp @@ -49,17 +49,6 @@ #define UV_FS_FREE_PTR 0x0008 #define UV_FS_CLEANEDUP 0x0010 -#ifndef FILE_DISPOSITION_DELETE -#define FILE_DISPOSITION_DELETE 0x0001 -#endif /* FILE_DISPOSITION_DELETE */ - -#ifndef FILE_DISPOSITION_POSIX_SEMANTICS -#define FILE_DISPOSITION_POSIX_SEMANTICS 0x0002 -#endif /* FILE_DISPOSITION_POSIX_SEMANTICS */ - -#ifndef FILE_DISPOSITION_IGNORE_READONLY_ATTRIBUTE -#define FILE_DISPOSITION_IGNORE_READONLY_ATTRIBUTE 0x0010 -#endif /* FILE_DISPOSITION_IGNORE_READONLY_ATTRIBUTE */ #define INIT(subtype) \ do { \ @@ -72,7 +61,7 @@ #define POST \ do { \ if (cb != NULL) { \ - uv__req_register(loop); \ + uv__req_register(loop, req); \ uv__work_submit(loop, \ &req->work_req, \ UV__WORK_FAST_IO, \ @@ -111,14 +100,13 @@ return; \ } -#define NSEC_PER_TICK 100 -#define TICKS_PER_SEC ((int64_t) 1e9 / NSEC_PER_TICK) -static const int64_t WIN_TO_UNIX_TICK_OFFSET = 11644473600 * TICKS_PER_SEC; +#define MILLION ((int64_t) 1000 * 1000) +#define BILLION ((int64_t) 1000 * 1000 * 1000) static void uv__filetime_to_timespec(uv_timespec_t *ts, int64_t filetime) { - filetime -= WIN_TO_UNIX_TICK_OFFSET; - ts->tv_sec = filetime / TICKS_PER_SEC; - ts->tv_nsec = (filetime % TICKS_PER_SEC) * NSEC_PER_TICK; + filetime -= 116444736 * BILLION; + ts->tv_sec = (long) (filetime / (10 * MILLION)); + ts->tv_nsec = (long) ((filetime - ts->tv_sec * 10 * MILLION) * 100U); if (ts->tv_nsec < 0) { ts->tv_sec -= 1; ts->tv_nsec += 1e9; @@ -127,7 +115,7 @@ static void uv__filetime_to_timespec(uv_timespec_t *ts, int64_t filetime) { #define TIME_T_TO_FILETIME(time, filetime_ptr) \ do { \ - int64_t bigtime = ((time) * TICKS_PER_SEC + WIN_TO_UNIX_TICK_OFFSET); \ + int64_t bigtime = ((time) * 10 * MILLION + 116444736 * BILLION); \ (filetime_ptr)->dwLowDateTime = (uint64_t) bigtime & 0xFFFFFFFF; \ (filetime_ptr)->dwHighDateTime = (uint64_t) bigtime >> 32; \ } while(0) @@ -151,16 +139,6 @@ static int uv__file_symlink_usermode_flag = SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGE static DWORD uv__allocation_granularity; -typedef enum { - FS__STAT_PATH_SUCCESS, - FS__STAT_PATH_ERROR, - FS__STAT_PATH_TRY_SLOW -} fs__stat_path_return_t; - -INLINE static void fs__stat_assign_statbuf_null(uv_stat_t* statbuf); -INLINE static void fs__stat_assign_statbuf(uv_stat_t* statbuf, - FILE_STAT_BASIC_INFORMATION stat_info, int do_lstat); - void uv__fs_init(void) { SYSTEM_INFO system_info; @@ -1086,15 +1064,22 @@ void fs__write(uv_fs_t* req) { } -static void fs__unlink_rmdir(uv_fs_t* req, BOOL isrmdir) { +void fs__rmdir(uv_fs_t* req) { + int result = _wrmdir(req->file.pathw); + if (result == -1) + SET_REQ_WIN32_ERROR(req, _doserrno); + else + SET_REQ_RESULT(req, 0); +} + + +void fs__unlink(uv_fs_t* req) { const WCHAR* pathw = req->file.pathw; HANDLE handle; BY_HANDLE_FILE_INFORMATION info; FILE_DISPOSITION_INFORMATION disposition; - FILE_DISPOSITION_INFORMATION_EX disposition_ex; IO_STATUS_BLOCK iosb; NTSTATUS status; - DWORD error; handle = CreateFileW(pathw, FILE_READ_ATTRIBUTES | FILE_WRITE_ATTRIBUTES | DELETE, @@ -1115,17 +1100,10 @@ static void fs__unlink_rmdir(uv_fs_t* req, BOOL isrmdir) { return; } - if (isrmdir && !(info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) { - /* Error if we're in rmdir mode but it is not a dir */ - SET_REQ_UV_ERROR(req, UV_ENOTDIR, ERROR_DIRECTORY); - CloseHandle(handle); - return; - } - - if (!isrmdir && (info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) { - /* If not explicitly allowed, do not allow deletion of directories, unless - * it is a symlink. When the path refers to a non-symlink directory, report - * EPERM as mandated by POSIX.1. */ + if (info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { + /* Do not allow deletion of directories, unless it is a symlink. When the + * path refers to a non-symlink directory, report EPERM as mandated by + * POSIX.1. */ /* Check if it is a reparse point. If it's not, it's a normal directory. */ if (!(info.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT)) { @@ -1137,7 +1115,7 @@ static void fs__unlink_rmdir(uv_fs_t* req, BOOL isrmdir) { /* Read the reparse point and check if it is a valid symlink. If not, don't * unlink. */ if (fs__readlink_handle(handle, NULL, NULL) < 0) { - error = GetLastError(); + DWORD error = GetLastError(); if (error == ERROR_SYMLINK_NOT_SUPPORTED) error = ERROR_ACCESS_DENIED; SET_REQ_WIN32_ERROR(req, error); @@ -1146,77 +1124,42 @@ static void fs__unlink_rmdir(uv_fs_t* req, BOOL isrmdir) { } } - /* Try posix delete first */ - disposition_ex.Flags = FILE_DISPOSITION_DELETE | FILE_DISPOSITION_POSIX_SEMANTICS | - FILE_DISPOSITION_IGNORE_READONLY_ATTRIBUTE; + if (info.dwFileAttributes & FILE_ATTRIBUTE_READONLY) { + /* Remove read-only attribute */ + FILE_BASIC_INFORMATION basic = { 0 }; + + basic.FileAttributes = (info.dwFileAttributes & ~FILE_ATTRIBUTE_READONLY) | + FILE_ATTRIBUTE_ARCHIVE; + + status = pNtSetInformationFile(handle, + &iosb, + &basic, + sizeof basic, + FileBasicInformation); + if (!NT_SUCCESS(status)) { + SET_REQ_WIN32_ERROR(req, pRtlNtStatusToDosError(status)); + CloseHandle(handle); + return; + } + } + /* Try to set the delete flag. */ + disposition.DeleteFile = TRUE; status = pNtSetInformationFile(handle, &iosb, - &disposition_ex, - sizeof disposition_ex, - FileDispositionInformationEx); + &disposition, + sizeof disposition, + FileDispositionInformation); if (NT_SUCCESS(status)) { SET_REQ_SUCCESS(req); } else { - /* If status == STATUS_CANNOT_DELETE here, given we set - * FILE_DISPOSITION_IGNORE_READONLY_ATTRIBUTE, STATUS_CANNOT_DELETE can only mean - * that there is an existing mapped view to the file, preventing delete. - * STATUS_CANNOT_DELETE maps to UV_EACCES so it's not specifically worth handling */ - error = pRtlNtStatusToDosError(status); - if (error == ERROR_NOT_SUPPORTED /* filesystem does not support posix deletion */ || - error == ERROR_INVALID_PARAMETER /* pre Windows 10 error */ || - error == ERROR_INVALID_FUNCTION /* pre Windows 10 1607 error */) { - /* posix delete not supported so try fallback */ - if (info.dwFileAttributes & FILE_ATTRIBUTE_READONLY) { - /* Remove read-only attribute */ - FILE_BASIC_INFORMATION basic = { 0 }; - - basic.FileAttributes = (info.dwFileAttributes & ~FILE_ATTRIBUTE_READONLY) | - FILE_ATTRIBUTE_ARCHIVE; - - status = pNtSetInformationFile(handle, - &iosb, - &basic, - sizeof basic, - FileBasicInformation); - if (!NT_SUCCESS(status)) { - SET_REQ_WIN32_ERROR(req, pRtlNtStatusToDosError(status)); - CloseHandle(handle); - return; - } - } - - /* Try to set the delete flag. */ - disposition.DeleteFile = TRUE; - status = pNtSetInformationFile(handle, - &iosb, - &disposition, - sizeof disposition, - FileDispositionInformation); - if (NT_SUCCESS(status)) { - SET_REQ_SUCCESS(req); - } else { - SET_REQ_WIN32_ERROR(req, pRtlNtStatusToDosError(status)); - } - } else { - SET_REQ_WIN32_ERROR(req, error); - } + SET_REQ_WIN32_ERROR(req, pRtlNtStatusToDosError(status)); } CloseHandle(handle); } -static void fs__rmdir(uv_fs_t* req) { - fs__unlink_rmdir(req, /*isrmdir*/1); -} - - -static void fs__unlink(uv_fs_t* req) { - fs__unlink_rmdir(req, /*isrmdir*/0); -} - - void fs__mkdir(uv_fs_t* req) { /* TODO: use req->mode. */ if (CreateDirectoryW(req->file.pathw, NULL)) { @@ -1242,7 +1185,7 @@ void fs__mktemp(uv_fs_t* req, uv__fs_mktemp_func func) { size_t len; uint64_t v; char* path; - + path = (char*)req->path; len = wcslen(req->file.pathw); ep = req->file.pathw + len; @@ -1687,43 +1630,6 @@ void fs__closedir(uv_fs_t* req) { SET_REQ_RESULT(req, 0); } -INLINE static fs__stat_path_return_t fs__stat_path(WCHAR* path, - uv_stat_t* statbuf, int do_lstat) { - FILE_STAT_BASIC_INFORMATION stat_info; - - // Check if the new fast API is available. - if (!pGetFileInformationByName) { - return FS__STAT_PATH_TRY_SLOW; - } - - // Check if the API call fails. - if (!pGetFileInformationByName(path, FileStatBasicByNameInfo, &stat_info, - sizeof(stat_info))) { - switch(GetLastError()) { - case ERROR_FILE_NOT_FOUND: - case ERROR_PATH_NOT_FOUND: - case ERROR_NOT_READY: - case ERROR_BAD_NET_NAME: - /* These errors aren't worth retrying with the slow path. */ - return FS__STAT_PATH_ERROR; - } - return FS__STAT_PATH_TRY_SLOW; - } - - // A file handle is needed to get st_size for links. - if ((stat_info.FileAttributes & FILE_ATTRIBUTE_REPARSE_POINT)) { - return FS__STAT_PATH_TRY_SLOW; - } - - if (stat_info.DeviceType == FILE_DEVICE_NULL) { - fs__stat_assign_statbuf_null(statbuf); - return FS__STAT_PATH_SUCCESS; - } - - fs__stat_assign_statbuf(statbuf, stat_info, do_lstat); - return FS__STAT_PATH_SUCCESS; -} - INLINE static int fs__stat_handle(HANDLE handle, uv_stat_t* statbuf, int do_lstat) { size_t target_length = 0; @@ -1732,7 +1638,6 @@ INLINE static int fs__stat_handle(HANDLE handle, uv_stat_t* statbuf, FILE_FS_VOLUME_INFORMATION volume_info; NTSTATUS nt_status; IO_STATUS_BLOCK io_status; - FILE_STAT_BASIC_INFORMATION stat_info; nt_status = pNtQueryVolumeInformationFile(handle, &io_status, @@ -1748,7 +1653,13 @@ INLINE static int fs__stat_handle(HANDLE handle, uv_stat_t* statbuf, /* If it's NUL device set fields as reasonable as possible and return. */ if (device_info.DeviceType == FILE_DEVICE_NULL) { - fs__stat_assign_statbuf_null(statbuf); + memset(statbuf, 0, sizeof(uv_stat_t)); + statbuf->st_mode = _S_IFCHR; + statbuf->st_mode |= (_S_IREAD | _S_IWRITE) | ((_S_IREAD | _S_IWRITE) >> 3) | + ((_S_IREAD | _S_IWRITE) >> 6); + statbuf->st_nlink = 1; + statbuf->st_blksize = 4096; + statbuf->st_rdev = FILE_DEVICE_NULL << 16; return 0; } @@ -1772,65 +1683,14 @@ INLINE static int fs__stat_handle(HANDLE handle, uv_stat_t* statbuf, /* Buffer overflow (a warning status code) is expected here. */ if (io_status.Status == STATUS_NOT_IMPLEMENTED) { - stat_info.VolumeSerialNumber.QuadPart = 0; + statbuf->st_dev = 0; } else if (NT_ERROR(nt_status)) { SetLastError(pRtlNtStatusToDosError(nt_status)); return -1; } else { - stat_info.VolumeSerialNumber.QuadPart = volume_info.VolumeSerialNumber; - } - - stat_info.DeviceType = device_info.DeviceType; - stat_info.FileAttributes = file_info.BasicInformation.FileAttributes; - stat_info.NumberOfLinks = file_info.StandardInformation.NumberOfLinks; - stat_info.FileId.QuadPart = - file_info.InternalInformation.IndexNumber.QuadPart; - stat_info.ChangeTime.QuadPart = - file_info.BasicInformation.ChangeTime.QuadPart; - stat_info.CreationTime.QuadPart = - file_info.BasicInformation.CreationTime.QuadPart; - stat_info.LastAccessTime.QuadPart = - file_info.BasicInformation.LastAccessTime.QuadPart; - stat_info.LastWriteTime.QuadPart = - file_info.BasicInformation.LastWriteTime.QuadPart; - stat_info.AllocationSize.QuadPart = - file_info.StandardInformation.AllocationSize.QuadPart; - - if (do_lstat && - (file_info.BasicInformation.FileAttributes & FILE_ATTRIBUTE_REPARSE_POINT)) { - /* - * If reading the link fails, the reparse point is not a symlink and needs - * to be treated as a regular file. The higher level lstat function will - * detect this failure and retry without do_lstat if appropriate. - */ - if (fs__readlink_handle(handle, NULL, &target_length) != 0) { - fs__stat_assign_statbuf(statbuf, stat_info, do_lstat); - return -1; - } - stat_info.EndOfFile.QuadPart = target_length; - } else { - stat_info.EndOfFile.QuadPart = - file_info.StandardInformation.EndOfFile.QuadPart; + statbuf->st_dev = volume_info.VolumeSerialNumber; } - fs__stat_assign_statbuf(statbuf, stat_info, do_lstat); - return 0; -} - -INLINE static void fs__stat_assign_statbuf_null(uv_stat_t* statbuf) { - memset(statbuf, 0, sizeof(uv_stat_t)); - statbuf->st_mode = _S_IFCHR; - statbuf->st_mode |= (_S_IREAD | _S_IWRITE) | ((_S_IREAD | _S_IWRITE) >> 3) | - ((_S_IREAD | _S_IWRITE) >> 6); - statbuf->st_nlink = 1; - statbuf->st_blksize = 4096; - statbuf->st_rdev = FILE_DEVICE_NULL << 16; -} - -INLINE static void fs__stat_assign_statbuf(uv_stat_t* statbuf, - FILE_STAT_BASIC_INFORMATION stat_info, int do_lstat) { - statbuf->st_dev = stat_info.VolumeSerialNumber.QuadPart; - /* Todo: st_mode should probably always be 0666 for everyone. We might also * want to report 0777 if the file is a .exe or a directory. * @@ -1862,43 +1722,50 @@ INLINE static void fs__stat_assign_statbuf(uv_stat_t* statbuf, * target. Otherwise, reparse points must be treated as regular files. */ if (do_lstat && - (stat_info.FileAttributes & FILE_ATTRIBUTE_REPARSE_POINT)) { + (file_info.BasicInformation.FileAttributes & FILE_ATTRIBUTE_REPARSE_POINT)) { + /* + * If reading the link fails, the reparse point is not a symlink and needs + * to be treated as a regular file. The higher level lstat function will + * detect this failure and retry without do_lstat if appropriate. + */ + if (fs__readlink_handle(handle, NULL, &target_length) != 0) + return -1; statbuf->st_mode |= S_IFLNK; - statbuf->st_size = stat_info.EndOfFile.QuadPart; + statbuf->st_size = target_length; } if (statbuf->st_mode == 0) { - if (stat_info.FileAttributes & FILE_ATTRIBUTE_DIRECTORY) { + if (file_info.BasicInformation.FileAttributes & FILE_ATTRIBUTE_DIRECTORY) { statbuf->st_mode |= _S_IFDIR; statbuf->st_size = 0; } else { statbuf->st_mode |= _S_IFREG; - statbuf->st_size = stat_info.EndOfFile.QuadPart; + statbuf->st_size = file_info.StandardInformation.EndOfFile.QuadPart; } } - if (stat_info.FileAttributes & FILE_ATTRIBUTE_READONLY) + if (file_info.BasicInformation.FileAttributes & FILE_ATTRIBUTE_READONLY) statbuf->st_mode |= _S_IREAD | (_S_IREAD >> 3) | (_S_IREAD >> 6); else statbuf->st_mode |= (_S_IREAD | _S_IWRITE) | ((_S_IREAD | _S_IWRITE) >> 3) | ((_S_IREAD | _S_IWRITE) >> 6); uv__filetime_to_timespec(&statbuf->st_atim, - stat_info.LastAccessTime.QuadPart); + file_info.BasicInformation.LastAccessTime.QuadPart); uv__filetime_to_timespec(&statbuf->st_ctim, - stat_info.ChangeTime.QuadPart); + file_info.BasicInformation.ChangeTime.QuadPart); uv__filetime_to_timespec(&statbuf->st_mtim, - stat_info.LastWriteTime.QuadPart); + file_info.BasicInformation.LastWriteTime.QuadPart); uv__filetime_to_timespec(&statbuf->st_birthtim, - stat_info.CreationTime.QuadPart); + file_info.BasicInformation.CreationTime.QuadPart); - statbuf->st_ino = stat_info.FileId.QuadPart; + statbuf->st_ino = file_info.InternalInformation.IndexNumber.QuadPart; /* st_blocks contains the on-disk allocation size in 512-byte units. */ statbuf->st_blocks = - (uint64_t) stat_info.AllocationSize.QuadPart >> 9; + (uint64_t) file_info.StandardInformation.AllocationSize.QuadPart >> 9; - statbuf->st_nlink = stat_info.NumberOfLinks; + statbuf->st_nlink = file_info.StandardInformation.NumberOfLinks; /* The st_blksize is supposed to be the 'optimal' number of bytes for reading * and writing to the disk. That is, for any definition of 'optimal' - it's @@ -1930,6 +1797,8 @@ INLINE static void fs__stat_assign_statbuf(uv_stat_t* statbuf, statbuf->st_uid = 0; statbuf->st_rdev = 0; statbuf->st_gen = 0; + + return 0; } @@ -1951,17 +1820,6 @@ INLINE static DWORD fs__stat_impl_from_path(WCHAR* path, DWORD flags; DWORD ret; - // If new API exists, try to use it. - switch (fs__stat_path(path, statbuf, do_lstat)) { - case FS__STAT_PATH_SUCCESS: - return 0; - case FS__STAT_PATH_ERROR: - return GetLastError(); - case FS__STAT_PATH_TRY_SLOW: - break; - } - - // If the new API does not exist, use the old API. flags = FILE_FLAG_BACKUP_SEMANTICS; if (do_lstat) flags |= FILE_FLAG_OPEN_REPARSE_POINT; @@ -2975,7 +2833,7 @@ static void uv__fs_done(struct uv__work* w, int status) { uv_fs_t* req; req = container_of(w, uv_fs_t, work_req); - uv__req_unregister(req->loop); + uv__req_unregister(req->loop, req); if (status == UV_ECANCELED) { assert(req->result == 0); diff --git a/wpinet/src/main/native/thirdparty/libuv/src/win/getaddrinfo.cpp b/wpinet/src/main/native/thirdparty/libuv/src/win/getaddrinfo.cpp index 1181695550d..5bc63d8e194 100644 --- a/wpinet/src/main/native/thirdparty/libuv/src/win/getaddrinfo.cpp +++ b/wpinet/src/main/native/thirdparty/libuv/src/win/getaddrinfo.cpp @@ -71,9 +71,10 @@ int uv__getaddrinfo_translate_error(int sys_err) { DECLSPEC_IMPORT void WSAAPI FreeAddrInfoW(PADDRINFOW pAddrInfo); #endif -static size_t align_offset(size_t off, size_t alignment) { - return ((off + alignment - 1) / alignment) * alignment; -} + +/* Adjust size value to be multiple of 4. Use to keep pointer aligned. + * Do we need different versions of this for different architectures? */ +#define ALIGNED_SIZE(X) ((((X) + 3) >> 2) << 2) #ifndef NDIS_IF_MAX_STRING_SIZE #define NDIS_IF_MAX_STRING_SIZE IF_MAX_STRING_SIZE @@ -102,7 +103,17 @@ static void uv__getaddrinfo_work(struct uv__work* w) { * Each size calculation is adjusted to avoid unaligned pointers. */ static void uv__getaddrinfo_done(struct uv__work* w, int status) { - uv_getaddrinfo_t* req = container_of(w, uv_getaddrinfo_t, work_req); + uv_getaddrinfo_t* req; + size_t addrinfo_len = 0; + ssize_t name_len = 0; + size_t addrinfo_struct_len = ALIGNED_SIZE(sizeof(struct addrinfo)); + struct addrinfoW* addrinfow_ptr; + struct addrinfo* addrinfo_ptr; + char* alloc_ptr = NULL; + char* cur_ptr = NULL; + int r; + + req = container_of(w, uv_getaddrinfo_t, work_req); /* release input parameter memory */ uv__free(req->alloc); @@ -115,44 +126,34 @@ static void uv__getaddrinfo_done(struct uv__work* w, int status) { } if (req->retcode == 0) { - char* alloc_ptr = NULL; - size_t cur_off = 0; - size_t addrinfo_len; /* Convert addrinfoW to addrinfo. First calculate required length. */ - struct addrinfoW* addrinfow_ptr = req->addrinfow; + addrinfow_ptr = req->addrinfow; while (addrinfow_ptr != NULL) { - cur_off = align_offset(cur_off, sizeof(void*)); - cur_off += sizeof(struct addrinfo); - /* TODO: This alignment could be smaller, if we could - portably get the alignment for sockaddr. */ - cur_off = align_offset(cur_off, sizeof(void*)); - cur_off += addrinfow_ptr->ai_addrlen; + addrinfo_len += addrinfo_struct_len + + ALIGNED_SIZE(addrinfow_ptr->ai_addrlen); if (addrinfow_ptr->ai_canonname != NULL) { - ssize_t name_len = - uv_utf16_length_as_wtf8((const uint16_t*)addrinfow_ptr->ai_canonname, -1); + name_len = uv_utf16_length_as_wtf8((const uint16_t*)addrinfow_ptr->ai_canonname, -1); if (name_len < 0) { req->retcode = name_len; goto complete; } - cur_off += name_len + 1; + addrinfo_len += ALIGNED_SIZE(name_len + 1); } addrinfow_ptr = addrinfow_ptr->ai_next; } /* allocate memory for addrinfo results */ - addrinfo_len = cur_off; alloc_ptr = (char*)uv__malloc(addrinfo_len); /* do conversions */ if (alloc_ptr != NULL) { - struct addrinfo *addrinfo_ptr = (struct addrinfo *)alloc_ptr; - cur_off = 0; + cur_ptr = alloc_ptr; addrinfow_ptr = req->addrinfow; - for (;;) { - cur_off += sizeof(struct addrinfo); - assert(cur_off <= addrinfo_len); + while (addrinfow_ptr != NULL) { /* copy addrinfo struct data */ + assert(cur_ptr + addrinfo_struct_len <= alloc_ptr + addrinfo_len); + addrinfo_ptr = (struct addrinfo*)cur_ptr; addrinfo_ptr->ai_family = addrinfow_ptr->ai_family; addrinfo_ptr->ai_socktype = addrinfow_ptr->ai_socktype; addrinfo_ptr->ai_protocol = addrinfow_ptr->ai_protocol; @@ -162,37 +163,35 @@ static void uv__getaddrinfo_done(struct uv__work* w, int status) { addrinfo_ptr->ai_addr = NULL; addrinfo_ptr->ai_next = NULL; + cur_ptr += addrinfo_struct_len; + /* copy sockaddr */ if (addrinfo_ptr->ai_addrlen > 0) { - cur_off = align_offset(cur_off, sizeof(void *)); - addrinfo_ptr->ai_addr = (struct sockaddr *)(alloc_ptr + cur_off); - cur_off += addrinfo_ptr->ai_addrlen; - assert(cur_off <= addrinfo_len); - memcpy(addrinfo_ptr->ai_addr, - addrinfow_ptr->ai_addr, - addrinfo_ptr->ai_addrlen); + assert(cur_ptr + addrinfo_ptr->ai_addrlen <= + alloc_ptr + addrinfo_len); + memcpy(cur_ptr, addrinfow_ptr->ai_addr, addrinfo_ptr->ai_addrlen); + addrinfo_ptr->ai_addr = (struct sockaddr*)cur_ptr; + cur_ptr += ALIGNED_SIZE(addrinfo_ptr->ai_addrlen); } /* convert canonical name to UTF-8 */ if (addrinfow_ptr->ai_canonname != NULL) { - ssize_t name_len = addrinfo_len - cur_off; - addrinfo_ptr->ai_canonname = alloc_ptr + cur_off; - int r = uv__copy_utf16_to_utf8(addrinfow_ptr->ai_canonname, - -1, - addrinfo_ptr->ai_canonname, - (size_t*)&name_len); + name_len = alloc_ptr + addrinfo_len - cur_ptr; + r = uv__copy_utf16_to_utf8(addrinfow_ptr->ai_canonname, + -1, + cur_ptr, + (size_t*)&name_len); assert(r == 0); - cur_off += name_len + 1; - assert(cur_off <= addrinfo_len); + addrinfo_ptr->ai_canonname = cur_ptr; + cur_ptr += ALIGNED_SIZE(name_len + 1); } + assert(cur_ptr <= alloc_ptr + addrinfo_len); /* set next ptr */ addrinfow_ptr = addrinfow_ptr->ai_next; - if (addrinfow_ptr == NULL) - break; - cur_off = align_offset(cur_off, sizeof(void *)); - addrinfo_ptr = (struct addrinfo *)(alloc_ptr + cur_off); - addrinfo_ptr->ai_next = addrinfo_ptr; + if (addrinfow_ptr != NULL) { + addrinfo_ptr->ai_next = (struct addrinfo*)cur_ptr; + } } req->addrinfo = (struct addrinfo*)alloc_ptr; } else { @@ -207,7 +206,7 @@ static void uv__getaddrinfo_done(struct uv__work* w, int status) { } complete: - uv__req_unregister(req->loop); + uv__req_unregister(req->loop, req); /* finally do callback with converted result */ if (req->getaddrinfo_cb) @@ -243,12 +242,10 @@ int uv_getaddrinfo(uv_loop_t* loop, const char* service, const struct addrinfo* hints) { char hostname_ascii[256]; - size_t off = 0; size_t nodesize = 0; size_t servicesize = 0; - size_t serviceoff = 0; size_t hintssize = 0; - size_t hintoff = 0; + char* alloc_ptr = NULL; ssize_t rc; if (req == NULL || (node == NULL && service == NULL)) { @@ -271,7 +268,6 @@ int uv_getaddrinfo(uv_loop_t* loop, return rc; nodesize = strlen(hostname_ascii) + 1; node = hostname_ascii; - off += nodesize * sizeof(WCHAR); } if (service != NULL) { @@ -279,28 +275,27 @@ int uv_getaddrinfo(uv_loop_t* loop, if (rc < 0) return rc; servicesize = rc; - off = align_offset(off, sizeof(WCHAR)); - serviceoff = off; - off += servicesize * sizeof(WCHAR); } - if (hints != NULL) { - off = align_offset(off, sizeof(void *)); - hintoff = off; - hintssize = sizeof(struct addrinfoW); - off += hintssize; + hintssize = ALIGNED_SIZE(sizeof(struct addrinfoW)); } /* allocate memory for inputs, and partition it as needed */ - req->alloc = (char*)uv__malloc(off); - if (!req->alloc) + alloc_ptr = (char*)uv__malloc(ALIGNED_SIZE(nodesize * sizeof(WCHAR)) + + ALIGNED_SIZE(servicesize * sizeof(WCHAR)) + + hintssize); + if (!alloc_ptr) return UV_ENOMEM; + /* save alloc_ptr now so we can free if error */ + req->alloc = (void*) alloc_ptr; + /* Convert node string to UTF16 into allocated memory and save pointer in the * request. The node here has been converted to ascii. */ if (node != NULL) { - req->node = (WCHAR*) req->alloc; - uv_wtf8_to_utf16(node, (uint16_t*)req->node, nodesize); + req->node = (WCHAR*) alloc_ptr; + uv_wtf8_to_utf16(node, (uint16_t*) alloc_ptr, nodesize); + alloc_ptr += ALIGNED_SIZE(nodesize * sizeof(WCHAR)); } else { req->node = NULL; } @@ -308,15 +303,16 @@ int uv_getaddrinfo(uv_loop_t* loop, /* Convert service string to UTF16 into allocated memory and save pointer in * the req. */ if (service != NULL) { - req->service = (WCHAR*) ((char*) req->alloc + serviceoff); - uv_wtf8_to_utf16(service, (uint16_t*)req->service, servicesize); + req->service = (WCHAR*) alloc_ptr; + uv_wtf8_to_utf16(service, (uint16_t*) alloc_ptr, servicesize); + alloc_ptr += ALIGNED_SIZE(servicesize * sizeof(WCHAR)); } else { req->service = NULL; } /* copy hints to allocated memory and save pointer in req */ if (hints != NULL) { - req->addrinfow = (struct addrinfoW*) ((char*) req->alloc + hintoff); + req->addrinfow = (struct addrinfoW*) alloc_ptr; req->addrinfow->ai_family = hints->ai_family; req->addrinfow->ai_socktype = hints->ai_socktype; req->addrinfow->ai_protocol = hints->ai_protocol; @@ -329,7 +325,7 @@ int uv_getaddrinfo(uv_loop_t* loop, req->addrinfow = NULL; } - uv__req_register(loop); + uv__req_register(loop, req); if (getaddrinfo_cb) { uv__work_submit(loop, diff --git a/wpinet/src/main/native/thirdparty/libuv/src/win/getnameinfo.cpp b/wpinet/src/main/native/thirdparty/libuv/src/win/getnameinfo.cpp index 695549580d2..32863176ef6 100644 --- a/wpinet/src/main/native/thirdparty/libuv/src/win/getnameinfo.cpp +++ b/wpinet/src/main/native/thirdparty/libuv/src/win/getnameinfo.cpp @@ -82,7 +82,7 @@ static void uv__getnameinfo_done(struct uv__work* w, int status) { char* service; req = container_of(w, uv_getnameinfo_t, work_req); - uv__req_unregister(req->loop); + uv__req_unregister(req->loop, req); host = service = NULL; if (status == UV_ECANCELED) { @@ -124,7 +124,7 @@ int uv_getnameinfo(uv_loop_t* loop, } UV_REQ_INIT(req, UV_GETNAMEINFO); - uv__req_register(loop); + uv__req_register(loop, req); req->getnameinfo_cb = getnameinfo_cb; req->flags = flags; diff --git a/wpinet/src/main/native/thirdparty/libuv/src/win/pipe.cpp b/wpinet/src/main/native/thirdparty/libuv/src/win/pipe.cpp index 43ea270e618..d747dc72362 100644 --- a/wpinet/src/main/native/thirdparty/libuv/src/win/pipe.cpp +++ b/wpinet/src/main/native/thirdparty/libuv/src/win/pipe.cpp @@ -108,8 +108,8 @@ static int includes_nul(const char *s, size_t n) { } -static void uv__unique_pipe_name(unsigned long long ptr, char* name, size_t size) { - snprintf(name, size, "\\\\?\\pipe\\uv\\%llu-%lu", ptr, GetCurrentProcessId()); +static void uv__unique_pipe_name(char* ptr, char* name, size_t size) { + snprintf(name, size, "\\\\?\\pipe\\uv\\%p-%lu", ptr, GetCurrentProcessId()); } @@ -210,7 +210,7 @@ static void close_pipe(uv_pipe_t* pipe) { static int uv__pipe_server( HANDLE* pipeHandle_ptr, DWORD access, - char* name, size_t nameSize, unsigned long long random) { + char* name, size_t nameSize, char* random) { HANDLE pipeHandle; int err; @@ -251,7 +251,7 @@ static int uv__pipe_server( static int uv__create_pipe_pair( HANDLE* server_pipe_ptr, HANDLE* client_pipe_ptr, unsigned int server_flags, unsigned int client_flags, - int inherit_client, unsigned long long random) { + int inherit_client, char* random) { /* allowed flags are: UV_READABLE_PIPE | UV_WRITABLE_PIPE | UV_NONBLOCK_PIPE */ char pipe_name[64]; SECURITY_ATTRIBUTES sa; @@ -359,12 +359,7 @@ int uv_pipe(uv_file fds[2], int read_flags, int write_flags) { /* TODO: better source of local randomness than &fds? */ read_flags |= UV_READABLE_PIPE; write_flags |= UV_WRITABLE_PIPE; - err = uv__create_pipe_pair(&readh, - &writeh, - read_flags, - write_flags, - 0, - (uintptr_t) &fds[0]); + err = uv__create_pipe_pair(&readh, &writeh, read_flags, write_flags, 0, (char*) &fds[0]); if (err != 0) return err; temp[0] = _open_osfhandle((intptr_t) readh, 0); @@ -428,7 +423,7 @@ int uv__create_stdio_pipe_pair(uv_loop_t* loop, } err = uv__create_pipe_pair(&server_pipe, &client_pipe, - server_flags, client_flags, 1, (uintptr_t) server_pipe); + server_flags, client_flags, 1, (char*) server_pipe); if (err) goto error; @@ -674,10 +669,15 @@ void uv__pipe_endgame(uv_loop_t* loop, uv_pipe_t* handle) { } handle->pipe.conn.ipc_xfer_queue_length = 0; - assert(handle->read_req.wait_handle == INVALID_HANDLE_VALUE); - if (handle->read_req.event_handle != NULL) { - CloseHandle(handle->read_req.event_handle); - handle->read_req.event_handle = NULL; + if (handle->flags & UV_HANDLE_EMULATE_IOCP) { + if (handle->read_req.wait_handle != INVALID_HANDLE_VALUE) { + UnregisterWait(handle->read_req.wait_handle); + handle->read_req.wait_handle = INVALID_HANDLE_VALUE; + } + if (handle->read_req.event_handle != NULL) { + CloseHandle(handle->read_req.event_handle); + handle->read_req.event_handle = NULL; + } } if (handle->flags & UV_HANDLE_NON_OVERLAPPED_PIPE) @@ -870,7 +870,7 @@ void uv_pipe_connect(uv_connect_t* req, SET_REQ_ERROR(req, err); uv__insert_pending_req(loop, (uv_req_t*) req); handle->reqs_pending++; - REGISTER_HANDLE_REQ(loop, handle); + REGISTER_HANDLE_REQ(loop, handle, req); } } @@ -961,7 +961,7 @@ int uv_pipe_connect2(uv_connect_t* req, goto error; } - REGISTER_HANDLE_REQ(loop, handle); + REGISTER_HANDLE_REQ(loop, handle, req); handle->reqs_pending++; return 0; @@ -976,7 +976,7 @@ int uv_pipe_connect2(uv_connect_t* req, SET_REQ_SUCCESS(req); uv__insert_pending_req(loop, (uv_req_t*) req); handle->reqs_pending++; - REGISTER_HANDLE_REQ(loop, handle); + REGISTER_HANDLE_REQ(loop, handle, req); return 0; error: @@ -994,7 +994,7 @@ int uv_pipe_connect2(uv_connect_t* req, SET_REQ_ERROR(req, err); uv__insert_pending_req(loop, (uv_req_t*) req); handle->reqs_pending++; - REGISTER_HANDLE_REQ(loop, handle); + REGISTER_HANDLE_REQ(loop, handle, req); return 0; } @@ -1419,12 +1419,13 @@ static void uv__pipe_queue_read(uv_loop_t* loop, uv_pipe_t* handle) { } if (handle->flags & UV_HANDLE_EMULATE_IOCP) { - assert(req->wait_handle == INVALID_HANDLE_VALUE); - if (!RegisterWaitForSingleObject(&req->wait_handle, - req->event_handle, post_completion_read_wait, (void*) req, - INFINITE, WT_EXECUTEINWAITTHREAD | WT_EXECUTEONLYONCE)) { - SET_REQ_ERROR(req, GetLastError()); - goto error; + if (req->wait_handle == INVALID_HANDLE_VALUE) { + if (!RegisterWaitForSingleObject(&req->wait_handle, + req->event_handle, post_completion_read_wait, (void*) req, + INFINITE, WT_EXECUTEINWAITTHREAD)) { + SET_REQ_ERROR(req, GetLastError()); + goto error; + } } } } @@ -1452,16 +1453,16 @@ int uv__pipe_read_start(uv_pipe_t* handle, handle->read_cb = read_cb; handle->alloc_cb = alloc_cb; - if (handle->read_req.event_handle == NULL) { - handle->read_req.event_handle = CreateEvent(NULL, 0, 0, NULL); - if (handle->read_req.event_handle == NULL) { - uv_fatal_error(GetLastError(), "CreateEvent"); - } - } - /* If reading was stopped and then started again, there could still be a read * request pending. */ if (!(handle->flags & UV_HANDLE_READ_PENDING)) { + if (handle->flags & UV_HANDLE_EMULATE_IOCP && + handle->read_req.event_handle == NULL) { + handle->read_req.event_handle = CreateEvent(NULL, 0, 0, NULL); + if (handle->read_req.event_handle == NULL) { + uv_fatal_error(GetLastError(), "CreateEvent"); + } + } uv__pipe_queue_read(loop, handle); } @@ -1639,7 +1640,7 @@ static int uv__pipe_write_data(uv_loop_t* loop, req->u.io.queued_bytes = 0; } - REGISTER_HANDLE_REQ(loop, handle); + REGISTER_HANDLE_REQ(loop, handle, req); handle->reqs_pending++; handle->stream.conn.write_reqs_pending++; POST_COMPLETION_FOR_REQ(loop, req); @@ -1687,7 +1688,7 @@ static int uv__pipe_write_data(uv_loop_t* loop, CloseHandle(req->event_handle); req->event_handle = NULL; - REGISTER_HANDLE_REQ(loop, handle); + REGISTER_HANDLE_REQ(loop, handle, req); handle->reqs_pending++; handle->stream.conn.write_reqs_pending++; return 0; @@ -1714,13 +1715,13 @@ static int uv__pipe_write_data(uv_loop_t* loop, if (handle->flags & UV_HANDLE_EMULATE_IOCP) { if (!RegisterWaitForSingleObject(&req->wait_handle, req->event_handle, post_completion_write_wait, (void*) req, - INFINITE, WT_EXECUTEINWAITTHREAD | WT_EXECUTEONLYONCE)) { + INFINITE, WT_EXECUTEINWAITTHREAD)) { return GetLastError(); } } } - REGISTER_HANDLE_REQ(loop, handle); + REGISTER_HANDLE_REQ(loop, handle, req); handle->reqs_pending++; handle->stream.conn.write_reqs_pending++; @@ -1890,7 +1891,7 @@ static void uv__pipe_read_error(uv_loop_t* loop, uv_pipe_t* handle, int error, static void uv__pipe_read_error_or_eof(uv_loop_t* loop, uv_pipe_t* handle, - DWORD error, uv_buf_t buf) { + int error, uv_buf_t buf) { if (error == ERROR_BROKEN_PIPE) { uv__pipe_read_eof(loop, handle, buf); } else { @@ -1920,25 +1921,17 @@ static void uv__pipe_queue_ipc_xfer_info( /* Read an exact number of bytes from a pipe. If an error or end-of-file is * encountered before the requested number of bytes are read, an error is * returned. */ -static DWORD uv__pipe_read_exactly(uv_pipe_t* handle, void* buffer, DWORD count) { - uv_read_t* req; - DWORD bytes_read; - DWORD bytes_read_now; +static int uv__pipe_read_exactly(HANDLE h, void* buffer, DWORD count) { + DWORD bytes_read, bytes_read_now; bytes_read = 0; while (bytes_read < count) { - req = &handle->read_req; - memset(&req->u.io.overlapped, 0, sizeof(req->u.io.overlapped)); - req->u.io.overlapped.hEvent = (HANDLE) ((uintptr_t) req->event_handle | 1); - if (!ReadFile(handle->handle, + if (!ReadFile(h, (char*) buffer + bytes_read, count - bytes_read, &bytes_read_now, - &req->u.io.overlapped)) { - if (GetLastError() != ERROR_IO_PENDING) - return GetLastError(); - if (!GetOverlappedResult(handle->handle, &req->u.io.overlapped, &bytes_read_now, TRUE)) - return GetLastError(); + NULL)) { + return GetLastError(); } bytes_read += bytes_read_now; @@ -1949,19 +1942,16 @@ static DWORD uv__pipe_read_exactly(uv_pipe_t* handle, void* buffer, DWORD count) } -static int uv__pipe_read_data(uv_loop_t* loop, - uv_pipe_t* handle, - DWORD* bytes_read, /* inout argument */ - DWORD max_bytes) { +static DWORD uv__pipe_read_data(uv_loop_t* loop, + uv_pipe_t* handle, + DWORD suggested_bytes, + DWORD max_bytes) { + DWORD bytes_read; uv_buf_t buf; - uv_read_t* req; - DWORD r; - DWORD bytes_available; - int more; /* Ask the user for a buffer to read data into. */ buf = uv_buf_init(NULL, 0); - handle->alloc_cb((uv_handle_t*) handle, *bytes_read, &buf); + handle->alloc_cb((uv_handle_t*) handle, suggested_bytes, &buf); if (buf.base == NULL || buf.len == 0) { handle->read_cb((uv_stream_t*) handle, UV_ENOBUFS, &buf); return 0; /* Break out of read loop. */ @@ -1970,77 +1960,33 @@ static int uv__pipe_read_data(uv_loop_t* loop, /* Ensure we read at most the smaller of: * (a) the length of the user-allocated buffer. * (b) the maximum data length as specified by the `max_bytes` argument. - * (c) the amount of data that can be read non-blocking */ if (max_bytes > buf.len) max_bytes = buf.len; - if (handle->flags & UV_HANDLE_NON_OVERLAPPED_PIPE) { - /* The user failed to supply a pipe that can be used non-blocking or with - * threads. Try to estimate the amount of data that is safe to read without - * blocking, in a race-y way however. */ - bytes_available = 0; - if (!PeekNamedPipe(handle->handle, NULL, 0, NULL, &bytes_available, NULL)) { - r = GetLastError(); - } else { - if (max_bytes > bytes_available) - max_bytes = bytes_available; - *bytes_read = 0; - if (max_bytes == 0 || ReadFile(handle->handle, buf.base, max_bytes, bytes_read, NULL)) - r = ERROR_SUCCESS; - else - r = GetLastError(); - } - more = max_bytes < bytes_available; - } else { - /* Read into the user buffer. - * Prepare an Event so that we can cancel if it doesn't complete immediately. - */ - req = &handle->read_req; - memset(&req->u.io.overlapped, 0, sizeof(req->u.io.overlapped)); - req->u.io.overlapped.hEvent = (HANDLE) ((uintptr_t) req->event_handle | 1); - if (ReadFile(handle->handle, buf.base, max_bytes, bytes_read, &req->u.io.overlapped)) { - r = ERROR_SUCCESS; - } else { - r = GetLastError(); - *bytes_read = 0; - if (r == ERROR_IO_PENDING) { - r = CancelIoEx(handle->handle, &req->u.io.overlapped); - assert(r || GetLastError() == ERROR_NOT_FOUND); - if (GetOverlappedResult(handle->handle, &req->u.io.overlapped, bytes_read, TRUE)) { - r = ERROR_SUCCESS; - } else { - r = GetLastError(); - *bytes_read = 0; - } - } - } - more = *bytes_read == max_bytes; + /* Read into the user buffer. */ + if (!ReadFile(handle->handle, buf.base, max_bytes, &bytes_read, NULL)) { + uv__pipe_read_error_or_eof(loop, handle, GetLastError(), buf); + return 0; /* Break out of read loop. */ } /* Call the read callback. */ - if (r == ERROR_SUCCESS || r == ERROR_OPERATION_ABORTED) - handle->read_cb((uv_stream_t*) handle, *bytes_read, &buf); - else - uv__pipe_read_error_or_eof(loop, handle, r, buf); + handle->read_cb((uv_stream_t*) handle, bytes_read, &buf); - return more; + return bytes_read; } -static int uv__pipe_read_ipc(uv_loop_t* loop, uv_pipe_t* handle) { - uint32_t* data_remaining; - DWORD err; - DWORD more; - DWORD bytes_read; - - data_remaining = &handle->pipe.conn.ipc_data_frame.payload_remaining; +static DWORD uv__pipe_read_ipc(uv_loop_t* loop, uv_pipe_t* handle) { + uint32_t* data_remaining = &handle->pipe.conn.ipc_data_frame.payload_remaining; + int err; if (*data_remaining > 0) { /* Read frame data payload. */ - bytes_read = *data_remaining; - more = uv__pipe_read_data(loop, handle, &bytes_read, bytes_read); + DWORD bytes_read = + uv__pipe_read_data(loop, handle, *data_remaining, *data_remaining); *data_remaining -= bytes_read; + return bytes_read; } else { /* Start of a new IPC frame. */ @@ -2051,7 +1997,7 @@ static int uv__pipe_read_ipc(uv_loop_t* loop, uv_pipe_t* handle) { /* Read the IPC frame header. */ err = uv__pipe_read_exactly( - handle, &frame_header, sizeof frame_header); + handle->handle, &frame_header, sizeof frame_header); if (err) goto error; @@ -2087,28 +2033,21 @@ static int uv__pipe_read_ipc(uv_loop_t* loop, uv_pipe_t* handle) { /* If no socket xfer info follows, return here. Data will be read in a * subsequent invocation of uv__pipe_read_ipc(). */ - if (xfer_type != UV__IPC_SOCKET_XFER_NONE) { - /* Read transferred socket information. */ - err = uv__pipe_read_exactly(handle, &xfer_info, sizeof xfer_info); - if (err) - goto error; + if (xfer_type == UV__IPC_SOCKET_XFER_NONE) + return sizeof frame_header; /* Number of bytes read. */ - /* Store the pending socket info. */ - uv__pipe_queue_ipc_xfer_info(handle, xfer_type, &xfer_info); - } + /* Read transferred socket information. */ + err = uv__pipe_read_exactly(handle->handle, &xfer_info, sizeof xfer_info); + if (err) + goto error; - more = 1; - } + /* Store the pending socket info. */ + uv__pipe_queue_ipc_xfer_info(handle, xfer_type, &xfer_info); - /* Return whether the caller should immediately try another read call to get - * more data. */ - if (more && *data_remaining == 0) { - /* TODO: use PeekNamedPipe to see if it is really worth trying to do - * another ReadFile call. */ + /* Return number of bytes read. */ + return sizeof frame_header + sizeof xfer_info; } - return more; - invalid: /* Invalid frame. */ err = WSAECONNABORTED; /* Maps to UV_ECONNABORTED. */ @@ -2122,20 +2061,12 @@ static int uv__pipe_read_ipc(uv_loop_t* loop, uv_pipe_t* handle) { void uv__process_pipe_read_req(uv_loop_t* loop, uv_pipe_t* handle, uv_req_t* req) { - DWORD err; - DWORD more; - DWORD bytes_requested; assert(handle->type == UV_NAMED_PIPE); handle->flags &= ~(UV_HANDLE_READ_PENDING | UV_HANDLE_CANCELLATION_PENDING); DECREASE_PENDING_REQ_COUNT(handle); eof_timer_stop(handle); - if (handle->read_req.wait_handle != INVALID_HANDLE_VALUE) { - UnregisterWait(handle->read_req.wait_handle); - handle->read_req.wait_handle = INVALID_HANDLE_VALUE; - } - /* At this point, we're done with bookkeeping. If the user has stopped * reading the pipe in the meantime, there is nothing left to do, since there * is no callback that we can call. */ @@ -2144,7 +2075,7 @@ void uv__process_pipe_read_req(uv_loop_t* loop, if (!REQ_SUCCESS(req)) { /* An error occurred doing the zero-read. */ - err = GET_REQ_ERROR(req); + DWORD err = GET_REQ_ERROR(req); /* If the read was cancelled by uv__pipe_interrupt_read(), the request may * indicate an ERROR_OPERATION_ABORTED error. This error isn't relevant to @@ -2155,18 +2086,34 @@ void uv__process_pipe_read_req(uv_loop_t* loop, } else { /* The zero-read completed without error, indicating there is data * available in the kernel buffer. */ - while (handle->flags & UV_HANDLE_READING) { - bytes_requested = 65536; + DWORD avail; + + /* Get the number of bytes available. */ + avail = 0; + if (!PeekNamedPipe(handle->handle, NULL, 0, NULL, &avail, NULL)) + uv__pipe_read_error_or_eof(loop, handle, GetLastError(), uv_null_buf_); + + /* Read until we've either read all the bytes available, or the 'reading' + * flag is cleared. */ + while (avail > 0 && handle->flags & UV_HANDLE_READING) { /* Depending on the type of pipe, read either IPC frames or raw data. */ - if (handle->ipc) - more = uv__pipe_read_ipc(loop, handle); - else - more = uv__pipe_read_data(loop, handle, &bytes_requested, INT32_MAX); + DWORD bytes_read = + handle->ipc ? uv__pipe_read_ipc(loop, handle) + : uv__pipe_read_data(loop, handle, avail, (DWORD) -1); /* If no bytes were read, treat this as an indication that an error * occurred, and break out of the read loop. */ - if (more == 0) + if (bytes_read == 0) + break; + + /* It is possible that more bytes were read than we thought were + * available. To prevent `avail` from underflowing, break out of the loop + * if this is the case. */ + if (bytes_read > avail) break; + + /* Recompute the number of bytes available. */ + avail -= bytes_read; } } @@ -2187,15 +2134,17 @@ void uv__process_pipe_write_req(uv_loop_t* loop, uv_pipe_t* handle, assert(handle->write_queue_size >= req->u.io.queued_bytes); handle->write_queue_size -= req->u.io.queued_bytes; - UNREGISTER_HANDLE_REQ(loop, handle); + UNREGISTER_HANDLE_REQ(loop, handle, req); - if (req->wait_handle != INVALID_HANDLE_VALUE) { - UnregisterWait(req->wait_handle); - req->wait_handle = INVALID_HANDLE_VALUE; - } - if (req->event_handle) { - CloseHandle(req->event_handle); - req->event_handle = NULL; + if (handle->flags & UV_HANDLE_EMULATE_IOCP) { + if (req->wait_handle != INVALID_HANDLE_VALUE) { + UnregisterWait(req->wait_handle); + req->wait_handle = INVALID_HANDLE_VALUE; + } + if (req->event_handle) { + CloseHandle(req->event_handle); + req->event_handle = NULL; + } } err = GET_REQ_ERROR(req); @@ -2272,7 +2221,7 @@ void uv__process_pipe_connect_req(uv_loop_t* loop, uv_pipe_t* handle, assert(handle->type == UV_NAMED_PIPE); - UNREGISTER_HANDLE_REQ(loop, handle); + UNREGISTER_HANDLE_REQ(loop, handle, req); err = 0; if (REQ_SUCCESS(req)) { @@ -2304,7 +2253,7 @@ void uv__process_pipe_shutdown_req(uv_loop_t* loop, uv_pipe_t* handle, /* Clear the shutdown_req field so we don't go here again. */ handle->stream.conn.shutdown_req = NULL; - UNREGISTER_HANDLE_REQ(loop, handle); + UNREGISTER_HANDLE_REQ(loop, handle, req); if (handle->flags & UV_HANDLE_CLOSING) { /* Already closing. Cancel the shutdown. */ diff --git a/wpinet/src/main/native/thirdparty/libuv/src/win/process-stdio.cpp b/wpinet/src/main/native/thirdparty/libuv/src/win/process-stdio.cpp index 181db92ea30..0db35723731 100644 --- a/wpinet/src/main/native/thirdparty/libuv/src/win/process-stdio.cpp +++ b/wpinet/src/main/native/thirdparty/libuv/src/win/process-stdio.cpp @@ -46,12 +46,12 @@ #define CHILD_STDIO_CRT_FLAGS(buffer, fd) \ *((unsigned char*) (buffer) + sizeof(int) + fd) -#define CHILD_STDIO_HANDLE(buffer, fd) \ - ((void*) ((unsigned char*) (buffer) + \ - sizeof(int) + \ - sizeof(unsigned char) * \ - CHILD_STDIO_COUNT((buffer)) + \ - sizeof(HANDLE) * (fd))) +#define CHILD_STDIO_HANDLE(buffer, fd) \ + *((HANDLE*) ((unsigned char*) (buffer) + \ + sizeof(int) + \ + sizeof(unsigned char) * \ + CHILD_STDIO_COUNT((buffer)) + \ + sizeof(HANDLE) * (fd))) /* CRT file descriptor mode flags */ @@ -194,7 +194,7 @@ int uv__stdio_create(uv_loop_t* loop, CHILD_STDIO_COUNT(buffer) = count; for (i = 0; i < count; i++) { CHILD_STDIO_CRT_FLAGS(buffer, i) = 0; - memset(CHILD_STDIO_HANDLE(buffer, i), 0xFF, sizeof(HANDLE)); + CHILD_STDIO_HANDLE(buffer, i) = INVALID_HANDLE_VALUE; } for (i = 0; i < count; i++) { @@ -215,15 +215,14 @@ int uv__stdio_create(uv_loop_t* loop, * handles in the stdio buffer are initialized with. * INVALID_HANDLE_VALUE, which should be okay. */ if (i <= 2) { - HANDLE nul; DWORD access = (i == 0) ? FILE_GENERIC_READ : FILE_GENERIC_WRITE | FILE_READ_ATTRIBUTES; - err = uv__create_nul_handle(&nul, access); + err = uv__create_nul_handle(&CHILD_STDIO_HANDLE(buffer, i), + access); if (err) goto error; - memcpy(CHILD_STDIO_HANDLE(buffer, i), &nul, sizeof(HANDLE)); CHILD_STDIO_CRT_FLAGS(buffer, i) = FOPEN | FDEV; } break; @@ -248,7 +247,7 @@ int uv__stdio_create(uv_loop_t* loop, if (err) goto error; - memcpy(CHILD_STDIO_HANDLE(buffer, i), &child_pipe, sizeof(HANDLE)); + CHILD_STDIO_HANDLE(buffer, i) = child_pipe; CHILD_STDIO_CRT_FLAGS(buffer, i) = FOPEN | FPIPE; break; } @@ -264,7 +263,7 @@ int uv__stdio_create(uv_loop_t* loop, * error. */ if (fdopt.data.fd <= 2 && err == ERROR_INVALID_HANDLE) { CHILD_STDIO_CRT_FLAGS(buffer, i) = 0; - memset(CHILD_STDIO_HANDLE(buffer, i), 0xFF, sizeof(HANDLE)); + CHILD_STDIO_HANDLE(buffer, i) = INVALID_HANDLE_VALUE; break; } goto error; @@ -299,7 +298,7 @@ int uv__stdio_create(uv_loop_t* loop, return -1; } - memcpy(CHILD_STDIO_HANDLE(buffer, i), &child_handle, sizeof(HANDLE)); + CHILD_STDIO_HANDLE(buffer, i) = child_handle; break; } @@ -335,7 +334,7 @@ int uv__stdio_create(uv_loop_t* loop, if (err) goto error; - memcpy(CHILD_STDIO_HANDLE(buffer, i), &child_handle, sizeof(HANDLE)); + CHILD_STDIO_HANDLE(buffer, i) = child_handle; CHILD_STDIO_CRT_FLAGS(buffer, i) = crt_flags; break; } @@ -360,7 +359,7 @@ void uv__stdio_destroy(BYTE* buffer) { count = CHILD_STDIO_COUNT(buffer); for (i = 0; i < count; i++) { - HANDLE handle = uv__stdio_handle(buffer, i); + HANDLE handle = CHILD_STDIO_HANDLE(buffer, i); if (handle != INVALID_HANDLE_VALUE) { CloseHandle(handle); } @@ -375,7 +374,7 @@ void uv__stdio_noinherit(BYTE* buffer) { count = CHILD_STDIO_COUNT(buffer); for (i = 0; i < count; i++) { - HANDLE handle = uv__stdio_handle(buffer, i); + HANDLE handle = CHILD_STDIO_HANDLE(buffer, i); if (handle != INVALID_HANDLE_VALUE) { SetHandleInformation(handle, HANDLE_FLAG_INHERIT, 0); } @@ -413,7 +412,5 @@ WORD uv__stdio_size(BYTE* buffer) { HANDLE uv__stdio_handle(BYTE* buffer, int fd) { - HANDLE handle; - memcpy(&handle, CHILD_STDIO_HANDLE(buffer, fd), sizeof(HANDLE)); - return handle; + return CHILD_STDIO_HANDLE(buffer, fd); } diff --git a/wpinet/src/main/native/thirdparty/libuv/src/win/process.cpp b/wpinet/src/main/native/thirdparty/libuv/src/win/process.cpp index d6b61c14015..e4bf93d707d 100644 --- a/wpinet/src/main/native/thirdparty/libuv/src/win/process.cpp +++ b/wpinet/src/main/native/thirdparty/libuv/src/win/process.cpp @@ -28,6 +28,7 @@ #include #include #include +#include /* _alloca */ #include "uv.h" #include "internal.h" @@ -596,9 +597,11 @@ int make_program_args(char** args, int verbatim_arguments, WCHAR** dst_ptr) { } -static int env_strncmp(const wchar_t* a, int na, const wchar_t* b) { +int env_strncmp(const wchar_t* a, int na, const wchar_t* b) { const wchar_t* a_eq; const wchar_t* b_eq; + wchar_t* A; + wchar_t* B; int nb; int r; @@ -613,8 +616,27 @@ static int env_strncmp(const wchar_t* a, int na, const wchar_t* b) { assert(b_eq); nb = b_eq - b; - r = CompareStringOrdinal(a, na, b, nb, /*case insensitive*/TRUE); - return r - CSTR_EQUAL; + A = (wchar_t*)_alloca((na+1) * sizeof(wchar_t)); + B = (wchar_t*)_alloca((nb+1) * sizeof(wchar_t)); + + r = LCMapStringW(LOCALE_INVARIANT, LCMAP_UPPERCASE, a, na, A, na); + assert(r==na); + A[na] = L'\0'; + r = LCMapStringW(LOCALE_INVARIANT, LCMAP_UPPERCASE, b, nb, B, nb); + assert(r==nb); + B[nb] = L'\0'; + + for (;;) { + wchar_t AA = *A++; + wchar_t BB = *B++; + if (AA < BB) { + return -1; + } else if (AA > BB) { + return 1; + } else if (!AA && !BB) { + return 0; + } + } } @@ -653,7 +675,6 @@ int make_program_env(char* env_block[], WCHAR** dst_ptr) { WCHAR* dst_copy; WCHAR** ptr_copy; WCHAR** env_copy; - char* p; size_t required_vars_value_len[ARRAY_SIZE(required_vars)]; /* first pass: determine size in UTF-16 */ @@ -669,13 +690,11 @@ int make_program_env(char* env_block[], WCHAR** dst_ptr) { } /* second pass: copy to UTF-16 environment block */ - len = env_block_count * sizeof(WCHAR*); - p = (char*)uv__malloc(len + env_len * sizeof(WCHAR)); - if (p == NULL) { + dst_copy = (WCHAR*)uv__malloc(env_len * sizeof(WCHAR)); + if (dst_copy == NULL && env_len > 0) { return UV_ENOMEM; } - env_copy = (WCHAR**) &p[0]; - dst_copy = (WCHAR*) &p[len]; + env_copy = (WCHAR**)_alloca(env_block_count * sizeof(WCHAR*)); ptr = dst_copy; ptr_copy = env_copy; @@ -725,7 +744,7 @@ int make_program_env(char* env_block[], WCHAR** dst_ptr) { /* final pass: copy, in sort order, and inserting required variables */ dst = (WCHAR*)uv__malloc((1+env_len) * sizeof(WCHAR)); if (!dst) { - uv__free(p); + uv__free(dst_copy); return UV_ENOMEM; } @@ -770,7 +789,7 @@ int make_program_env(char* env_block[], WCHAR** dst_ptr) { assert(env_len == (size_t) (ptr - dst)); *ptr = L'\0'; - uv__free(p); + uv__free(dst_copy); *dst_ptr = dst; return 0; } @@ -1166,34 +1185,16 @@ static int uv__kill(HANDLE process_handle, int signum) { /* Unconditionally terminate the process. On Windows, killed processes * normally return 1. */ int err; - DWORD status; if (TerminateProcess(process_handle, 1)) return 0; - /* If the process already exited before TerminateProcess was called, + /* If the process already exited before TerminateProcess was called,. * TerminateProcess will fail with ERROR_ACCESS_DENIED. */ err = GetLastError(); - if (err == ERROR_ACCESS_DENIED) { - /* First check using GetExitCodeProcess() with status different from - * STILL_ACTIVE (259). This check can be set incorrectly by the process, - * though that is uncommon. */ - if (GetExitCodeProcess(process_handle, &status) && - status != STILL_ACTIVE) { - return UV_ESRCH; - } - - /* But the process could have exited with code == STILL_ACTIVE, use then - * WaitForSingleObject with timeout zero. This is prone to a race - * condition as it could return WAIT_TIMEOUT because the handle might - * not have been signaled yet.That would result in returning the wrong - * error code here (UV_EACCES instead of UV_ESRCH), but we cannot fix - * the kernel synchronization issue that TerminateProcess is - * inconsistent with WaitForSingleObject with just the APIs available to - * us in user space. */ - if (WaitForSingleObject(process_handle, 0) == WAIT_OBJECT_0) { - return UV_ESRCH; - } + if (err == ERROR_ACCESS_DENIED && + WaitForSingleObject(process_handle, 0) == WAIT_OBJECT_0) { + return UV_ESRCH; } return uv_translate_sys_error(err); @@ -1201,14 +1202,6 @@ static int uv__kill(HANDLE process_handle, int signum) { case 0: { /* Health check: is the process still alive? */ - DWORD status; - - if (!GetExitCodeProcess(process_handle, &status)) - return uv_translate_sys_error(GetLastError()); - - if (status != STILL_ACTIVE) - return UV_ESRCH; - switch (WaitForSingleObject(process_handle, 0)) { case WAIT_OBJECT_0: return UV_ESRCH; diff --git a/wpinet/src/main/native/thirdparty/libuv/src/win/req-inl.h b/wpinet/src/main/native/thirdparty/libuv/src/win/req-inl.h index cf16e8ba41f..9e2075906f5 100644 --- a/wpinet/src/main/native/thirdparty/libuv/src/win/req-inl.h +++ b/wpinet/src/main/native/thirdparty/libuv/src/win/req-inl.h @@ -53,16 +53,16 @@ (uv__ntstatus_to_winsock_error(GET_REQ_STATUS((req)))) -#define REGISTER_HANDLE_REQ(loop, handle) \ +#define REGISTER_HANDLE_REQ(loop, handle, req) \ do { \ INCREASE_ACTIVE_COUNT((loop), (handle)); \ - uv__req_register((loop)); \ + uv__req_register((loop), (req)); \ } while (0) -#define UNREGISTER_HANDLE_REQ(loop, handle) \ +#define UNREGISTER_HANDLE_REQ(loop, handle, req) \ do { \ DECREASE_ACTIVE_COUNT((loop), (handle)); \ - uv__req_unregister((loop)); \ + uv__req_unregister((loop), (req)); \ } while (0) @@ -83,7 +83,7 @@ INLINE static uv_req_t* uv__overlapped_to_req(OVERLAPPED* overlapped) { - return container_of(overlapped, uv_req_t, u.io.overlapped); + return CONTAINING_RECORD(overlapped, uv_req_t, u.io.overlapped); } diff --git a/wpinet/src/main/native/thirdparty/libuv/src/win/signal.cpp b/wpinet/src/main/native/thirdparty/libuv/src/win/signal.cpp index 85730b27b2b..8c79871b9bb 100644 --- a/wpinet/src/main/native/thirdparty/libuv/src/win/signal.cpp +++ b/wpinet/src/main/native/thirdparty/libuv/src/win/signal.cpp @@ -91,7 +91,7 @@ int uv__signal_dispatch(int signum) { for (handle = RB_NFIND(uv_signal_tree_s, &uv__signal_tree, &lookup); handle != NULL && handle->signum == signum; - handle = RB_NEXT(uv_signal_tree_s, handle)) { + handle = RB_NEXT(uv_signal_tree_s, &uv__signal_tree, handle)) { unsigned long previous = InterlockedExchange( (volatile LONG*) &handle->pending_signum, signum); diff --git a/wpinet/src/main/native/thirdparty/libuv/src/win/stream.cpp b/wpinet/src/main/native/thirdparty/libuv/src/win/stream.cpp index 61a82fe4e6e..7bf9ca388cb 100644 --- a/wpinet/src/main/native/thirdparty/libuv/src/win/stream.cpp +++ b/wpinet/src/main/native/thirdparty/libuv/src/win/stream.cpp @@ -216,7 +216,7 @@ int uv_shutdown(uv_shutdown_t* req, uv_stream_t* handle, uv_shutdown_cb cb) { handle->flags &= ~UV_HANDLE_WRITABLE; handle->stream.conn.shutdown_req = req; handle->reqs_pending++; - REGISTER_HANDLE_REQ(loop, handle); + REGISTER_HANDLE_REQ(loop, handle, req); if (handle->stream.conn.write_reqs_pending == 0) { if (handle->type == UV_NAMED_PIPE) diff --git a/wpinet/src/main/native/thirdparty/libuv/src/win/tcp.cpp b/wpinet/src/main/native/thirdparty/libuv/src/win/tcp.cpp index 2b43d03ea22..d8da4d941a5 100644 --- a/wpinet/src/main/native/thirdparty/libuv/src/win/tcp.cpp +++ b/wpinet/src/main/native/thirdparty/libuv/src/win/tcp.cpp @@ -58,17 +58,11 @@ static int uv__tcp_keepalive(uv_tcp_t* handle, SOCKET socket, int enable, unsign return WSAGetLastError(); } - if (!enable) - return 0; - - if (delay < 1) - return UV_EINVAL; - - if (setsockopt(socket, - IPPROTO_TCP, - TCP_KEEPALIVE, - (const char*)&delay, - sizeof delay) == -1) { + if (enable && setsockopt(socket, + IPPROTO_TCP, + TCP_KEEPALIVE, + (const char*)&delay, + sizeof delay) == -1) { return WSAGetLastError(); } @@ -212,7 +206,7 @@ void uv__process_tcp_shutdown_req(uv_loop_t* loop, uv_tcp_t* stream, uv_shutdown assert(stream->flags & UV_HANDLE_CONNECTION); stream->stream.conn.shutdown_req = NULL; - UNREGISTER_HANDLE_REQ(loop, stream); + UNREGISTER_HANDLE_REQ(loop, stream, req); err = 0; if (stream->flags & UV_HANDLE_CLOSING) @@ -292,12 +286,6 @@ static int uv__tcp_try_bind(uv_tcp_t* handle, DWORD err; int r; - /* There is no SO_REUSEPORT on Windows, Windows only knows SO_REUSEADDR. - * so we just return an error directly when UV_TCP_REUSEPORT is requested - * for binding the socket. */ - if (flags & UV_TCP_REUSEPORT) - return ERROR_NOT_SUPPORTED; - if (handle->socket == INVALID_SOCKET) { SOCKET sock; @@ -834,7 +822,7 @@ static int uv__tcp_try_connect(uv_connect_t* req, if (handle->delayed_error != 0) { /* Process the req without IOCP. */ handle->reqs_pending++; - REGISTER_HANDLE_REQ(loop, handle); + REGISTER_HANDLE_REQ(loop, handle, req); uv__insert_pending_req(loop, (uv_req_t*)req); return 0; } @@ -850,12 +838,12 @@ static int uv__tcp_try_connect(uv_connect_t* req, if (UV_SUCCEEDED_WITHOUT_IOCP(success)) { /* Process the req without IOCP. */ handle->reqs_pending++; - REGISTER_HANDLE_REQ(loop, handle); + REGISTER_HANDLE_REQ(loop, handle, req); uv__insert_pending_req(loop, (uv_req_t*)req); } else if (UV_SUCCEEDED_WITH_IOCP(success)) { /* The req will be processed with IOCP. */ handle->reqs_pending++; - REGISTER_HANDLE_REQ(loop, handle); + REGISTER_HANDLE_REQ(loop, handle, req); } else { return WSAGetLastError(); } @@ -925,14 +913,14 @@ int uv__tcp_write(uv_loop_t* loop, req->u.io.queued_bytes = 0; handle->reqs_pending++; handle->stream.conn.write_reqs_pending++; - REGISTER_HANDLE_REQ(loop, handle); + REGISTER_HANDLE_REQ(loop, handle, req); uv__insert_pending_req(loop, (uv_req_t*) req); } else if (UV_SUCCEEDED_WITH_IOCP(result == 0)) { /* Request queued by the kernel. */ req->u.io.queued_bytes = uv__count_bufs(bufs, nbufs); handle->reqs_pending++; handle->stream.conn.write_reqs_pending++; - REGISTER_HANDLE_REQ(loop, handle); + REGISTER_HANDLE_REQ(loop, handle, req); handle->write_queue_size += req->u.io.queued_bytes; if (handle->flags & UV_HANDLE_EMULATE_IOCP && !RegisterWaitForSingleObject(&req->wait_handle, @@ -946,7 +934,7 @@ int uv__tcp_write(uv_loop_t* loop, req->u.io.queued_bytes = 0; handle->reqs_pending++; handle->stream.conn.write_reqs_pending++; - REGISTER_HANDLE_REQ(loop, handle); + REGISTER_HANDLE_REQ(loop, handle, req); SET_REQ_ERROR(req, WSAGetLastError()); uv__insert_pending_req(loop, (uv_req_t*) req); } @@ -1117,7 +1105,7 @@ void uv__process_tcp_write_req(uv_loop_t* loop, uv_tcp_t* handle, assert(handle->write_queue_size >= req->u.io.queued_bytes); handle->write_queue_size -= req->u.io.queued_bytes; - UNREGISTER_HANDLE_REQ(loop, handle); + UNREGISTER_HANDLE_REQ(loop, handle, req); if (handle->flags & UV_HANDLE_EMULATE_IOCP) { if (req->wait_handle != INVALID_HANDLE_VALUE) { @@ -1209,7 +1197,7 @@ void uv__process_tcp_connect_req(uv_loop_t* loop, uv_tcp_t* handle, assert(handle->type == UV_TCP); - UNREGISTER_HANDLE_REQ(loop, handle); + UNREGISTER_HANDLE_REQ(loop, handle, req); err = 0; if (handle->delayed_error) { @@ -1563,6 +1551,11 @@ int uv__tcp_connect(uv_connect_t* req, return 0; } +#ifndef WSA_FLAG_NO_HANDLE_INHERIT +/* Added in Windows 7 SP1. Specify this to avoid race conditions, */ +/* but also manually clear the inherit flag in case this failed. */ +#define WSA_FLAG_NO_HANDLE_INHERIT 0x80 +#endif int uv_socketpair(int type, int protocol, uv_os_sock_t fds[2], int flags0, int flags1) { SOCKET server = INVALID_SOCKET; diff --git a/wpinet/src/main/native/thirdparty/libuv/src/win/thread.cpp b/wpinet/src/main/native/thirdparty/libuv/src/win/thread.cpp index 6a4d4498577..03b33e9b4de 100644 --- a/wpinet/src/main/native/thirdparty/libuv/src/win/thread.cpp +++ b/wpinet/src/main/native/thirdparty/libuv/src/win/thread.cpp @@ -32,23 +32,45 @@ #include "uv.h" #include "internal.h" -typedef void (*uv__once_cb)(void); +static void uv__once_inner(uv_once_t* guard, void (*callback)(void)) { + DWORD result; + HANDLE existing_event, created_event; + + created_event = CreateEvent(NULL, 1, 0, NULL); + if (created_event == 0) { + /* Could fail in a low-memory situation? */ + uv_fatal_error(GetLastError(), "CreateEvent"); + } -typedef struct { - uv__once_cb callback; -} uv__once_data_t; + existing_event = InterlockedCompareExchangePointer(&guard->event, + created_event, + NULL); -static BOOL WINAPI uv__once_inner(INIT_ONCE *once, void* param, void** context) { - uv__once_data_t* data = (uv__once_data_t*)param; + if (existing_event == NULL) { + /* We won the race */ + callback(); - data->callback(); + result = SetEvent(created_event); + assert(result); + guard->ran = 1; - return TRUE; + } else { + /* We lost the race. Destroy the event we created and wait for the existing + * one to become signaled. */ + CloseHandle(created_event); + result = WaitForSingleObject(existing_event, INFINITE); + assert(result == WAIT_OBJECT_0); + } } -void uv_once(uv_once_t* guard, uv__once_cb callback) { - uv__once_data_t data = { .callback = callback }; - InitOnceExecuteOnce(&guard->init_once, uv__once_inner, (void*) &data, NULL); + +void uv_once(uv_once_t* guard, void (*callback)(void)) { + /* Fast case - avoid WaitForSingleObject. */ + if (guard->ran) { + return; + } + + uv__once_inner(guard, callback); } diff --git a/wpinet/src/main/native/thirdparty/libuv/src/win/tty.cpp b/wpinet/src/main/native/thirdparty/libuv/src/win/tty.cpp index f1acef2c64e..f7d5ef6c29f 100644 --- a/wpinet/src/main/native/thirdparty/libuv/src/win/tty.cpp +++ b/wpinet/src/main/native/thirdparty/libuv/src/win/tty.cpp @@ -2187,7 +2187,7 @@ int uv__tty_write(uv_loop_t* loop, handle->reqs_pending++; handle->stream.conn.write_reqs_pending++; - REGISTER_HANDLE_REQ(loop, handle); + REGISTER_HANDLE_REQ(loop, handle, req); req->u.io.queued_bytes = 0; @@ -2223,7 +2223,7 @@ void uv__process_tty_write_req(uv_loop_t* loop, uv_tty_t* handle, int err; handle->write_queue_size -= req->u.io.queued_bytes; - UNREGISTER_HANDLE_REQ(loop, handle); + UNREGISTER_HANDLE_REQ(loop, handle, req); if (req->cb) { err = GET_REQ_ERROR(req); @@ -2267,7 +2267,7 @@ void uv__process_tty_shutdown_req(uv_loop_t* loop, uv_tty_t* stream, uv_shutdown assert(req); stream->stream.conn.shutdown_req = NULL; - UNREGISTER_HANDLE_REQ(loop, stream); + UNREGISTER_HANDLE_REQ(loop, stream, req); /* TTY shutdown is really just a no-op */ if (req->cb) { @@ -2384,8 +2384,8 @@ static DWORD WINAPI uv__tty_console_resize_watcher_thread(void* param) { /* Make sure to not overwhelm the system with resize events */ Sleep(33); WaitForSingleObject(uv__tty_console_resized, INFINITE); - ResetEvent(uv__tty_console_resized); uv__tty_console_signal_resize(); + ResetEvent(uv__tty_console_resized); } return 0; } diff --git a/wpinet/src/main/native/thirdparty/libuv/src/win/udp.cpp b/wpinet/src/main/native/thirdparty/libuv/src/win/udp.cpp index 5c8f6e1dd0b..eab53842d4f 100644 --- a/wpinet/src/main/native/thirdparty/libuv/src/win/udp.cpp +++ b/wpinet/src/main/native/thirdparty/libuv/src/win/udp.cpp @@ -200,12 +200,6 @@ static int uv__udp_maybe_bind(uv_udp_t* handle, if (handle->flags & UV_HANDLE_BOUND) return 0; - /* There is no SO_REUSEPORT on Windows, Windows only knows SO_REUSEADDR. - * so we just return an error directly when UV_UDP_REUSEPORT is requested - * for binding the socket. */ - if (flags & UV_UDP_REUSEPORT) - return ERROR_NOT_SUPPORTED; - if ((flags & UV_UDP_IPV6ONLY) && addr->sa_family != AF_INET6) { /* UV_UDP_IPV6ONLY is supported only for IPV6 sockets */ return ERROR_INVALID_PARAMETER; @@ -382,7 +376,7 @@ static int uv__send(uv_udp_send_t* req, handle->reqs_pending++; handle->send_queue_size += req->u.io.queued_bytes; handle->send_queue_count++; - REGISTER_HANDLE_REQ(loop, handle); + REGISTER_HANDLE_REQ(loop, handle, req); uv__insert_pending_req(loop, (uv_req_t*)req); } else if (UV_SUCCEEDED_WITH_IOCP(result == 0)) { /* Request queued by the kernel. */ @@ -390,7 +384,7 @@ static int uv__send(uv_udp_send_t* req, handle->reqs_pending++; handle->send_queue_size += req->u.io.queued_bytes; handle->send_queue_count++; - REGISTER_HANDLE_REQ(loop, handle); + REGISTER_HANDLE_REQ(loop, handle, req); } else { /* Send failed due to an error. */ return WSAGetLastError(); @@ -533,7 +527,7 @@ void uv__process_udp_send_req(uv_loop_t* loop, uv_udp_t* handle, handle->send_queue_size -= req->u.io.queued_bytes; handle->send_queue_count--; - UNREGISTER_HANDLE_REQ(loop, handle); + UNREGISTER_HANDLE_REQ(loop, handle, req); if (req->cb) { err = 0; diff --git a/wpinet/src/main/native/thirdparty/libuv/src/win/util.cpp b/wpinet/src/main/native/thirdparty/libuv/src/win/util.cpp index 907a0984093..6529aa36f32 100644 --- a/wpinet/src/main/native/thirdparty/libuv/src/win/util.cpp +++ b/wpinet/src/main/native/thirdparty/libuv/src/win/util.cpp @@ -326,19 +326,25 @@ uv_pid_t uv_os_getpid(void) { uv_pid_t uv_os_getppid(void) { - NTSTATUS nt_status; - PROCESS_BASIC_INFORMATION basic_info; - - nt_status = pNtQueryInformationProcess(GetCurrentProcess(), - ProcessBasicInformation, - &basic_info, - sizeof(basic_info), - NULL); - if (NT_SUCCESS(nt_status)) { - return basic_info.InheritedFromUniqueProcessId; - } else { - return -1; + int parent_pid = -1; + HANDLE handle; + PROCESSENTRY32 pe; + DWORD current_pid = GetCurrentProcessId(); + + pe.dwSize = sizeof(PROCESSENTRY32); + handle = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); + + if (Process32First(handle, &pe)) { + do { + if (pe.th32ProcessID == current_pid) { + parent_pid = pe.th32ParentProcessID; + break; + } + } while( Process32Next(handle, &pe)); } + + CloseHandle(handle); + return parent_pid; } @@ -516,23 +522,19 @@ int uv_uptime(double* uptime) { unsigned int uv_available_parallelism(void) { - DWORD_PTR procmask; - DWORD_PTR sysmask; - int count; - int i; + SYSTEM_INFO info; + unsigned rc; /* TODO(bnoordhuis) Use GetLogicalProcessorInformationEx() to support systems * with > 64 CPUs? See https://github.com/libuv/libuv/pull/3458 */ - count = 0; - if (GetProcessAffinityMask(GetCurrentProcess(), &procmask, &sysmask)) - for (i = 0; i < 8 * sizeof(procmask); i++) - count += 1 & (procmask >> i); + GetSystemInfo(&info); - if (count > 0) - return count; + rc = info.dwNumberOfProcessors; + if (rc < 1) + rc = 1; - return 1; + return rc; } @@ -951,13 +953,8 @@ int uv_os_homedir(char* buffer, size_t* size) { r = uv_os_getenv("USERPROFILE", buffer, size); /* Don't return an error if USERPROFILE was not found. */ - if (r != UV_ENOENT) { - /* USERPROFILE is empty or invalid */ - if (r == 0 && *size < 3) { - return UV_ENOENT; - } + if (r != UV_ENOENT) return r; - } /* USERPROFILE is not set, so call uv_os_get_passwd() */ r = uv_os_get_passwd(&pwd); @@ -994,12 +991,6 @@ int uv_os_tmpdir(char* buffer, size_t* size) { if (len == 0) { return uv_translate_sys_error(GetLastError()); } - - /* tmp path is empty or invalid */ - if (len < 3) { - return UV_ENOENT; - } - /* Include space for terminating null char. */ len += 1; path = (wchar_t*)uv__malloc(len * sizeof(wchar_t)); @@ -1279,9 +1270,6 @@ int uv_os_getenv(const char* name, char* buffer, size_t* size) { SetLastError(ERROR_SUCCESS); len = GetEnvironmentVariableW(name_w, var, varlen); - if (len == 0) - r = uv_translate_sys_error(GetLastError()); - if (len < varlen) break; @@ -1303,8 +1291,15 @@ int uv_os_getenv(const char* name, char* buffer, size_t* size) { uv__free(name_w); name_w = NULL; - if (r == 0) - r = uv__copy_utf16_to_utf8(var, len, buffer, size); + if (len == 0) { + r = GetLastError(); + if (r != ERROR_SUCCESS) { + r = uv_translate_sys_error(r); + goto fail; + } + } + + r = uv__copy_utf16_to_utf8(var, len, buffer, size); fail: @@ -1544,7 +1539,20 @@ int uv_os_uname(uv_utsname_t* buffer) { os_info.dwOSVersionInfoSize = sizeof(os_info); os_info.szCSDVersion[0] = L'\0'; - pRtlGetVersion(&os_info); + /* Try calling RtlGetVersion(), and fall back to the deprecated GetVersionEx() + if RtlGetVersion() is not available. */ + if (pRtlGetVersion) { + pRtlGetVersion(&os_info); + } else { + /* Silence GetVersionEx() deprecation warning. */ + #ifdef _MSC_VER + #pragma warning(disable : 4996) + #endif + if (GetVersionExW(&os_info) == 0) { + r = uv_translate_sys_error(GetLastError()); + goto error; + } + } /* Populate the version field. */ version_size = 0; diff --git a/wpinet/src/main/native/thirdparty/libuv/src/win/winapi.cpp b/wpinet/src/main/native/thirdparty/libuv/src/win/winapi.cpp index 4add0e27372..53147b8262e 100644 --- a/wpinet/src/main/native/thirdparty/libuv/src/win/winapi.cpp +++ b/wpinet/src/main/native/thirdparty/libuv/src/win/winapi.cpp @@ -48,16 +48,12 @@ sSetWinEventHook pSetWinEventHook; /* ws2_32.dll function pointer */ uv_sGetHostNameW pGetHostNameW; -/* api-ms-win-core-file-l2-1-4.dll function pointer */ -sGetFileInformationByName pGetFileInformationByName; - void uv__winapi_init(void) { HMODULE ntdll_module; HMODULE powrprof_module; HMODULE user32_module; HMODULE kernel32_module; HMODULE ws2_32_module; - HMODULE api_win_core_file_module; ntdll_module = GetModuleHandleA("ntdll.dll"); if (ntdll_module == NULL) { @@ -148,10 +144,4 @@ void uv__winapi_init(void) { ws2_32_module, "GetHostNameW"); } - - api_win_core_file_module = GetModuleHandleA("api-ms-win-core-file-l2-1-4.dll"); - if (api_win_core_file_module != NULL) { - pGetFileInformationByName = (sGetFileInformationByName)GetProcAddress( - api_win_core_file_module, "GetFileInformationByName"); - } } diff --git a/wpinet/src/main/native/thirdparty/libuv/src/win/winapi.h b/wpinet/src/main/native/thirdparty/libuv/src/win/winapi.h index 548081f23a9..d380bda42a3 100644 --- a/wpinet/src/main/native/thirdparty/libuv/src/win/winapi.h +++ b/wpinet/src/main/native/thirdparty/libuv/src/win/winapi.h @@ -4125,24 +4125,6 @@ typedef const UNICODE_STRING *PCUNICODE_STRING; # define DEVICE_TYPE DWORD #endif -typedef struct _FILE_STAT_BASIC_INFORMATION { - LARGE_INTEGER FileId; - LARGE_INTEGER CreationTime; - LARGE_INTEGER LastAccessTime; - LARGE_INTEGER LastWriteTime; - LARGE_INTEGER ChangeTime; - LARGE_INTEGER AllocationSize; - LARGE_INTEGER EndOfFile; - ULONG FileAttributes; - ULONG ReparseTag; - ULONG NumberOfLinks; - ULONG DeviceType; - ULONG DeviceCharacteristics; - ULONG Reserved; - FILE_ID_128 FileId128; - LARGE_INTEGER VolumeSerialNumber; -} FILE_STAT_BASIC_INFORMATION; - /* MinGW already has a definition for REPARSE_DATA_BUFFER, but mingw-w64 does * not. */ @@ -4242,15 +4224,6 @@ typedef enum _FILE_INFORMATION_CLASS { FileNumaNodeInformation, FileStandardLinkInformation, FileRemoteProtocolInformation, - FileRenameInformationBypassAccessCheck, - FileLinkInformationBypassAccessCheck, - FileVolumeNameInformation, - FileIdInformation, - FileIdExtdDirectoryInformation, - FileReplaceCompletionInformation, - FileHardLinkFullIdInformation, - FileIdExtdBothDirectoryInformation, - FileDispositionInformationEx, /* based on https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/wdm/ne-wdm-_file_information_class */ FileMaximumInformation } FILE_INFORMATION_CLASS, *PFILE_INFORMATION_CLASS; @@ -4350,10 +4323,6 @@ typedef struct _FILE_DISPOSITION_INFORMATION { BOOLEAN DeleteFile; } FILE_DISPOSITION_INFORMATION, *PFILE_DISPOSITION_INFORMATION; -typedef struct _FILE_DISPOSITION_INFORMATION_EX { - DWORD Flags; -} FILE_DISPOSITION_INFORMATION_EX, *PFILE_DISPOSITION_INFORMATION_EX; - typedef struct _FILE_PIPE_LOCAL_INFORMATION { ULONG NamedPipeType; ULONG NamedPipeConfiguration; @@ -4458,14 +4427,6 @@ typedef struct _FILE_FS_SECTOR_SIZE_INFORMATION { ULONG ByteOffsetForPartitionAlignment; } FILE_FS_SECTOR_SIZE_INFORMATION, *PFILE_FS_SECTOR_SIZE_INFORMATION; -typedef struct _PROCESS_BASIC_INFORMATION { - PVOID Reserved1; - PVOID PebBaseAddress; - PVOID Reserved2[2]; - ULONG_PTR UniqueProcessId; - ULONG_PTR InheritedFromUniqueProcessId; -} PROCESS_BASIC_INFORMATION, *PPROCESS_BASIC_INFORMATION; - typedef struct _SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION { LARGE_INTEGER IdleTime; LARGE_INTEGER KernelTime; @@ -4479,10 +4440,6 @@ typedef struct _SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION { # define SystemProcessorPerformanceInformation 8 #endif -#ifndef ProcessBasicInformation -# define ProcessBasicInformation 0 -#endif - #ifndef ProcessConsoleHostProcess # define ProcessConsoleHostProcess 49 #endif @@ -4782,21 +4739,6 @@ typedef struct _TCP_INITIAL_RTO_PARAMETERS { # define SIO_TCP_INITIAL_RTO _WSAIOW(IOC_VENDOR,17) #endif -/* from winnt.h */ -typedef enum _FILE_INFO_BY_NAME_CLASS { - FileStatByNameInfo, - FileStatLxByNameInfo, - FileCaseSensitiveByNameInfo, - FileStatBasicByNameInfo, - MaximumFileInfoByNameClass -} FILE_INFO_BY_NAME_CLASS; - -typedef BOOL(WINAPI* sGetFileInformationByName)( - PCWSTR FileName, - FILE_INFO_BY_NAME_CLASS FileInformationClass, - PVOID FileInfoBuffer, - ULONG FileInfoBufferSize); - /* Ntdll function pointers */ extern sRtlGetVersion pRtlGetVersion; extern sRtlNtStatusToDosError pRtlNtStatusToDosError; @@ -4817,9 +4759,6 @@ extern sPowerRegisterSuspendResumeNotification pPowerRegisterSuspendResumeNotifi /* User32.dll function pointer */ extern sSetWinEventHook pSetWinEventHook; -/* api-ms-win-core-file-l2-1-4.dll function pointers */ -extern sGetFileInformationByName pGetFileInformationByName; - /* ws2_32.dll function pointer */ /* mingw doesn't have this definition, so let's declare it here locally */ typedef int (WINAPI *uv_sGetHostNameW)