Skip to content

Commit

Permalink
Upgrade to libuv 1.46.0
Browse files Browse the repository at this point in the history
  • Loading branch information
calcmogul committed Jul 14, 2023
1 parent aaea85f commit b42e90b
Show file tree
Hide file tree
Showing 79 changed files with 6,375 additions and 4,851 deletions.
696 changes: 398 additions & 298 deletions upstream_utils/libuv_patches/0001-Fix-missing-casts.patch

Large diffs are not rendered by default.

234 changes: 75 additions & 159 deletions upstream_utils/libuv_patches/0002-Fix-warnings.patch
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: PJ Reiniger <pj.reiniger@gmail.com>
Date: Tue, 26 Apr 2022 15:09:43 -0400
Subject: [PATCH 02/10] Fix warnings
Subject: [PATCH 2/8] Fix warnings

---
include/uv/win.h | 5 +++
src/idna.c | 2 +-
src/inet.c | 4 ++
src/threadpool.c | 4 ++
src/unix/core.c | 12 ++++-
src/unix/darwin.c | 106 +++++++++++++++++++++++---------------------
src/unix/internal.h | 4 +-
src/unix/thread.c | 6 ---
src/uv-common.c | 8 ++++
src/win/fs-event.c | 2 +
src/win/fs.c | 2 +
src/win/pipe.c | 2 +
src/win/process.c | 2 +
src/win/tty.c | 2 +
14 files changed, 99 insertions(+), 62 deletions(-)
include/uv/win.h | 5 +++++
src/idna.c | 2 +-
src/inet.c | 4 ++++
src/threadpool.c | 4 ++++
src/unix/core.c | 12 ++++++++++--
src/unix/internal.h | 4 ++--
src/unix/linux.c | 15 ++++++++++++---
src/unix/thread.c | 6 ------
src/uv-common.c | 8 ++++++++
src/win/fs-event.c | 2 ++
src/win/fs.c | 2 ++
src/win/pipe.c | 2 ++
src/win/process.c | 2 ++
src/win/tty.c | 2 ++
14 files changed, 56 insertions(+), 14 deletions(-)

diff --git a/include/uv/win.h b/include/uv/win.h
index 56a4cf1151cd9262062d79c3676b83a287757426..10d5e8f169b04e9d48c87e3760320dba5cd310ce 100644
index 6f8c47298e407bcb0151cf383a8370b71074f03e..c5473c2b82614c916f64ffd979d6dd7272221e3e 100644
--- a/include/uv/win.h
+++ b/include/uv/win.h
@@ -201,11 +201,16 @@ typedef int (WSAAPI* LPFN_WSARECVFROM)
@@ -202,11 +202,16 @@ typedef int (WSAAPI* LPFN_WSARECVFROM)
LPWSAOVERLAPPED overlapped,
LPWSAOVERLAPPED_COMPLETION_ROUTINE completion_routine);

Expand Down Expand Up @@ -55,10 +55,10 @@ index 93d982ca018f2d39d9c0ffab07998c2c637029eb..36a39a089019fb4c2a35ec84516658c3
unsigned k;
unsigned n;
diff --git a/src/inet.c b/src/inet.c
index ca8b6ac8b69779655f69da758aa63d810332c800..1b190255ed5f4813428dbb3ba81a50cfd26c5bf1 100644
index dd94bea3886ca37945fcad7909d765e3700e3c21..71c9e5b774d64d505e6c6d6ed2637178b8532d4d 100644
--- a/src/inet.c
+++ b/src/inet.c
@@ -27,6 +27,10 @@
@@ -22,6 +22,10 @@
#include "uv.h"
#include "uv-common.h"

Expand All @@ -70,7 +70,7 @@ index ca8b6ac8b69779655f69da758aa63d810332c800..1b190255ed5f4813428dbb3ba81a50cf
#define UV__INET6_ADDRSTRLEN 46

diff --git a/src/threadpool.c b/src/threadpool.c
index 1241ace1cc304c14bf1b79cc2a588c1a50ef4507..718972c33b968ad123e6c8afac230f17282830a8 100644
index f572de5aaf1a1b150e58c7b989949441cac279c4..aa282af468935b680140295a175e503ca82d8fa4 100644
--- a/src/threadpool.c
+++ b/src/threadpool.c
@@ -27,6 +27,10 @@
Expand All @@ -85,10 +85,10 @@ index 1241ace1cc304c14bf1b79cc2a588c1a50ef4507..718972c33b968ad123e6c8afac230f17

static uv_once_t once = UV_ONCE_INIT;
diff --git a/src/unix/core.c b/src/unix/core.c
index 6353b0e3cc9448aa35dc2ccc9b259277b3fae9a5..223c55131b1ca01696792d9305ab33f0d21af73c 100644
index 28c036f94f3e76717afa651451969f128c5a573c..268fc9652f437eb0d0cda2a9e0b06b9e91eb9742 100644
--- a/src/unix/core.c
+++ b/src/unix/core.c
@@ -544,6 +544,16 @@ int uv__accept(int sockfd) {
@@ -575,6 +575,16 @@ int uv__accept(int sockfd) {
return peerfd;
}

Expand All @@ -105,7 +105,7 @@ index 6353b0e3cc9448aa35dc2ccc9b259277b3fae9a5..223c55131b1ca01696792d9305ab33f0

/* 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.
@@ -558,10 +568,8 @@ int uv__close_nocancel(int fd) {
@@ -589,10 +599,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
Expand All @@ -116,135 +116,11 @@ index 6353b0e3cc9448aa35dc2ccc9b259277b3fae9a5..223c55131b1ca01696792d9305ab33f0
return close$NOCANCEL$UNIX2003(fd);
#endif
#pragma GCC diagnostic pop
diff --git a/src/unix/darwin.c b/src/unix/darwin.c
index 5fbf734218fa17cc61c03402c8b1dd6b66110ecb..eeb35720f55bf26363a064443bd02fb9aae682a4 100644
--- a/src/unix/darwin.c
+++ b/src/unix/darwin.c
@@ -253,64 +253,68 @@ static int uv__get_cpu_speed(uint64_t* speed) {

#define S(s) pCFStringCreateWithCString(NULL, (s), kCFStringEncodingUTF8)

- kr = pIOMasterPort(MACH_PORT_NULL, &mach_port);
- assert(kr == KERN_SUCCESS);
- CFMutableDictionaryRef classes_to_match
- = pIOServiceMatching("IOPlatformDevice");
- kr = pIOServiceGetMatchingServices(mach_port, classes_to_match, &it);
- assert(kr == KERN_SUCCESS);
- service = pIOIteratorNext(it);
-
- CFStringRef device_type_str = S("device_type");
- CFStringRef clock_frequency_str = S("clock-frequency");
-
- while (service != 0) {
- CFDataRef data;
- data = pIORegistryEntryCreateCFProperty(service,
- device_type_str,
- NULL,
- 0);
- if (data) {
- const UInt8* raw = pCFDataGetBytePtr(data);
- if (strncmp((char*)raw, "cpu", 3) == 0 ||
- strncmp((char*)raw, "processor", 9) == 0) {
- CFDataRef freq_ref;
- freq_ref = pIORegistryEntryCreateCFProperty(service,
- clock_frequency_str,
- NULL,
- 0);
- if (freq_ref) {
- const UInt8* freq_ref_ptr = pCFDataGetBytePtr(freq_ref);
- CFIndex len = pCFDataGetLength(freq_ref);
- if (len == 8)
- memcpy(speed, freq_ref_ptr, 8);
- else if (len == 4) {
- uint32_t v;
- memcpy(&v, freq_ref_ptr, 4);
- *speed = v;
- } else {
- *speed = 0;
- }
+ // Braces ensure goto doesn't jump into device_type_str's and
+ // clock_frequency_str's lifetimes after their initialization
+ {
+ kr = pIOMasterPort(MACH_PORT_NULL, &mach_port);
+ assert(kr == KERN_SUCCESS);
+ CFMutableDictionaryRef classes_to_match
+ = pIOServiceMatching("IOPlatformDevice");
+ kr = pIOServiceGetMatchingServices(mach_port, classes_to_match, &it);
+ assert(kr == KERN_SUCCESS);
+ service = pIOIteratorNext(it);

- pCFRelease(freq_ref);
- pCFRelease(data);
- break;
+ CFStringRef device_type_str = S("device_type");
+ CFStringRef clock_frequency_str = S("clock-frequency");
+
+ while (service != 0) {
+ CFDataRef data;
+ data = pIORegistryEntryCreateCFProperty(service,
+ device_type_str,
+ NULL,
+ 0);
+ if (data) {
+ const UInt8* raw = pCFDataGetBytePtr(data);
+ if (strncmp((char*)raw, "cpu", 3) == 0 ||
+ strncmp((char*)raw, "processor", 9) == 0) {
+ CFDataRef freq_ref;
+ freq_ref = pIORegistryEntryCreateCFProperty(service,
+ clock_frequency_str,
+ NULL,
+ 0);
+ if (freq_ref) {
+ const UInt8* freq_ref_ptr = pCFDataGetBytePtr(freq_ref);
+ CFIndex len = pCFDataGetLength(freq_ref);
+ if (len == 8)
+ memcpy(speed, freq_ref_ptr, 8);
+ else if (len == 4) {
+ uint32_t v;
+ memcpy(&v, freq_ref_ptr, 4);
+ *speed = v;
+ } else {
+ *speed = 0;
+ }
+
+ pCFRelease(freq_ref);
+ pCFRelease(data);
+ break;
+ }
}
+ pCFRelease(data);
}
- pCFRelease(data);
- }

- service = pIOIteratorNext(it);
- }
+ service = pIOIteratorNext(it);
+ }

- pIOObjectRelease(it);
+ pIOObjectRelease(it);

- err = 0;
+ err = 0;

- if (device_type_str != NULL)
- pCFRelease(device_type_str);
- if (clock_frequency_str != NULL)
- pCFRelease(clock_frequency_str);
+ if (device_type_str != NULL)
+ pCFRelease(device_type_str);
+ if (clock_frequency_str != NULL)
+ pCFRelease(clock_frequency_str);
+ }

out:
if (core_foundation_handle != NULL)
diff --git a/src/unix/internal.h b/src/unix/internal.h
index cee35c2106aed2990e28ab7d32335061fe7d6d47..f9d1666d8b2104b7437f11c4e0d9c4ae82ff0e31 100644
index fe5885136039d5332623467b86bf52cd4b32ca0f..98c437dcadec5b5106d697e82d5394d459f55e47 100644
--- a/src/unix/internal.h
+++ b/src/unix/internal.h
@@ -312,8 +312,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;
}

Expand All @@ -255,11 +131,51 @@ index cee35c2106aed2990e28ab7d32335061fe7d6d47..f9d1666d8b2104b7437f11c4e0d9c4ae

s = strrchr(path, '/');
if (s == NULL)
diff --git a/src/unix/linux.c b/src/unix/linux.c
index 9173850bd158eaf9c41deca38f9ba84762a027a1..157443792f1216c83b4221c3810d17c81c5913c4 100644
--- a/src/unix/linux.c
+++ b/src/unix/linux.c
@@ -1718,7 +1718,11 @@ int uv_cpu_info(uv_cpu_info_t** ci, int* count) {
return UV__ERR(errno);
}

- fgets(buf, sizeof(buf), fp); /* Skip first line. */
+ /* Skip first line. */
+ if (!fgets(buf, sizeof(buf), fp)) {
+ uv__free(cpus);
+ return UV__ERR(errno);
+ }

for (;;) {
memset(&t, 0, sizeof(t));
@@ -1729,7 +1733,10 @@ int uv_cpu_info(uv_cpu_info_t** ci, int* count) {
if (n != 7)
break;

- fgets(buf, sizeof(buf), fp); /* Skip rest of line. */
+ /* Skip rest of line. */
+ if (!fgets(buf, sizeof(buf), fp)) {
+ break;
+ }

if (cpu >= ARRAY_SIZE(*cpus))
continue;
@@ -1809,7 +1816,9 @@ nocpuinfo:
if (fp == NULL)
continue;

- fscanf(fp, "%llu", &(*cpus)[cpu].freq);
+ if (0 > fscanf(fp, "%llu", &(*cpus)[cpu].freq)) {
+ (*cpus)[cpu].freq = 0llu;
+ }
fclose(fp);
fp = NULL;
}
diff --git a/src/unix/thread.c b/src/unix/thread.c
index 759cd0c28518928127837ba82cbf8e761c6223d3..64726bd618b930e1aa7e1de3cbceb8aa712ff617 100644
index 531c6211bb4321e5f11031a0644b4e3ab9174396..f8600947e3e7df015c4302af4feee740707b2c46 100644
--- a/src/unix/thread.c
+++ b/src/unix/thread.c
@@ -244,12 +244,6 @@ int uv_thread_create_ex(uv_thread_t* tid,
@@ -137,12 +137,6 @@ int uv_thread_create_ex(uv_thread_t* tid,
size_t stack_size;
size_t min_stack_size;

Expand All @@ -273,10 +189,10 @@ index 759cd0c28518928127837ba82cbf8e761c6223d3..64726bd618b930e1aa7e1de3cbceb8aa
params->flags & UV_THREAD_HAS_STACK_SIZE ? params->stack_size : 0;

diff --git a/src/uv-common.c b/src/uv-common.c
index dfb606e3e842ccb3b2d9327e2b3048c4cfdd0314..49026c03c53a0779a051b8f6bd5809961f5c54e2 100644
index c04f93596ab1f730576256d86e216ccb7f258b72..cd10b36b4a393e325ea03b93eb9897193ca9800b 100644
--- a/src/uv-common.c
+++ b/src/uv-common.c
@@ -758,6 +758,10 @@ void uv__fs_readdir_cleanup(uv_fs_t* req) {
@@ -799,6 +799,10 @@ void uv__fs_readdir_cleanup(uv_fs_t* req) {
}
}

Expand All @@ -287,7 +203,7 @@ index dfb606e3e842ccb3b2d9327e2b3048c4cfdd0314..49026c03c53a0779a051b8f6bd580996

int uv_loop_configure(uv_loop_t* loop, uv_loop_option option, ...) {
va_list ap;
@@ -771,6 +775,10 @@ int uv_loop_configure(uv_loop_t* loop, uv_loop_option option, ...) {
@@ -812,6 +816,10 @@ int uv_loop_configure(uv_loop_t* loop, uv_loop_option option, ...) {
return err;
}

Expand All @@ -312,7 +228,7 @@ index 150467313d576bfe2966b55f3d8cffa23cbb8ea3..3244a4e4320d7ce98f226b49b2634c65
#include <errno.h>
#include <stdio.h>
diff --git a/src/win/fs.c b/src/win/fs.c
index 8374012f0e9ee094eed5db19e5f7d12286052d70..f71b3c04487a949690fdfd8a6975fd8648acc793 100644
index 328c8f2e0513562b53c948ffea59d0841e14b264..565c05fff13c2e6e74091c1da7b31636d7fd370d 100644
--- a/src/win/fs.c
+++ b/src/win/fs.c
@@ -19,6 +19,8 @@
Expand All @@ -325,7 +241,7 @@ index 8374012f0e9ee094eed5db19e5f7d12286052d70..f71b3c04487a949690fdfd8a6975fd86
#include <stdlib.h>
#include <direct.h>
diff --git a/src/win/pipe.c b/src/win/pipe.c
index cd77061a079094b11350a01ddd364e15fa3078bc..f413a72dab5c9d58bfbc768152314dc347f7469d 100644
index c1739efe82b8755999145860b4da6b50c73518a2..258d6a684c67f154096a25e7226f1a7d08b93d5b 100644
--- a/src/win/pipe.c
+++ b/src/win/pipe.c
@@ -19,6 +19,8 @@
Expand All @@ -338,7 +254,7 @@ index cd77061a079094b11350a01ddd364e15fa3078bc..f413a72dab5c9d58bfbc768152314dc3
#include <io.h>
#include <stdio.h>
diff --git a/src/win/process.c b/src/win/process.c
index e857db3e98eb24f8de12e6b6d90ae3905cc49ce7..a49016f65601c0127b4c0ba5b538e2556314eb46 100644
index f25fc6549cfee4d47d8ebe86009e53f6d2be0cc5..edb6a37fb3d810d4fc7320df5dc0788f84cb6b4f 100644
--- a/src/win/process.c
+++ b/src/win/process.c
@@ -19,6 +19,8 @@
Expand All @@ -351,7 +267,7 @@ index e857db3e98eb24f8de12e6b6d90ae3905cc49ce7..a49016f65601c0127b4c0ba5b538e255
#include <io.h>
#include <stdio.h>
diff --git a/src/win/tty.c b/src/win/tty.c
index 267ca64519963ff87b2404f08a60c111e25b89c2..d75226681c2653dc2a5118756b72e0b601cf9701 100644
index 7e1f15544b177382a774300f832bc982d85bd62b..abbe1315883257d6825b794344dcd4cba9514097 100644
--- a/src/win/tty.c
+++ b/src/win/tty.c
@@ -19,6 +19,8 @@
Expand Down
Loading

0 comments on commit b42e90b

Please sign in to comment.