diff options
-rw-r--r-- | docs/requirements.txt | 51 | ||||
-rw-r--r-- | src/random.c | 2 | ||||
-rw-r--r-- | src/win/fs.c | 2 | ||||
-rw-r--r-- | src/win/internal.h | 2 | ||||
-rw-r--r-- | src/win/udp.c | 7 | ||||
-rw-r--r-- | src/win/util.c | 12 | ||||
-rw-r--r-- | src/win/winapi.c | 99 | ||||
-rw-r--r-- | src/win/winapi.h | 5 | ||||
-rw-r--r-- | test/run-benchmarks.c | 2 | ||||
-rw-r--r-- | test/run-tests.c | 2 | ||||
-rw-r--r-- | test/runner-win.c | 2 | ||||
-rw-r--r-- | test/task.h | 50 | ||||
-rw-r--r-- | test/test-tcp-close-accept.c | 4 |
13 files changed, 147 insertions, 93 deletions
diff --git a/docs/requirements.txt b/docs/requirements.txt index 2e310ebe..0319b308 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -1,36 +1,29 @@ # primary -furo==2023.5.20 -Sphinx==6.1.3 +furo==2024.8.6 +Sphinx==7.0.1 # dependencies -alabaster==0.7.13 -Babel==2.11.0 -beautifulsoup4==4.12.2 -certifi==2022.12.7 -charset-normalizer==3.0.1 -colorama==0.4.6 -docutils==0.19 -idna==3.4 +alabaster==0.7.16 +babel==2.17.0 +beautifulsoup4==4.13.3 +certifi==2025.1.31 +charset-normalizer==3.4.1 +docutils==0.20.1 +idna==3.10 imagesize==1.4.1 -importlib-metadata==6.0.0 -Jinja2==3.1.2 -livereload==2.6.3 -MarkupSafe==2.1.2 -packaging==23.0 -Pygments==2.14.0 -pytz==2022.7.1 -requests==2.28.2 -six==1.16.0 +Jinja2==3.1.6 +MarkupSafe==3.0.2 +packaging==24.2 +Pygments==2.19.1 +requests==2.32.3 snowballstemmer==2.2.0 -soupsieve==2.4.1 -sphinx-autobuild==2021.3.14 +soupsieve==2.6 sphinx-basic-ng==1.0.0b2 -sphinxcontrib-devhelp==1.0.2 -sphinxcontrib-htmlhelp==2.0.0 +sphinxcontrib-applehelp==2.0.0 +sphinxcontrib-devhelp==2.0.0 +sphinxcontrib-htmlhelp==2.1.0 sphinxcontrib-jsmath==1.0.1 -sphinxcontrib-qthelp==1.0.3 -sphinxcontrib-serializinghtml==1.1.5 -sphinxcontrib.applehelp==1.0.3 -tornado==6.3.2 -urllib3==1.26.14 -zipp==3.11.0 +sphinxcontrib-qthelp==2.0.0 +sphinxcontrib-serializinghtml==2.0.0 +typing_extensions==4.13.0 +urllib3==2.3.0 diff --git a/src/random.c b/src/random.c index 57fc0d91..402678cb 100644 --- a/src/random.c +++ b/src/random.c @@ -61,7 +61,7 @@ static int uv__random(void* buf, size_t buflen) { # endif #elif defined(_WIN32) uv__once_init(); - rc = uv__random_rtlgenrandom(buf, buflen); + rc = uv__random_winrandom(buf, buflen); #else rc = uv__random_devurandom(buf, buflen); #endif diff --git a/src/win/fs.c b/src/win/fs.c index 4e156930..acaa5689 100644 --- a/src/win/fs.c +++ b/src/win/fs.c @@ -1269,7 +1269,7 @@ void fs__mktemp(uv_fs_t* req, uv__fs_mktemp_func func) { tries = TMP_MAX; do { - if (uv__random_rtlgenrandom((void *)&v, sizeof(v)) < 0) { + if (uv__random_winrandom(&v, sizeof(v)) < 0) { SET_REQ_UV_ERROR(req, UV_EIO, ERROR_IO_DEVICE); goto clobber; } diff --git a/src/win/internal.h b/src/win/internal.h index be408af6..db488be7 100644 --- a/src/win/internal.h +++ b/src/win/internal.h @@ -269,7 +269,7 @@ int uv__getsockpeername(const uv_handle_t* handle, int* namelen, int delayed_error); -int uv__random_rtlgenrandom(void* buf, size_t buflen); +int uv__random_winrandom(void* buf, size_t buflen); /* diff --git a/src/win/udp.c b/src/win/udp.c index e0873c2a..f8aa2435 100644 --- a/src/win/udp.c +++ b/src/win/udp.c @@ -1149,10 +1149,13 @@ int uv__udp_try_send2(uv_udp_t* handle, uv_buf_t* bufs[/*count*/], unsigned int nbufs[/*count*/], struct sockaddr* addrs[/*count*/]) { - unsigned int i; + int i; int r; - for (i = 0; i < count; i++) { + if (count > INT_MAX) + return UV_EINVAL; + + for (i = 0; i < (int) count; i++) { r = uv_udp_try_send(handle, bufs[i], nbufs[i], addrs[i]); if (r < 0) return i > 0 ? i : r; /* Error if first packet, else send count. */ diff --git a/src/win/util.c b/src/win/util.c index 8c2681fe..9e3daac8 100644 --- a/src/win/util.c +++ b/src/win/util.c @@ -513,8 +513,8 @@ int uv_uptime(double* uptime) { unsigned int uv_available_parallelism(void) { DWORD_PTR procmask; DWORD_PTR sysmask; - int count; - int i; + unsigned count; + unsigned i; /* TODO(bnoordhuis) Use GetLogicalProcessorInformationEx() to support systems * with > 64 CPUs? See https://github.com/libuv/libuv/pull/3458 @@ -1712,6 +1712,9 @@ int uv_os_uname(uv_utsname_t* buffer) { case PROCESSOR_ARCHITECTURE_ARM: uv__strscpy(buffer->machine, "arm", sizeof(buffer->machine)); break; + case PROCESSOR_ARCHITECTURE_ARM64: + uv__strscpy(buffer->machine, "arm64", sizeof(buffer->machine)); + break; default: uv__strscpy(buffer->machine, "unknown", sizeof(buffer->machine)); break; @@ -1744,10 +1747,13 @@ int uv_gettimeofday(uv_timeval64_t* tv) { return 0; } -int uv__random_rtlgenrandom(void* buf, size_t buflen) { +int uv__random_winrandom(void* buf, size_t buflen) { if (buflen == 0) return 0; + if (pProcessPrng != NULL && pProcessPrng(buf, buflen)) + return 0; + if (SystemFunction036(buf, buflen) == FALSE) return UV_EIO; diff --git a/src/win/winapi.c b/src/win/winapi.c index 786a9daa..7ed08dd2 100644 --- a/src/win/winapi.c +++ b/src/win/winapi.c @@ -39,6 +39,9 @@ sNtQueryInformationProcess pNtQueryInformationProcess; /* Powrprof.dll function pointer */ sPowerRegisterSuspendResumeNotification pPowerRegisterSuspendResumeNotification; +/* bcryptprimitives.dll function pointer */ +sProcessPrng pProcessPrng; + /* User32.dll function pointer */ sSetWinEventHook pSetWinEventHook; @@ -53,92 +56,118 @@ void uv__winapi_init(void) { HMODULE powrprof_module; HMODULE user32_module; HMODULE ws2_32_module; + HMODULE bcryptprimitives_module; HMODULE api_win_core_file_module; + union { + FARPROC proc; + sRtlGetVersion pRtlGetVersion; + sRtlNtStatusToDosError pRtlNtStatusToDosError; + sNtDeviceIoControlFile pNtDeviceIoControlFile; + sNtQueryInformationFile pNtQueryInformationFile; + sNtSetInformationFile pNtSetInformationFile; + sNtQueryVolumeInformationFile pNtQueryVolumeInformationFile; + sNtQueryDirectoryFile pNtQueryDirectoryFile; + sNtQuerySystemInformation pNtQuerySystemInformation; + sNtQueryInformationProcess pNtQueryInformationProcess; + sPowerRegisterSuspendResumeNotification pPowerRegisterSuspendResumeNotification; + sProcessPrng pProcessPrng; + sSetWinEventHook pSetWinEventHook; + uv_sGetHostNameW pGetHostNameW; + sGetFileInformationByName pGetFileInformationByName; + } u; + ntdll_module = GetModuleHandleW(L"ntdll.dll"); if (ntdll_module == NULL) { uv_fatal_error(GetLastError(), "GetModuleHandleW"); } - pRtlGetVersion = (sRtlGetVersion) GetProcAddress(ntdll_module, - "RtlGetVersion"); + u.proc = GetProcAddress(ntdll_module, "RtlGetVersion"); + pRtlGetVersion = u.pRtlGetVersion; - pRtlNtStatusToDosError = (sRtlNtStatusToDosError) GetProcAddress( - ntdll_module, - "RtlNtStatusToDosError"); + u.proc = GetProcAddress(ntdll_module, "RtlNtStatusToDosError"); + pRtlNtStatusToDosError = u.pRtlNtStatusToDosError; if (pRtlNtStatusToDosError == NULL) { uv_fatal_error(GetLastError(), "GetProcAddress"); } - pNtDeviceIoControlFile = (sNtDeviceIoControlFile) GetProcAddress( - ntdll_module, - "NtDeviceIoControlFile"); + u.proc = GetProcAddress(ntdll_module, "NtDeviceIoControlFile"); + pNtDeviceIoControlFile = u.pNtDeviceIoControlFile; if (pNtDeviceIoControlFile == NULL) { uv_fatal_error(GetLastError(), "GetProcAddress"); } - pNtQueryInformationFile = (sNtQueryInformationFile) GetProcAddress( - ntdll_module, - "NtQueryInformationFile"); + u.proc = GetProcAddress(ntdll_module, "NtQueryInformationFile"); + pNtQueryInformationFile = u.pNtQueryInformationFile; if (pNtQueryInformationFile == NULL) { uv_fatal_error(GetLastError(), "GetProcAddress"); } - pNtSetInformationFile = (sNtSetInformationFile) GetProcAddress( - ntdll_module, - "NtSetInformationFile"); + u.proc = GetProcAddress(ntdll_module, "NtSetInformationFile"); + pNtSetInformationFile = u.pNtSetInformationFile; if (pNtSetInformationFile == NULL) { uv_fatal_error(GetLastError(), "GetProcAddress"); } - pNtQueryVolumeInformationFile = (sNtQueryVolumeInformationFile) - GetProcAddress(ntdll_module, "NtQueryVolumeInformationFile"); + u.proc = GetProcAddress(ntdll_module, "NtQueryVolumeInformationFile"); + pNtQueryVolumeInformationFile = u.pNtQueryVolumeInformationFile; if (pNtQueryVolumeInformationFile == NULL) { uv_fatal_error(GetLastError(), "GetProcAddress"); } - pNtQueryDirectoryFile = (sNtQueryDirectoryFile) - GetProcAddress(ntdll_module, "NtQueryDirectoryFile"); + u.proc = GetProcAddress(ntdll_module, "NtQueryDirectoryFile"); + pNtQueryDirectoryFile = u.pNtQueryDirectoryFile; if (pNtQueryDirectoryFile == NULL) { uv_fatal_error(GetLastError(), "GetProcAddress"); } - pNtQuerySystemInformation = (sNtQuerySystemInformation) GetProcAddress( - ntdll_module, - "NtQuerySystemInformation"); + u.proc = GetProcAddress(ntdll_module, "NtQuerySystemInformation"); + pNtQuerySystemInformation = u.pNtQuerySystemInformation; if (pNtQuerySystemInformation == NULL) { uv_fatal_error(GetLastError(), "GetProcAddress"); } - pNtQueryInformationProcess = (sNtQueryInformationProcess) GetProcAddress( - ntdll_module, - "NtQueryInformationProcess"); + u.proc = GetProcAddress(ntdll_module, "NtQueryInformationProcess"); + pNtQueryInformationProcess = u.pNtQueryInformationProcess; if (pNtQueryInformationProcess == NULL) { uv_fatal_error(GetLastError(), "GetProcAddress"); } - powrprof_module = LoadLibraryExA("powrprof.dll", NULL, LOAD_LIBRARY_SEARCH_SYSTEM32); + powrprof_module = LoadLibraryExA("powrprof.dll", + NULL, + LOAD_LIBRARY_SEARCH_SYSTEM32); if (powrprof_module != NULL) { - pPowerRegisterSuspendResumeNotification = (sPowerRegisterSuspendResumeNotification) - GetProcAddress(powrprof_module, "PowerRegisterSuspendResumeNotification"); + u.proc = GetProcAddress(powrprof_module, + "PowerRegisterSuspendResumeNotification"); + pPowerRegisterSuspendResumeNotification = + u.pPowerRegisterSuspendResumeNotification; + } + + bcryptprimitives_module = LoadLibraryExA("bcryptprimitives.dll", + NULL, + LOAD_LIBRARY_SEARCH_SYSTEM32); + if (bcryptprimitives_module != NULL) { + u.proc = GetProcAddress(bcryptprimitives_module, "ProcessPrng"); + pProcessPrng = u.pProcessPrng; } user32_module = GetModuleHandleW(L"user32.dll"); if (user32_module != NULL) { - pSetWinEventHook = (sSetWinEventHook) - GetProcAddress(user32_module, "SetWinEventHook"); + u.proc = GetProcAddress(user32_module, "SetWinEventHook"); + pSetWinEventHook = u.pSetWinEventHook; } ws2_32_module = GetModuleHandleW(L"ws2_32.dll"); if (ws2_32_module != NULL) { - pGetHostNameW = (uv_sGetHostNameW) GetProcAddress( - ws2_32_module, - "GetHostNameW"); + u.proc = GetProcAddress(ws2_32_module, "GetHostNameW"); + pGetHostNameW = u.pGetHostNameW; } - api_win_core_file_module = GetModuleHandleW(L"api-ms-win-core-file-l2-1-4.dll"); + api_win_core_file_module = + GetModuleHandleW(L"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"); + u.proc = GetProcAddress(api_win_core_file_module, + "GetFileInformationByName"); + pGetFileInformationByName = u.pGetFileInformationByName; } } diff --git a/src/win/winapi.h b/src/win/winapi.h index b9c9f1ab..a7e1b179 100644 --- a/src/win/winapi.h +++ b/src/win/winapi.h @@ -4751,6 +4751,8 @@ typedef DWORD (WINAPI *sPowerRegisterSuspendResumeNotification) HANDLE Recipient, _PHPOWERNOTIFY RegistrationHandle); +typedef BOOL (WINAPI *sProcessPrng)(/*_Out_*/PBYTE pbData, SIZE_T cbData); + /* from Winuser.h */ typedef VOID (CALLBACK* WINEVENTPROC) (HWINEVENTHOOK hWinEventHook, @@ -4815,6 +4817,9 @@ extern sNtQueryInformationProcess pNtQueryInformationProcess; /* Powrprof.dll function pointer */ extern sPowerRegisterSuspendResumeNotification pPowerRegisterSuspendResumeNotification; +/* bcryptprimitives.dll function pointer */ +extern sProcessPrng pProcessPrng; + /* User32.dll function pointer */ extern sSetWinEventHook pSetWinEventHook; diff --git a/test/run-benchmarks.c b/test/run-benchmarks.c index 2b343da4..d7290f96 100644 --- a/test/run-benchmarks.c +++ b/test/run-benchmarks.c @@ -31,7 +31,7 @@ #ifdef __MVS__ #include "zos-base.h" /* Initialize environment and zoslib */ -__attribute__((constructor)) void init() { +__attribute__((constructor)) void init(void) { zoslib_config_t config; init_zoslib_config(&config); init_zoslib(config); diff --git a/test/run-tests.c b/test/run-tests.c index a5007e24..51170749 100644 --- a/test/run-tests.c +++ b/test/run-tests.c @@ -40,7 +40,7 @@ #ifdef __MVS__ #include "zos-base.h" /* Initialize environment and zoslib */ -__attribute__((constructor)) void init() { +__attribute__((constructor)) void init(void) { zoslib_config_t config; init_zoslib_config(&config); init_zoslib(config); diff --git a/test/runner-win.c b/test/runner-win.c index 8035ca62..52e0f64d 100644 --- a/test/runner-win.c +++ b/test/runner-win.c @@ -340,7 +340,7 @@ static int clear_line(void) { } -void rewind_cursor() { +void rewind_cursor(void) { if (clear_line() == -1) { /* If clear_line fails (stdout is not a console), print a newline. */ fprintf(stderr, "\n"); diff --git a/test/task.h b/test/task.h index d3eeaf77..2600da5e 100644 --- a/test/task.h +++ b/test/task.h @@ -113,8 +113,8 @@ typedef enum { #define ASSERT_BASE(a, operator, b, type, conv) \ do { \ - volatile type eval_a = (type) (a); \ - volatile type eval_b = (type) (b); \ + type const eval_a = (a); \ + type const eval_b = (b); \ if (!(eval_a operator eval_b)) { \ fprintf(stderr, \ "Assertion failed in %s on line %d: `%s %s %s` " \ @@ -131,6 +131,21 @@ typedef enum { } \ } while (0) +#define ASSERT_OK(a) \ + do { \ + int64_t const eval_a = (a); \ + if (eval_a) { \ + fprintf(stderr, \ + "Assertion failed in %s on line %d: `%s` okay " \ + "(error: %"PRId64")\n", \ + __FILE__, \ + __LINE__, \ + #a, \ + eval_a); \ + abort(); \ + } \ + } while (0) + #define ASSERT_BASE_STR(expr, a, operator, b, type, conv) \ do { \ if (!(expr)) { \ @@ -173,8 +188,8 @@ typedef enum { do { \ if (!(expr)) { \ int i; \ - unsigned char* a_ = (unsigned char*)a; \ - unsigned char* b_ = (unsigned char*)b; \ + const unsigned char* a_ = (a); \ + const unsigned char* b_ = (b); \ fprintf(stderr, \ "Assertion failed in %s on line %d: `%s %s %s` (", \ __FILE__, \ @@ -202,7 +217,6 @@ typedef enum { #define ASSERT_LE(a, b) ASSERT_BASE(a, <=, b, int64_t, PRId64) #define ASSERT_LT(a, b) ASSERT_BASE(a, <, b, int64_t, PRId64) #define ASSERT_NE(a, b) ASSERT_BASE(a, !=, b, int64_t, PRId64) -#define ASSERT_OK(a) ASSERT_BASE(a, ==, 0, int64_t, PRId64) #define ASSERT_UINT64_EQ(a, b) ASSERT_BASE(a, ==, b, uint64_t, PRIu64) #define ASSERT_UINT64_GE(a, b) ASSERT_BASE(a, >=, b, uint64_t, PRIu64) @@ -211,12 +225,12 @@ typedef enum { #define ASSERT_UINT64_LT(a, b) ASSERT_BASE(a, <, b, uint64_t, PRIu64) #define ASSERT_UINT64_NE(a, b) ASSERT_BASE(a, !=, b, uint64_t, PRIu64) -#define ASSERT_DOUBLE_EQ(a, b) ASSERT_BASE(a, ==, b, double, "f") -#define ASSERT_DOUBLE_GE(a, b) ASSERT_BASE(a, >=, b, double, "f") -#define ASSERT_DOUBLE_GT(a, b) ASSERT_BASE(a, >, b, double, "f") -#define ASSERT_DOUBLE_LE(a, b) ASSERT_BASE(a, <=, b, double, "f") -#define ASSERT_DOUBLE_LT(a, b) ASSERT_BASE(a, <, b, double, "f") -#define ASSERT_DOUBLE_NE(a, b) ASSERT_BASE(a, !=, b, double, "f") +#define ASSERT_DOUBLE_EQ(a, b) ASSERT_BASE(a, ==, b, volatile double, "f") +#define ASSERT_DOUBLE_GE(a, b) ASSERT_BASE(a, >=, b, volatile double, "f") +#define ASSERT_DOUBLE_GT(a, b) ASSERT_BASE(a, >, b, volatile double, "f") +#define ASSERT_DOUBLE_LE(a, b) ASSERT_BASE(a, <=, b, volatile double, "f") +#define ASSERT_DOUBLE_LT(a, b) ASSERT_BASE(a, <, b, volatile double, "f") +#define ASSERT_DOUBLE_NE(a, b) ASSERT_BASE(a, !=, b, volatile double, "f") #define ASSERT_STR_EQ(a, b) \ ASSERT_BASE_STR(strcmp(a, b) == 0, a, == , b, char*, "s") @@ -237,19 +251,23 @@ typedef enum { ASSERT_BASE_HEX(memcmp(a, b, size) != 0, a, !=, b, size) #define ASSERT_NULL(a) \ - ASSERT_BASE(a, ==, NULL, void*, "p") + ASSERT_BASE(a, ==, NULL, const void*, "p") #define ASSERT_NOT_NULL(a) \ - ASSERT_BASE(a, !=, NULL, void*, "p") + ASSERT_BASE(a, !=, NULL, const void*, "p") #define ASSERT_PTR_EQ(a, b) \ - ASSERT_BASE(a, ==, b, void*, "p") + ASSERT_BASE(a, ==, b, const void*, "p") #define ASSERT_PTR_NE(a, b) \ - ASSERT_BASE(a, !=, b, void*, "p") + ASSERT_BASE(a, !=, b, const void*, "p") #define ASSERT_PTR_LT(a, b) \ - ASSERT_BASE(a, <, b, void*, "p") + ASSERT_BASE(a, <, b, const void*, "p") +#define ASSERT_PTR_LE(a, b) \ + ASSERT_BASE(a, <=, b, const void*, "p") +#define ASSERT_PTR_GE(a, b) \ + ASSERT_BASE(a, >=, b, const void*, "p") /* This macro cleans up the event loop. This is used to avoid valgrind * warnings about memory being "leaked" by the event loop. diff --git a/test/test-tcp-close-accept.c b/test/test-tcp-close-accept.c index 4988dd13..30e1f1fa 100644 --- a/test/test-tcp-close-accept.c +++ b/test/test-tcp-close-accept.c @@ -69,8 +69,8 @@ static void connect_cb(uv_connect_t* req, int status) { } ASSERT_OK(status); - ASSERT_LE(connect_reqs, req); - ASSERT_LE(req, connect_reqs + ARRAY_SIZE(connect_reqs)); + ASSERT_PTR_LE(connect_reqs, req); + ASSERT_PTR_LE(req, connect_reqs + ARRAY_SIZE(connect_reqs)); i = req - connect_reqs; buf = uv_buf_init("x", 1); |