diff --git a/SOURCES/deps-cares-Add-str-len-check-in-config_sortlist-to-a.patch b/SOURCES/deps-cares-Add-str-len-check-in-config_sortlist-to-a.patch deleted file mode 100644 index c81988f..0000000 --- a/SOURCES/deps-cares-Add-str-len-check-in-config_sortlist-to-a.patch +++ /dev/null @@ -1,52 +0,0 @@ -From 58725d71e4306c83a474d6c3035e72580d0c4592 Mon Sep 17 00:00:00 2001 -From: hopper-vul <118949689+hopper-vul@users.noreply.github.com> -Date: Wed, 18 Jan 2023 22:14:26 +0800 -Subject: [PATCH] deps(cares): Add str len check in config_sortlist to avoid - stack overflow (#497) - -In ares_set_sortlist, it calls config_sortlist(..., sortstr) to parse -the input str and initialize a sortlist configuration. - -However, ares_set_sortlist has not any checks about the validity of the input str. -It is very easy to create an arbitrary length stack overflow with the unchecked -`memcpy(ipbuf, str, q-str);` and `memcpy(ipbufpfx, str, q-str);` -statements in the config_sortlist call, which could potentially cause severe -security impact in practical programs. - -This commit add necessary check for `ipbuf` and `ipbufpfx` which avoid the -potential stack overflows. - -fixes #496 - -Fix By: @hopper-vul - -Signed-off-by: rpm-build ---- - deps/cares/src/lib/ares_init.c | 4 ++++ - 1 file changed, 4 insertions(+) - -diff --git a/deps/cares/src/lib/ares_init.c b/deps/cares/src/lib/ares_init.c -index de5d86c..d5858f6 100644 ---- a/deps/cares/src/lib/ares_init.c -+++ b/deps/cares/src/lib/ares_init.c -@@ -2243,6 +2243,8 @@ static int config_sortlist(struct apattern **sortlist, int *nsort, - q = str; - while (*q && *q != '/' && *q != ';' && !ISSPACE(*q)) - q++; -+ if (q-str >= 16) -+ return ARES_EBADSTR; - memcpy(ipbuf, str, q-str); - ipbuf[q-str] = '\0'; - /* Find the prefix */ -@@ -2251,6 +2253,8 @@ static int config_sortlist(struct apattern **sortlist, int *nsort, - const char *str2 = q+1; - while (*q && *q != ';' && !ISSPACE(*q)) - q++; -+ if (q-str >= 32) -+ return ARES_EBADSTR; - memcpy(ipbufpfx, str, q-str); - ipbufpfx[q-str] = '\0'; - str = str2; --- -2.39.2 - diff --git a/SOURCES/deps-update-c-ares-to-1.19.1.patch b/SOURCES/deps-update-c-ares-to-1.19.1.patch new file mode 100644 index 0000000..bbcd0fa --- /dev/null +++ b/SOURCES/deps-update-c-ares-to-1.19.1.patch @@ -0,0 +1,16768 @@ +From 02702784ab844ecc0ee9e30059cc1115db64e6db Mon Sep 17 00:00:00 2001 +From: rpm-build +Date: Mon, 12 Jun 2023 12:14:34 +0200 +Subject: [PATCH] deps: update c-ares to 1.19.1 + +Signed-off-by: rpm-build +--- + deps/cares/CHANGES | 907 ++++-- + deps/cares/CMakeLists.txt | 27 +- + deps/cares/INSTALL.md | 14 + + deps/cares/Makefile.Watcom | 50 +- + deps/cares/Makefile.in | 2 + + deps/cares/README.md | 2 +- + deps/cares/RELEASE-NOTES | 118 +- + deps/cares/aclocal.m4 | 1 + + deps/cares/aminclude_static.am | 2 +- + deps/cares/c-ares-config.cmake.in | 13 +- + deps/cares/cares.gyp | 1 + + deps/cares/config.guess | 1500 ++++++---- + deps/cares/config.sub | 2609 +++++++++-------- + deps/cares/configure | 1052 +++++-- + deps/cares/configure.ac | 19 +- + deps/cares/docs/Makefile.in | 2 + + deps/cares/docs/acountry.1 | 2 +- + deps/cares/docs/adig.1 | 24 +- + deps/cares/docs/ahost.1 | 2 +- + deps/cares/docs/ares_destroy_options.3 | 6 +- + deps/cares/docs/ares_dup.3 | 6 +- + deps/cares/docs/ares_expand_name.3 | 10 +- + deps/cares/docs/ares_expand_string.3 | 10 +- + deps/cares/docs/ares_free_data.3 | 8 +- + deps/cares/docs/ares_free_hostent.3 | 6 +- + deps/cares/docs/ares_free_string.3 | 6 +- + deps/cares/docs/ares_get_servers.3 | 11 +- + deps/cares/docs/ares_getaddrinfo.3 | 18 +- + deps/cares/docs/ares_gethostbyaddr.3 | 17 +- + deps/cares/docs/ares_gethostbyname.3 | 16 +- + deps/cares/docs/ares_gethostbyname_file.3 | 8 +- + deps/cares/docs/ares_getnameinfo.3 | 17 +- + deps/cares/docs/ares_getsock.3 | 8 +- + deps/cares/docs/ares_inet_ntop.3 | 8 +- + deps/cares/docs/ares_inet_pton.3 | 6 +- + deps/cares/docs/ares_init_options.3 | 23 +- + deps/cares/docs/ares_library_init.3 | 3 +- + deps/cares/docs/ares_mkquery.3 | 10 +- + deps/cares/docs/ares_parse_a_reply.3 | 10 +- + deps/cares/docs/ares_parse_aaaa_reply.3 | 10 +- + deps/cares/docs/ares_parse_mx_reply.3 | 9 +- + deps/cares/docs/ares_parse_naptr_reply.3 | 8 +- + deps/cares/docs/ares_parse_ns_reply.3 | 8 +- + deps/cares/docs/ares_parse_ptr_reply.3 | 10 +- + deps/cares/docs/ares_parse_soa_reply.3 | 8 +- + deps/cares/docs/ares_parse_srv_reply.3 | 8 +- + deps/cares/docs/ares_parse_txt_reply.3 | 14 +- + deps/cares/docs/ares_parse_uri_reply.3 | 8 +- + deps/cares/docs/ares_process.3 | 2 +- + deps/cares/docs/ares_query.3 | 17 +- + deps/cares/docs/ares_save_options.3 | 7 +- + deps/cares/docs/ares_search.3 | 17 +- + deps/cares/docs/ares_send.3 | 15 +- + deps/cares/docs/ares_set_local_dev.3 | 6 +- + deps/cares/docs/ares_set_local_ip4.3 | 6 +- + deps/cares/docs/ares_set_local_ip6.3 | 14 +- + deps/cares/docs/ares_set_servers.3 | 11 +- + deps/cares/docs/ares_set_servers_csv.3 | 9 +- + deps/cares/docs/ares_set_socket_callback.3 | 14 +- + .../docs/ares_set_socket_configure_callback.3 | 16 +- + deps/cares/docs/ares_set_socket_functions.3 | 25 +- + deps/cares/docs/ares_set_sortlist.3 | 6 +- + deps/cares/docs/ares_strerror.3 | 6 +- + deps/cares/include/Makefile.in | 2 + + deps/cares/include/ares.h | 9 + + deps/cares/include/ares_version.h | 4 +- + deps/cares/libcares.pc.cmake | 7 +- + deps/cares/ltmain.sh | 827 ++++-- + deps/cares/m4/ax_cxx_compile_stdcxx.m4 | 1009 +++++++ + deps/cares/m4/ax_cxx_compile_stdcxx_11.m4 | 158 +- + deps/cares/m4/ax_pthread.m4 | 444 ++- + deps/cares/m4/cares-compilers.m4 | 4 +- + deps/cares/m4/cares-functions.m4 | 85 + + deps/cares/m4/libtool.m4 | 229 +- + deps/cares/m4/ltoptions.m4 | 4 +- + deps/cares/m4/ltsugar.m4 | 2 +- + deps/cares/m4/ltversion.m4 | 13 +- + deps/cares/m4/lt~obsolete.m4 | 4 +- + deps/cares/src/Makefile.in | 2 + + deps/cares/src/lib/CMakeLists.txt | 5 + + deps/cares/src/lib/Makefile.in | 32 +- + deps/cares/src/lib/Makefile.inc | 4 +- + deps/cares/src/lib/ares__addrinfo_localhost.c | 2 +- + deps/cares/src/lib/ares__readaddrinfo.c | 9 +- + deps/cares/src/lib/ares_config.h.cmake | 3 + + deps/cares/src/lib/ares_config.h.in | 3 + + deps/cares/src/lib/ares_data.h | 5 + + deps/cares/src/lib/ares_destroy.c | 8 + + deps/cares/src/lib/ares_expand_name.c | 12 +- + deps/cares/src/lib/ares_getaddrinfo.c | 89 +- + deps/cares/src/lib/ares_init.c | 576 +--- + deps/cares/src/lib/ares_library_init.c | 91 +- + deps/cares/src/lib/ares_library_init.h | 43 - + deps/cares/src/lib/ares_private.h | 22 +- + deps/cares/src/lib/ares_process.c | 71 +- + deps/cares/src/lib/ares_query.c | 36 +- + deps/cares/src/lib/ares_rand.c | 279 ++ + deps/cares/src/lib/ares_send.c | 12 +- + deps/cares/src/lib/ares_strsplit.c | 172 +- + deps/cares/src/lib/ares_strsplit.h | 19 +- + deps/cares/src/lib/inet_net_pton.c | 194 +- + deps/cares/src/tools/Makefile.am | 4 +- + deps/cares/src/tools/Makefile.in | 17 +- + deps/cares/src/tools/acountry.c | 11 +- + deps/cares/src/tools/adig.c | 39 +- + deps/cares/src/tools/ahost.c | 23 +- + 106 files changed, 6955 insertions(+), 4437 deletions(-) + create mode 100644 deps/cares/m4/ax_cxx_compile_stdcxx.m4 + delete mode 100644 deps/cares/src/lib/ares_library_init.h + create mode 100644 deps/cares/src/lib/ares_rand.c + +diff --git a/deps/cares/CHANGES b/deps/cares/CHANGES +index fcdc043..d465143 100644 +--- a/deps/cares/CHANGES ++++ b/deps/cares/CHANGES +@@ -1,5 +1,675 @@ + Changelog for the c-ares project. Generated with git2changes.pl + ++Version 1.19.1 (22 May 2023) ++ ++bradh352 (22 May 2023) ++- Makefile.inc Windows requires tabs not spaces for nmake ++ ++GitHub (22 May 2023) ++- [Daniel Stenberg brought this change] ++ ++ ares_expand_name: fix compiler warnings (#522) ++ ++ Fix some compiler warnings (not introduced in this release) ++ ++ Fix By: Daniel Stenberg (@bagder) ++ ++bradh352 (22 May 2023) ++- windows MSVC compiler fix on 32bit ++ ++- update security advisory links ++ ++- minor CI issues fixes for imported inet_net_pton ++ ++- ares_rand static analysis fixes from CI ++ ++- windows build fix ++ ++- security release notes ++ ++GitHub (22 May 2023) ++- [Brad House brought this change] ++ ++ Merge pull request from GHSA-9g78-jv2r-p7vc ++ ++- [Brad House brought this change] ++ ++ Merge pull request from GHSA-x6mf-cxr9-8q6v ++ ++ * Merged latest OpenBSD changes for inet_net_pton_ipv6() into c-ares. ++ * Always use our own IP conversion functions now, do not delegate to OS ++ so we can have consistency in testing and fuzzing. ++ * Removed bogus test cases that never should have passed. ++ * Add new test case for crash bug found. ++ ++ Fix By: Brad House (@bradh352) ++ ++- [Brad House brought this change] ++ ++ Merge pull request from GHSA-8r8p-23f3-64c2 ++ ++ * segment random number generation into own file ++ ++ * abstract random code to make it more modular so we can have multiple backends ++ ++ * rand: add support for arc4random_buf() and also direct CARES_RANDOM_FILE reading ++ ++ * autotools: fix detection of arc4random_buf ++ ++ * rework initial rc4 seed for PRNG as last fallback ++ ++ * rc4: more proper implementation, simplified for clarity ++ ++ * clarifications ++ ++bradh352 (20 May 2023) ++- add public release note information ++ ++- bump version to 1.19.1 ++ ++GitHub (6 May 2023) ++- [Gregor Jasny brought this change] ++ ++ test: fix warning about uninitialized memory (#515) ++ ++ fix warning in tests ++ ++ Fix By: Gregor Jasny (@gjasny) ++ ++- [lifenjoiner brought this change] ++ ++ Turn off IPV6_V6ONLY on Windows if it is supported (#520) ++ ++ Turn off IPV6_V6ONLY on Windows if it is supported, support for IPv4-mapped IPv6 addresses. ++ ++ IPV6_V6ONLY refs: ++ https://en.wikipedia.org/wiki/IPv6#IPv4-mapped_IPv6_addresses ++ https://github.com/golang/go/blob/master/src/net/ipsock_posix.go ++ https://en.wikipedia.org/wiki/Unix-like ++ off: ++ https://www.kernel.org/doc/html/latest/networking/ip-sysctl.html#proc-sys-net-ipv6-variables ++ https://man.netbsd.org/inet6.4 ++ https://man.freebsd.org/cgi/man.cgi?query=inet6 ++ https://github.com/apple-oss-distributions/xnu/blob/main/bsd/man/man4/inet6.4 ++ on: ++ https://learn.microsoft.com/en-us/windows/win32/winsock/ipproto-ipv6-socket-options ++ acts like off, but returns 1 and dummy setting: ++ https://man.dragonflybsd.org/?command=inet6 ++ https://man.dragonflybsd.org/?command=ip6 ++ unsupported and read-only returns 1: ++ https://man.openbsd.org/inet6.4 ++ ++ default value refs: ++ https://datatracker.ietf.org/doc/html/rfc3493#section-5.3 ++ https://www.kernel.org/doc/html/latest/networking/ip-sysctl.html#proc-sys-net-ipv6-variables ++ ++- [Brad House brought this change] ++ ++ Merge pull request from GHSA-54xr-f67r-4pc4 ++ ++ * CARES_RANDOM_FILE should always default to /dev/urandom ++ ++ During cross-compilation, CARES_RANDOM_FILE may not be able to be appropriately ++ detected, therefore we should always set it to /dev/urandom and allow the ++ entity requesting compilation override the value. The code does appropriately ++ fall back if CARES_RANDOM_FILE cannot be opened. ++ ++ * use set not option ++ ++bradh352 (18 Mar 2023) ++- ares_getaddrinfo using service of "0" should be allowed ++ ++ As per #517 glibc allows a service/servname of "0" to be treated the ++ same as if NULL was provided. Also, add a sanity check to ensure ++ the port number is in range instead of a blind cast. ++ ++ Fixes: #517 ++ Fix By: Brad House (@bradh352) ++ ++GitHub (10 Feb 2023) ++- [Nikolaos Chatzikonstantinou brought this change] ++ ++ fix memory leak in ares_send (#511) ++ ++ When the condition channel->nservers < 1 holds, the function returns ++ prematurely, without deallocating query->tcpbuf. We rearrange the ++ check to be done prior to the allocations, avoiding the memory ++ leak. In this way, we also avoid unnecessary allocations if ++ channel->nservers < 1 holds. ++ ++ Fix By: Nikolaos Chatzikonstantinou (@createyourpersonalaccount) ++ ++- [Nikolaos Chatzikonstantinou brought this change] ++ ++ change comment style to old-style (#513) ++ ++ Following the README.md guidelines, ++ ++ "Comments must be written in the old-style" ++ ++ the comment is changed to the old style. ++ ++ Fix By: Nikolaos Chatzikonstantinou (@createyourpersonalaccount) ++ ++- [Nikolaos Chatzikonstantinou brought this change] ++ ++ use strncasecmp in ares__strsplit (#512) ++ ++ strncasecmp on platforms that don't already have it is already #define'd to a private implementation. There is no need to have OS-specific logic. Also removes ares__strsplit.h as a header as ares_private.h already includes it. ++ ++ Fix By: Nikolaos Chatzikonstantinou (@createyourpersonalaccount) ++ ++- [Yijie Ma brought this change] ++ ++ Fix a typo in ares_init_options.3 (#510) ++ ++ that -> than ++ ++ Fix By: Yijie Ma (@yijiem) ++ ++- [Douglas R. Reno brought this change] ++ ++ Watcom Portability Improvements (#509) ++ ++ - Modify the Watcom Makefile for the source code reorganization (#352) ++ - Add *.map files into .gitignore ++ - Fix build errors with Watcom's builtin Windows SDK (which is rather ++ outdated). It's smart enough to understand Windows Vista, but doesn't ++ have PMIB_UNICASTIPADDRESS_TABLE or MIB_IPFORWARD_ROW2. ++ ++ It may be possible to use a different Windows SDK with the Watcom ++ compiler, such as the most recent Windows 10 SDK. Alternatively the SDK ++ in OpenWatcom 2.0 (which is in development) should fix this. ++ ++ I have no problems testing this Makefile prior to releases, just give me ++ a ping. ++ ++ Tested with Windows Vista, Windows 7, and Windows 10 using 'adig', ++ 'acountry', and 'ahost'. This also seems to work on Windows XP, though ++ this is likely due to the compiler in use. ++ ++ Fix By: Douglas R. Reno (@renodr) ++ Fixes Bug: #352 ++ ++- [Jay Freeman (saurik) brought this change] ++ ++ ignore aminclude_static.am, as generated by AX_AM_MACROS_STATIC (#508) ++ ++ Fix By: Jay Freeman (@saurik) ++ ++- [Jay Freeman (saurik) brought this change] ++ ++ sync ax_pthread.m4 with upstream (#507) ++ ++ The version in the repository is many years old so this PR simply pulls in the latest ++ available revision from: ++ http://git.savannah.gnu.org/gitweb/?p=autoconf-archive.git;a=tree;f=m4 ++ ++ Fix By: Jay Freeman (@saurik) ++ ++- [Chilledheart brought this change] ++ ++ Windows: Invalid stack variable out of scope for HOSTS file path (#502) ++ ++ In some conditions Windows might try to use a stack address that has gone out of scope when determining where to read the hosts data from for file lookups. ++ ++ Fix By: @Chilledheart ++ ++- [Brad House brought this change] ++ ++ sync ax_cxx_compile_stdcxx_11.m4 with upstream (#505) ++ ++ It was reported that ax_cxx_compile_stdcxx_11.m4 was not compatible with uclibc. ++ The version in the repository is many years old so this PR simply pulls in the latest ++ available revision from: ++ http://git.savannah.gnu.org/gitweb/?p=autoconf-archive.git;a=tree;f=m4 ++ ++ Fixes Bug: #504 ++ Fix By: Brad House (@bradh352) ++ ++Version 1.19.0 (18 Jan 2023) ++ ++bradh352 (18 Jan 2023) ++- Prep for 1.19.0 release ++ ++- Fix inverted logic in 25523e2 ++ ++ Fix .localhost. handling in prior commit ++ ++ Fix By: Brad House (@bradh352) ++ ++- RFC6761 localhost definition includes subdomains ++ ++ RFC6761 6.3 states: ++ The domain "localhost." and any names falling within ".localhost." ++ ++ We were only honoring "localhost". ++ ++ Fixes: #477 ++ Fix By: Brad House (@bradh352) ++ ++- docs: ARES_OPT_UDP_PORT and ARES_OPT_TCP_PORT docs wrong byte order ++ ++ As per #487, documentation states the port should be in network byte ++ order, but we can see from the test cases using MockServers on ++ different ports that this is not the case, it is definitely in host ++ byte order. ++ ++ Fix By: Brad House (@bradh352) ++ ++GitHub (18 Jan 2023) ++- [hopper-vul brought this change] ++ ++ Add str len check in config_sortlist to avoid stack overflow (#497) ++ ++ In ares_set_sortlist, it calls config_sortlist(..., sortstr) to parse ++ the input str and initialize a sortlist configuration. ++ ++ However, ares_set_sortlist has not any checks about the validity of the input str. ++ It is very easy to create an arbitrary length stack overflow with the unchecked ++ `memcpy(ipbuf, str, q-str);` and `memcpy(ipbufpfx, str, q-str);` ++ statements in the config_sortlist call, which could potentially cause severe ++ security impact in practical programs. ++ ++ This commit add necessary check for `ipbuf` and `ipbufpfx` which avoid the ++ potential stack overflows. ++ ++ fixes #496 ++ ++ Fix By: @hopper-vul ++ ++bradh352 (18 Jan 2023) ++- Fix build due to str-split sed gone wrong ++ ++ Fix By: Brad House (@bradh352) ++ ++- cirrus-ci: switch to scan-build-py for MacOS ++ ++ MacOS seems to work better with scan-build-py ++ ++ Fix By: Brad House (@bradh352) ++ ++- ares_strsplit* -> ares__strsplit* to comply with internal function naming ++ ++ Inspired by #495, but was missing test cases and would failed to build. ++ ++ Fix By: Brad House (@bradh352), Daniel Stenberg (@bagder) ++ ++- Cirrus-CI: MacOS Homebrew has changed from /usr/local/opt to /opt/homebrew ++ ++ Fix paths for homebrew. ++ ++ Fix By: Brad House (@bradh352) ++ ++- cirrus-ci: iOS build needs to use ARM MacOS image ++ ++ CirrusCI removed Intel-based MacOS images. Need to switch ++ iOS builds to use new ARM images as well. ++ ++ Fix By: Brad House (@bradh352) ++ ++- cirrus-ci: new MacOS image ++ ++ Cirrus-CI has recently EOL'd Intel MacOS VMs, switch to the latest ++ ARM-based image. ++ ++ Fix By: Brad House (@bradh352) ++ ++- acountry was passing stack variable to callback ++ ++ Recent ASAN versions picked up that acountry was passing stack ++ variables to ares_gethostbyname() then leaving the stack context. ++ We will now allocate a buffer for this. ++ ++ Fix By: Brad House (@bradh352) ++ ++GitHub (13 Dec 2022) ++- [Daniel Stenberg brought this change] ++ ++ docs: reformat/cleanup man pages SYNOPSIS sections (#494) ++ ++ To make them render "nicer" in both terminals and on the website. ++ ++ - Removes the bold ++ - Removes .PP lines ++ - Indents them more like proper code style ++ ++ Fix By: Daniel Stenberg (@bagder) ++ ++- [Nikolaos Chatzikonstantinou brought this change] ++ ++ bug fix: new ares_strsplit (#492) ++ ++ * add ares_strsplit unit test ++ ++ The test reveals a bug in the implementation of ares_strsplit when the ++ make_set parameter is set to 1, as distinct domains are confused for ++ equal: ++ ++ out = ares_strsplit("example.com, example.co", ", ", 1, &n); ++ ++ evaluates to n = 1 with out = { "example.com" }. ++ ++ * bugfix and cleanup of ares_strsplit ++ ++ The purpose of ares_strsplit in c-ares is to split a comma-delimited ++ string of unique (up to letter case) domains. However, because the ++ terminating NUL byte was not checked in the substrings when comparing ++ for uniqueness, the function would sometimes drop domains it should ++ not. For example, ++ ++ ares_strsplit("example.com, example.co", ",") ++ ++ would only result in a single domain "example.com". ++ ++ Aside from this bugfix, the following cleanup is performed: ++ ++ 1. The tokenization now happens with the help of strcspn instead of the ++ custom function is_delim. ++ 2. The function list_contains has been inlined. ++ 3. The interface of ares_strsplit has been simplified by removing the ++ parameter make_set since in practice it was always 1. ++ 4. There are fewer passes over the input string. ++ 5. We resize the table using realloc() down to its minimum size. ++ 6. The docstring of ares_strsplit is updated and also a couple typos ++ are fixed. ++ ++ There occurs a single use of ares_strsplit and since the make_set ++ parameter has been removed, the call in ares_init.c is modified ++ accordingly. The unit test for ares_strsplit is also updated. ++ ++ Fix By: Nikolaos Chatzikonstantinou (@createyourpersonalaccount) ++ ++bradh352 (23 Oct 2022) ++- CirrusCI: update freebsd image ++ ++ Old FreeBSD image for CirrusCI has issues with newer symbols, update to later one. ++ ++ Fix By: Brad House (@bradh352) ++ ++GitHub (23 Oct 2022) ++- [Stephen Sachs brought this change] ++ ++ Fix Intel compiler deprecated options (#485) ++ ++ Options `-we ###` and `-wd ###` should not include a whitespace. They are also deprecated and `-diag-error` and `-diag-disable` are their replacements. ++ ++ Intel compiler 2021.6 is not able to be used in configure without the proposed patch. ++ ++ Fix By: Stephen Sachs (@stephenmsachs) ++ ++- [Jonathan Ringer brought this change] ++ ++ Allow for CMake to use absolute install paths (#486) ++ ++ Generated libcares.pc could have bad paths when using absolute paths. ++ ++ Fix By: Jonathan Ringer (@jonringer) ++ ++- [Thomas Dreibholz brought this change] ++ ++ Fix for issue #488: ensure that the number of iovec entries does not exceed system limits. (#489) ++ ++ c-ares could try to exceed maximum number of iovec entries supported by system. ++ ++ Fix By: Thomas Dreibholz (@dreibh) ++ ++- [bsergean brought this change] ++ ++ Add include guards to ares_data.h (#491) ++ ++ All the other header files in the src/lib folder do have an include guard so it look like an overthought. ++ ++ Fix By: @bsergean ++ ++- [Brad Spencer brought this change] ++ ++ Fix typo in docs for ares_process_fd (#490) ++ ++ A single letter was missing ++ ++ Fix By: Brad Spencer (@b-spencer) ++ ++- [lifenjoiner brought this change] ++ ++ tools: refine help (#481) ++ ++ fix invalid help options and documentation typos ++ ++ Fix By: @lifenjoiner ++ ++- [lifenjoiner brought this change] ++ ++ Git: ignore CMake temporary files (#480) ++ ++ exclude more files from git ++ ++ Fix By: @lifenjoiner ++ ++- [lifenjoiner brought this change] ++ ++ adig: fix `-T` option (#479) ++ ++ Helper was missing flag to enable TCP mode of operation. ++ ++ Fix By: @lifenjoiner ++ ++- [Frank brought this change] ++ ++ Add vcpkg installation instructions (#478) ++ ++ Update to include vcpkg installation instructions ++ ++ Fix By: @FrankXie05 ++ ++- [marc-groundctl brought this change] ++ ++ Convert total timeout to per-query (#467) ++ ++ On Apple platforms, libresolv reports the total timeout in retrans, not the per-query time. This patch undoes that math to get the per-query time, which is what c-ares expects. This is not perfect because libresolv is inconsistent on whether the timeout is multiplied by retry or retry+1, but I don't see any way to distinguish these cases. ++ ++ Fix By: Marc Aldorasi (@marc-groundctl) ++ ++- [marc-groundctl brought this change] ++ ++ Don't include version info in the static library (#468) ++ ++ The static library should not contain version info, since it would be linked into an executable or dll with its own version info. ++ ++ Fix By: @marc-groundctl ++ ++- [Ridge Kennedy brought this change] ++ ++ Fix ares_getaddrinfo() numerical address fast path with AF_UNSPEC (#469) ++ ++ The conversion of numeric IPv4 addresses in fake_addrinfo() is broken when ++ the family is AF_UNSPEC. The initial call to ares_inet_pton with AF_INET ++ will succeed, but the subsequent call using AF_INET6 will fail. This results ++ in the fake_addrinfo() fast path failing, and ares_getaddrinfo() making a ++ query when none should be required. ++ ++ Resolve this by only attempting the call to ares_inet_pton with AF_INET6 ++ if the initial call with AF_INET was unsuccessful. ++ ++ Fix By: Ridge Kennedy (@ridgek) ++ ++- [Manish Mehra brought this change] ++ ++ Configurable hosts path for file_lookup (#465) ++ ++ This changeset adds support for configurable hosts file ++ ARES_OPT_HOSTS_FILE (similar to ARES_OPT_RESOLVCONF). ++ ++ Co-authored-by: Manish Mehra (@mmehra) ++ ++bradh352 (27 Apr 2022) ++- CMake: Windows DLLs lack version information ++ ++ The cares.rc was not included in the build for CMake. Conditionally ++ add it when building for Windows. ++ ++ Fix By: Brad House (@bradh352) ++ Fixes Bug: #460 ++ ++GitHub (27 Apr 2022) ++- [Kai Pastor brought this change] ++ ++ CMake: Guard target creation in exported config (#464) ++ ++ User projects may call 'find_package(c-ares)' multiple times (e.g. ++ via dependencies), but targets must be created only once. ++ Shared and static target must be treated independently. ++ ++ Fix By: Kai Pastor (@dg0yt) ++ ++bradh352 (27 Apr 2022) ++- Honor valid DNS result even if other class returned an error ++ ++ When using ares_getaddrinfo() with PF_UNSPEC, if a DNS server returned ++ good data on an A record, followed by bad data on an AAAA record, the ++ good record would be thrown away and an error returned. ++ ++ If we got a good response from one of the two queries, regardless of ++ the order returned, we should honor that. ++ ++ Fix By: Dmitry Karpov (dkarpov@roku.com) ++ Signed Off By: Brad House (@bradh352) ++ ++GitHub (2 Apr 2022) ++- [Sam James brought this change] ++ ++ configure.ac: fix STDC_HEADERS typo (#459) ++ ++ There is no autoconf macro called STDC_HEADERS. AC_HEADER_STDC however does ++ exist and it defines the STDC_HEADERS macro for use. ++ ++ Not clear that STDC_HEADERS from its use in the repo is needed but ++ would rather not meddle with it for now. ++ ++ Fixes an annoying warning on `./configure`: ++ ``` ++ /var/tmp/portage/net-dns/c-ares-1.18.1/work/c-ares-1.18.1/configure: 24546: STDC_HEADERS: not found ++ ``` ++ ++ Signed-off-by: Sam James ++ ++bradh352 (2 Mar 2022) ++- Asterisks should be allowed in host validation as CNAMEs may reference wildcard domains ++ ++ CloudFlare appears to use this logic in CNAMEs as per ++ https://github.com/nodejs/node/issues/42171 ++ ++ Fixes: #457 ++ Fix By: Brad House (@bradh352) ++ ++- Don't return on file lookup failure, set status ++ ++ When resolving a host via /etc/hosts, don't return with a predefined ++ error as there may be other tries. ++ ++ Fix By: Brad House (@bradh352) ++ ++- 'localhost' special treatment enhancement ++ ++ Since localhost is special-cased, any errors should be ignored when ++ reading /etc/hosts as otherwise we could return an error if there ++ were for instance an invalidly formatted /etc/hosts or if /etc/hosts ++ had a permissions error while reading. ++ ++ This exact behavior appears to have been seen on OS/400 PASE ++ environments which allows AIX binares to run. ++ ++ Fix By: Brad House (@bradh352) ++ ++- If chain building c-ares as part of another project, detect of res_servicename could fail (#451) ++ ++ If libresolv is already included with the build, c-ares wouldn't properly detect its use. ++ ++ May fix: #451 ++ Fix by: Brad House (@bradh352) ++ ++- no analyze capability on ios ++ ++- attempt to use scan-build on ios ++ ++- disable tests on ios ++ ++- fix switch statement ++ ++- code coverage had gotten disabled ++ ++- looks like shell expansion doesn't work with cirrus-ci, lets do it another way ++ ++- attempt to autobuild for iOS ++ ++GitHub (8 Dec 2021) ++- [Brad House brought this change] ++ ++ Windows: rework/simplify initialization code, drop long EOL systems (#445) ++ ++ There was a lot of windows initialization code specific to the era that predates Windows Vista such as reading DNS configuration from the registry, and dynamically loading libraries to get access to functions that didn't exist in XP or earlier releases. ++ ++ Vista was released in January 2007, and was EOL'd in 2017, and support for Vista is still maintained with this patch set. ++ ++ XP was EOL'd in Apr 8 2014. ++ ++ I believe the last OS based on something earlier than Vista was POSReady 2009, as it was XP based for some reason, and that was EOL'd in January 2019. Considering any POS system falls under the PCI-DSS rules, they aren't allow to run POSReady 2009 any more so there is no reason to try to continue supporting such systems. ++ ++ We have also targeted with our build system Vista support for the last few years, and while developers could change the target, we haven't had any reports that they have. ++ ++bradh352 (9 Nov 2021) ++- Fix memory leak in reading /etc/hosts ++ ++ When an /etc/hosts lookup is performed, but fails with ENOTFOUND, and ++ a valid RFC6761 Section 6.3 fallback is performed, it could overwrite ++ variables that were already set and therefore leave the pointers ++ dangling, never to be cleaned up. ++ ++ Clean up explicitly on ENOTFOUND when returning from the file parser. ++ ++ Fixes: #439 ++ Fix By: Brad House (@bradh352) ++ ++GitHub (2 Nov 2021) ++- [Bobby Reynolds brought this change] ++ ++ Fix cross-compilation from Windows to Linux due to CPACK logic (#436) ++ ++ When determining value for CPACK_PACKAGE_ARCHITECTURE, prefer to use ++ value from CMAKE_SYSTEM_PROCESSOR before falling back to uname output. ++ ++ Additionally, if building from a Windows host, emit a fatal error ++ instead of attempting to call uname. ++ ++ Fix By: Bobby Reynolds (@reynoldsbd) ++ ++bradh352 (1 Nov 2021) ++- fix coveralls link ++ ++- coveralls needs token ++ ++- coveralls appears to require git ++ ++- fix a couple of coveralls vars ++ ++- more coveralls fixes ++ ++- add code coverage libs to LDADD instead of _LIBS ++ ++- make verbose ++ ++- try to fix code coverage building ++ ++- need -y for install ++ ++- try to fix asan/ubsan/lsan when built with clang. try to support code coverage properly. ++ ++- try another path ++ ++- fix pip ++ ++- attempt to enable some other build types that travis supported ++ + Version 1.18.1 (26 Oct 2021) + + bradh352 (26 Oct 2021) +@@ -4882,240 +5552,3 @@ Daniel Stenberg (23 Mar 2010) + - git now, not CVS + + - ignore lots of generated files +- +-- [Daniel Johnson brought this change] +- +- Fix warnings for clang +- +-Yang Tse (17 Mar 2010) +-- replaced intel compiler option -no-ansi-alias with -fno-strict-aliasing +- +-- update outdated serial number +- +-- fix compiler warning +- +-- watt32 compilation fix +- +-- Added another VS10 version string +- +-- fix line break +- +-- removed usage of 's6_addr', fixing compilation issue triggered with no +- longer using 'in6_addr' but only our 'ares_in6_addr' struct +- +-Daniel Stenberg (5 Mar 2010) +-- Daniel Johnson provided fixes for building with the clang compiler +- +-Yang Tse (5 Mar 2010) +-- Added IPv6 name servers support +- +-Gisle Vanem (5 Mar 2010) +-- Ops!. Readded ares_nowarn.h. +- +-- Added ares_nowarn.c. +- +-Yang Tse (28 Feb 2010) +-- Added SIZEOF_INT and SIZEOF_SHORT definitions for non-configure systems +- +-- Added ares_nowarn.* to VC6 project file +- +-- Added SIZEOF_INT definition +- +-- fix compiler warning +- +-- fix compiler warning +- +-- fix compiler warning +- +-Daniel Stenberg (17 Feb 2010) +-- ares_reinit() +- +- - To allow an app to force a re-read of /etc/resolv.conf etc, pretty much +- like the res_init() resolver function offers +- +-- - Tommie Gannert pointed out a silly bug in ares_process_fd() since it didn't +- check for broken connections like ares_process() did. Based on that, I +- merged the two functions into a single generic one with two front-ends. +- +-Yang Tse (30 Dec 2009) +-- VMS specific preprocessor symbol checking adjustments +- +-- Mention last changes +- +-- - Fix configure_socket() to use ares_socket_t instead of int data type. +- +-- - Where run-time error checks enabling compiler option /GZ was used it is now +- replaced with equivalent /RTCsu for Visual Studio 2003 and newer versions. +- +- - Compiler option /GX is now replaced with equivalent /EHsc for all versions. +- +-- - Ingmar Runge noticed that Windows config-win32.h configuration file +- did not include a definition for HAVE_CLOSESOCKET which resulted in +- function close() being inappropriately used to close sockets. +- +-Daniel Stenberg (30 Nov 2009) +-- start working on 1.7.1 +- +-Version 1.7.0 (27 Nov 2009) +- +-Yang Tse (27 Nov 2009) +-- Preserve empty line following last target +- +-- - Larry Lansing fixed ares_parse_srv_reply to properly parse replies +- which might contain non-SRV answers, skipping over potential non-SRV +- ones such as CNAMEs. +- +-- When using icc, compile with -fpic and link with intel dynamic libraries. +- +-- Added 'currently' in italics to insist on transient situation. +- +-- Fix language +- +-- Daniel wants upcoming release to be 1.7.0 +- +-- Mention last changes +- +-- - Removed from external interface preprocessor symbol definition for +- CARES_HAVE_ARES_FREE_DATA. Current functionality of ares_free_data() +- makes it unnecessary. +- +-- Added README.msvc +- +-- Changed c-ares naming conventions when using MSVC as described in README.msvc +- +-- - Mention other recent changes +- +-- - Jakub Hrozek renamed addrttl and addr6ttl structs to ares_addrttl and +- ares_addr6ttl in order to prevent name space pollution, along with +- necessary changes to code base and man pages.This change does not break +- ABI, there is no need to recompile existing applications. But existing +- applications using these structs with the old name will need source code +- adjustments when recompiled using c-ares 1.6.1. +- +-- - Jakub Hrozek fixed more function prototypes in man pages to sync them +- with the ones declared in ares.h +- +-- Make configure remove the ares_build.h file included in distribution tarballs. +- +-- Fix macro redefinition. +- +-- Fix name space pollution. +- +-- Allow using different extra import libraries for debug and release builds. +- +-- Add manifest stuff to msvc makefile +- +-- Sync man page with reality +- +-- Add missing external API decoration for ares_set_socket_callback() +- +-- Add ares_free_data() man page. +- +-- - Provide in external interface preprocessor symbol definitions for +- CARES_HAVE_ARES_FREE_DATA as an indication of function availability. +- +-- Remove typecast +- +-- Fix comment +- +-- Add ares_data.c and ares_data.h +- +-- Jakub Hrozek modified ares_parse_srv_reply() and ares_parse_txt_reply() API +- to return a linked lists of results. These were also modified to internally +- use the ares_data memory struct and as such its result must be free'ed with +- ares_free_data(). +- +-- Initial support for the generic ares_free_data() function that will allow +- applications to free memory allocated and returned by some c-ares funtions. +- +-- Make usage of calloc()'s arguments consistent with rest of code base +- +-- workaround icc 9.1 optimizer issue +- +-- Add icc fvisibility bug test +- +-- Fix icc 9.0 compiler warning: external definition with no prior declaration +- +-- Fix three var names +- +-- Add check for assert.h header file +- +-- getaddrinfo is fully thread safe on solaris versions which +- implement the function even when h_errno is not a macro. +- +- The h_errno macro test now only done on systems for which there +- is no hard coded knowledge about getaddrinfo's thread safeness. +- +-- Remove files generated on previous buildconf/configure run +- +-- Remove enable-thread / disable-thread configure option. These were only placebo +- options. The library is always built as thread safe as possible on every system. +- +-- Refactor how preprocessor symbol _THREAD_SAFE definition is done. +- +-- Assume that getaddrinfo is thread safe, unless hard coded +- knowledge says the contrary or h_errno is not defined. +- +-- Related with the threadsafe capability of getaddrinfo: +- +- - Constantine Sapuntzakis reported that Darwin 6.0 a.k.a. MAC OS X 10.2 +- and newer have a threadsafe getaddrinfo. +- +- - Fix Dragonfly BSD triplet detection. +- +- - In case the hard-coded knowledge says that getaddrinfo is threadsafe, +- an additional check is done to verify that h_errno is also defined. +- If h_errno isn't defined, we finally assume that it isn't threadsafe. +- Jamie Lokier provided the inspiration for this extra check. +- +-- AIX 5.2 and newer have threadsafe getaddrinfo. +- +- Add some comments to better understand what the regex's pretend to achieve. +- +-- HP-UX 11.11 and later have threadsafe getaddrinfo +- +-- Check if getaddrinfo is threadsafe when function check allows it to be used +- +-- Renamed fpGetNetworkParams and fpSystemFunction036 to avoid namespace pollution with static library +- +-- Add kernel32.lib +- +-- Mention last changes +- +-- Reinstate copyright symbol lost in previous commit +- +-- Make some strings different in resource file for debug or release builds +- +-- Ignore more subdirs +- +-- Fix compiler warning: conditional expression is constant +- +-- Sync linker and resource compiler options with Makefile.msvc +- +-- Follow Makefile.msvc subdirectory naming scheme, and sync compiler options +- +-- Updated MSVC makefile that allows building dynamic and static +- c-ares libraries in debug and release flavours. +- +- Additionally each of the three sample programs is built against +- each of the four possible c-ares libraries, generating all this +- a total number of 12 executables and 4 libraries. +- +-- Test for USE_WINSOCK since it is more restrictive than WIN32 +- +-- Make header inclusion depend on HAVE_*_H definition +- +-- Remove unneeded preprocessor directives +- +-- Adjust c-ares include paths for memory tracking enabled (--enable-curldebug) builds +- +-- source files used by sample programs +- +-- Renamed c-ares setup.h to ares_setup.h +- +-- Adjust include paths to take in account that currently: +- +- c-ares with --enable-curldebug uses memdebug.h from libcurl's lib subdirectory. +- +- memdebug.h needs access to libcurl's setup.h from libcurl's lib subdirectory +- and also needs access to libcurl's generated curl_config.h +diff --git a/deps/cares/CMakeLists.txt b/deps/cares/CMakeLists.txt +index cc4b590..9379014 100644 +--- a/deps/cares/CMakeLists.txt ++++ b/deps/cares/CMakeLists.txt +@@ -8,10 +8,10 @@ INCLUDE (CheckCSourceCompiles) + INCLUDE (CheckStructHasMember) + INCLUDE (CheckLibraryExists) + +-PROJECT (c-ares LANGUAGES C VERSION "1.18.0" ) ++PROJECT (c-ares LANGUAGES C VERSION "1.19.1" ) + + # Set this version before release +-SET (CARES_VERSION "1.18.1") ++SET (CARES_VERSION "1.19.1") + + INCLUDE (GNUInstallDirs) # include this *AFTER* PROJECT(), otherwise paths are wrong. + +@@ -26,7 +26,7 @@ INCLUDE (GNUInstallDirs) # include this *AFTER* PROJECT(), otherwise paths are w + # For example, a version of 4:0:2 would generate output such as: + # libname.so -> libname.so.2 + # libname.so.2 -> libname.so.2.2.0 +-SET (CARES_LIB_VERSIONINFO "7:1:5") ++SET (CARES_LIB_VERSIONINFO "8:1:6") + + + OPTION (CARES_STATIC "Build as a static library" OFF) +@@ -36,6 +36,8 @@ OPTION (CARES_STATIC_PIC "Build the static library as PIC (position independent) + OPTION (CARES_BUILD_TESTS "Build and run tests" OFF) + OPTION (CARES_BUILD_CONTAINER_TESTS "Build and run container tests (implies CARES_BUILD_TESTS, Linux only)" OFF) + OPTION (CARES_BUILD_TOOLS "Build tools" ON) ++SET (CARES_RANDOM_FILE "/dev/urandom" CACHE STRING "Suitable File / Device Path for entropy, such as /dev/urandom") ++ + + # Tests require static to be enabled on Windows to be able to access otherwise hidden symbols + IF (CARES_BUILD_TESTS AND (NOT CARES_STATIC) AND WIN32) +@@ -82,9 +84,14 @@ SET (TARGETS_INST_DEST + + # Function in Library + # CHECK_LIBRARY_EXISTS can't be used as it will return true if the function +-# is found in a different dependent library. ++# is found in a different required/dependent library. + MACRO (CARES_FUNCTION_IN_LIBRARY func lib var) ++ ++ SET (_ORIG_CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}") ++ SET (CMAKE_REQUIRED_LIBRARIES ) + CHECK_FUNCTION_EXISTS ("${func}" "_CARES_FUNC_IN_LIB_GLOBAL_${func}") ++ SET (CMAKE_REQUIRED_LIBRARIES "${_ORIG_CMAKE_REQUIRED_LIBRARIES}") ++ + IF ("${_CARES_FUNC_IN_LIB_GLOBAL_${func}}") + SET (${var} FALSE) + ELSE () +@@ -386,6 +393,8 @@ CHECK_SYMBOL_EXISTS (strncasecmp "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_STRNCAS + CHECK_SYMBOL_EXISTS (strncmpi "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_STRNCMPI) + CHECK_SYMBOL_EXISTS (strnicmp "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_STRNICMP) + CHECK_SYMBOL_EXISTS (writev "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_WRITEV) ++CHECK_SYMBOL_EXISTS (arc4random_buf "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_ARC4RANDOM_BUF) ++ + + # On Android, the system headers may define __system_property_get(), but excluded + # from libc. We need to perform a link test instead of a header/symbol test. +@@ -397,10 +406,6 @@ SET (CMAKE_REQUIRED_DEFINITIONS) + SET (CMAKE_REQUIRED_LIBRARIES) + + +-find_file(CARES_RANDOM_FILE urandom /dev) +-mark_as_advanced(CARES_RANDOM_FILE) +- +- + ################################################################################ + # recv, recvfrom, send, getnameinfo, gethostname + # ARGUMENTS AND RETURN VALUES +@@ -689,6 +694,12 @@ IF (CARES_INSTALL) + if( ${CMAKE_SYSTEM_NAME} STREQUAL "Linux" ) + + if ( "${CPACK_PACKAGE_ARCHITECTURE}" STREQUAL "" ) ++ set( CPACK_PACKAGE_ARCHITECTURE "${CMAKE_SYSTEM_PROCESSOR}" ) ++ endif() ++ if ( "${CPACK_PACKAGE_ARCHITECTURE}" STREQUAL "" ) ++ if ( "${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Windows" ) ++ message( FATAL_ERROR "Failed to determine CPACK_PACKAGE_ARCHITECTURE. Is CMAKE_SYSTEM_PROCESSOR set?" ) ++ endif() + # Note: the architecture should default to the local architecture, but it + # in fact comes up empty. We call `uname -m` to ask the kernel instead. + EXECUTE_PROCESS( COMMAND uname -m COMMAND tr -d '\n' OUTPUT_VARIABLE CPACK_PACKAGE_ARCHITECTURE ) +diff --git a/deps/cares/INSTALL.md b/deps/cares/INSTALL.md +index 1e33ad7..0f9d95a 100644 +--- a/deps/cares/INSTALL.md ++++ b/deps/cares/INSTALL.md +@@ -382,6 +382,20 @@ sure that the var `OSTYPE` contains the string 'linux'; set the var + `NDKBASE` to point to the base of your Novell NDK; and then type + `make -f Makefile.netware` from the top source directory; + ++VCPKG ++===== ++ ++You can build and install c-ares using [vcpkg](https://github.com/Microsoft/vcpkg/) dependency manager: ++ ++```sh or powershell ++ git clone https://github.com/Microsoft/vcpkg.git ++ cd vcpkg ++ ./bootstrap-vcpkg.sh ++ ./vcpkg integrate install ++ ./vcpkg install c-ares ++``` ++ ++The c-ares port in vcpkg is kept up to date by Microsoft team members and community contributors. If the version is out of date, please [create an issue or pull request](https://github.com/Microsoft/vcpkg) on the vcpkg repository. + + PORTS + ===== +diff --git a/deps/cares/Makefile.Watcom b/deps/cares/Makefile.Watcom +index fa529a5..34e07bb 100644 +--- a/deps/cares/Makefile.Watcom ++++ b/deps/cares/Makefile.Watcom +@@ -1,6 +1,7 @@ + # + # Watcom / OpenWatcom / Win32 makefile for cares. + # Quick hack by Guenter; comments to: /dev/nul ++# Updated by Douglas R. Reno, comments to: renodr2002@gmail.com. 2023 + # + + !ifndef %watcom +@@ -38,9 +39,9 @@ MD = mkdir + RD = rmdir /q /s 2>NUL + CP = copy + +-CFLAGS = -3r -mf -hc -zff -zgf -zq -zm -zc -s -fr=con -w2 -fpi -oilrtfm & +- -wcd=201 -bt=nt -d+ -dWIN32 -dCARES_BUILDING_LIBRARY & +- -dNTDDI_VERSION=0x05010000 -I. $(SYS_INCL) ++CFLAGS = -3r -mf -hc -zff -zgf -zq -zm -zc -s -fr=con -w2 -fpi -oilrtfm -aa & ++ -wcd=201 -bt=nt -d+ -dWIN32 -dCARES_BUILDING_LIBRARY & ++ -dNTDDI_VERSION=0x06000000 -I. -I.\include -I.\src\lib $(SYS_INCL) + + LFLAGS = option quiet, map, caseexact, eliminate + +@@ -69,7 +70,7 @@ LIB_ARG = $(OBJ_BASE)\stat\wlib.arg + !ifneq __MAKEOPTS__ -u + !error You MUST call wmake with the -u switch! + !else +-!include Makefile.inc ++!include src\lib\Makefile.inc + !endif + + OBJS = $(CSOURCES:.c=.obj) +@@ -82,10 +83,11 @@ OBJ_DIR = $(OBJ_BASE)\stat + OBJS_STAT = $+ $(OBJS) $- + + OBJ_DIR = $(OBJ_BASE)\dyn +-OBJS_DYN = $+ $(OBJS) $- ++OBJS_DYN += $(OBJS) $- + + ARESBUILDH = ares_build.h + RESOURCE = $(OBJ_BASE)\dyn\cares.res ++ARESBUILDH = include\ares_build.h + + all: $(ARESBUILDH) $(OBJ_BASE) $(TARGETS) $(DEMOS) .SYMBOLIC + @echo Welcome to cares +@@ -94,10 +96,10 @@ $(OBJ_BASE): + -$(MD) $^@ + -$(MD) $^@\stat + -$(MD) $^@\dyn +- -$(MD) $^@\demos ++ -$(MD) $^@\tools + + $(ARESBUILDH): .EXISTSONLY +- $(CP) $^@.dist $^@ ++ @echo Make sure to run buildconf.bat! + + $(LIBNAME).dll: $(OBJS_DYN) $(RESOURCE) $(LINK_ARG) + $(LD) name $^@ @$]@ +@@ -105,14 +107,20 @@ $(LIBNAME).dll: $(OBJS_DYN) $(RESOURCE) $(LINK_ARG) + $(LIBNAME).lib: $(OBJS_STAT) $(LIB_ARG) + $(AR) -q -b -c $^@ @$]@ + +-adig.exe: $(OBJ_BASE)\demos\adig.obj $(OBJ_BASE)\demos\ares_getopt.obj $(LIBNAME).lib +- $(LD) name $^@ system nt $(LFLAGS) file { $(OBJ_BASE)\demos\ares_getopt.obj $[@ } library $]@, ws2_32.lib ++$(OBJ_BASE)\tools\ares_getopt.obj: ++ $(CC) $(CFLAGS) -DCARES_STATICLIB .\src\tools\ares_getopt.c -fo=$^@ + +-ahost.exe: $(OBJ_BASE)\demos\ahost.obj $(OBJ_BASE)\demos\ares_getopt.obj $(LIBNAME).lib +- $(LD) name $^@ system nt $(LFLAGS) file { $(OBJ_BASE)\demos\ares_getopt.obj $[@ } library $]@, ws2_32.lib ++adig.exe: $(OBJ_BASE)\tools\ares_getopt.obj $(LIBNAME).lib ++ $(CC) $(CFLAGS) src\tools\adig.c -fo=$(OBJ_BASE)\tools\adig.obj ++ $(LD) name $^@ system nt $(LFLAGS) file { $(OBJ_BASE)\tools\adig.obj $[@ } library $]@, ws2_32.lib, iphlpapi.lib + +-acountry.exe: $(OBJ_BASE)\demos\acountry.obj $(OBJ_BASE)\demos\ares_getopt.obj $(LIBNAME).lib +- $(LD) name $^@ system nt $(LFLAGS) file { $(OBJ_BASE)\demos\ares_getopt.obj $[@ } library $]@, ws2_32.lib ++ahost.exe: $(OBJ_BASE)\tools\ares_getopt.obj $(LIBNAME).lib ++ $(CC) $(CFLAGS) src\tools\ahost.c -fo=$(OBJ_BASE)\tools\ahost.obj ++ $(LD) name $^@ system nt $(LFLAGS) file { $(OBJ_BASE)\tools\ahost.obj $[@ } library $]@, ws2_32.lib, iphlpapi.lib ++ ++acountry.exe: $(OBJ_BASE)\tools\ares_getopt.obj $(LIBNAME).lib ++ $(CC) $(CFLAGS) src\tools\acountry.c -fo=$(OBJ_BASE)\tools\acountry.obj ++ $(LD) name $^@ system nt $(LFLAGS) file { $(OBJ_BASE)\tools\acountry.obj $[@ } library $]@, ws2_32.lib, iphlpapi.lib + + clean: .SYMBOLIC + -$(RM) $(OBJS_STAT) +@@ -124,24 +132,23 @@ vclean realclean: clean .SYMBOLIC + -$(RM) $(DEMOS) $(DEMOS:.exe=.map) + -$(RD) $(OBJ_BASE)\stat + -$(RD) $(OBJ_BASE)\dyn +- -$(RD) $(OBJ_BASE)\demos ++ -$(RD) $(OBJ_BASE)\tools + -$(RD) $(OBJ_BASE) + + .ERASE +-$(RESOURCE): cares.rc .AUTODEPEND ++.c: .\src\lib ++ ++.ERASE ++$(RESOURCE): src\lib\cares.rc .AUTODEPEND + $(RC) $(DEBUG) -q -r -zm -I..\include $(SYS_INCL) $[@ -fo=$^@ + + .ERASE + .c{$(OBJ_BASE)\dyn}.obj: +- $(CC) $(CFLAGS) -bd $[@ -fo=$^@ ++ $(CC) $(CFLAGS) -bd .\src\lib\$^& -fo=$^@ + + .ERASE + .c{$(OBJ_BASE)\stat}.obj: +- $(CC) $(CFLAGS) -DCARES_STATICLIB $[@ -fo=$^@ +- +-.ERASE +-.c{$(OBJ_BASE)\demos}.obj: +- $(CC) $(CFLAGS) -DCARES_STATICLIB $[@ -fo=$^@ ++ $(CC) $(CFLAGS) -DCARES_STATICLIB .\src\lib\$^& -fo=$^@ + + $(LINK_ARG): $(__MAKEFILES__) + %create $^@ +@@ -155,6 +162,7 @@ $(LINK_ARG): $(__MAKEFILES__) + @%append $^@ library $(%watt_root)\lib\wattcpw_imp.lib + !else + @%append $^@ library ws2_32.lib ++ @%append $^@ library iphlpapi.lib + !endif + + $(LIB_ARG): $(__MAKEFILES__) +diff --git a/deps/cares/Makefile.in b/deps/cares/Makefile.in +index 7d7b59e..3dfa479 100644 +--- a/deps/cares/Makefile.in ++++ b/deps/cares/Makefile.in +@@ -96,6 +96,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_ac_append_to_file.m4 \ + $(top_srcdir)/m4/ax_am_macros_static.m4 \ + $(top_srcdir)/m4/ax_check_gnu_make.m4 \ + $(top_srcdir)/m4/ax_code_coverage.m4 \ ++ $(top_srcdir)/m4/ax_cxx_compile_stdcxx.m4 \ + $(top_srcdir)/m4/ax_cxx_compile_stdcxx_11.m4 \ + $(top_srcdir)/m4/ax_file_escapes.m4 \ + $(top_srcdir)/m4/ax_require_defined.m4 \ +@@ -297,6 +298,7 @@ EGREP = @EGREP@ + ETAGS = @ETAGS@ + EXEEXT = @EXEEXT@ + FGREP = @FGREP@ ++FILECMD = @FILECMD@ + GCOV = @GCOV@ + GENHTML = @GENHTML@ + GREP = @GREP@ +diff --git a/deps/cares/README.md b/deps/cares/README.md +index 24a96c4..b507a5c 100644 +--- a/deps/cares/README.md ++++ b/deps/cares/README.md +@@ -3,7 +3,7 @@ c-ares + + [![Build Status](https://api.cirrus-ci.com/github/c-ares/c-ares.svg)](https://cirrus-ci.com/github/c-ares/c-ares) + [![Windows Build Status](https://ci.appveyor.com/api/projects/status/aevgc5914tm72pvs/branch/master?svg=true)](https://ci.appveyor.com/project/c-ares/c-ares/branch/master) +-[![Coverage Status](https://coveralls.io/repos/c-ares/c-ares/badge.svg?branch=master&service=github)](https://coveralls.io/github/c-ares/c-ares?branch=master) ++[![Coverage Status](https://coveralls.io/repos/github/c-ares/c-ares/badge.svg)](https://coveralls.io/github/c-ares/c-ares) + [![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/291/badge)](https://bestpractices.coreinfrastructure.org/projects/291) + [![Fuzzing Status](https://oss-fuzz-build-logs.storage.googleapis.com/badges/c-ares.svg)](https://bugs.chromium.org/p/oss-fuzz/issues/list?sort=-opened&can=1&q=proj:c-ares) + [![Releases](https://coderelease.io/badge/c-ares/c-ares)](https://coderelease.io/github/repository/c-ares/c-ares) +diff --git a/deps/cares/RELEASE-NOTES b/deps/cares/RELEASE-NOTES +index d095749..2524f3c 100644 +--- a/deps/cares/RELEASE-NOTES ++++ b/deps/cares/RELEASE-NOTES +@@ -1,85 +1,57 @@ +-c-ares version 1.18.1 ++c-ares version 1.19.1 + +-This is an urgent bugfix release for a regression made in 1.18.0. ++This is a security and bugfix release. + +-Bug fixes: +- o ares_getaddrinfo() would return ai_addrlen of 16 for ipv6 +- adddresses rather than the sizeof(struct sockaddr_in6) +- +- +- +-c-ares version 1.18.0 +- +-This is a feature and bugfix release. It addresses a couple of new feature +-requests as well as a couple of bug fixes. ++A special thanks goes out to the Open Source Technology Improvement Fund ++(https://ostif.org) for sponsoring a security audit of c-ares performed by X41 ++(https://x41-dsec.de). + +-Changes: +- o Add support for URI(Uniform Resource Identifier) records via +- ares_parse_uri_reply() [1] +- o Provide ares_nameser.h as a public interface as needed by NodeJS [5] +- o Update URLs from c-ares.haxx.se to c-ares.org [9] +- o During a domain search, treat ARES_ENODATA as ARES_NXDOMAIN so that the +- search process will continue to the next domain in the search. [11] +- o Turn ares_gethostbyname() into a wrapper for ares_getaddrinfo() as they +- followed very similar code paths and ares_gethostbyaddr() has some more +- desirable features such as priority sorting and parallel queries for +- AF_UNSPEC. [12] +- o ares_getaddrinfo() now contains a name element in the address info +- structure as the last element. This is not an API or ABI break due to +- the structure always being internally allocated and it being the last +- element. [12] +- o ares_parse_a_reply() and ares_parse_aaaa_reply() were nearly identical, those +- now use the same helper functions for parsing rather than having their own +- code. [12] +- o RFC6761 Section 6.3 says "localhost" lookups need to be special cased to +- return loopback addresses, and not forward queries to recursive dns servers. +- On Windows this now returns all loopback addresses, on other systems it +- returns 127.0.0.1 or ::1 always, and will never forward a request for +- "localhost" to outside DNS servers. [13] +- o Haiki: port [14] ++Security: ++ o CVE-2023-32067. High. 0-byte UDP payload causes Denial of Service [12] ++ o CVE-2023-31147. Moderate. Insufficient randomness in generation of DNS ++ query IDs [13] ++ o CVE-2023-31130. Moderate. Buffer Underwrite in ares_inet_net_pton() [14] ++ o CVE-2023-31124. Low. AutoTools does not set CARES_RANDOM_FILE during cross ++ compilation [15] + + Bug fixes: +- o add build to .gitignore [2] +- o z/OS minor update, add missing semicolon in ares_init.c [3] +- o Fix building when latest ax_code_coverage.m4 is imported [4] +- o Work around autotools 'error: too many loops' and other newer autotools +- import related bugs. +- o MinGW cross builds need advapi32 link as lower case [6] +- o Cygwin build fix due to containing both socket.h and winsock2.h [7] +- o ares_expand_name should allow underscores (_) as SRV records legitimately use +- them [8] +- o Allow '/' as a valid character for a returned name for CNAME in-addr.arpa +- delegation [10] +- o ares_getaddrinfo() was not honoring HOSTALIASES [12] +- o ares_getaddrinfo() had some test cases disabled due to a bug in the test +- framework itself which has now been resolved [12] +- o Due to Travis-CI becoming unfriendly to open-source, Cirrus-CI has now been +- brought online for automated unit testing. ++ o Fix uninitialized memory warning in test [1] ++ o Turn off IPV6_V6ONLY on Windows to allow IPv4-mapped IPv6 addresses [2] ++ o ares_getaddrinfo() should allow a port of 0 [3] ++ o Fix memory leak in ares_send() on error [4] ++ o Fix comment style in ares_data.h [5] ++ o Remove unneeded ifdef for Windows [6] ++ o Fix typo in ares_init_options.3 [7] ++ o Re-add support for Watcom compiler [8] ++ o Sync ax_pthread.m4 with upstream [9] ++ o Windows: Invalid stack variable used out of scope for HOSTS path [10] ++ o Sync ax_cxx_compile_stdcxx_11.m4 with upstream to fix uclibc support [11] + + Thanks go to these friendly people for their efforts and contributions: +- Biswapriyo Nath (@Biswa96) + Brad House (@bradh352) +- Daniel Bevenius (@danbev) ++ @Chilledheart + Daniel Stenberg (@bagder) +- Dhrumil Rana (@dhrumilrana) +- Felix Yan (@felixonmars) +- Jérôme Duval (@korli) +- Martin Holeš (@martin-256) +- Sinan Kaya ++ Douglas R. Reno (@renodr) ++ Gregor Jasny (@gjasny) ++ Jay Freeman (@saurik) ++ @lifenjoiner ++ Nikolaos Chatzikonstantinou (@createyourpersonalaccount) ++ Yijie Ma (@yijiem) + (9 contributors) + + References to bug reports and discussions on issues: +- [1] = https://github.com/c-ares/c-ares/pull/411 +- [2] = https://github.com/c-ares/c-ares/pull/410 +- [3] = https://github.com/c-ares/c-ares/pull/414 +- [4] = https://github.com/c-ares/c-ares/pull/418 +- [5] = https://github.com/c-ares/c-ares/pull/417 +- [6] = https://github.com/c-ares/c-ares/pull/420 +- [7] = https://github.com/c-ares/c-ares/pull/422 +- [8] = https://github.com/c-ares/c-ares/issues/424 +- [9] = https://github.com/c-ares/c-ares/issues/423 +- [10] = https://github.com/c-ares/c-ares/issues/427 +- [11] = https://github.com/c-ares/c-ares/issues/426 +- [12] = https://github.com/c-ares/c-ares/pull/428 +- [13] = https://github.com/c-ares/c-ares/pull/430 +- [14] = https://github.com/c-ares/c-ares/pull/431 ++ [1] = https://github.com/c-ares/c-ares/pull/515 ++ [2] = https://github.com/c-ares/c-ares/pull/520 ++ [3] = https://github.com/c-ares/c-ares/issues/517 ++ [4] = https://github.com/c-ares/c-ares/pull/511 ++ [5] = https://github.com/c-ares/c-ares/pull/513 ++ [6] = https://github.com/c-ares/c-ares/pull/512 ++ [7] = https://github.com/c-ares/c-ares/pull/510 ++ [8] = https://github.com/c-ares/c-ares/pull/509 ++ [9] = https://github.com/c-ares/c-ares/pull/507 ++ [10] = https://github.com/c-ares/c-ares/pull/502 ++ [11] = https://github.com/c-ares/c-ares/pull/505 ++ [12] = https://github.com/c-ares/c-ares/security/advisories/GHSA-9g78-jv2r-p7vc ++ [13] = https://github.com/c-ares/c-ares/security/advisories/GHSA-8r8p-23f3-64c2 ++ [14] = https://github.com/c-ares/c-ares/security/advisories/GHSA-x6mf-cxr9-8q6v ++ [15] = https://github.com/c-ares/c-ares/security/advisories/GHSA-54xr-f67r-4pc4 +diff --git a/deps/cares/aclocal.m4 b/deps/cares/aclocal.m4 +index e7ced79..ef2987b 100644 +--- a/deps/cares/aclocal.m4 ++++ b/deps/cares/aclocal.m4 +@@ -1190,6 +1190,7 @@ m4_include([m4/ax_add_am_macro_static.m4]) + m4_include([m4/ax_am_macros_static.m4]) + m4_include([m4/ax_check_gnu_make.m4]) + m4_include([m4/ax_code_coverage.m4]) ++m4_include([m4/ax_cxx_compile_stdcxx.m4]) + m4_include([m4/ax_cxx_compile_stdcxx_11.m4]) + m4_include([m4/ax_file_escapes.m4]) + m4_include([m4/ax_require_defined.m4]) +diff --git a/deps/cares/aminclude_static.am b/deps/cares/aminclude_static.am +index c90aef6..94db7e3 100644 +--- a/deps/cares/aminclude_static.am ++++ b/deps/cares/aminclude_static.am +@@ -1,6 +1,6 @@ + + # aminclude_static.am generated automatically by Autoconf +-# from AX_AM_MACROS_STATIC on Wed Oct 27 08:06:13 CEST 2021 ++# from AX_AM_MACROS_STATIC on Mon May 22 14:23:05 CEST 2023 + + + # Code coverage +diff --git a/deps/cares/c-ares-config.cmake.in b/deps/cares/c-ares-config.cmake.in +index 464837b..1d05b24 100644 +--- a/deps/cares/c-ares-config.cmake.in ++++ b/deps/cares/c-ares-config.cmake.in +@@ -8,14 +8,17 @@ include("${CMAKE_CURRENT_LIST_DIR}/c-ares-targets.cmake") + set(c-ares_LIBRARY c-ares::cares) + + if(@CARES_SHARED@) +- add_library(c-ares::cares_shared INTERFACE IMPORTED) +- set_target_properties(c-ares::cares_shared PROPERTIES INTERFACE_LINK_LIBRARIES "c-ares::cares") ++ if(NOT TARGET c-ares::cares_shared) ++ add_library(c-ares::cares_shared INTERFACE IMPORTED) ++ set_target_properties(c-ares::cares_shared PROPERTIES INTERFACE_LINK_LIBRARIES "c-ares::cares") ++ endif() + set(c-ares_SHARED_LIBRARY c-ares::cares_shared) +-elseif(@CARES_STATIC@) +- add_library(c-ares::cares_static INTERFACE IMPORTED) +- set_target_properties(c-ares::cares_static PROPERTIES INTERFACE_LINK_LIBRARIES "c-ares::cares") + endif() + + if(@CARES_STATIC@) ++ if(NOT TARGET c-ares::cares_static) ++ add_library(c-ares::cares_static INTERFACE IMPORTED) ++ set_target_properties(c-ares::cares_static PROPERTIES INTERFACE_LINK_LIBRARIES "c-ares::cares") ++ endif() + set(c-ares_STATIC_LIBRARY c-ares::cares_static) + endif() +diff --git a/deps/cares/cares.gyp b/deps/cares/cares.gyp +index 88933e0..a308487 100644 +--- a/deps/cares/cares.gyp ++++ b/deps/cares/cares.gyp +@@ -88,6 +88,7 @@ + 'src/lib/ares_private.h', + 'src/lib/ares_process.c', + 'src/lib/ares_query.c', ++ 'src/lib/ares_rand.c', + 'src/lib/ares__read_line.c', + 'src/lib/ares__readaddrinfo.c', + 'src/lib/ares_search.c', +diff --git a/deps/cares/config.guess b/deps/cares/config.guess +index f50dcdb..7f76b62 100755 +--- a/deps/cares/config.guess ++++ b/deps/cares/config.guess +@@ -1,12 +1,14 @@ + #! /bin/sh + # Attempt to guess a canonical system name. +-# Copyright 1992-2018 Free Software Foundation, Inc. ++# Copyright 1992-2022 Free Software Foundation, Inc. + +-timestamp='2018-02-24' ++# shellcheck disable=SC2006,SC2268 # see below for rationale ++ ++timestamp='2022-01-09' + + # This file is free software; you can redistribute it and/or modify it + # under the terms of the GNU General Public License as published by +-# the Free Software Foundation; either version 3 of the License, or ++# the Free Software Foundation, either version 3 of the License, or + # (at your option) any later version. + # + # This program is distributed in the hope that it will be useful, but +@@ -27,11 +29,19 @@ timestamp='2018-02-24' + # Originally written by Per Bothner; maintained since 2000 by Ben Elliston. + # + # You can get the latest version of this script from: +-# https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess ++# https://git.savannah.gnu.org/cgit/config.git/plain/config.guess + # + # Please send patches to . + + ++# The "shellcheck disable" line above the timestamp inhibits complaints ++# about features and limitations of the classic Bourne shell that were ++# superseded or lifted in POSIX. However, this script identifies a wide ++# variety of pre-POSIX systems that do not have POSIX shells at all, and ++# even some reasonably current systems (Solaris 10 as case-in-point) still ++# have a pre-POSIX /bin/sh. ++ ++ + me=`echo "$0" | sed -e 's,.*/,,'` + + usage="\ +@@ -50,7 +60,7 @@ version="\ + GNU config.guess ($timestamp) + + Originally written by Per Bothner. +-Copyright 1992-2018 Free Software Foundation, Inc. ++Copyright 1992-2022 Free Software Foundation, Inc. + + This is free software; see the source for copying conditions. There is NO + warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." +@@ -84,7 +94,8 @@ if test $# != 0; then + exit 1 + fi + +-trap 'exit 1' 1 2 15 ++# Just in case it came from the environment. ++GUESS= + + # CC_FOR_BUILD -- compiler used by this script. Note that the use of a + # compiler to aid in system detection is discouraged as it requires +@@ -96,73 +107,90 @@ trap 'exit 1' 1 2 15 + + # Portable tmp directory creation inspired by the Autoconf team. + +-set_cc_for_build=' +-trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; +-trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; +-: ${TMPDIR=/tmp} ; +- { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || +- { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || +- { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || +- { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; +-dummy=$tmp/dummy ; +-tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; +-case $CC_FOR_BUILD,$HOST_CC,$CC in +- ,,) echo "int x;" > "$dummy.c" ; +- for c in cc gcc c89 c99 ; do +- if ($c -c -o "$dummy.o" "$dummy.c") >/dev/null 2>&1 ; then +- CC_FOR_BUILD="$c"; break ; +- fi ; +- done ; +- if test x"$CC_FOR_BUILD" = x ; then +- CC_FOR_BUILD=no_compiler_found ; +- fi +- ;; +- ,,*) CC_FOR_BUILD=$CC ;; +- ,*,*) CC_FOR_BUILD=$HOST_CC ;; +-esac ; set_cc_for_build= ;' ++tmp= ++# shellcheck disable=SC2172 ++trap 'test -z "$tmp" || rm -fr "$tmp"' 0 1 2 13 15 ++ ++set_cc_for_build() { ++ # prevent multiple calls if $tmp is already set ++ test "$tmp" && return 0 ++ : "${TMPDIR=/tmp}" ++ # shellcheck disable=SC2039,SC3028 ++ { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || ++ { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir "$tmp" 2>/dev/null) ; } || ++ { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir "$tmp" 2>/dev/null) && echo "Warning: creating insecure temp directory" >&2 ; } || ++ { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ++ dummy=$tmp/dummy ++ case ${CC_FOR_BUILD-},${HOST_CC-},${CC-} in ++ ,,) echo "int x;" > "$dummy.c" ++ for driver in cc gcc c89 c99 ; do ++ if ($driver -c -o "$dummy.o" "$dummy.c") >/dev/null 2>&1 ; then ++ CC_FOR_BUILD=$driver ++ break ++ fi ++ done ++ if test x"$CC_FOR_BUILD" = x ; then ++ CC_FOR_BUILD=no_compiler_found ++ fi ++ ;; ++ ,,*) CC_FOR_BUILD=$CC ;; ++ ,*,*) CC_FOR_BUILD=$HOST_CC ;; ++ esac ++} + + # This is needed to find uname on a Pyramid OSx when run in the BSD universe. + # (ghazi@noc.rutgers.edu 1994-08-24) +-if (test -f /.attbin/uname) >/dev/null 2>&1 ; then ++if test -f /.attbin/uname ; then + PATH=$PATH:/.attbin ; export PATH + fi + + UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown + UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown +-UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown ++UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown + UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown + +-case "$UNAME_SYSTEM" in ++case $UNAME_SYSTEM in + Linux|GNU|GNU/*) +- # If the system lacks a compiler, then just pick glibc. +- # We could probably try harder. +- LIBC=gnu ++ LIBC=unknown + +- eval "$set_cc_for_build" ++ set_cc_for_build + cat <<-EOF > "$dummy.c" + #include + #if defined(__UCLIBC__) + LIBC=uclibc + #elif defined(__dietlibc__) + LIBC=dietlibc +- #else ++ #elif defined(__GLIBC__) + LIBC=gnu ++ #else ++ #include ++ /* First heuristic to detect musl libc. */ ++ #ifdef __DEFINED_va_list ++ LIBC=musl ++ #endif + #endif + EOF +- eval "`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^LIBC' | sed 's, ,,g'`" ++ cc_set_libc=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^LIBC' | sed 's, ,,g'` ++ eval "$cc_set_libc" + +- # If ldd exists, use it to detect musl libc. +- if command -v ldd >/dev/null && \ +- ldd --version 2>&1 | grep -q ^musl +- then +- LIBC=musl ++ # Second heuristic to detect musl libc. ++ if [ "$LIBC" = unknown ] && ++ command -v ldd >/dev/null && ++ ldd --version 2>&1 | grep -q ^musl; then ++ LIBC=musl ++ fi ++ ++ # If the system lacks a compiler, then just pick glibc. ++ # We could probably try harder. ++ if [ "$LIBC" = unknown ]; then ++ LIBC=gnu + fi + ;; + esac + + # Note: order is significant - the case branches are not exclusive. + +-case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in ++case $UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION in + *:NetBSD:*:*) + # NetBSD (nbsd) targets should (where applicable) match one or + # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*, +@@ -174,12 +202,12 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in + # + # Note: NetBSD doesn't particularly care about the vendor + # portion of the name. We always set it to "unknown". +- sysctl="sysctl -n hw.machine_arch" + UNAME_MACHINE_ARCH=`(uname -p 2>/dev/null || \ +- "/sbin/$sysctl" 2>/dev/null || \ +- "/usr/sbin/$sysctl" 2>/dev/null || \ ++ /sbin/sysctl -n hw.machine_arch 2>/dev/null || \ ++ /usr/sbin/sysctl -n hw.machine_arch 2>/dev/null || \ + echo unknown)` +- case "$UNAME_MACHINE_ARCH" in ++ case $UNAME_MACHINE_ARCH in ++ aarch64eb) machine=aarch64_be-unknown ;; + armeb) machine=armeb-unknown ;; + arm*) machine=arm-unknown ;; + sh3el) machine=shl-unknown ;; +@@ -188,18 +216,18 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in + earmv*) + arch=`echo "$UNAME_MACHINE_ARCH" | sed -e 's,^e\(armv[0-9]\).*$,\1,'` + endian=`echo "$UNAME_MACHINE_ARCH" | sed -ne 's,^.*\(eb\)$,\1,p'` +- machine="${arch}${endian}"-unknown ++ machine=${arch}${endian}-unknown + ;; +- *) machine="$UNAME_MACHINE_ARCH"-unknown ;; ++ *) machine=$UNAME_MACHINE_ARCH-unknown ;; + esac + # The Operating System including object format, if it has switched + # to ELF recently (or will in the future) and ABI. +- case "$UNAME_MACHINE_ARCH" in ++ case $UNAME_MACHINE_ARCH in + earm*) + os=netbsdelf + ;; + arm*|i386|m68k|ns32k|sh3*|sparc|vax) +- eval "$set_cc_for_build" ++ set_cc_for_build + if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep -q __ELF__ + then +@@ -215,7 +243,7 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in + ;; + esac + # Determine ABI tags. +- case "$UNAME_MACHINE_ARCH" in ++ case $UNAME_MACHINE_ARCH in + earm*) + expr='s/^earmv[0-9]/-eabi/;s/eb$//' + abi=`echo "$UNAME_MACHINE_ARCH" | sed -e "$expr"` +@@ -226,7 +254,7 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in + # thus, need a distinct triplet. However, they do not need + # kernel version information, so it can be replaced with a + # suitable tag, in the style of linux-gnu. +- case "$UNAME_VERSION" in ++ case $UNAME_VERSION in + Debian*) + release='-gnu' + ;; +@@ -237,45 +265,57 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in + # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: + # contains redundant information, the shorter form: + # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. +- echo "$machine-${os}${release}${abi}" +- exit ;; ++ GUESS=$machine-${os}${release}${abi-} ++ ;; + *:Bitrig:*:*) + UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'` +- echo "$UNAME_MACHINE_ARCH"-unknown-bitrig"$UNAME_RELEASE" +- exit ;; ++ GUESS=$UNAME_MACHINE_ARCH-unknown-bitrig$UNAME_RELEASE ++ ;; + *:OpenBSD:*:*) + UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` +- echo "$UNAME_MACHINE_ARCH"-unknown-openbsd"$UNAME_RELEASE" +- exit ;; ++ GUESS=$UNAME_MACHINE_ARCH-unknown-openbsd$UNAME_RELEASE ++ ;; ++ *:SecBSD:*:*) ++ UNAME_MACHINE_ARCH=`arch | sed 's/SecBSD.//'` ++ GUESS=$UNAME_MACHINE_ARCH-unknown-secbsd$UNAME_RELEASE ++ ;; + *:LibertyBSD:*:*) + UNAME_MACHINE_ARCH=`arch | sed 's/^.*BSD\.//'` +- echo "$UNAME_MACHINE_ARCH"-unknown-libertybsd"$UNAME_RELEASE" +- exit ;; ++ GUESS=$UNAME_MACHINE_ARCH-unknown-libertybsd$UNAME_RELEASE ++ ;; + *:MidnightBSD:*:*) +- echo "$UNAME_MACHINE"-unknown-midnightbsd"$UNAME_RELEASE" +- exit ;; ++ GUESS=$UNAME_MACHINE-unknown-midnightbsd$UNAME_RELEASE ++ ;; + *:ekkoBSD:*:*) +- echo "$UNAME_MACHINE"-unknown-ekkobsd"$UNAME_RELEASE" +- exit ;; ++ GUESS=$UNAME_MACHINE-unknown-ekkobsd$UNAME_RELEASE ++ ;; + *:SolidBSD:*:*) +- echo "$UNAME_MACHINE"-unknown-solidbsd"$UNAME_RELEASE" +- exit ;; ++ GUESS=$UNAME_MACHINE-unknown-solidbsd$UNAME_RELEASE ++ ;; ++ *:OS108:*:*) ++ GUESS=$UNAME_MACHINE-unknown-os108_$UNAME_RELEASE ++ ;; + macppc:MirBSD:*:*) +- echo powerpc-unknown-mirbsd"$UNAME_RELEASE" +- exit ;; ++ GUESS=powerpc-unknown-mirbsd$UNAME_RELEASE ++ ;; + *:MirBSD:*:*) +- echo "$UNAME_MACHINE"-unknown-mirbsd"$UNAME_RELEASE" +- exit ;; ++ GUESS=$UNAME_MACHINE-unknown-mirbsd$UNAME_RELEASE ++ ;; + *:Sortix:*:*) +- echo "$UNAME_MACHINE"-unknown-sortix +- exit ;; ++ GUESS=$UNAME_MACHINE-unknown-sortix ++ ;; ++ *:Twizzler:*:*) ++ GUESS=$UNAME_MACHINE-unknown-twizzler ++ ;; + *:Redox:*:*) +- echo "$UNAME_MACHINE"-unknown-redox +- exit ;; ++ GUESS=$UNAME_MACHINE-unknown-redox ++ ;; + mips:OSF1:*.*) +- echo mips-dec-osf1 +- exit ;; ++ GUESS=mips-dec-osf1 ++ ;; + alpha:OSF1:*:*) ++ # Reset EXIT trap before exiting to avoid spurious non-zero exit code. ++ trap '' 0 + case $UNAME_RELEASE in + *4.0) + UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` +@@ -289,7 +329,7 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in + # covers most systems running today. This code pipes the CPU + # types through head -n 1, so we only detect the type of CPU 0. + ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` +- case "$ALPHA_CPU_TYPE" in ++ case $ALPHA_CPU_TYPE in + "EV4 (21064)") + UNAME_MACHINE=alpha ;; + "EV4.5 (21064)") +@@ -326,117 +366,121 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in + # A Tn.n version is a released field test version. + # A Xn.n version is an unreleased experimental baselevel. + # 1.2 uses "1.2" for uname -r. +- echo "$UNAME_MACHINE"-dec-osf"`echo "$UNAME_RELEASE" | sed -e 's/^[PVTX]//' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`" +- # Reset EXIT trap before exiting to avoid spurious non-zero exit code. +- exitcode=$? +- trap '' 0 +- exit $exitcode ;; ++ OSF_REL=`echo "$UNAME_RELEASE" | sed -e 's/^[PVTX]//' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz` ++ GUESS=$UNAME_MACHINE-dec-osf$OSF_REL ++ ;; + Amiga*:UNIX_System_V:4.0:*) +- echo m68k-unknown-sysv4 +- exit ;; ++ GUESS=m68k-unknown-sysv4 ++ ;; + *:[Aa]miga[Oo][Ss]:*:*) +- echo "$UNAME_MACHINE"-unknown-amigaos +- exit ;; ++ GUESS=$UNAME_MACHINE-unknown-amigaos ++ ;; + *:[Mm]orph[Oo][Ss]:*:*) +- echo "$UNAME_MACHINE"-unknown-morphos +- exit ;; ++ GUESS=$UNAME_MACHINE-unknown-morphos ++ ;; + *:OS/390:*:*) +- echo i370-ibm-openedition +- exit ;; ++ GUESS=i370-ibm-openedition ++ ;; + *:z/VM:*:*) +- echo s390-ibm-zvmoe +- exit ;; ++ GUESS=s390-ibm-zvmoe ++ ;; + *:OS400:*:*) +- echo powerpc-ibm-os400 +- exit ;; ++ GUESS=powerpc-ibm-os400 ++ ;; + arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) +- echo arm-acorn-riscix"$UNAME_RELEASE" +- exit ;; ++ GUESS=arm-acorn-riscix$UNAME_RELEASE ++ ;; + arm*:riscos:*:*|arm*:RISCOS:*:*) +- echo arm-unknown-riscos +- exit ;; ++ GUESS=arm-unknown-riscos ++ ;; + SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) +- echo hppa1.1-hitachi-hiuxmpp +- exit ;; ++ GUESS=hppa1.1-hitachi-hiuxmpp ++ ;; + Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) + # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. +- if test "`(/bin/universe) 2>/dev/null`" = att ; then +- echo pyramid-pyramid-sysv3 +- else +- echo pyramid-pyramid-bsd +- fi +- exit ;; ++ case `(/bin/universe) 2>/dev/null` in ++ att) GUESS=pyramid-pyramid-sysv3 ;; ++ *) GUESS=pyramid-pyramid-bsd ;; ++ esac ++ ;; + NILE*:*:*:dcosx) +- echo pyramid-pyramid-svr4 +- exit ;; ++ GUESS=pyramid-pyramid-svr4 ++ ;; + DRS?6000:unix:4.0:6*) +- echo sparc-icl-nx6 +- exit ;; ++ GUESS=sparc-icl-nx6 ++ ;; + DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) + case `/usr/bin/uname -p` in +- sparc) echo sparc-icl-nx7; exit ;; +- esac ;; ++ sparc) GUESS=sparc-icl-nx7 ;; ++ esac ++ ;; + s390x:SunOS:*:*) +- echo "$UNAME_MACHINE"-ibm-solaris2"`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`" +- exit ;; ++ SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'` ++ GUESS=$UNAME_MACHINE-ibm-solaris2$SUN_REL ++ ;; + sun4H:SunOS:5.*:*) +- echo sparc-hal-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`" +- exit ;; ++ SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'` ++ GUESS=sparc-hal-solaris2$SUN_REL ++ ;; + sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) +- echo sparc-sun-solaris2"`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`" +- exit ;; ++ SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'` ++ GUESS=sparc-sun-solaris2$SUN_REL ++ ;; + i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*) +- echo i386-pc-auroraux"$UNAME_RELEASE" +- exit ;; ++ GUESS=i386-pc-auroraux$UNAME_RELEASE ++ ;; + i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) +- eval "$set_cc_for_build" ++ set_cc_for_build + SUN_ARCH=i386 + # If there is a compiler, see if it is configured for 64-bit objects. + # Note that the Sun cc does not turn __LP64__ into 1 like gcc does. + # This test works for both compilers. +- if [ "$CC_FOR_BUILD" != no_compiler_found ]; then ++ if test "$CC_FOR_BUILD" != no_compiler_found; then + if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \ +- (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ ++ (CCOPTS="" $CC_FOR_BUILD -m64 -E - 2>/dev/null) | \ + grep IS_64BIT_ARCH >/dev/null + then + SUN_ARCH=x86_64 + fi + fi +- echo "$SUN_ARCH"-pc-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`" +- exit ;; ++ SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'` ++ GUESS=$SUN_ARCH-pc-solaris2$SUN_REL ++ ;; + sun4*:SunOS:6*:*) + # According to config.sub, this is the proper way to canonicalize + # SunOS6. Hard to guess exactly what SunOS6 will be like, but + # it's likely to be more like Solaris than SunOS4. +- echo sparc-sun-solaris3"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`" +- exit ;; ++ SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'` ++ GUESS=sparc-sun-solaris3$SUN_REL ++ ;; + sun4*:SunOS:*:*) +- case "`/usr/bin/arch -k`" in ++ case `/usr/bin/arch -k` in + Series*|S4*) + UNAME_RELEASE=`uname -v` + ;; + esac + # Japanese Language versions have a version number like `4.1.3-JL'. +- echo sparc-sun-sunos"`echo "$UNAME_RELEASE"|sed -e 's/-/_/'`" +- exit ;; ++ SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/-/_/'` ++ GUESS=sparc-sun-sunos$SUN_REL ++ ;; + sun3*:SunOS:*:*) +- echo m68k-sun-sunos"$UNAME_RELEASE" +- exit ;; ++ GUESS=m68k-sun-sunos$UNAME_RELEASE ++ ;; + sun*:*:4.2BSD:*) + UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` + test "x$UNAME_RELEASE" = x && UNAME_RELEASE=3 +- case "`/bin/arch`" in ++ case `/bin/arch` in + sun3) +- echo m68k-sun-sunos"$UNAME_RELEASE" ++ GUESS=m68k-sun-sunos$UNAME_RELEASE + ;; + sun4) +- echo sparc-sun-sunos"$UNAME_RELEASE" ++ GUESS=sparc-sun-sunos$UNAME_RELEASE + ;; + esac +- exit ;; ++ ;; + aushp:SunOS:*:*) +- echo sparc-auspex-sunos"$UNAME_RELEASE" +- exit ;; ++ GUESS=sparc-auspex-sunos$UNAME_RELEASE ++ ;; + # The situation for MiNT is a little confusing. The machine name + # can be virtually everything (everything which is not + # "atarist" or "atariste" at least should have a processor +@@ -446,43 +490,43 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in + # MiNT. But MiNT is downward compatible to TOS, so this should + # be no problem. + atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) +- echo m68k-atari-mint"$UNAME_RELEASE" +- exit ;; ++ GUESS=m68k-atari-mint$UNAME_RELEASE ++ ;; + atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) +- echo m68k-atari-mint"$UNAME_RELEASE" +- exit ;; ++ GUESS=m68k-atari-mint$UNAME_RELEASE ++ ;; + *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) +- echo m68k-atari-mint"$UNAME_RELEASE" +- exit ;; ++ GUESS=m68k-atari-mint$UNAME_RELEASE ++ ;; + milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) +- echo m68k-milan-mint"$UNAME_RELEASE" +- exit ;; ++ GUESS=m68k-milan-mint$UNAME_RELEASE ++ ;; + hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) +- echo m68k-hades-mint"$UNAME_RELEASE" +- exit ;; ++ GUESS=m68k-hades-mint$UNAME_RELEASE ++ ;; + *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) +- echo m68k-unknown-mint"$UNAME_RELEASE" +- exit ;; ++ GUESS=m68k-unknown-mint$UNAME_RELEASE ++ ;; + m68k:machten:*:*) +- echo m68k-apple-machten"$UNAME_RELEASE" +- exit ;; ++ GUESS=m68k-apple-machten$UNAME_RELEASE ++ ;; + powerpc:machten:*:*) +- echo powerpc-apple-machten"$UNAME_RELEASE" +- exit ;; ++ GUESS=powerpc-apple-machten$UNAME_RELEASE ++ ;; + RISC*:Mach:*:*) +- echo mips-dec-mach_bsd4.3 +- exit ;; ++ GUESS=mips-dec-mach_bsd4.3 ++ ;; + RISC*:ULTRIX:*:*) +- echo mips-dec-ultrix"$UNAME_RELEASE" +- exit ;; ++ GUESS=mips-dec-ultrix$UNAME_RELEASE ++ ;; + VAX*:ULTRIX*:*:*) +- echo vax-dec-ultrix"$UNAME_RELEASE" +- exit ;; ++ GUESS=vax-dec-ultrix$UNAME_RELEASE ++ ;; + 2020:CLIX:*:* | 2430:CLIX:*:*) +- echo clipper-intergraph-clix"$UNAME_RELEASE" +- exit ;; ++ GUESS=clipper-intergraph-clix$UNAME_RELEASE ++ ;; + mips:*:*:UMIPS | mips:*:*:RISCos) +- eval "$set_cc_for_build" ++ set_cc_for_build + sed 's/^ //' << EOF > "$dummy.c" + #ifdef __cplusplus + #include /* for printf() prototype */ +@@ -508,78 +552,79 @@ EOF + dummyarg=`echo "$UNAME_RELEASE" | sed -n 's/\([0-9]*\).*/\1/p'` && + SYSTEM_NAME=`"$dummy" "$dummyarg"` && + { echo "$SYSTEM_NAME"; exit; } +- echo mips-mips-riscos"$UNAME_RELEASE" +- exit ;; ++ GUESS=mips-mips-riscos$UNAME_RELEASE ++ ;; + Motorola:PowerMAX_OS:*:*) +- echo powerpc-motorola-powermax +- exit ;; ++ GUESS=powerpc-motorola-powermax ++ ;; + Motorola:*:4.3:PL8-*) +- echo powerpc-harris-powermax +- exit ;; ++ GUESS=powerpc-harris-powermax ++ ;; + Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) +- echo powerpc-harris-powermax +- exit ;; ++ GUESS=powerpc-harris-powermax ++ ;; + Night_Hawk:Power_UNIX:*:*) +- echo powerpc-harris-powerunix +- exit ;; ++ GUESS=powerpc-harris-powerunix ++ ;; + m88k:CX/UX:7*:*) +- echo m88k-harris-cxux7 +- exit ;; ++ GUESS=m88k-harris-cxux7 ++ ;; + m88k:*:4*:R4*) +- echo m88k-motorola-sysv4 +- exit ;; ++ GUESS=m88k-motorola-sysv4 ++ ;; + m88k:*:3*:R3*) +- echo m88k-motorola-sysv3 +- exit ;; ++ GUESS=m88k-motorola-sysv3 ++ ;; + AViiON:dgux:*:*) + # DG/UX returns AViiON for all architectures + UNAME_PROCESSOR=`/usr/bin/uname -p` +- if [ "$UNAME_PROCESSOR" = mc88100 ] || [ "$UNAME_PROCESSOR" = mc88110 ] ++ if test "$UNAME_PROCESSOR" = mc88100 || test "$UNAME_PROCESSOR" = mc88110 + then +- if [ "$TARGET_BINARY_INTERFACE"x = m88kdguxelfx ] || \ +- [ "$TARGET_BINARY_INTERFACE"x = x ] ++ if test "$TARGET_BINARY_INTERFACE"x = m88kdguxelfx || \ ++ test "$TARGET_BINARY_INTERFACE"x = x + then +- echo m88k-dg-dgux"$UNAME_RELEASE" ++ GUESS=m88k-dg-dgux$UNAME_RELEASE + else +- echo m88k-dg-dguxbcs"$UNAME_RELEASE" ++ GUESS=m88k-dg-dguxbcs$UNAME_RELEASE + fi + else +- echo i586-dg-dgux"$UNAME_RELEASE" ++ GUESS=i586-dg-dgux$UNAME_RELEASE + fi +- exit ;; ++ ;; + M88*:DolphinOS:*:*) # DolphinOS (SVR3) +- echo m88k-dolphin-sysv3 +- exit ;; ++ GUESS=m88k-dolphin-sysv3 ++ ;; + M88*:*:R3*:*) + # Delta 88k system running SVR3 +- echo m88k-motorola-sysv3 +- exit ;; ++ GUESS=m88k-motorola-sysv3 ++ ;; + XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) +- echo m88k-tektronix-sysv3 +- exit ;; ++ GUESS=m88k-tektronix-sysv3 ++ ;; + Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) +- echo m68k-tektronix-bsd +- exit ;; ++ GUESS=m68k-tektronix-bsd ++ ;; + *:IRIX*:*:*) +- echo mips-sgi-irix"`echo "$UNAME_RELEASE"|sed -e 's/-/_/g'`" +- exit ;; ++ IRIX_REL=`echo "$UNAME_RELEASE" | sed -e 's/-/_/g'` ++ GUESS=mips-sgi-irix$IRIX_REL ++ ;; + ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. +- echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id +- exit ;; # Note that: echo "'`uname -s`'" gives 'AIX ' ++ GUESS=romp-ibm-aix # uname -m gives an 8 hex-code CPU id ++ ;; # Note that: echo "'`uname -s`'" gives 'AIX ' + i*86:AIX:*:*) +- echo i386-ibm-aix +- exit ;; ++ GUESS=i386-ibm-aix ++ ;; + ia64:AIX:*:*) +- if [ -x /usr/bin/oslevel ] ; then ++ if test -x /usr/bin/oslevel ; then + IBM_REV=`/usr/bin/oslevel` + else +- IBM_REV="$UNAME_VERSION.$UNAME_RELEASE" ++ IBM_REV=$UNAME_VERSION.$UNAME_RELEASE + fi +- echo "$UNAME_MACHINE"-ibm-aix"$IBM_REV" +- exit ;; ++ GUESS=$UNAME_MACHINE-ibm-aix$IBM_REV ++ ;; + *:AIX:2:3) + if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then +- eval "$set_cc_for_build" ++ set_cc_for_build + sed 's/^ //' << EOF > "$dummy.c" + #include + +@@ -593,16 +638,16 @@ EOF + EOF + if $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"` + then +- echo "$SYSTEM_NAME" ++ GUESS=$SYSTEM_NAME + else +- echo rs6000-ibm-aix3.2.5 ++ GUESS=rs6000-ibm-aix3.2.5 + fi + elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then +- echo rs6000-ibm-aix3.2.4 ++ GUESS=rs6000-ibm-aix3.2.4 + else +- echo rs6000-ibm-aix3.2 ++ GUESS=rs6000-ibm-aix3.2 + fi +- exit ;; ++ ;; + *:AIX:*:[4567]) + IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` + if /usr/sbin/lsattr -El "$IBM_CPU_ID" | grep ' POWER' >/dev/null 2>&1; then +@@ -610,57 +655,57 @@ EOF + else + IBM_ARCH=powerpc + fi +- if [ -x /usr/bin/lslpp ] ; then +- IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc | ++ if test -x /usr/bin/lslpp ; then ++ IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc | \ + awk -F: '{ print $3 }' | sed s/[0-9]*$/0/` + else +- IBM_REV="$UNAME_VERSION.$UNAME_RELEASE" ++ IBM_REV=$UNAME_VERSION.$UNAME_RELEASE + fi +- echo "$IBM_ARCH"-ibm-aix"$IBM_REV" +- exit ;; ++ GUESS=$IBM_ARCH-ibm-aix$IBM_REV ++ ;; + *:AIX:*:*) +- echo rs6000-ibm-aix +- exit ;; ++ GUESS=rs6000-ibm-aix ++ ;; + ibmrt:4.4BSD:*|romp-ibm:4.4BSD:*) +- echo romp-ibm-bsd4.4 +- exit ;; ++ GUESS=romp-ibm-bsd4.4 ++ ;; + ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and +- echo romp-ibm-bsd"$UNAME_RELEASE" # 4.3 with uname added to +- exit ;; # report: romp-ibm BSD 4.3 ++ GUESS=romp-ibm-bsd$UNAME_RELEASE # 4.3 with uname added to ++ ;; # report: romp-ibm BSD 4.3 + *:BOSX:*:*) +- echo rs6000-bull-bosx +- exit ;; ++ GUESS=rs6000-bull-bosx ++ ;; + DPX/2?00:B.O.S.:*:*) +- echo m68k-bull-sysv3 +- exit ;; ++ GUESS=m68k-bull-sysv3 ++ ;; + 9000/[34]??:4.3bsd:1.*:*) +- echo m68k-hp-bsd +- exit ;; ++ GUESS=m68k-hp-bsd ++ ;; + hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) +- echo m68k-hp-bsd4.4 +- exit ;; ++ GUESS=m68k-hp-bsd4.4 ++ ;; + 9000/[34678]??:HP-UX:*:*) +- HPUX_REV=`echo "$UNAME_RELEASE"|sed -e 's/[^.]*.[0B]*//'` +- case "$UNAME_MACHINE" in ++ HPUX_REV=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*.[0B]*//'` ++ case $UNAME_MACHINE in + 9000/31?) HP_ARCH=m68000 ;; + 9000/[34]??) HP_ARCH=m68k ;; + 9000/[678][0-9][0-9]) +- if [ -x /usr/bin/getconf ]; then ++ if test -x /usr/bin/getconf; then + sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` + sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` +- case "$sc_cpu_version" in ++ case $sc_cpu_version in + 523) HP_ARCH=hppa1.0 ;; # CPU_PA_RISC1_0 + 528) HP_ARCH=hppa1.1 ;; # CPU_PA_RISC1_1 + 532) # CPU_PA_RISC2_0 +- case "$sc_kernel_bits" in ++ case $sc_kernel_bits in + 32) HP_ARCH=hppa2.0n ;; + 64) HP_ARCH=hppa2.0w ;; + '') HP_ARCH=hppa2.0 ;; # HP-UX 10.20 + esac ;; + esac + fi +- if [ "$HP_ARCH" = "" ]; then +- eval "$set_cc_for_build" ++ if test "$HP_ARCH" = ""; then ++ set_cc_for_build + sed 's/^ //' << EOF > "$dummy.c" + + #define _HPUX_SOURCE +@@ -698,9 +743,9 @@ EOF + test -z "$HP_ARCH" && HP_ARCH=hppa + fi ;; + esac +- if [ "$HP_ARCH" = hppa2.0w ] ++ if test "$HP_ARCH" = hppa2.0w + then +- eval "$set_cc_for_build" ++ set_cc_for_build + + # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating + # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler +@@ -719,14 +764,14 @@ EOF + HP_ARCH=hppa64 + fi + fi +- echo "$HP_ARCH"-hp-hpux"$HPUX_REV" +- exit ;; ++ GUESS=$HP_ARCH-hp-hpux$HPUX_REV ++ ;; + ia64:HP-UX:*:*) +- HPUX_REV=`echo "$UNAME_RELEASE"|sed -e 's/[^.]*.[0B]*//'` +- echo ia64-hp-hpux"$HPUX_REV" +- exit ;; ++ HPUX_REV=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*.[0B]*//'` ++ GUESS=ia64-hp-hpux$HPUX_REV ++ ;; + 3050*:HI-UX:*:*) +- eval "$set_cc_for_build" ++ set_cc_for_build + sed 's/^ //' << EOF > "$dummy.c" + #include + int +@@ -754,36 +799,36 @@ EOF + EOF + $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"` && + { echo "$SYSTEM_NAME"; exit; } +- echo unknown-hitachi-hiuxwe2 +- exit ;; ++ GUESS=unknown-hitachi-hiuxwe2 ++ ;; + 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:*) +- echo hppa1.1-hp-bsd +- exit ;; ++ GUESS=hppa1.1-hp-bsd ++ ;; + 9000/8??:4.3bsd:*:*) +- echo hppa1.0-hp-bsd +- exit ;; ++ GUESS=hppa1.0-hp-bsd ++ ;; + *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) +- echo hppa1.0-hp-mpeix +- exit ;; ++ GUESS=hppa1.0-hp-mpeix ++ ;; + hp7??:OSF1:*:* | hp8?[79]:OSF1:*:*) +- echo hppa1.1-hp-osf +- exit ;; ++ GUESS=hppa1.1-hp-osf ++ ;; + hp8??:OSF1:*:*) +- echo hppa1.0-hp-osf +- exit ;; ++ GUESS=hppa1.0-hp-osf ++ ;; + i*86:OSF1:*:*) +- if [ -x /usr/sbin/sysversion ] ; then +- echo "$UNAME_MACHINE"-unknown-osf1mk ++ if test -x /usr/sbin/sysversion ; then ++ GUESS=$UNAME_MACHINE-unknown-osf1mk + else +- echo "$UNAME_MACHINE"-unknown-osf1 ++ GUESS=$UNAME_MACHINE-unknown-osf1 + fi +- exit ;; ++ ;; + parisc*:Lites*:*:*) +- echo hppa1.1-hp-lites +- exit ;; ++ GUESS=hppa1.1-hp-lites ++ ;; + C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) +- echo c1-convex-bsd +- exit ;; ++ GUESS=c1-convex-bsd ++ ;; + C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) + if getsysinfo -f scalar_acc + then echo c32-convex-bsd +@@ -791,17 +836,18 @@ EOF + fi + exit ;; + C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) +- echo c34-convex-bsd +- exit ;; ++ GUESS=c34-convex-bsd ++ ;; + C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) +- echo c38-convex-bsd +- exit ;; ++ GUESS=c38-convex-bsd ++ ;; + C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) +- echo c4-convex-bsd +- exit ;; ++ GUESS=c4-convex-bsd ++ ;; + CRAY*Y-MP:*:*:*) +- echo ymp-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' +- exit ;; ++ CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'` ++ GUESS=ymp-cray-unicos$CRAY_REL ++ ;; + CRAY*[A-Z]90:*:*:*) + echo "$UNAME_MACHINE"-cray-unicos"$UNAME_RELEASE" \ + | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ +@@ -809,103 +855,129 @@ EOF + -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*TS:*:*:*) +- echo t90-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' +- exit ;; ++ CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'` ++ GUESS=t90-cray-unicos$CRAY_REL ++ ;; + CRAY*T3E:*:*:*) +- echo alphaev5-cray-unicosmk"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' +- exit ;; ++ CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'` ++ GUESS=alphaev5-cray-unicosmk$CRAY_REL ++ ;; + CRAY*SV1:*:*:*) +- echo sv1-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' +- exit ;; ++ CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'` ++ GUESS=sv1-cray-unicos$CRAY_REL ++ ;; + *:UNICOS/mp:*:*) +- echo craynv-cray-unicosmp"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' +- exit ;; ++ CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'` ++ GUESS=craynv-cray-unicosmp$CRAY_REL ++ ;; + F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) + FUJITSU_PROC=`uname -m | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz` + FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'` + FUJITSU_REL=`echo "$UNAME_RELEASE" | sed -e 's/ /_/'` +- echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" +- exit ;; ++ GUESS=${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL} ++ ;; + 5000:UNIX_System_V:4.*:*) + FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'` + FUJITSU_REL=`echo "$UNAME_RELEASE" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/ /_/'` +- echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" +- exit ;; ++ GUESS=sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL} ++ ;; + i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) +- echo "$UNAME_MACHINE"-pc-bsdi"$UNAME_RELEASE" +- exit ;; ++ GUESS=$UNAME_MACHINE-pc-bsdi$UNAME_RELEASE ++ ;; + sparc*:BSD/OS:*:*) +- echo sparc-unknown-bsdi"$UNAME_RELEASE" +- exit ;; ++ GUESS=sparc-unknown-bsdi$UNAME_RELEASE ++ ;; + *:BSD/OS:*:*) +- echo "$UNAME_MACHINE"-unknown-bsdi"$UNAME_RELEASE" +- exit ;; ++ GUESS=$UNAME_MACHINE-unknown-bsdi$UNAME_RELEASE ++ ;; ++ arm:FreeBSD:*:*) ++ UNAME_PROCESSOR=`uname -p` ++ set_cc_for_build ++ if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ ++ | grep -q __ARM_PCS_VFP ++ then ++ FREEBSD_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'` ++ GUESS=$UNAME_PROCESSOR-unknown-freebsd$FREEBSD_REL-gnueabi ++ else ++ FREEBSD_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'` ++ GUESS=$UNAME_PROCESSOR-unknown-freebsd$FREEBSD_REL-gnueabihf ++ fi ++ ;; + *:FreeBSD:*:*) + UNAME_PROCESSOR=`/usr/bin/uname -p` +- case "$UNAME_PROCESSOR" in ++ case $UNAME_PROCESSOR in + amd64) + UNAME_PROCESSOR=x86_64 ;; + i386) + UNAME_PROCESSOR=i586 ;; + esac +- echo "$UNAME_PROCESSOR"-unknown-freebsd"`echo "$UNAME_RELEASE"|sed -e 's/[-(].*//'`" +- exit ;; ++ FREEBSD_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'` ++ GUESS=$UNAME_PROCESSOR-unknown-freebsd$FREEBSD_REL ++ ;; + i*:CYGWIN*:*) +- echo "$UNAME_MACHINE"-pc-cygwin +- exit ;; ++ GUESS=$UNAME_MACHINE-pc-cygwin ++ ;; + *:MINGW64*:*) +- echo "$UNAME_MACHINE"-pc-mingw64 +- exit ;; ++ GUESS=$UNAME_MACHINE-pc-mingw64 ++ ;; + *:MINGW*:*) +- echo "$UNAME_MACHINE"-pc-mingw32 +- exit ;; ++ GUESS=$UNAME_MACHINE-pc-mingw32 ++ ;; + *:MSYS*:*) +- echo "$UNAME_MACHINE"-pc-msys +- exit ;; ++ GUESS=$UNAME_MACHINE-pc-msys ++ ;; + i*:PW*:*) +- echo "$UNAME_MACHINE"-pc-pw32 +- exit ;; ++ GUESS=$UNAME_MACHINE-pc-pw32 ++ ;; ++ *:SerenityOS:*:*) ++ GUESS=$UNAME_MACHINE-pc-serenity ++ ;; + *:Interix*:*) +- case "$UNAME_MACHINE" in ++ case $UNAME_MACHINE in + x86) +- echo i586-pc-interix"$UNAME_RELEASE" +- exit ;; ++ GUESS=i586-pc-interix$UNAME_RELEASE ++ ;; + authenticamd | genuineintel | EM64T) +- echo x86_64-unknown-interix"$UNAME_RELEASE" +- exit ;; ++ GUESS=x86_64-unknown-interix$UNAME_RELEASE ++ ;; + IA64) +- echo ia64-unknown-interix"$UNAME_RELEASE" +- exit ;; ++ GUESS=ia64-unknown-interix$UNAME_RELEASE ++ ;; + esac ;; + i*:UWIN*:*) +- echo "$UNAME_MACHINE"-pc-uwin +- exit ;; ++ GUESS=$UNAME_MACHINE-pc-uwin ++ ;; + amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) +- echo x86_64-unknown-cygwin +- exit ;; ++ GUESS=x86_64-pc-cygwin ++ ;; + prep*:SunOS:5.*:*) +- echo powerpcle-unknown-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`" +- exit ;; ++ SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'` ++ GUESS=powerpcle-unknown-solaris2$SUN_REL ++ ;; + *:GNU:*:*) + # the GNU system +- echo "`echo "$UNAME_MACHINE"|sed -e 's,[-/].*$,,'`-unknown-$LIBC`echo "$UNAME_RELEASE"|sed -e 's,/.*$,,'`" +- exit ;; ++ GNU_ARCH=`echo "$UNAME_MACHINE" | sed -e 's,[-/].*$,,'` ++ GNU_REL=`echo "$UNAME_RELEASE" | sed -e 's,/.*$,,'` ++ GUESS=$GNU_ARCH-unknown-$LIBC$GNU_REL ++ ;; + *:GNU/*:*:*) + # other systems with GNU libc and userland +- echo "$UNAME_MACHINE-unknown-`echo "$UNAME_SYSTEM" | sed 's,^[^/]*/,,' | tr "[:upper:]" "[:lower:]"``echo "$UNAME_RELEASE"|sed -e 's/[-(].*//'`-$LIBC" +- exit ;; +- i*86:Minix:*:*) +- echo "$UNAME_MACHINE"-pc-minix +- exit ;; ++ GNU_SYS=`echo "$UNAME_SYSTEM" | sed 's,^[^/]*/,,' | tr "[:upper:]" "[:lower:]"` ++ GNU_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'` ++ GUESS=$UNAME_MACHINE-unknown-$GNU_SYS$GNU_REL-$LIBC ++ ;; ++ *:Minix:*:*) ++ GUESS=$UNAME_MACHINE-unknown-minix ++ ;; + aarch64:Linux:*:*) +- echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" +- exit ;; ++ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC ++ ;; + aarch64_be:Linux:*:*) + UNAME_MACHINE=aarch64_be +- echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" +- exit ;; ++ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC ++ ;; + alpha:Linux:*:*) +- case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in ++ case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' /proc/cpuinfo 2>/dev/null` in + EV5) UNAME_MACHINE=alphaev5 ;; + EV56) UNAME_MACHINE=alphaev56 ;; + PCA56) UNAME_MACHINE=alphapca56 ;; +@@ -916,187 +988,225 @@ EOF + esac + objdump --private-headers /bin/sh | grep -q ld.so.1 + if test "$?" = 0 ; then LIBC=gnulibc1 ; fi +- echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" +- exit ;; +- arc:Linux:*:* | arceb:Linux:*:*) +- echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" +- exit ;; ++ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC ++ ;; ++ arc:Linux:*:* | arceb:Linux:*:* | arc32:Linux:*:* | arc64:Linux:*:*) ++ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC ++ ;; + arm*:Linux:*:*) +- eval "$set_cc_for_build" ++ set_cc_for_build + if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep -q __ARM_EABI__ + then +- echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" ++ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + else + if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep -q __ARM_PCS_VFP + then +- echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"eabi ++ GUESS=$UNAME_MACHINE-unknown-linux-${LIBC}eabi + else +- echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"eabihf ++ GUESS=$UNAME_MACHINE-unknown-linux-${LIBC}eabihf + fi + fi +- exit ;; ++ ;; + avr32*:Linux:*:*) +- echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" +- exit ;; ++ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC ++ ;; + cris:Linux:*:*) +- echo "$UNAME_MACHINE"-axis-linux-"$LIBC" +- exit ;; ++ GUESS=$UNAME_MACHINE-axis-linux-$LIBC ++ ;; + crisv32:Linux:*:*) +- echo "$UNAME_MACHINE"-axis-linux-"$LIBC" +- exit ;; ++ GUESS=$UNAME_MACHINE-axis-linux-$LIBC ++ ;; + e2k:Linux:*:*) +- echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" +- exit ;; ++ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC ++ ;; + frv:Linux:*:*) +- echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" +- exit ;; ++ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC ++ ;; + hexagon:Linux:*:*) +- echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" +- exit ;; ++ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC ++ ;; + i*86:Linux:*:*) +- echo "$UNAME_MACHINE"-pc-linux-"$LIBC" +- exit ;; ++ GUESS=$UNAME_MACHINE-pc-linux-$LIBC ++ ;; + ia64:Linux:*:*) +- echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" +- exit ;; ++ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC ++ ;; + k1om:Linux:*:*) +- echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" +- exit ;; ++ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC ++ ;; ++ loongarch32:Linux:*:* | loongarch64:Linux:*:* | loongarchx32:Linux:*:*) ++ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC ++ ;; + m32r*:Linux:*:*) +- echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" +- exit ;; ++ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC ++ ;; + m68*:Linux:*:*) +- echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" +- exit ;; ++ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC ++ ;; + mips:Linux:*:* | mips64:Linux:*:*) +- eval "$set_cc_for_build" ++ set_cc_for_build ++ IS_GLIBC=0 ++ test x"${LIBC}" = xgnu && IS_GLIBC=1 + sed 's/^ //' << EOF > "$dummy.c" + #undef CPU +- #undef ${UNAME_MACHINE} +- #undef ${UNAME_MACHINE}el ++ #undef mips ++ #undef mipsel ++ #undef mips64 ++ #undef mips64el ++ #if ${IS_GLIBC} && defined(_ABI64) ++ LIBCABI=gnuabi64 ++ #else ++ #if ${IS_GLIBC} && defined(_ABIN32) ++ LIBCABI=gnuabin32 ++ #else ++ LIBCABI=${LIBC} ++ #endif ++ #endif ++ ++ #if ${IS_GLIBC} && defined(__mips64) && defined(__mips_isa_rev) && __mips_isa_rev>=6 ++ CPU=mipsisa64r6 ++ #else ++ #if ${IS_GLIBC} && !defined(__mips64) && defined(__mips_isa_rev) && __mips_isa_rev>=6 ++ CPU=mipsisa32r6 ++ #else ++ #if defined(__mips64) ++ CPU=mips64 ++ #else ++ CPU=mips ++ #endif ++ #endif ++ #endif ++ + #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) +- CPU=${UNAME_MACHINE}el ++ MIPS_ENDIAN=el + #else + #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) +- CPU=${UNAME_MACHINE} ++ MIPS_ENDIAN= + #else +- CPU= ++ MIPS_ENDIAN= + #endif + #endif + EOF +- eval "`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^CPU'`" +- test "x$CPU" != x && { echo "$CPU-unknown-linux-$LIBC"; exit; } ++ cc_set_vars=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^CPU\|^MIPS_ENDIAN\|^LIBCABI'` ++ eval "$cc_set_vars" ++ test "x$CPU" != x && { echo "$CPU${MIPS_ENDIAN}-unknown-linux-$LIBCABI"; exit; } + ;; + mips64el:Linux:*:*) +- echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" +- exit ;; ++ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC ++ ;; + openrisc*:Linux:*:*) +- echo or1k-unknown-linux-"$LIBC" +- exit ;; ++ GUESS=or1k-unknown-linux-$LIBC ++ ;; + or32:Linux:*:* | or1k*:Linux:*:*) +- echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" +- exit ;; ++ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC ++ ;; + padre:Linux:*:*) +- echo sparc-unknown-linux-"$LIBC" +- exit ;; ++ GUESS=sparc-unknown-linux-$LIBC ++ ;; + parisc64:Linux:*:* | hppa64:Linux:*:*) +- echo hppa64-unknown-linux-"$LIBC" +- exit ;; ++ GUESS=hppa64-unknown-linux-$LIBC ++ ;; + parisc:Linux:*:* | hppa:Linux:*:*) + # Look for CPU level + case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in +- PA7*) echo hppa1.1-unknown-linux-"$LIBC" ;; +- PA8*) echo hppa2.0-unknown-linux-"$LIBC" ;; +- *) echo hppa-unknown-linux-"$LIBC" ;; ++ PA7*) GUESS=hppa1.1-unknown-linux-$LIBC ;; ++ PA8*) GUESS=hppa2.0-unknown-linux-$LIBC ;; ++ *) GUESS=hppa-unknown-linux-$LIBC ;; + esac +- exit ;; ++ ;; + ppc64:Linux:*:*) +- echo powerpc64-unknown-linux-"$LIBC" +- exit ;; ++ GUESS=powerpc64-unknown-linux-$LIBC ++ ;; + ppc:Linux:*:*) +- echo powerpc-unknown-linux-"$LIBC" +- exit ;; ++ GUESS=powerpc-unknown-linux-$LIBC ++ ;; + ppc64le:Linux:*:*) +- echo powerpc64le-unknown-linux-"$LIBC" +- exit ;; ++ GUESS=powerpc64le-unknown-linux-$LIBC ++ ;; + ppcle:Linux:*:*) +- echo powerpcle-unknown-linux-"$LIBC" +- exit ;; +- riscv32:Linux:*:* | riscv64:Linux:*:*) +- echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" +- exit ;; ++ GUESS=powerpcle-unknown-linux-$LIBC ++ ;; ++ riscv32:Linux:*:* | riscv32be:Linux:*:* | riscv64:Linux:*:* | riscv64be:Linux:*:*) ++ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC ++ ;; + s390:Linux:*:* | s390x:Linux:*:*) +- echo "$UNAME_MACHINE"-ibm-linux-"$LIBC" +- exit ;; ++ GUESS=$UNAME_MACHINE-ibm-linux-$LIBC ++ ;; + sh64*:Linux:*:*) +- echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" +- exit ;; ++ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC ++ ;; + sh*:Linux:*:*) +- echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" +- exit ;; ++ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC ++ ;; + sparc:Linux:*:* | sparc64:Linux:*:*) +- echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" +- exit ;; ++ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC ++ ;; + tile*:Linux:*:*) +- echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" +- exit ;; ++ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC ++ ;; + vax:Linux:*:*) +- echo "$UNAME_MACHINE"-dec-linux-"$LIBC" +- exit ;; ++ GUESS=$UNAME_MACHINE-dec-linux-$LIBC ++ ;; + x86_64:Linux:*:*) +- if objdump -f /bin/sh | grep -q elf32-x86-64; then +- echo "$UNAME_MACHINE"-pc-linux-"$LIBC"x32 +- else +- echo "$UNAME_MACHINE"-pc-linux-"$LIBC" ++ set_cc_for_build ++ LIBCABI=$LIBC ++ if test "$CC_FOR_BUILD" != no_compiler_found; then ++ if (echo '#ifdef __ILP32__'; echo IS_X32; echo '#endif') | \ ++ (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ ++ grep IS_X32 >/dev/null ++ then ++ LIBCABI=${LIBC}x32 ++ fi + fi +- exit ;; ++ GUESS=$UNAME_MACHINE-pc-linux-$LIBCABI ++ ;; + xtensa*:Linux:*:*) +- echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" +- exit ;; ++ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC ++ ;; + i*86:DYNIX/ptx:4*:*) + # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. + # earlier versions are messed up and put the nodename in both + # sysname and nodename. +- echo i386-sequent-sysv4 +- exit ;; ++ GUESS=i386-sequent-sysv4 ++ ;; + i*86:UNIX_SV:4.2MP:2.*) + # Unixware is an offshoot of SVR4, but it has its own version + # number series starting with 2... + # I am not positive that other SVR4 systems won't match this, + # I just have to hope. -- rms. + # Use sysv4.2uw... so that sysv4* matches it. +- echo "$UNAME_MACHINE"-pc-sysv4.2uw"$UNAME_VERSION" +- exit ;; ++ GUESS=$UNAME_MACHINE-pc-sysv4.2uw$UNAME_VERSION ++ ;; + i*86:OS/2:*:*) + # If we were able to find `uname', then EMX Unix compatibility + # is probably installed. +- echo "$UNAME_MACHINE"-pc-os2-emx +- exit ;; ++ GUESS=$UNAME_MACHINE-pc-os2-emx ++ ;; + i*86:XTS-300:*:STOP) +- echo "$UNAME_MACHINE"-unknown-stop +- exit ;; ++ GUESS=$UNAME_MACHINE-unknown-stop ++ ;; + i*86:atheos:*:*) +- echo "$UNAME_MACHINE"-unknown-atheos +- exit ;; ++ GUESS=$UNAME_MACHINE-unknown-atheos ++ ;; + i*86:syllable:*:*) +- echo "$UNAME_MACHINE"-pc-syllable +- exit ;; ++ GUESS=$UNAME_MACHINE-pc-syllable ++ ;; + i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*) +- echo i386-unknown-lynxos"$UNAME_RELEASE" +- exit ;; ++ GUESS=i386-unknown-lynxos$UNAME_RELEASE ++ ;; + i*86:*DOS:*:*) +- echo "$UNAME_MACHINE"-pc-msdosdjgpp +- exit ;; ++ GUESS=$UNAME_MACHINE-pc-msdosdjgpp ++ ;; + i*86:*:4.*:*) + UNAME_REL=`echo "$UNAME_RELEASE" | sed 's/\/MP$//'` + if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then +- echo "$UNAME_MACHINE"-univel-sysv"$UNAME_REL" ++ GUESS=$UNAME_MACHINE-univel-sysv$UNAME_REL + else +- echo "$UNAME_MACHINE"-pc-sysv"$UNAME_REL" ++ GUESS=$UNAME_MACHINE-pc-sysv$UNAME_REL + fi +- exit ;; ++ ;; + i*86:*:5:[678]*) + # UnixWare 7.x, OpenUNIX and OpenServer 6. + case `/bin/uname -X | grep "^Machine"` in +@@ -1104,12 +1214,12 @@ EOF + *Pentium) UNAME_MACHINE=i586 ;; + *Pent*|*Celeron) UNAME_MACHINE=i686 ;; + esac +- echo "$UNAME_MACHINE-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}{$UNAME_VERSION}" +- exit ;; ++ GUESS=$UNAME_MACHINE-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} ++ ;; + i*86:*:3.2:*) + if test -f /usr/options/cb.name; then + UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then + UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` + (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 +@@ -1119,11 +1229,11 @@ EOF + && UNAME_MACHINE=i686 + (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ + && UNAME_MACHINE=i686 +- echo "$UNAME_MACHINE"-pc-sco"$UNAME_REL" ++ GUESS=$UNAME_MACHINE-pc-sco$UNAME_REL + else +- echo "$UNAME_MACHINE"-pc-sysv32 ++ GUESS=$UNAME_MACHINE-pc-sysv32 + fi +- exit ;; ++ ;; + pc:*:*:*) + # Left here for compatibility: + # uname -m prints for DJGPP always 'pc', but it prints nothing about +@@ -1131,31 +1241,31 @@ EOF + # Note: whatever this is, it MUST be the same as what config.sub + # prints for the "djgpp" host, or else GDB configure will decide that + # this is a cross-build. +- echo i586-pc-msdosdjgpp +- exit ;; ++ GUESS=i586-pc-msdosdjgpp ++ ;; + Intel:Mach:3*:*) +- echo i386-pc-mach3 +- exit ;; ++ GUESS=i386-pc-mach3 ++ ;; + paragon:*:*:*) +- echo i860-intel-osf1 +- exit ;; ++ GUESS=i860-intel-osf1 ++ ;; + i860:*:4.*:*) # i860-SVR4 + if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then +- echo i860-stardent-sysv"$UNAME_RELEASE" # Stardent Vistra i860-SVR4 ++ GUESS=i860-stardent-sysv$UNAME_RELEASE # Stardent Vistra i860-SVR4 + else # Add other i860-SVR4 vendors below as they are discovered. +- echo i860-unknown-sysv"$UNAME_RELEASE" # Unknown i860-SVR4 ++ GUESS=i860-unknown-sysv$UNAME_RELEASE # Unknown i860-SVR4 + fi +- exit ;; ++ ;; + mini*:CTIX:SYS*5:*) + # "miniframe" +- echo m68010-convergent-sysv +- exit ;; ++ GUESS=m68010-convergent-sysv ++ ;; + mc68k:UNIX:SYSTEM5:3.51m) +- echo m68k-convergent-sysv +- exit ;; ++ GUESS=m68k-convergent-sysv ++ ;; + M680?0:D-NIX:5.3:*) +- echo m68k-diab-dnix +- exit ;; ++ GUESS=m68k-diab-dnix ++ ;; + M68*:*:R3V[5678]*:*) + test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; + 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) +@@ -1180,249 +1290,404 @@ EOF + /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \ + && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;; + m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) +- echo m68k-unknown-lynxos"$UNAME_RELEASE" +- exit ;; ++ GUESS=m68k-unknown-lynxos$UNAME_RELEASE ++ ;; + mc68030:UNIX_System_V:4.*:*) +- echo m68k-atari-sysv4 +- exit ;; ++ GUESS=m68k-atari-sysv4 ++ ;; + TSUNAMI:LynxOS:2.*:*) +- echo sparc-unknown-lynxos"$UNAME_RELEASE" +- exit ;; ++ GUESS=sparc-unknown-lynxos$UNAME_RELEASE ++ ;; + rs6000:LynxOS:2.*:*) +- echo rs6000-unknown-lynxos"$UNAME_RELEASE" +- exit ;; ++ GUESS=rs6000-unknown-lynxos$UNAME_RELEASE ++ ;; + PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*) +- echo powerpc-unknown-lynxos"$UNAME_RELEASE" +- exit ;; ++ GUESS=powerpc-unknown-lynxos$UNAME_RELEASE ++ ;; + SM[BE]S:UNIX_SV:*:*) +- echo mips-dde-sysv"$UNAME_RELEASE" +- exit ;; ++ GUESS=mips-dde-sysv$UNAME_RELEASE ++ ;; + RM*:ReliantUNIX-*:*:*) +- echo mips-sni-sysv4 +- exit ;; ++ GUESS=mips-sni-sysv4 ++ ;; + RM*:SINIX-*:*:*) +- echo mips-sni-sysv4 +- exit ;; ++ GUESS=mips-sni-sysv4 ++ ;; + *:SINIX-*:*:*) + if uname -p 2>/dev/null >/dev/null ; then + UNAME_MACHINE=`(uname -p) 2>/dev/null` +- echo "$UNAME_MACHINE"-sni-sysv4 ++ GUESS=$UNAME_MACHINE-sni-sysv4 + else +- echo ns32k-sni-sysv ++ GUESS=ns32k-sni-sysv + fi +- exit ;; ++ ;; + PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort + # says +- echo i586-unisys-sysv4 +- exit ;; ++ GUESS=i586-unisys-sysv4 ++ ;; + *:UNIX_System_V:4*:FTX*) + # From Gerald Hewes . + # How about differentiating between stratus architectures? -djm +- echo hppa1.1-stratus-sysv4 +- exit ;; ++ GUESS=hppa1.1-stratus-sysv4 ++ ;; + *:*:*:FTX*) + # From seanf@swdc.stratus.com. +- echo i860-stratus-sysv4 +- exit ;; ++ GUESS=i860-stratus-sysv4 ++ ;; + i*86:VOS:*:*) + # From Paul.Green@stratus.com. +- echo "$UNAME_MACHINE"-stratus-vos +- exit ;; ++ GUESS=$UNAME_MACHINE-stratus-vos ++ ;; + *:VOS:*:*) + # From Paul.Green@stratus.com. +- echo hppa1.1-stratus-vos +- exit ;; ++ GUESS=hppa1.1-stratus-vos ++ ;; + mc68*:A/UX:*:*) +- echo m68k-apple-aux"$UNAME_RELEASE" +- exit ;; ++ GUESS=m68k-apple-aux$UNAME_RELEASE ++ ;; + news*:NEWS-OS:6*:*) +- echo mips-sony-newsos6 +- exit ;; ++ GUESS=mips-sony-newsos6 ++ ;; + R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) +- if [ -d /usr/nec ]; then +- echo mips-nec-sysv"$UNAME_RELEASE" ++ if test -d /usr/nec; then ++ GUESS=mips-nec-sysv$UNAME_RELEASE + else +- echo mips-unknown-sysv"$UNAME_RELEASE" ++ GUESS=mips-unknown-sysv$UNAME_RELEASE + fi +- exit ;; ++ ;; + BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. +- echo powerpc-be-beos +- exit ;; ++ GUESS=powerpc-be-beos ++ ;; + BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. +- echo powerpc-apple-beos +- exit ;; ++ GUESS=powerpc-apple-beos ++ ;; + BePC:BeOS:*:*) # BeOS running on Intel PC compatible. +- echo i586-pc-beos +- exit ;; ++ GUESS=i586-pc-beos ++ ;; + BePC:Haiku:*:*) # Haiku running on Intel PC compatible. +- echo i586-pc-haiku +- exit ;; ++ GUESS=i586-pc-haiku ++ ;; + x86_64:Haiku:*:*) +- echo x86_64-unknown-haiku +- exit ;; ++ GUESS=x86_64-unknown-haiku ++ ;; + SX-4:SUPER-UX:*:*) +- echo sx4-nec-superux"$UNAME_RELEASE" +- exit ;; ++ GUESS=sx4-nec-superux$UNAME_RELEASE ++ ;; + SX-5:SUPER-UX:*:*) +- echo sx5-nec-superux"$UNAME_RELEASE" +- exit ;; ++ GUESS=sx5-nec-superux$UNAME_RELEASE ++ ;; + SX-6:SUPER-UX:*:*) +- echo sx6-nec-superux"$UNAME_RELEASE" +- exit ;; ++ GUESS=sx6-nec-superux$UNAME_RELEASE ++ ;; + SX-7:SUPER-UX:*:*) +- echo sx7-nec-superux"$UNAME_RELEASE" +- exit ;; ++ GUESS=sx7-nec-superux$UNAME_RELEASE ++ ;; + SX-8:SUPER-UX:*:*) +- echo sx8-nec-superux"$UNAME_RELEASE" +- exit ;; ++ GUESS=sx8-nec-superux$UNAME_RELEASE ++ ;; + SX-8R:SUPER-UX:*:*) +- echo sx8r-nec-superux"$UNAME_RELEASE" +- exit ;; ++ GUESS=sx8r-nec-superux$UNAME_RELEASE ++ ;; + SX-ACE:SUPER-UX:*:*) +- echo sxace-nec-superux"$UNAME_RELEASE" +- exit ;; ++ GUESS=sxace-nec-superux$UNAME_RELEASE ++ ;; + Power*:Rhapsody:*:*) +- echo powerpc-apple-rhapsody"$UNAME_RELEASE" +- exit ;; ++ GUESS=powerpc-apple-rhapsody$UNAME_RELEASE ++ ;; + *:Rhapsody:*:*) +- echo "$UNAME_MACHINE"-apple-rhapsody"$UNAME_RELEASE" +- exit ;; ++ GUESS=$UNAME_MACHINE-apple-rhapsody$UNAME_RELEASE ++ ;; ++ arm64:Darwin:*:*) ++ GUESS=aarch64-apple-darwin$UNAME_RELEASE ++ ;; + *:Darwin:*:*) +- UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown +- eval "$set_cc_for_build" +- if test "$UNAME_PROCESSOR" = unknown ; then +- UNAME_PROCESSOR=powerpc ++ UNAME_PROCESSOR=`uname -p` ++ case $UNAME_PROCESSOR in ++ unknown) UNAME_PROCESSOR=powerpc ;; ++ esac ++ if command -v xcode-select > /dev/null 2> /dev/null && \ ++ ! xcode-select --print-path > /dev/null 2> /dev/null ; then ++ # Avoid executing cc if there is no toolchain installed as ++ # cc will be a stub that puts up a graphical alert ++ # prompting the user to install developer tools. ++ CC_FOR_BUILD=no_compiler_found ++ else ++ set_cc_for_build + fi +- if test "`echo "$UNAME_RELEASE" | sed -e 's/\..*//'`" -le 10 ; then +- if [ "$CC_FOR_BUILD" != no_compiler_found ]; then +- if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ +- (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ +- grep IS_64BIT_ARCH >/dev/null +- then +- case $UNAME_PROCESSOR in +- i386) UNAME_PROCESSOR=x86_64 ;; +- powerpc) UNAME_PROCESSOR=powerpc64 ;; +- esac +- fi +- # On 10.4-10.6 one might compile for PowerPC via gcc -arch ppc +- if (echo '#ifdef __POWERPC__'; echo IS_PPC; echo '#endif') | \ +- (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ +- grep IS_PPC >/dev/null +- then +- UNAME_PROCESSOR=powerpc +- fi ++ if test "$CC_FOR_BUILD" != no_compiler_found; then ++ if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ ++ (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ ++ grep IS_64BIT_ARCH >/dev/null ++ then ++ case $UNAME_PROCESSOR in ++ i386) UNAME_PROCESSOR=x86_64 ;; ++ powerpc) UNAME_PROCESSOR=powerpc64 ;; ++ esac ++ fi ++ # On 10.4-10.6 one might compile for PowerPC via gcc -arch ppc ++ if (echo '#ifdef __POWERPC__'; echo IS_PPC; echo '#endif') | \ ++ (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ ++ grep IS_PPC >/dev/null ++ then ++ UNAME_PROCESSOR=powerpc + fi + elif test "$UNAME_PROCESSOR" = i386 ; then +- # Avoid executing cc on OS X 10.9, as it ships with a stub +- # that puts up a graphical alert prompting to install +- # developer tools. Any system running Mac OS X 10.7 or +- # later (Darwin 11 and later) is required to have a 64-bit +- # processor. This is not true of the ARM version of Darwin +- # that Apple uses in portable devices. +- UNAME_PROCESSOR=x86_64 ++ # uname -m returns i386 or x86_64 ++ UNAME_PROCESSOR=$UNAME_MACHINE + fi +- echo "$UNAME_PROCESSOR"-apple-darwin"$UNAME_RELEASE" +- exit ;; ++ GUESS=$UNAME_PROCESSOR-apple-darwin$UNAME_RELEASE ++ ;; + *:procnto*:*:* | *:QNX:[0123456789]*:*) + UNAME_PROCESSOR=`uname -p` + if test "$UNAME_PROCESSOR" = x86; then + UNAME_PROCESSOR=i386 + UNAME_MACHINE=pc + fi +- echo "$UNAME_PROCESSOR"-"$UNAME_MACHINE"-nto-qnx"$UNAME_RELEASE" +- exit ;; ++ GUESS=$UNAME_PROCESSOR-$UNAME_MACHINE-nto-qnx$UNAME_RELEASE ++ ;; + *:QNX:*:4*) +- echo i386-pc-qnx +- exit ;; ++ GUESS=i386-pc-qnx ++ ;; + NEO-*:NONSTOP_KERNEL:*:*) +- echo neo-tandem-nsk"$UNAME_RELEASE" +- exit ;; ++ GUESS=neo-tandem-nsk$UNAME_RELEASE ++ ;; + NSE-*:NONSTOP_KERNEL:*:*) +- echo nse-tandem-nsk"$UNAME_RELEASE" +- exit ;; ++ GUESS=nse-tandem-nsk$UNAME_RELEASE ++ ;; + NSR-*:NONSTOP_KERNEL:*:*) +- echo nsr-tandem-nsk"$UNAME_RELEASE" +- exit ;; ++ GUESS=nsr-tandem-nsk$UNAME_RELEASE ++ ;; + NSV-*:NONSTOP_KERNEL:*:*) +- echo nsv-tandem-nsk"$UNAME_RELEASE" +- exit ;; ++ GUESS=nsv-tandem-nsk$UNAME_RELEASE ++ ;; + NSX-*:NONSTOP_KERNEL:*:*) +- echo nsx-tandem-nsk"$UNAME_RELEASE" +- exit ;; ++ GUESS=nsx-tandem-nsk$UNAME_RELEASE ++ ;; + *:NonStop-UX:*:*) +- echo mips-compaq-nonstopux +- exit ;; ++ GUESS=mips-compaq-nonstopux ++ ;; + BS2000:POSIX*:*:*) +- echo bs2000-siemens-sysv +- exit ;; ++ GUESS=bs2000-siemens-sysv ++ ;; + DS/*:UNIX_System_V:*:*) +- echo "$UNAME_MACHINE"-"$UNAME_SYSTEM"-"$UNAME_RELEASE" +- exit ;; ++ GUESS=$UNAME_MACHINE-$UNAME_SYSTEM-$UNAME_RELEASE ++ ;; + *:Plan9:*:*) + # "uname -m" is not consistent, so use $cputype instead. 386 + # is converted to i386 for consistency with other x86 + # operating systems. +- if test "$cputype" = 386; then ++ if test "${cputype-}" = 386; then + UNAME_MACHINE=i386 +- else +- UNAME_MACHINE="$cputype" ++ elif test "x${cputype-}" != x; then ++ UNAME_MACHINE=$cputype + fi +- echo "$UNAME_MACHINE"-unknown-plan9 +- exit ;; ++ GUESS=$UNAME_MACHINE-unknown-plan9 ++ ;; + *:TOPS-10:*:*) +- echo pdp10-unknown-tops10 +- exit ;; ++ GUESS=pdp10-unknown-tops10 ++ ;; + *:TENEX:*:*) +- echo pdp10-unknown-tenex +- exit ;; ++ GUESS=pdp10-unknown-tenex ++ ;; + KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) +- echo pdp10-dec-tops20 +- exit ;; ++ GUESS=pdp10-dec-tops20 ++ ;; + XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) +- echo pdp10-xkl-tops20 +- exit ;; ++ GUESS=pdp10-xkl-tops20 ++ ;; + *:TOPS-20:*:*) +- echo pdp10-unknown-tops20 +- exit ;; ++ GUESS=pdp10-unknown-tops20 ++ ;; + *:ITS:*:*) +- echo pdp10-unknown-its +- exit ;; ++ GUESS=pdp10-unknown-its ++ ;; + SEI:*:*:SEIUX) +- echo mips-sei-seiux"$UNAME_RELEASE" +- exit ;; ++ GUESS=mips-sei-seiux$UNAME_RELEASE ++ ;; + *:DragonFly:*:*) +- echo "$UNAME_MACHINE"-unknown-dragonfly"`echo "$UNAME_RELEASE"|sed -e 's/[-(].*//'`" +- exit ;; ++ DRAGONFLY_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'` ++ GUESS=$UNAME_MACHINE-unknown-dragonfly$DRAGONFLY_REL ++ ;; + *:*VMS:*:*) + UNAME_MACHINE=`(uname -p) 2>/dev/null` +- case "$UNAME_MACHINE" in +- A*) echo alpha-dec-vms ; exit ;; +- I*) echo ia64-dec-vms ; exit ;; +- V*) echo vax-dec-vms ; exit ;; ++ case $UNAME_MACHINE in ++ A*) GUESS=alpha-dec-vms ;; ++ I*) GUESS=ia64-dec-vms ;; ++ V*) GUESS=vax-dec-vms ;; + esac ;; + *:XENIX:*:SysV) +- echo i386-pc-xenix +- exit ;; ++ GUESS=i386-pc-xenix ++ ;; + i*86:skyos:*:*) +- echo "$UNAME_MACHINE"-pc-skyos"`echo "$UNAME_RELEASE" | sed -e 's/ .*$//'`" +- exit ;; ++ SKYOS_REL=`echo "$UNAME_RELEASE" | sed -e 's/ .*$//'` ++ GUESS=$UNAME_MACHINE-pc-skyos$SKYOS_REL ++ ;; + i*86:rdos:*:*) +- echo "$UNAME_MACHINE"-pc-rdos +- exit ;; +- i*86:AROS:*:*) +- echo "$UNAME_MACHINE"-pc-aros +- exit ;; ++ GUESS=$UNAME_MACHINE-pc-rdos ++ ;; ++ i*86:Fiwix:*:*) ++ GUESS=$UNAME_MACHINE-pc-fiwix ++ ;; ++ *:AROS:*:*) ++ GUESS=$UNAME_MACHINE-unknown-aros ++ ;; + x86_64:VMkernel:*:*) +- echo "$UNAME_MACHINE"-unknown-esx +- exit ;; ++ GUESS=$UNAME_MACHINE-unknown-esx ++ ;; + amd64:Isilon\ OneFS:*:*) +- echo x86_64-unknown-onefs +- exit ;; ++ GUESS=x86_64-unknown-onefs ++ ;; ++ *:Unleashed:*:*) ++ GUESS=$UNAME_MACHINE-unknown-unleashed$UNAME_RELEASE ++ ;; + esac + ++# Do we have a guess based on uname results? ++if test "x$GUESS" != x; then ++ echo "$GUESS" ++ exit ++fi ++ ++# No uname command or uname output not recognized. ++set_cc_for_build ++cat > "$dummy.c" < ++#include ++#endif ++#if defined(ultrix) || defined(_ultrix) || defined(__ultrix) || defined(__ultrix__) ++#if defined (vax) || defined (__vax) || defined (__vax__) || defined(mips) || defined(__mips) || defined(__mips__) || defined(MIPS) || defined(__MIPS__) ++#include ++#if defined(_SIZE_T_) || defined(SIGLOST) ++#include ++#endif ++#endif ++#endif ++main () ++{ ++#if defined (sony) ++#if defined (MIPSEB) ++ /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, ++ I don't know.... */ ++ printf ("mips-sony-bsd\n"); exit (0); ++#else ++#include ++ printf ("m68k-sony-newsos%s\n", ++#ifdef NEWSOS4 ++ "4" ++#else ++ "" ++#endif ++ ); exit (0); ++#endif ++#endif ++ ++#if defined (NeXT) ++#if !defined (__ARCHITECTURE__) ++#define __ARCHITECTURE__ "m68k" ++#endif ++ int version; ++ version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; ++ if (version < 4) ++ printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); ++ else ++ printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); ++ exit (0); ++#endif ++ ++#if defined (MULTIMAX) || defined (n16) ++#if defined (UMAXV) ++ printf ("ns32k-encore-sysv\n"); exit (0); ++#else ++#if defined (CMU) ++ printf ("ns32k-encore-mach\n"); exit (0); ++#else ++ printf ("ns32k-encore-bsd\n"); exit (0); ++#endif ++#endif ++#endif ++ ++#if defined (__386BSD__) ++ printf ("i386-pc-bsd\n"); exit (0); ++#endif ++ ++#if defined (sequent) ++#if defined (i386) ++ printf ("i386-sequent-dynix\n"); exit (0); ++#endif ++#if defined (ns32000) ++ printf ("ns32k-sequent-dynix\n"); exit (0); ++#endif ++#endif ++ ++#if defined (_SEQUENT_) ++ struct utsname un; ++ ++ uname(&un); ++ if (strncmp(un.version, "V2", 2) == 0) { ++ printf ("i386-sequent-ptx2\n"); exit (0); ++ } ++ if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ ++ printf ("i386-sequent-ptx1\n"); exit (0); ++ } ++ printf ("i386-sequent-ptx\n"); exit (0); ++#endif ++ ++#if defined (vax) ++#if !defined (ultrix) ++#include ++#if defined (BSD) ++#if BSD == 43 ++ printf ("vax-dec-bsd4.3\n"); exit (0); ++#else ++#if BSD == 199006 ++ printf ("vax-dec-bsd4.3reno\n"); exit (0); ++#else ++ printf ("vax-dec-bsd\n"); exit (0); ++#endif ++#endif ++#else ++ printf ("vax-dec-bsd\n"); exit (0); ++#endif ++#else ++#if defined(_SIZE_T_) || defined(SIGLOST) ++ struct utsname un; ++ uname (&un); ++ printf ("vax-dec-ultrix%s\n", un.release); exit (0); ++#else ++ printf ("vax-dec-ultrix\n"); exit (0); ++#endif ++#endif ++#endif ++#if defined(ultrix) || defined(_ultrix) || defined(__ultrix) || defined(__ultrix__) ++#if defined(mips) || defined(__mips) || defined(__mips__) || defined(MIPS) || defined(__MIPS__) ++#if defined(_SIZE_T_) || defined(SIGLOST) ++ struct utsname *un; ++ uname (&un); ++ printf ("mips-dec-ultrix%s\n", un.release); exit (0); ++#else ++ printf ("mips-dec-ultrix\n"); exit (0); ++#endif ++#endif ++#endif ++ ++#if defined (alliant) && defined (i860) ++ printf ("i860-alliant-bsd\n"); exit (0); ++#endif ++ ++ exit (1); ++} ++EOF ++ ++$CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null && SYSTEM_NAME=`"$dummy"` && ++ { echo "$SYSTEM_NAME"; exit; } ++ ++# Apollos put the system type in the environment. ++test -d /usr/apollo && { echo "$ISP-apollo-$SYSTYPE"; exit; } ++ + echo "$0: unable to guess system type" >&2 + +-case "$UNAME_MACHINE:$UNAME_SYSTEM" in ++case $UNAME_MACHINE:$UNAME_SYSTEM in + mips:Linux | mips64:Linux) + # If we got here on MIPS GNU/Linux, output extra information. + cat >&2 <&2 <&2 + exit 1 ;; + + *local*) +@@ -110,1223 +119,1186 @@ case $# in + exit 1;; + esac + +-# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). +-# Here we must recognize all the valid KERNEL-OS combinations. +-maybe_os=`echo "$1" | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` +-case $maybe_os in +- nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \ +- linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ +- knetbsd*-gnu* | netbsd*-gnu* | netbsd*-eabi* | \ +- kopensolaris*-gnu* | cloudabi*-eabi* | \ +- storm-chaos* | os2-emx* | rtmk-nova*) +- os=-$maybe_os +- basic_machine=`echo "$1" | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` +- ;; +- android-linux) +- os=-linux-android +- basic_machine=`echo "$1" | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown +- ;; +- *) +- basic_machine=`echo "$1" | sed 's/-[^-]*$//'` +- if [ "$basic_machine" != "$1" ] +- then os=`echo "$1" | sed 's/.*-/-/'` +- else os=; fi +- ;; +-esac ++# Split fields of configuration type ++# shellcheck disable=SC2162 ++saved_IFS=$IFS ++IFS="-" read field1 field2 field3 field4 <&2 ++ exit 1 + ;; +- -lynx*) +- os=-lynxos ++ *-*-*-*) ++ basic_machine=$field1-$field2 ++ basic_os=$field3-$field4 + ;; +- -ptx*) +- basic_machine=`echo "$1" | sed -e 's/86-.*/86-sequent/'` ++ *-*-*) ++ # Ambiguous whether COMPANY is present, or skipped and KERNEL-OS is two ++ # parts ++ maybe_os=$field2-$field3 ++ case $maybe_os in ++ nto-qnx* | linux-* | uclinux-uclibc* \ ++ | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* \ ++ | netbsd*-eabi* | kopensolaris*-gnu* | cloudabi*-eabi* \ ++ | storm-chaos* | os2-emx* | rtmk-nova*) ++ basic_machine=$field1 ++ basic_os=$maybe_os ++ ;; ++ android-linux) ++ basic_machine=$field1-unknown ++ basic_os=linux-android ++ ;; ++ *) ++ basic_machine=$field1-$field2 ++ basic_os=$field3 ++ ;; ++ esac + ;; +- -psos*) +- os=-psos ++ *-*) ++ # A lone config we happen to match not fitting any pattern ++ case $field1-$field2 in ++ decstation-3100) ++ basic_machine=mips-dec ++ basic_os= ++ ;; ++ *-*) ++ # Second component is usually, but not always the OS ++ case $field2 in ++ # Prevent following clause from handling this valid os ++ sun*os*) ++ basic_machine=$field1 ++ basic_os=$field2 ++ ;; ++ zephyr*) ++ basic_machine=$field1-unknown ++ basic_os=$field2 ++ ;; ++ # Manufacturers ++ dec* | mips* | sequent* | encore* | pc533* | sgi* | sony* \ ++ | att* | 7300* | 3300* | delta* | motorola* | sun[234]* \ ++ | unicom* | ibm* | next | hp | isi* | apollo | altos* \ ++ | convergent* | ncr* | news | 32* | 3600* | 3100* \ ++ | hitachi* | c[123]* | convex* | sun | crds | omron* | dg \ ++ | ultra | tti* | harris | dolphin | highlevel | gould \ ++ | cbm | ns | masscomp | apple | axis | knuth | cray \ ++ | microblaze* | sim | cisco \ ++ | oki | wec | wrs | winbond) ++ basic_machine=$field1-$field2 ++ basic_os= ++ ;; ++ *) ++ basic_machine=$field1 ++ basic_os=$field2 ++ ;; ++ esac ++ ;; ++ esac + ;; +- -mint | -mint[0-9]*) +- basic_machine=m68k-atari +- os=-mint ++ *) ++ # Convert single-component short-hands not valid as part of ++ # multi-component configurations. ++ case $field1 in ++ 386bsd) ++ basic_machine=i386-pc ++ basic_os=bsd ++ ;; ++ a29khif) ++ basic_machine=a29k-amd ++ basic_os=udi ++ ;; ++ adobe68k) ++ basic_machine=m68010-adobe ++ basic_os=scout ++ ;; ++ alliant) ++ basic_machine=fx80-alliant ++ basic_os= ++ ;; ++ altos | altos3068) ++ basic_machine=m68k-altos ++ basic_os= ++ ;; ++ am29k) ++ basic_machine=a29k-none ++ basic_os=bsd ++ ;; ++ amdahl) ++ basic_machine=580-amdahl ++ basic_os=sysv ++ ;; ++ amiga) ++ basic_machine=m68k-unknown ++ basic_os= ++ ;; ++ amigaos | amigados) ++ basic_machine=m68k-unknown ++ basic_os=amigaos ++ ;; ++ amigaunix | amix) ++ basic_machine=m68k-unknown ++ basic_os=sysv4 ++ ;; ++ apollo68) ++ basic_machine=m68k-apollo ++ basic_os=sysv ++ ;; ++ apollo68bsd) ++ basic_machine=m68k-apollo ++ basic_os=bsd ++ ;; ++ aros) ++ basic_machine=i386-pc ++ basic_os=aros ++ ;; ++ aux) ++ basic_machine=m68k-apple ++ basic_os=aux ++ ;; ++ balance) ++ basic_machine=ns32k-sequent ++ basic_os=dynix ++ ;; ++ blackfin) ++ basic_machine=bfin-unknown ++ basic_os=linux ++ ;; ++ cegcc) ++ basic_machine=arm-unknown ++ basic_os=cegcc ++ ;; ++ convex-c1) ++ basic_machine=c1-convex ++ basic_os=bsd ++ ;; ++ convex-c2) ++ basic_machine=c2-convex ++ basic_os=bsd ++ ;; ++ convex-c32) ++ basic_machine=c32-convex ++ basic_os=bsd ++ ;; ++ convex-c34) ++ basic_machine=c34-convex ++ basic_os=bsd ++ ;; ++ convex-c38) ++ basic_machine=c38-convex ++ basic_os=bsd ++ ;; ++ cray) ++ basic_machine=j90-cray ++ basic_os=unicos ++ ;; ++ crds | unos) ++ basic_machine=m68k-crds ++ basic_os= ++ ;; ++ da30) ++ basic_machine=m68k-da30 ++ basic_os= ++ ;; ++ decstation | pmax | pmin | dec3100 | decstatn) ++ basic_machine=mips-dec ++ basic_os= ++ ;; ++ delta88) ++ basic_machine=m88k-motorola ++ basic_os=sysv3 ++ ;; ++ dicos) ++ basic_machine=i686-pc ++ basic_os=dicos ++ ;; ++ djgpp) ++ basic_machine=i586-pc ++ basic_os=msdosdjgpp ++ ;; ++ ebmon29k) ++ basic_machine=a29k-amd ++ basic_os=ebmon ++ ;; ++ es1800 | OSE68k | ose68k | ose | OSE) ++ basic_machine=m68k-ericsson ++ basic_os=ose ++ ;; ++ gmicro) ++ basic_machine=tron-gmicro ++ basic_os=sysv ++ ;; ++ go32) ++ basic_machine=i386-pc ++ basic_os=go32 ++ ;; ++ h8300hms) ++ basic_machine=h8300-hitachi ++ basic_os=hms ++ ;; ++ h8300xray) ++ basic_machine=h8300-hitachi ++ basic_os=xray ++ ;; ++ h8500hms) ++ basic_machine=h8500-hitachi ++ basic_os=hms ++ ;; ++ harris) ++ basic_machine=m88k-harris ++ basic_os=sysv3 ++ ;; ++ hp300 | hp300hpux) ++ basic_machine=m68k-hp ++ basic_os=hpux ++ ;; ++ hp300bsd) ++ basic_machine=m68k-hp ++ basic_os=bsd ++ ;; ++ hppaosf) ++ basic_machine=hppa1.1-hp ++ basic_os=osf ++ ;; ++ hppro) ++ basic_machine=hppa1.1-hp ++ basic_os=proelf ++ ;; ++ i386mach) ++ basic_machine=i386-mach ++ basic_os=mach ++ ;; ++ isi68 | isi) ++ basic_machine=m68k-isi ++ basic_os=sysv ++ ;; ++ m68knommu) ++ basic_machine=m68k-unknown ++ basic_os=linux ++ ;; ++ magnum | m3230) ++ basic_machine=mips-mips ++ basic_os=sysv ++ ;; ++ merlin) ++ basic_machine=ns32k-utek ++ basic_os=sysv ++ ;; ++ mingw64) ++ basic_machine=x86_64-pc ++ basic_os=mingw64 ++ ;; ++ mingw32) ++ basic_machine=i686-pc ++ basic_os=mingw32 ++ ;; ++ mingw32ce) ++ basic_machine=arm-unknown ++ basic_os=mingw32ce ++ ;; ++ monitor) ++ basic_machine=m68k-rom68k ++ basic_os=coff ++ ;; ++ morphos) ++ basic_machine=powerpc-unknown ++ basic_os=morphos ++ ;; ++ moxiebox) ++ basic_machine=moxie-unknown ++ basic_os=moxiebox ++ ;; ++ msdos) ++ basic_machine=i386-pc ++ basic_os=msdos ++ ;; ++ msys) ++ basic_machine=i686-pc ++ basic_os=msys ++ ;; ++ mvs) ++ basic_machine=i370-ibm ++ basic_os=mvs ++ ;; ++ nacl) ++ basic_machine=le32-unknown ++ basic_os=nacl ++ ;; ++ ncr3000) ++ basic_machine=i486-ncr ++ basic_os=sysv4 ++ ;; ++ netbsd386) ++ basic_machine=i386-pc ++ basic_os=netbsd ++ ;; ++ netwinder) ++ basic_machine=armv4l-rebel ++ basic_os=linux ++ ;; ++ news | news700 | news800 | news900) ++ basic_machine=m68k-sony ++ basic_os=newsos ++ ;; ++ news1000) ++ basic_machine=m68030-sony ++ basic_os=newsos ++ ;; ++ necv70) ++ basic_machine=v70-nec ++ basic_os=sysv ++ ;; ++ nh3000) ++ basic_machine=m68k-harris ++ basic_os=cxux ++ ;; ++ nh[45]000) ++ basic_machine=m88k-harris ++ basic_os=cxux ++ ;; ++ nindy960) ++ basic_machine=i960-intel ++ basic_os=nindy ++ ;; ++ mon960) ++ basic_machine=i960-intel ++ basic_os=mon960 ++ ;; ++ nonstopux) ++ basic_machine=mips-compaq ++ basic_os=nonstopux ++ ;; ++ os400) ++ basic_machine=powerpc-ibm ++ basic_os=os400 ++ ;; ++ OSE68000 | ose68000) ++ basic_machine=m68000-ericsson ++ basic_os=ose ++ ;; ++ os68k) ++ basic_machine=m68k-none ++ basic_os=os68k ++ ;; ++ paragon) ++ basic_machine=i860-intel ++ basic_os=osf ++ ;; ++ parisc) ++ basic_machine=hppa-unknown ++ basic_os=linux ++ ;; ++ psp) ++ basic_machine=mipsallegrexel-sony ++ basic_os=psp ++ ;; ++ pw32) ++ basic_machine=i586-unknown ++ basic_os=pw32 ++ ;; ++ rdos | rdos64) ++ basic_machine=x86_64-pc ++ basic_os=rdos ++ ;; ++ rdos32) ++ basic_machine=i386-pc ++ basic_os=rdos ++ ;; ++ rom68k) ++ basic_machine=m68k-rom68k ++ basic_os=coff ++ ;; ++ sa29200) ++ basic_machine=a29k-amd ++ basic_os=udi ++ ;; ++ sei) ++ basic_machine=mips-sei ++ basic_os=seiux ++ ;; ++ sequent) ++ basic_machine=i386-sequent ++ basic_os= ++ ;; ++ sps7) ++ basic_machine=m68k-bull ++ basic_os=sysv2 ++ ;; ++ st2000) ++ basic_machine=m68k-tandem ++ basic_os= ++ ;; ++ stratus) ++ basic_machine=i860-stratus ++ basic_os=sysv4 ++ ;; ++ sun2) ++ basic_machine=m68000-sun ++ basic_os= ++ ;; ++ sun2os3) ++ basic_machine=m68000-sun ++ basic_os=sunos3 ++ ;; ++ sun2os4) ++ basic_machine=m68000-sun ++ basic_os=sunos4 ++ ;; ++ sun3) ++ basic_machine=m68k-sun ++ basic_os= ++ ;; ++ sun3os3) ++ basic_machine=m68k-sun ++ basic_os=sunos3 ++ ;; ++ sun3os4) ++ basic_machine=m68k-sun ++ basic_os=sunos4 ++ ;; ++ sun4) ++ basic_machine=sparc-sun ++ basic_os= ++ ;; ++ sun4os3) ++ basic_machine=sparc-sun ++ basic_os=sunos3 ++ ;; ++ sun4os4) ++ basic_machine=sparc-sun ++ basic_os=sunos4 ++ ;; ++ sun4sol2) ++ basic_machine=sparc-sun ++ basic_os=solaris2 ++ ;; ++ sun386 | sun386i | roadrunner) ++ basic_machine=i386-sun ++ basic_os= ++ ;; ++ sv1) ++ basic_machine=sv1-cray ++ basic_os=unicos ++ ;; ++ symmetry) ++ basic_machine=i386-sequent ++ basic_os=dynix ++ ;; ++ t3e) ++ basic_machine=alphaev5-cray ++ basic_os=unicos ++ ;; ++ t90) ++ basic_machine=t90-cray ++ basic_os=unicos ++ ;; ++ toad1) ++ basic_machine=pdp10-xkl ++ basic_os=tops20 ++ ;; ++ tpf) ++ basic_machine=s390x-ibm ++ basic_os=tpf ++ ;; ++ udi29k) ++ basic_machine=a29k-amd ++ basic_os=udi ++ ;; ++ ultra3) ++ basic_machine=a29k-nyu ++ basic_os=sym1 ++ ;; ++ v810 | necv810) ++ basic_machine=v810-nec ++ basic_os=none ++ ;; ++ vaxv) ++ basic_machine=vax-dec ++ basic_os=sysv ++ ;; ++ vms) ++ basic_machine=vax-dec ++ basic_os=vms ++ ;; ++ vsta) ++ basic_machine=i386-pc ++ basic_os=vsta ++ ;; ++ vxworks960) ++ basic_machine=i960-wrs ++ basic_os=vxworks ++ ;; ++ vxworks68) ++ basic_machine=m68k-wrs ++ basic_os=vxworks ++ ;; ++ vxworks29k) ++ basic_machine=a29k-wrs ++ basic_os=vxworks ++ ;; ++ xbox) ++ basic_machine=i686-pc ++ basic_os=mingw32 ++ ;; ++ ymp) ++ basic_machine=ymp-cray ++ basic_os=unicos ++ ;; ++ *) ++ basic_machine=$1 ++ basic_os= ++ ;; ++ esac + ;; + esac + +-# Decode aliases for certain CPU-COMPANY combinations. ++# Decode 1-component or ad-hoc basic machines + case $basic_machine in +- # Recognize the basic CPU types without company name. +- # Some are omitted here because they have special meanings below. +- 1750a | 580 \ +- | a29k \ +- | aarch64 | aarch64_be \ +- | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ +- | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ +- | am33_2.0 \ +- | arc | arceb \ +- | arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \ +- | avr | avr32 \ +- | ba \ +- | be32 | be64 \ +- | bfin \ +- | c4x | c8051 | clipper \ +- | d10v | d30v | dlx | dsp16xx \ +- | e2k | epiphany \ +- | fido | fr30 | frv | ft32 \ +- | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ +- | hexagon \ +- | i370 | i860 | i960 | ia16 | ia64 \ +- | ip2k | iq2000 \ +- | k1om \ +- | le32 | le64 \ +- | lm32 \ +- | m32c | m32r | m32rle | m68000 | m68k | m88k \ +- | maxq | mb | microblaze | microblazeel | mcore | mep | metag \ +- | mips | mipsbe | mipseb | mipsel | mipsle \ +- | mips16 \ +- | mips64 | mips64el \ +- | mips64octeon | mips64octeonel \ +- | mips64orion | mips64orionel \ +- | mips64r5900 | mips64r5900el \ +- | mips64vr | mips64vrel \ +- | mips64vr4100 | mips64vr4100el \ +- | mips64vr4300 | mips64vr4300el \ +- | mips64vr5000 | mips64vr5000el \ +- | mips64vr5900 | mips64vr5900el \ +- | mipsisa32 | mipsisa32el \ +- | mipsisa32r2 | mipsisa32r2el \ +- | mipsisa32r6 | mipsisa32r6el \ +- | mipsisa64 | mipsisa64el \ +- | mipsisa64r2 | mipsisa64r2el \ +- | mipsisa64r6 | mipsisa64r6el \ +- | mipsisa64sb1 | mipsisa64sb1el \ +- | mipsisa64sr71k | mipsisa64sr71kel \ +- | mipsr5900 | mipsr5900el \ +- | mipstx39 | mipstx39el \ +- | mn10200 | mn10300 \ +- | moxie \ +- | mt \ +- | msp430 \ +- | nds32 | nds32le | nds32be \ +- | nios | nios2 | nios2eb | nios2el \ +- | ns16k | ns32k \ +- | open8 | or1k | or1knd | or32 \ +- | pdp10 | pj | pjl \ +- | powerpc | powerpc64 | powerpc64le | powerpcle \ +- | pru \ +- | pyramid \ +- | riscv32 | riscv64 \ +- | rl78 | rx \ +- | score \ +- | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[234]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ +- | sh64 | sh64le \ +- | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ +- | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ +- | spu \ +- | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \ +- | ubicom32 \ +- | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \ +- | visium \ +- | wasm32 \ +- | x86 | xc16x | xstormy16 | xtensa \ +- | z8k | z80) +- basic_machine=$basic_machine-unknown +- ;; +- c54x) +- basic_machine=tic54x-unknown +- ;; +- c55x) +- basic_machine=tic55x-unknown +- ;; +- c6x) +- basic_machine=tic6x-unknown +- ;; +- leon|leon[3-9]) +- basic_machine=sparc-$basic_machine +- ;; +- m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | nvptx | picochip) +- basic_machine=$basic_machine-unknown +- os=-none ++ # Here we handle the default manufacturer of certain CPU types. It is in ++ # some cases the only manufacturer, in others, it is the most popular. ++ w89k) ++ cpu=hppa1.1 ++ vendor=winbond + ;; +- m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65) ++ op50n) ++ cpu=hppa1.1 ++ vendor=oki + ;; +- ms1) +- basic_machine=mt-unknown ++ op60c) ++ cpu=hppa1.1 ++ vendor=oki + ;; +- +- strongarm | thumb | xscale) +- basic_machine=arm-unknown ++ ibm*) ++ cpu=i370 ++ vendor=ibm + ;; +- xgate) +- basic_machine=$basic_machine-unknown +- os=-none ++ orion105) ++ cpu=clipper ++ vendor=highlevel + ;; +- xscaleeb) +- basic_machine=armeb-unknown ++ mac | mpw | mac-mpw) ++ cpu=m68k ++ vendor=apple + ;; +- +- xscaleel) +- basic_machine=armel-unknown ++ pmac | pmac-mpw) ++ cpu=powerpc ++ vendor=apple + ;; + +- # We use `pc' rather than `unknown' +- # because (1) that's what they normally are, and +- # (2) the word "unknown" tends to confuse beginning users. +- i*86 | x86_64) +- basic_machine=$basic_machine-pc +- ;; +- # Object if more than one company name word. +- *-*-*) +- echo Invalid configuration \`"$1"\': machine \`"$basic_machine"\' not recognized 1>&2 +- exit 1 +- ;; +- # Recognize the basic CPU types with company name. +- 580-* \ +- | a29k-* \ +- | aarch64-* | aarch64_be-* \ +- | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ +- | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ +- | alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \ +- | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ +- | avr-* | avr32-* \ +- | ba-* \ +- | be32-* | be64-* \ +- | bfin-* | bs2000-* \ +- | c[123]* | c30-* | [cjt]90-* | c4x-* \ +- | c8051-* | clipper-* | craynv-* | cydra-* \ +- | d10v-* | d30v-* | dlx-* \ +- | e2k-* | elxsi-* \ +- | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ +- | h8300-* | h8500-* \ +- | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ +- | hexagon-* \ +- | i*86-* | i860-* | i960-* | ia16-* | ia64-* \ +- | ip2k-* | iq2000-* \ +- | k1om-* \ +- | le32-* | le64-* \ +- | lm32-* \ +- | m32c-* | m32r-* | m32rle-* \ +- | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ +- | m88110-* | m88k-* | maxq-* | mcore-* | metag-* \ +- | microblaze-* | microblazeel-* \ +- | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ +- | mips16-* \ +- | mips64-* | mips64el-* \ +- | mips64octeon-* | mips64octeonel-* \ +- | mips64orion-* | mips64orionel-* \ +- | mips64r5900-* | mips64r5900el-* \ +- | mips64vr-* | mips64vrel-* \ +- | mips64vr4100-* | mips64vr4100el-* \ +- | mips64vr4300-* | mips64vr4300el-* \ +- | mips64vr5000-* | mips64vr5000el-* \ +- | mips64vr5900-* | mips64vr5900el-* \ +- | mipsisa32-* | mipsisa32el-* \ +- | mipsisa32r2-* | mipsisa32r2el-* \ +- | mipsisa32r6-* | mipsisa32r6el-* \ +- | mipsisa64-* | mipsisa64el-* \ +- | mipsisa64r2-* | mipsisa64r2el-* \ +- | mipsisa64r6-* | mipsisa64r6el-* \ +- | mipsisa64sb1-* | mipsisa64sb1el-* \ +- | mipsisa64sr71k-* | mipsisa64sr71kel-* \ +- | mipsr5900-* | mipsr5900el-* \ +- | mipstx39-* | mipstx39el-* \ +- | mmix-* \ +- | mt-* \ +- | msp430-* \ +- | nds32-* | nds32le-* | nds32be-* \ +- | nios-* | nios2-* | nios2eb-* | nios2el-* \ +- | none-* | np1-* | ns16k-* | ns32k-* \ +- | open8-* \ +- | or1k*-* \ +- | orion-* \ +- | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ +- | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \ +- | pru-* \ +- | pyramid-* \ +- | riscv32-* | riscv64-* \ +- | rl78-* | romp-* | rs6000-* | rx-* \ +- | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ +- | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ +- | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ +- | sparclite-* \ +- | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx*-* \ +- | tahoe-* \ +- | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ +- | tile*-* \ +- | tron-* \ +- | ubicom32-* \ +- | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \ +- | vax-* \ +- | visium-* \ +- | wasm32-* \ +- | we32k-* \ +- | x86-* | x86_64-* | xc16x-* | xps100-* \ +- | xstormy16-* | xtensa*-* \ +- | ymp-* \ +- | z8k-* | z80-*) +- ;; +- # Recognize the basic CPU types without company name, with glob match. +- xtensa*) +- basic_machine=$basic_machine-unknown +- ;; + # Recognize the various machine names and aliases which stand + # for a CPU type and a company and sometimes even an OS. +- 386bsd) +- basic_machine=i386-pc +- os=-bsd +- ;; + 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) +- basic_machine=m68000-att ++ cpu=m68000 ++ vendor=att + ;; + 3b*) +- basic_machine=we32k-att +- ;; +- a29khif) +- basic_machine=a29k-amd +- os=-udi +- ;; +- abacus) +- basic_machine=abacus-unknown +- ;; +- adobe68k) +- basic_machine=m68010-adobe +- os=-scout +- ;; +- alliant | fx80) +- basic_machine=fx80-alliant +- ;; +- altos | altos3068) +- basic_machine=m68k-altos +- ;; +- am29k) +- basic_machine=a29k-none +- os=-bsd +- ;; +- amd64) +- basic_machine=x86_64-pc +- ;; +- amd64-*) +- basic_machine=x86_64-`echo "$basic_machine" | sed 's/^[^-]*-//'` +- ;; +- amdahl) +- basic_machine=580-amdahl +- os=-sysv +- ;; +- amiga | amiga-*) +- basic_machine=m68k-unknown +- ;; +- amigaos | amigados) +- basic_machine=m68k-unknown +- os=-amigaos +- ;; +- amigaunix | amix) +- basic_machine=m68k-unknown +- os=-sysv4 +- ;; +- apollo68) +- basic_machine=m68k-apollo +- os=-sysv +- ;; +- apollo68bsd) +- basic_machine=m68k-apollo +- os=-bsd +- ;; +- aros) +- basic_machine=i386-pc +- os=-aros +- ;; +- asmjs) +- basic_machine=asmjs-unknown +- ;; +- aux) +- basic_machine=m68k-apple +- os=-aux +- ;; +- balance) +- basic_machine=ns32k-sequent +- os=-dynix +- ;; +- blackfin) +- basic_machine=bfin-unknown +- os=-linux +- ;; +- blackfin-*) +- basic_machine=bfin-`echo "$basic_machine" | sed 's/^[^-]*-//'` +- os=-linux ++ cpu=we32k ++ vendor=att + ;; + bluegene*) +- basic_machine=powerpc-ibm +- os=-cnk +- ;; +- c54x-*) +- basic_machine=tic54x-`echo "$basic_machine" | sed 's/^[^-]*-//'` +- ;; +- c55x-*) +- basic_machine=tic55x-`echo "$basic_machine" | sed 's/^[^-]*-//'` +- ;; +- c6x-*) +- basic_machine=tic6x-`echo "$basic_machine" | sed 's/^[^-]*-//'` +- ;; +- c90) +- basic_machine=c90-cray +- os=-unicos +- ;; +- cegcc) +- basic_machine=arm-unknown +- os=-cegcc +- ;; +- convex-c1) +- basic_machine=c1-convex +- os=-bsd +- ;; +- convex-c2) +- basic_machine=c2-convex +- os=-bsd +- ;; +- convex-c32) +- basic_machine=c32-convex +- os=-bsd +- ;; +- convex-c34) +- basic_machine=c34-convex +- os=-bsd +- ;; +- convex-c38) +- basic_machine=c38-convex +- os=-bsd +- ;; +- cray | j90) +- basic_machine=j90-cray +- os=-unicos +- ;; +- craynv) +- basic_machine=craynv-cray +- os=-unicosmp +- ;; +- cr16 | cr16-*) +- basic_machine=cr16-unknown +- os=-elf +- ;; +- crds | unos) +- basic_machine=m68k-crds +- ;; +- crisv32 | crisv32-* | etraxfs*) +- basic_machine=crisv32-axis +- ;; +- cris | cris-* | etrax*) +- basic_machine=cris-axis +- ;; +- crx) +- basic_machine=crx-unknown +- os=-elf +- ;; +- da30 | da30-*) +- basic_machine=m68k-da30 +- ;; +- decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) +- basic_machine=mips-dec ++ cpu=powerpc ++ vendor=ibm ++ basic_os=cnk + ;; + decsystem10* | dec10*) +- basic_machine=pdp10-dec +- os=-tops10 ++ cpu=pdp10 ++ vendor=dec ++ basic_os=tops10 + ;; + decsystem20* | dec20*) +- basic_machine=pdp10-dec +- os=-tops20 ++ cpu=pdp10 ++ vendor=dec ++ basic_os=tops20 + ;; + delta | 3300 | motorola-3300 | motorola-delta \ + | 3300-motorola | delta-motorola) +- basic_machine=m68k-motorola +- ;; +- delta88) +- basic_machine=m88k-motorola +- os=-sysv3 +- ;; +- dicos) +- basic_machine=i686-pc +- os=-dicos +- ;; +- djgpp) +- basic_machine=i586-pc +- os=-msdosdjgpp +- ;; +- dpx20 | dpx20-*) +- basic_machine=rs6000-bull +- os=-bosx ++ cpu=m68k ++ vendor=motorola + ;; + dpx2*) +- basic_machine=m68k-bull +- os=-sysv3 +- ;; +- e500v[12]) +- basic_machine=powerpc-unknown +- os=$os"spe" +- ;; +- e500v[12]-*) +- basic_machine=powerpc-`echo "$basic_machine" | sed 's/^[^-]*-//'` +- os=$os"spe" +- ;; +- ebmon29k) +- basic_machine=a29k-amd +- os=-ebmon +- ;; +- elxsi) +- basic_machine=elxsi-elxsi +- os=-bsd ++ cpu=m68k ++ vendor=bull ++ basic_os=sysv3 + ;; + encore | umax | mmax) +- basic_machine=ns32k-encore ++ cpu=ns32k ++ vendor=encore + ;; +- es1800 | OSE68k | ose68k | ose | OSE) +- basic_machine=m68k-ericsson +- os=-ose ++ elxsi) ++ cpu=elxsi ++ vendor=elxsi ++ basic_os=${basic_os:-bsd} + ;; + fx2800) +- basic_machine=i860-alliant ++ cpu=i860 ++ vendor=alliant + ;; + genix) +- basic_machine=ns32k-ns +- ;; +- gmicro) +- basic_machine=tron-gmicro +- os=-sysv +- ;; +- go32) +- basic_machine=i386-pc +- os=-go32 ++ cpu=ns32k ++ vendor=ns + ;; + h3050r* | hiux*) +- basic_machine=hppa1.1-hitachi +- os=-hiuxwe2 +- ;; +- h8300hms) +- basic_machine=h8300-hitachi +- os=-hms +- ;; +- h8300xray) +- basic_machine=h8300-hitachi +- os=-xray +- ;; +- h8500hms) +- basic_machine=h8500-hitachi +- os=-hms +- ;; +- harris) +- basic_machine=m88k-harris +- os=-sysv3 +- ;; +- hp300-*) +- basic_machine=m68k-hp +- ;; +- hp300bsd) +- basic_machine=m68k-hp +- os=-bsd +- ;; +- hp300hpux) +- basic_machine=m68k-hp +- os=-hpux ++ cpu=hppa1.1 ++ vendor=hitachi ++ basic_os=hiuxwe2 + ;; + hp3k9[0-9][0-9] | hp9[0-9][0-9]) +- basic_machine=hppa1.0-hp ++ cpu=hppa1.0 ++ vendor=hp + ;; + hp9k2[0-9][0-9] | hp9k31[0-9]) +- basic_machine=m68000-hp ++ cpu=m68000 ++ vendor=hp + ;; + hp9k3[2-9][0-9]) +- basic_machine=m68k-hp ++ cpu=m68k ++ vendor=hp + ;; + hp9k6[0-9][0-9] | hp6[0-9][0-9]) +- basic_machine=hppa1.0-hp ++ cpu=hppa1.0 ++ vendor=hp + ;; + hp9k7[0-79][0-9] | hp7[0-79][0-9]) +- basic_machine=hppa1.1-hp ++ cpu=hppa1.1 ++ vendor=hp + ;; + hp9k78[0-9] | hp78[0-9]) + # FIXME: really hppa2.0-hp +- basic_machine=hppa1.1-hp ++ cpu=hppa1.1 ++ vendor=hp + ;; + hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) + # FIXME: really hppa2.0-hp +- basic_machine=hppa1.1-hp ++ cpu=hppa1.1 ++ vendor=hp + ;; + hp9k8[0-9][13679] | hp8[0-9][13679]) +- basic_machine=hppa1.1-hp ++ cpu=hppa1.1 ++ vendor=hp + ;; + hp9k8[0-9][0-9] | hp8[0-9][0-9]) +- basic_machine=hppa1.0-hp +- ;; +- hppaosf) +- basic_machine=hppa1.1-hp +- os=-osf +- ;; +- hppro) +- basic_machine=hppa1.1-hp +- os=-proelf +- ;; +- i370-ibm* | ibm*) +- basic_machine=i370-ibm ++ cpu=hppa1.0 ++ vendor=hp + ;; + i*86v32) +- basic_machine=`echo "$1" | sed -e 's/86.*/86-pc/'` +- os=-sysv32 ++ cpu=`echo "$1" | sed -e 's/86.*/86/'` ++ vendor=pc ++ basic_os=sysv32 + ;; + i*86v4*) +- basic_machine=`echo "$1" | sed -e 's/86.*/86-pc/'` +- os=-sysv4 ++ cpu=`echo "$1" | sed -e 's/86.*/86/'` ++ vendor=pc ++ basic_os=sysv4 + ;; + i*86v) +- basic_machine=`echo "$1" | sed -e 's/86.*/86-pc/'` +- os=-sysv ++ cpu=`echo "$1" | sed -e 's/86.*/86/'` ++ vendor=pc ++ basic_os=sysv + ;; + i*86sol2) +- basic_machine=`echo "$1" | sed -e 's/86.*/86-pc/'` +- os=-solaris2 +- ;; +- i386mach) +- basic_machine=i386-mach +- os=-mach ++ cpu=`echo "$1" | sed -e 's/86.*/86/'` ++ vendor=pc ++ basic_os=solaris2 + ;; +- vsta) +- basic_machine=i386-unknown +- os=-vsta ++ j90 | j90-cray) ++ cpu=j90 ++ vendor=cray ++ basic_os=${basic_os:-unicos} + ;; + iris | iris4d) +- basic_machine=mips-sgi +- case $os in +- -irix*) ++ cpu=mips ++ vendor=sgi ++ case $basic_os in ++ irix*) + ;; + *) +- os=-irix4 ++ basic_os=irix4 + ;; + esac + ;; +- isi68 | isi) +- basic_machine=m68k-isi +- os=-sysv +- ;; +- leon-*|leon[3-9]-*) +- basic_machine=sparc-`echo "$basic_machine" | sed 's/-.*//'` +- ;; +- m68knommu) +- basic_machine=m68k-unknown +- os=-linux +- ;; +- m68knommu-*) +- basic_machine=m68k-`echo "$basic_machine" | sed 's/^[^-]*-//'` +- os=-linux +- ;; +- magnum | m3230) +- basic_machine=mips-mips +- os=-sysv +- ;; +- merlin) +- basic_machine=ns32k-utek +- os=-sysv +- ;; +- microblaze*) +- basic_machine=microblaze-xilinx +- ;; +- mingw64) +- basic_machine=x86_64-pc +- os=-mingw64 +- ;; +- mingw32) +- basic_machine=i686-pc +- os=-mingw32 +- ;; +- mingw32ce) +- basic_machine=arm-unknown +- os=-mingw32ce +- ;; + miniframe) +- basic_machine=m68000-convergent +- ;; +- *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) +- basic_machine=m68k-atari +- os=-mint +- ;; +- mips3*-*) +- basic_machine=`echo "$basic_machine" | sed -e 's/mips3/mips64/'` +- ;; +- mips3*) +- basic_machine=`echo "$basic_machine" | sed -e 's/mips3/mips64/'`-unknown +- ;; +- monitor) +- basic_machine=m68k-rom68k +- os=-coff +- ;; +- morphos) +- basic_machine=powerpc-unknown +- os=-morphos +- ;; +- moxiebox) +- basic_machine=moxie-unknown +- os=-moxiebox ++ cpu=m68000 ++ vendor=convergent + ;; +- msdos) +- basic_machine=i386-pc +- os=-msdos +- ;; +- ms1-*) +- basic_machine=`echo "$basic_machine" | sed -e 's/ms1-/mt-/'` +- ;; +- msys) +- basic_machine=i686-pc +- os=-msys +- ;; +- mvs) +- basic_machine=i370-ibm +- os=-mvs +- ;; +- nacl) +- basic_machine=le32-unknown +- os=-nacl +- ;; +- ncr3000) +- basic_machine=i486-ncr +- os=-sysv4 +- ;; +- netbsd386) +- basic_machine=i386-unknown +- os=-netbsd +- ;; +- netwinder) +- basic_machine=armv4l-rebel +- os=-linux +- ;; +- news | news700 | news800 | news900) +- basic_machine=m68k-sony +- os=-newsos +- ;; +- news1000) +- basic_machine=m68030-sony +- os=-newsos ++ *mint | mint[0-9]* | *MiNT | *MiNT[0-9]*) ++ cpu=m68k ++ vendor=atari ++ basic_os=mint + ;; + news-3600 | risc-news) +- basic_machine=mips-sony +- os=-newsos +- ;; +- necv70) +- basic_machine=v70-nec +- os=-sysv ++ cpu=mips ++ vendor=sony ++ basic_os=newsos + ;; + next | m*-next) +- basic_machine=m68k-next +- case $os in +- -nextstep* ) ++ cpu=m68k ++ vendor=next ++ case $basic_os in ++ openstep*) ++ ;; ++ nextstep*) + ;; +- -ns2*) +- os=-nextstep2 ++ ns2*) ++ basic_os=nextstep2 + ;; + *) +- os=-nextstep3 ++ basic_os=nextstep3 + ;; + esac + ;; +- nh3000) +- basic_machine=m68k-harris +- os=-cxux +- ;; +- nh[45]000) +- basic_machine=m88k-harris +- os=-cxux +- ;; +- nindy960) +- basic_machine=i960-intel +- os=-nindy +- ;; +- mon960) +- basic_machine=i960-intel +- os=-mon960 +- ;; +- nonstopux) +- basic_machine=mips-compaq +- os=-nonstopux +- ;; + np1) +- basic_machine=np1-gould +- ;; +- neo-tandem) +- basic_machine=neo-tandem +- ;; +- nse-tandem) +- basic_machine=nse-tandem +- ;; +- nsr-tandem) +- basic_machine=nsr-tandem +- ;; +- nsv-tandem) +- basic_machine=nsv-tandem +- ;; +- nsx-tandem) +- basic_machine=nsx-tandem ++ cpu=np1 ++ vendor=gould + ;; + op50n-* | op60c-*) +- basic_machine=hppa1.1-oki +- os=-proelf +- ;; +- openrisc | openrisc-*) +- basic_machine=or32-unknown +- ;; +- os400) +- basic_machine=powerpc-ibm +- os=-os400 +- ;; +- OSE68000 | ose68000) +- basic_machine=m68000-ericsson +- os=-ose +- ;; +- os68k) +- basic_machine=m68k-none +- os=-os68k ++ cpu=hppa1.1 ++ vendor=oki ++ basic_os=proelf + ;; + pa-hitachi) +- basic_machine=hppa1.1-hitachi +- os=-hiuxwe2 +- ;; +- paragon) +- basic_machine=i860-intel +- os=-osf +- ;; +- parisc) +- basic_machine=hppa-unknown +- os=-linux +- ;; +- parisc-*) +- basic_machine=hppa-`echo "$basic_machine" | sed 's/^[^-]*-//'` +- os=-linux ++ cpu=hppa1.1 ++ vendor=hitachi ++ basic_os=hiuxwe2 + ;; + pbd) +- basic_machine=sparc-tti ++ cpu=sparc ++ vendor=tti + ;; + pbb) +- basic_machine=m68k-tti +- ;; +- pc532 | pc532-*) +- basic_machine=ns32k-pc532 +- ;; +- pc98) +- basic_machine=i386-pc ++ cpu=m68k ++ vendor=tti + ;; +- pc98-*) +- basic_machine=i386-`echo "$basic_machine" | sed 's/^[^-]*-//'` +- ;; +- pentium | p5 | k5 | k6 | nexgen | viac3) +- basic_machine=i586-pc +- ;; +- pentiumpro | p6 | 6x86 | athlon | athlon_*) +- basic_machine=i686-pc +- ;; +- pentiumii | pentium2 | pentiumiii | pentium3) +- basic_machine=i686-pc +- ;; +- pentium4) +- basic_machine=i786-pc +- ;; +- pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) +- basic_machine=i586-`echo "$basic_machine" | sed 's/^[^-]*-//'` +- ;; +- pentiumpro-* | p6-* | 6x86-* | athlon-*) +- basic_machine=i686-`echo "$basic_machine" | sed 's/^[^-]*-//'` +- ;; +- pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) +- basic_machine=i686-`echo "$basic_machine" | sed 's/^[^-]*-//'` +- ;; +- pentium4-*) +- basic_machine=i786-`echo "$basic_machine" | sed 's/^[^-]*-//'` ++ pc532) ++ cpu=ns32k ++ vendor=pc532 + ;; + pn) +- basic_machine=pn-gould +- ;; +- power) basic_machine=power-ibm +- ;; +- ppc | ppcbe) basic_machine=powerpc-unknown ++ cpu=pn ++ vendor=gould + ;; +- ppc-* | ppcbe-*) +- basic_machine=powerpc-`echo "$basic_machine" | sed 's/^[^-]*-//'` +- ;; +- ppcle | powerpclittle) +- basic_machine=powerpcle-unknown ++ power) ++ cpu=power ++ vendor=ibm + ;; +- ppcle-* | powerpclittle-*) +- basic_machine=powerpcle-`echo "$basic_machine" | sed 's/^[^-]*-//'` ++ ps2) ++ cpu=i386 ++ vendor=ibm + ;; +- ppc64) basic_machine=powerpc64-unknown ++ rm[46]00) ++ cpu=mips ++ vendor=siemens + ;; +- ppc64-*) basic_machine=powerpc64-`echo "$basic_machine" | sed 's/^[^-]*-//'` ++ rtpc | rtpc-*) ++ cpu=romp ++ vendor=ibm + ;; +- ppc64le | powerpc64little) +- basic_machine=powerpc64le-unknown ++ sde) ++ cpu=mipsisa32 ++ vendor=sde ++ basic_os=${basic_os:-elf} + ;; +- ppc64le-* | powerpc64little-*) +- basic_machine=powerpc64le-`echo "$basic_machine" | sed 's/^[^-]*-//'` ++ simso-wrs) ++ cpu=sparclite ++ vendor=wrs ++ basic_os=vxworks + ;; +- ps2) +- basic_machine=i386-ibm ++ tower | tower-32) ++ cpu=m68k ++ vendor=ncr + ;; +- pw32) +- basic_machine=i586-unknown +- os=-pw32 ++ vpp*|vx|vx-*) ++ cpu=f301 ++ vendor=fujitsu + ;; +- rdos | rdos64) +- basic_machine=x86_64-pc +- os=-rdos ++ w65) ++ cpu=w65 ++ vendor=wdc + ;; +- rdos32) +- basic_machine=i386-pc +- os=-rdos ++ w89k-*) ++ cpu=hppa1.1 ++ vendor=winbond ++ basic_os=proelf + ;; +- rom68k) +- basic_machine=m68k-rom68k +- os=-coff ++ none) ++ cpu=none ++ vendor=none + ;; +- rm[46]00) +- basic_machine=mips-siemens ++ leon|leon[3-9]) ++ cpu=sparc ++ vendor=$basic_machine + ;; +- rtpc | rtpc-*) +- basic_machine=romp-ibm ++ leon-*|leon[3-9]-*) ++ cpu=sparc ++ vendor=`echo "$basic_machine" | sed 's/-.*//'` + ;; +- s390 | s390-*) +- basic_machine=s390-ibm ++ ++ *-*) ++ # shellcheck disable=SC2162 ++ saved_IFS=$IFS ++ IFS="-" read cpu vendor <&2 +- exit 1 ++ # Recognize the canonical CPU types that are allowed with any ++ # company name. ++ case $cpu in ++ 1750a | 580 \ ++ | a29k \ ++ | aarch64 | aarch64_be \ ++ | abacus \ ++ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] \ ++ | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] \ ++ | alphapca5[67] | alpha64pca5[67] \ ++ | am33_2.0 \ ++ | amdgcn \ ++ | arc | arceb | arc32 | arc64 \ ++ | arm | arm[lb]e | arme[lb] | armv* \ ++ | avr | avr32 \ ++ | asmjs \ ++ | ba \ ++ | be32 | be64 \ ++ | bfin | bpf | bs2000 \ ++ | c[123]* | c30 | [cjt]90 | c4x \ ++ | c8051 | clipper | craynv | csky | cydra \ ++ | d10v | d30v | dlx | dsp16xx \ ++ | e2k | elxsi | epiphany \ ++ | f30[01] | f700 | fido | fr30 | frv | ft32 | fx80 \ ++ | h8300 | h8500 \ ++ | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ ++ | hexagon \ ++ | i370 | i*86 | i860 | i960 | ia16 | ia64 \ ++ | ip2k | iq2000 \ ++ | k1om \ ++ | le32 | le64 \ ++ | lm32 \ ++ | loongarch32 | loongarch64 | loongarchx32 \ ++ | m32c | m32r | m32rle \ ++ | m5200 | m68000 | m680[012346]0 | m68360 | m683?2 | m68k \ ++ | m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x \ ++ | m88110 | m88k | maxq | mb | mcore | mep | metag \ ++ | microblaze | microblazeel \ ++ | mips | mipsbe | mipseb | mipsel | mipsle \ ++ | mips16 \ ++ | mips64 | mips64eb | mips64el \ ++ | mips64octeon | mips64octeonel \ ++ | mips64orion | mips64orionel \ ++ | mips64r5900 | mips64r5900el \ ++ | mips64vr | mips64vrel \ ++ | mips64vr4100 | mips64vr4100el \ ++ | mips64vr4300 | mips64vr4300el \ ++ | mips64vr5000 | mips64vr5000el \ ++ | mips64vr5900 | mips64vr5900el \ ++ | mipsisa32 | mipsisa32el \ ++ | mipsisa32r2 | mipsisa32r2el \ ++ | mipsisa32r3 | mipsisa32r3el \ ++ | mipsisa32r5 | mipsisa32r5el \ ++ | mipsisa32r6 | mipsisa32r6el \ ++ | mipsisa64 | mipsisa64el \ ++ | mipsisa64r2 | mipsisa64r2el \ ++ | mipsisa64r3 | mipsisa64r3el \ ++ | mipsisa64r5 | mipsisa64r5el \ ++ | mipsisa64r6 | mipsisa64r6el \ ++ | mipsisa64sb1 | mipsisa64sb1el \ ++ | mipsisa64sr71k | mipsisa64sr71kel \ ++ | mipsr5900 | mipsr5900el \ ++ | mipstx39 | mipstx39el \ ++ | mmix \ ++ | mn10200 | mn10300 \ ++ | moxie \ ++ | mt \ ++ | msp430 \ ++ | nds32 | nds32le | nds32be \ ++ | nfp \ ++ | nios | nios2 | nios2eb | nios2el \ ++ | none | np1 | ns16k | ns32k | nvptx \ ++ | open8 \ ++ | or1k* \ ++ | or32 \ ++ | orion \ ++ | picochip \ ++ | pdp10 | pdp11 | pj | pjl | pn | power \ ++ | powerpc | powerpc64 | powerpc64le | powerpcle | powerpcspe \ ++ | pru \ ++ | pyramid \ ++ | riscv | riscv32 | riscv32be | riscv64 | riscv64be \ ++ | rl78 | romp | rs6000 | rx \ ++ | s390 | s390x \ ++ | score \ ++ | sh | shl \ ++ | sh[1234] | sh[24]a | sh[24]ae[lb] | sh[23]e | she[lb] | sh[lb]e \ ++ | sh[1234]e[lb] | sh[12345][lb]e | sh[23]ele | sh64 | sh64le \ ++ | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet \ ++ | sparclite \ ++ | sparcv8 | sparcv9 | sparcv9b | sparcv9v | sv1 | sx* \ ++ | spu \ ++ | tahoe \ ++ | thumbv7* \ ++ | tic30 | tic4x | tic54x | tic55x | tic6x | tic80 \ ++ | tron \ ++ | ubicom32 \ ++ | v70 | v850 | v850e | v850e1 | v850es | v850e2 | v850e2v3 \ ++ | vax \ ++ | visium \ ++ | w65 \ ++ | wasm32 | wasm64 \ ++ | we32k \ ++ | x86 | x86_64 | xc16x | xgate | xps100 \ ++ | xstormy16 | xtensa* \ ++ | ymp \ ++ | z8k | z80) ++ ;; ++ ++ *) ++ echo Invalid configuration \`"$1"\': machine \`"$cpu-$vendor"\' not recognized 1>&2 ++ exit 1 ++ ;; ++ esac + ;; + esac + + # Here we canonicalize certain aliases for manufacturers. +-case $basic_machine in +- *-digital*) +- basic_machine=`echo "$basic_machine" | sed 's/digital.*/dec/'` ++case $vendor in ++ digital*) ++ vendor=dec + ;; +- *-commodore*) +- basic_machine=`echo "$basic_machine" | sed 's/commodore.*/cbm/'` ++ commodore*) ++ vendor=cbm + ;; + *) + ;; +@@ -1334,203 +1306,215 @@ esac + + # Decode manufacturer-specific aliases for certain operating systems. + +-if [ x"$os" != x"" ] ++if test x$basic_os != x + then ++ ++# First recognize some ad-hoc cases, or perhaps split kernel-os, or else just ++# set os. ++case $basic_os in ++ gnu/linux*) ++ kernel=linux ++ os=`echo "$basic_os" | sed -e 's|gnu/linux|gnu|'` ++ ;; ++ os2-emx) ++ kernel=os2 ++ os=`echo "$basic_os" | sed -e 's|os2-emx|emx|'` ++ ;; ++ nto-qnx*) ++ kernel=nto ++ os=`echo "$basic_os" | sed -e 's|nto-qnx|qnx|'` ++ ;; ++ *-*) ++ # shellcheck disable=SC2162 ++ saved_IFS=$IFS ++ IFS="-" read kernel os <&2 +- exit 1 ++ # No normalization, but not necessarily accepted, that comes below. + ;; + esac ++ + else + + # Here we handle the default operating systems that come with various machines. +@@ -1543,258 +1527,363 @@ else + # will signal an error saying that MANUFACTURER isn't an operating + # system, and we'll never get to this point. + +-case $basic_machine in ++kernel= ++case $cpu-$vendor in + score-*) +- os=-elf ++ os=elf + ;; + spu-*) +- os=-elf ++ os=elf + ;; + *-acorn) +- os=-riscix1.2 ++ os=riscix1.2 + ;; + arm*-rebel) +- os=-linux ++ kernel=linux ++ os=gnu + ;; + arm*-semi) +- os=-aout ++ os=aout + ;; + c4x-* | tic4x-*) +- os=-coff ++ os=coff + ;; + c8051-*) +- os=-elf ++ os=elf ++ ;; ++ clipper-intergraph) ++ os=clix + ;; + hexagon-*) +- os=-elf ++ os=elf + ;; + tic54x-*) +- os=-coff ++ os=coff + ;; + tic55x-*) +- os=-coff ++ os=coff + ;; + tic6x-*) +- os=-coff ++ os=coff + ;; + # This must come before the *-dec entry. + pdp10-*) +- os=-tops20 ++ os=tops20 + ;; + pdp11-*) +- os=-none ++ os=none + ;; + *-dec | vax-*) +- os=-ultrix4.2 ++ os=ultrix4.2 + ;; + m68*-apollo) +- os=-domain ++ os=domain + ;; + i386-sun) +- os=-sunos4.0.2 ++ os=sunos4.0.2 + ;; + m68000-sun) +- os=-sunos3 ++ os=sunos3 + ;; + m68*-cisco) +- os=-aout ++ os=aout + ;; + mep-*) +- os=-elf ++ os=elf + ;; + mips*-cisco) +- os=-elf ++ os=elf + ;; + mips*-*) +- os=-elf ++ os=elf + ;; + or32-*) +- os=-coff ++ os=coff + ;; + *-tti) # must be before sparc entry or we get the wrong os. +- os=-sysv3 ++ os=sysv3 + ;; + sparc-* | *-sun) +- os=-sunos4.1.1 ++ os=sunos4.1.1 + ;; + pru-*) +- os=-elf ++ os=elf + ;; + *-be) +- os=-beos ++ os=beos + ;; + *-ibm) +- os=-aix ++ os=aix + ;; + *-knuth) +- os=-mmixware ++ os=mmixware + ;; + *-wec) +- os=-proelf ++ os=proelf + ;; + *-winbond) +- os=-proelf ++ os=proelf + ;; + *-oki) +- os=-proelf ++ os=proelf + ;; + *-hp) +- os=-hpux ++ os=hpux + ;; + *-hitachi) +- os=-hiux ++ os=hiux + ;; + i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) +- os=-sysv ++ os=sysv + ;; + *-cbm) +- os=-amigaos ++ os=amigaos + ;; + *-dg) +- os=-dgux ++ os=dgux + ;; + *-dolphin) +- os=-sysv3 ++ os=sysv3 + ;; + m68k-ccur) +- os=-rtu ++ os=rtu + ;; + m88k-omron*) +- os=-luna ++ os=luna + ;; + *-next) +- os=-nextstep ++ os=nextstep + ;; + *-sequent) +- os=-ptx ++ os=ptx + ;; + *-crds) +- os=-unos ++ os=unos + ;; + *-ns) +- os=-genix ++ os=genix + ;; + i370-*) +- os=-mvs ++ os=mvs + ;; + *-gould) +- os=-sysv ++ os=sysv + ;; + *-highlevel) +- os=-bsd ++ os=bsd + ;; + *-encore) +- os=-bsd ++ os=bsd + ;; + *-sgi) +- os=-irix ++ os=irix + ;; + *-siemens) +- os=-sysv4 ++ os=sysv4 + ;; + *-masscomp) +- os=-rtu ++ os=rtu + ;; + f30[01]-fujitsu | f700-fujitsu) +- os=-uxpv ++ os=uxpv + ;; + *-rom68k) +- os=-coff ++ os=coff + ;; + *-*bug) +- os=-coff ++ os=coff + ;; + *-apple) +- os=-macos ++ os=macos + ;; + *-atari*) +- os=-mint ++ os=mint ++ ;; ++ *-wrs) ++ os=vxworks + ;; + *) +- os=-none ++ os=none + ;; + esac ++ + fi + ++# Now, validate our (potentially fixed-up) OS. ++case $os in ++ # Sometimes we do "kernel-libc", so those need to count as OSes. ++ musl* | newlib* | relibc* | uclibc*) ++ ;; ++ # Likewise for "kernel-abi" ++ eabi* | gnueabi*) ++ ;; ++ # VxWorks passes extra cpu info in the 4th filed. ++ simlinux | simwindows | spe) ++ ;; ++ # Now accept the basic system types. ++ # The portable systems comes first. ++ # Each alternative MUST end in a * to match a version number. ++ gnu* | android* | bsd* | mach* | minix* | genix* | ultrix* | irix* \ ++ | *vms* | esix* | aix* | cnk* | sunos | sunos[34]* \ ++ | hpux* | unos* | osf* | luna* | dgux* | auroraux* | solaris* \ ++ | sym* | plan9* | psp* | sim* | xray* | os68k* | v88r* \ ++ | hiux* | abug | nacl* | netware* | windows* \ ++ | os9* | macos* | osx* | ios* \ ++ | mpw* | magic* | mmixware* | mon960* | lnews* \ ++ | amigaos* | amigados* | msdos* | newsos* | unicos* | aof* \ ++ | aos* | aros* | cloudabi* | sortix* | twizzler* \ ++ | nindy* | vxsim* | vxworks* | ebmon* | hms* | mvs* \ ++ | clix* | riscos* | uniplus* | iris* | isc* | rtu* | xenix* \ ++ | mirbsd* | netbsd* | dicos* | openedition* | ose* \ ++ | bitrig* | openbsd* | secbsd* | solidbsd* | libertybsd* | os108* \ ++ | ekkobsd* | freebsd* | riscix* | lynxos* | os400* \ ++ | bosx* | nextstep* | cxux* | aout* | elf* | oabi* \ ++ | ptx* | coff* | ecoff* | winnt* | domain* | vsta* \ ++ | udi* | lites* | ieee* | go32* | aux* | hcos* \ ++ | chorusrdb* | cegcc* | glidix* | serenity* \ ++ | cygwin* | msys* | pe* | moss* | proelf* | rtems* \ ++ | midipix* | mingw32* | mingw64* | mint* \ ++ | uxpv* | beos* | mpeix* | udk* | moxiebox* \ ++ | interix* | uwin* | mks* | rhapsody* | darwin* \ ++ | openstep* | oskit* | conix* | pw32* | nonstopux* \ ++ | storm-chaos* | tops10* | tenex* | tops20* | its* \ ++ | os2* | vos* | palmos* | uclinux* | nucleus* | morphos* \ ++ | scout* | superux* | sysv* | rtmk* | tpf* | windiss* \ ++ | powermax* | dnix* | nx6 | nx7 | sei* | dragonfly* \ ++ | skyos* | haiku* | rdos* | toppers* | drops* | es* \ ++ | onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \ ++ | midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi* \ ++ | nsk* | powerunix* | genode* | zvmoe* | qnx* | emx* | zephyr* \ ++ | fiwix* ) ++ ;; ++ # This one is extra strict with allowed versions ++ sco3.2v2 | sco3.2v[4-9]* | sco5v6*) ++ # Don't forget version if it is 3.2v4 or newer. ++ ;; ++ none) ++ ;; ++ *) ++ echo Invalid configuration \`"$1"\': OS \`"$os"\' not recognized 1>&2 ++ exit 1 ++ ;; ++esac ++ ++# As a final step for OS-related things, validate the OS-kernel combination ++# (given a valid OS), if there is a kernel. ++case $kernel-$os in ++ linux-gnu* | linux-dietlibc* | linux-android* | linux-newlib* \ ++ | linux-musl* | linux-relibc* | linux-uclibc* ) ++ ;; ++ uclinux-uclibc* ) ++ ;; ++ -dietlibc* | -newlib* | -musl* | -relibc* | -uclibc* ) ++ # These are just libc implementations, not actual OSes, and thus ++ # require a kernel. ++ echo "Invalid configuration \`$1': libc \`$os' needs explicit kernel." 1>&2 ++ exit 1 ++ ;; ++ kfreebsd*-gnu* | kopensolaris*-gnu*) ++ ;; ++ vxworks-simlinux | vxworks-simwindows | vxworks-spe) ++ ;; ++ nto-qnx*) ++ ;; ++ os2-emx) ++ ;; ++ *-eabi* | *-gnueabi*) ++ ;; ++ -*) ++ # Blank kernel with real OS is always fine. ++ ;; ++ *-*) ++ echo "Invalid configuration \`$1': Kernel \`$kernel' not known to work with OS \`$os'." 1>&2 ++ exit 1 ++ ;; ++esac ++ + # Here we handle the case where we know the os, and the CPU type, but not the + # manufacturer. We pick the logical manufacturer. +-vendor=unknown +-case $basic_machine in +- *-unknown) +- case $os in +- -riscix*) ++case $vendor in ++ unknown) ++ case $cpu-$os in ++ *-riscix*) + vendor=acorn + ;; +- -sunos*) ++ *-sunos*) + vendor=sun + ;; +- -cnk*|-aix*) ++ *-cnk* | *-aix*) + vendor=ibm + ;; +- -beos*) ++ *-beos*) + vendor=be + ;; +- -hpux*) ++ *-hpux*) + vendor=hp + ;; +- -mpeix*) ++ *-mpeix*) + vendor=hp + ;; +- -hiux*) ++ *-hiux*) + vendor=hitachi + ;; +- -unos*) ++ *-unos*) + vendor=crds + ;; +- -dgux*) ++ *-dgux*) + vendor=dg + ;; +- -luna*) ++ *-luna*) + vendor=omron + ;; +- -genix*) ++ *-genix*) + vendor=ns + ;; +- -mvs* | -opened*) ++ *-clix*) ++ vendor=intergraph ++ ;; ++ *-mvs* | *-opened*) ++ vendor=ibm ++ ;; ++ *-os400*) + vendor=ibm + ;; +- -os400*) ++ s390-* | s390x-*) + vendor=ibm + ;; +- -ptx*) ++ *-ptx*) + vendor=sequent + ;; +- -tpf*) ++ *-tpf*) + vendor=ibm + ;; +- -vxsim* | -vxworks* | -windiss*) ++ *-vxsim* | *-vxworks* | *-windiss*) + vendor=wrs + ;; +- -aux*) ++ *-aux*) + vendor=apple + ;; +- -hms*) ++ *-hms*) + vendor=hitachi + ;; +- -mpw* | -macos*) ++ *-mpw* | *-macos*) + vendor=apple + ;; +- -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) ++ *-*mint | *-mint[0-9]* | *-*MiNT | *-MiNT[0-9]*) + vendor=atari + ;; +- -vos*) ++ *-vos*) + vendor=stratus + ;; + esac +- basic_machine=`echo "$basic_machine" | sed "s/unknown/$vendor/"` + ;; + esac + +-echo "$basic_machine$os" ++echo "$cpu-$vendor-${kernel:+$kernel-}$os" + exit + + # Local variables: +-# eval: (add-hook 'write-file-functions 'time-stamp) ++# eval: (add-hook 'before-save-hook 'time-stamp) + # time-stamp-start: "timestamp='" + # time-stamp-format: "%:y-%02m-%02d" + # time-stamp-end: "'" +diff --git a/deps/cares/configure b/deps/cares/configure +index 737f0a0..2f182e0 100755 +--- a/deps/cares/configure ++++ b/deps/cares/configure +@@ -1,6 +1,6 @@ + #! /bin/sh + # Guess values for system-dependent variables and create Makefiles. +-# Generated by GNU Autoconf 2.71 for c-ares 1.18.1. ++# Generated by GNU Autoconf 2.71 for c-ares 1.19.1. + # + # Report bugs to . + # +@@ -855,8 +855,8 @@ MAKEFLAGS= + # Identity of this package. + PACKAGE_NAME='c-ares' + PACKAGE_TARNAME='c-ares' +-PACKAGE_VERSION='1.18.1' +-PACKAGE_STRING='c-ares 1.18.1' ++PACKAGE_VERSION='1.19.1' ++PACKAGE_STRING='c-ares 1.19.1' + PACKAGE_BUGREPORT='c-ares mailing list: http://lists.haxx.se/listinfo/c-ares' + PACKAGE_URL='' + +@@ -927,6 +927,7 @@ DSYMUTIL + MANIFEST_TOOL + RANLIB + ac_ct_AR ++FILECMD + LN_S + NM + ac_ct_DUMPBIN +@@ -1649,7 +1650,7 @@ if test "$ac_init_help" = "long"; then + # Omit some internal or obsolete options to make the list less imposing. + # This message is too long to be a string in the A/UX 3.1 sh. + cat <<_ACEOF +-\`configure' configures c-ares 1.18.1 to adapt to many kinds of systems. ++\`configure' configures c-ares 1.19.1 to adapt to many kinds of systems. + + Usage: $0 [OPTION]... [VAR=VALUE]... + +@@ -1720,7 +1721,7 @@ fi + + if test -n "$ac_init_help"; then + case $ac_init_help in +- short | recursive ) echo "Configuration of c-ares 1.18.1:";; ++ short | recursive ) echo "Configuration of c-ares 1.19.1:";; + esac + cat <<\_ACEOF + +@@ -1860,7 +1861,7 @@ fi + test -n "$ac_init_help" && exit $ac_status + if $ac_init_version; then + cat <<\_ACEOF +-c-ares configure 1.18.1 ++c-ares configure 1.19.1 + generated by GNU Autoconf 2.71 + + Copyright (C) 2021 Free Software Foundation, Inc. +@@ -2452,7 +2453,7 @@ cat >config.log <<_ACEOF + This file contains any messages produced by compilers while + running configure, to aid debugging if configure makes a mistake. + +-It was created by c-ares $as_me 1.18.1, which was ++It was created by c-ares $as_me 1.19.1, which was + generated by GNU Autoconf 2.71. Invocation command line was + + $ $0$ac_configure_args_raw +@@ -3425,7 +3426,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu + + + +-CARES_VERSION_INFO="7:1:5" ++CARES_VERSION_INFO="8:1:6" + + + +@@ -6204,11 +6205,11 @@ if test x$ac_prog_cxx_stdcxx = xno + then : + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CXX option to enable C++11 features" >&5 + printf %s "checking for $CXX option to enable C++11 features... " >&6; } +-if test ${ac_cv_prog_cxx_11+y} ++if test ${ac_cv_prog_cxx_cxx11+y} + then : + printf %s "(cached) " >&6 + else $as_nop +- ac_cv_prog_cxx_11=no ++ ac_cv_prog_cxx_cxx11=no + ac_save_CXX=$CXX + cat confdefs.h - <<_ACEOF >conftest.$ac_ext + /* end confdefs.h. */ +@@ -6250,11 +6251,11 @@ if test x$ac_prog_cxx_stdcxx = xno + then : + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CXX option to enable C++98 features" >&5 + printf %s "checking for $CXX option to enable C++98 features... " >&6; } +-if test ${ac_cv_prog_cxx_98+y} ++if test ${ac_cv_prog_cxx_cxx98+y} + then : + printf %s "(cached) " >&6 + else $as_nop +- ac_cv_prog_cxx_98=no ++ ac_cv_prog_cxx_cxx98=no + ac_save_CXX=$CXX + cat confdefs.h - <<_ACEOF >conftest.$ac_ext + /* end confdefs.h. */ +@@ -6300,144 +6301,323 @@ ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ex + ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + +- ax_cxx_compile_cxx11_required=false ++ ax_cxx_compile_alternatives="11 0x" ax_cxx_compile_cxx11_required=false + ac_ext=cpp + ac_cpp='$CXXCPP $CPPFLAGS' + ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' + ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' + ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + ac_success=no +- { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++11 features by default" >&5 +-printf %s "checking whether $CXX supports C++11 features by default... " >&6; } +-if test ${ax_cv_cxx_compile_cxx11+y} ++ ++ ++ ++ ++ ++ if test x$ac_success = xno; then ++ for alternative in ${ax_cxx_compile_alternatives}; do ++ for switch in -std=c++${alternative} +std=c++${alternative} "-h std=c++${alternative}"; do ++ cachevar=`printf "%s\n" "ax_cv_cxx_compile_cxx11_$switch" | $as_tr_sh` ++ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++11 features with $switch" >&5 ++printf %s "checking whether $CXX supports C++11 features with $switch... " >&6; } ++if eval test \${$cachevar+y} + then : + printf %s "(cached) " >&6 + else $as_nop +- cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++ ac_save_CXX="$CXX" ++ CXX="$CXX $switch" ++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext + /* end confdefs.h. */ + +- template ++ ++// If the compiler admits that it is not ready for C++11, why torture it? ++// Hopefully, this will speed up the test. ++ ++#ifndef __cplusplus ++ ++#error "This is not a C++ compiler" ++ ++// MSVC always sets __cplusplus to 199711L in older versions; newer versions ++// only set it correctly if /Zc:__cplusplus is specified as well as a ++// /std:c++NN switch: ++// https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/ ++#elif __cplusplus < 201103L && !defined _MSC_VER ++ ++#error "This is not a C++11 compiler" ++ ++#else ++ ++namespace cxx11 ++{ ++ ++ namespace test_static_assert ++ { ++ ++ template + struct check + { + static_assert(sizeof(int) <= sizeof(T), "not big enough"); + }; + +- struct Base { +- virtual void f() {} ++ } ++ ++ namespace test_final_override ++ { ++ ++ struct Base ++ { ++ virtual ~Base() {} ++ virtual void f() {} + }; +- struct Child : public Base { +- virtual void f() override {} ++ ++ struct Derived : public Base ++ { ++ virtual ~Derived() override {} ++ virtual void f() override {} + }; + +- typedef check> right_angle_brackets; ++ } + +- int a; +- decltype(a) b; ++ namespace test_double_right_angle_brackets ++ { + +- typedef check check_type; +- check_type c; +- check_type&& cr = static_cast(c); ++ template < typename T > ++ struct check {}; + +- auto d = a; +- auto l = [](){}; ++ typedef check single_type; ++ typedef check> double_type; ++ typedef check>> triple_type; ++ typedef check>>> quadruple_type; + +- // http://stackoverflow.com/questions/13728184/template-aliases-and-sfinae +- // Clang 3.1 fails with headers of libstd++ 4.8.3 when using std::function because of this +- namespace test_template_alias_sfinae { +- struct foo {}; ++ } + +- template +- using member = typename T::member_type; ++ namespace test_decltype ++ { + +- template +- void func(...) {} ++ int ++ f() ++ { ++ int a = 1; ++ decltype(a) b = 2; ++ return a + b; ++ } + +- template +- void func(member*) {} ++ } + +- void test(); ++ namespace test_type_deduction ++ { + +- void test() { +- func(0); +- } ++ template < typename T1, typename T2 > ++ struct is_same ++ { ++ static const bool value = false; ++ }; ++ ++ template < typename T > ++ struct is_same ++ { ++ static const bool value = true; ++ }; ++ ++ template < typename T1, typename T2 > ++ auto ++ add(T1 a1, T2 a2) -> decltype(a1 + a2) ++ { ++ return a1 + a2; + } + +-_ACEOF +-if ac_fn_cxx_try_compile "$LINENO" +-then : +- ax_cv_cxx_compile_cxx11=yes +-else $as_nop +- ax_cv_cxx_compile_cxx11=no +-fi +-rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +-fi +-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ax_cv_cxx_compile_cxx11" >&5 +-printf "%s\n" "$ax_cv_cxx_compile_cxx11" >&6; } +- if test x$ax_cv_cxx_compile_cxx11 = xyes; then +- ac_success=yes +- fi ++ int ++ test(const int c, volatile int v) ++ { ++ static_assert(is_same::value == true, ""); ++ static_assert(is_same::value == false, ""); ++ static_assert(is_same::value == false, ""); ++ auto ac = c; ++ auto av = v; ++ auto sumi = ac + av + 'x'; ++ auto sumf = ac + av + 1.0; ++ static_assert(is_same::value == true, ""); ++ static_assert(is_same::value == true, ""); ++ static_assert(is_same::value == true, ""); ++ static_assert(is_same::value == false, ""); ++ static_assert(is_same::value == true, ""); ++ return (sumf > 0.0) ? sumi : add(c, v); ++ } + ++ } + ++ namespace test_noexcept ++ { + +- if test x$ac_success = xno; then +- for switch in -std=c++11 -std=c++0x; do +- cachevar=`printf "%s\n" "ax_cv_cxx_compile_cxx11_$switch" | $as_tr_sh` +- { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++11 features with $switch" >&5 +-printf %s "checking whether $CXX supports C++11 features with $switch... " >&6; } +-if eval test \${$cachevar+y} +-then : +- printf %s "(cached) " >&6 +-else $as_nop +- ac_save_CXXFLAGS="$CXXFLAGS" +- CXXFLAGS="$CXXFLAGS $switch" +- cat confdefs.h - <<_ACEOF >conftest.$ac_ext +-/* end confdefs.h. */ ++ int f() { return 0; } ++ int g() noexcept { return 0; } + +- template +- struct check ++ static_assert(noexcept(f()) == false, ""); ++ static_assert(noexcept(g()) == true, ""); ++ ++ } ++ ++ namespace test_constexpr ++ { ++ ++ template < typename CharT > ++ unsigned long constexpr ++ strlen_c_r(const CharT *const s, const unsigned long acc) noexcept + { +- static_assert(sizeof(int) <= sizeof(T), "not big enough"); ++ return *s ? strlen_c_r(s + 1, acc + 1) : acc; ++ } ++ ++ template < typename CharT > ++ unsigned long constexpr ++ strlen_c(const CharT *const s) noexcept ++ { ++ return strlen_c_r(s, 0UL); ++ } ++ ++ static_assert(strlen_c("") == 0UL, ""); ++ static_assert(strlen_c("1") == 1UL, ""); ++ static_assert(strlen_c("example") == 7UL, ""); ++ static_assert(strlen_c("another\0example") == 7UL, ""); ++ ++ } ++ ++ namespace test_rvalue_references ++ { ++ ++ template < int N > ++ struct answer ++ { ++ static constexpr int value = N; + }; + +- struct Base { +- virtual void f() {} ++ answer<1> f(int&) { return answer<1>(); } ++ answer<2> f(const int&) { return answer<2>(); } ++ answer<3> f(int&&) { return answer<3>(); } ++ ++ void ++ test() ++ { ++ int i = 0; ++ const int c = 0; ++ static_assert(decltype(f(i))::value == 1, ""); ++ static_assert(decltype(f(c))::value == 2, ""); ++ static_assert(decltype(f(0))::value == 3, ""); ++ } ++ ++ } ++ ++ namespace test_uniform_initialization ++ { ++ ++ struct test ++ { ++ static const int zero {}; ++ static const int one {1}; + }; +- struct Child : public Base { +- virtual void f() override {} ++ ++ static_assert(test::zero == 0, ""); ++ static_assert(test::one == 1, ""); ++ ++ } ++ ++ namespace test_lambdas ++ { ++ ++ void ++ test1() ++ { ++ auto lambda1 = [](){}; ++ auto lambda2 = lambda1; ++ lambda1(); ++ lambda2(); ++ } ++ ++ int ++ test2() ++ { ++ auto a = [](int i, int j){ return i + j; }(1, 2); ++ auto b = []() -> int { return '0'; }(); ++ auto c = [=](){ return a + b; }(); ++ auto d = [&](){ return c; }(); ++ auto e = [a, &b](int x) mutable { ++ const auto identity = [](int y){ return y; }; ++ for (auto i = 0; i < a; ++i) ++ a += b--; ++ return x + identity(a + b); ++ }(0); ++ return a + b + c + d + e; ++ } ++ ++ int ++ test3() ++ { ++ const auto nullary = [](){ return 0; }; ++ const auto unary = [](int x){ return x; }; ++ using nullary_t = decltype(nullary); ++ using unary_t = decltype(unary); ++ const auto higher1st = [](nullary_t f){ return f(); }; ++ const auto higher2nd = [unary](nullary_t f1){ ++ return [unary, f1](unary_t f2){ return f2(unary(f1())); }; ++ }; ++ return higher1st(nullary) + higher2nd(nullary)(unary); ++ } ++ ++ } ++ ++ namespace test_variadic_templates ++ { ++ ++ template ++ struct sum; ++ ++ template ++ struct sum ++ { ++ static constexpr auto value = N0 + sum::value; + }; + +- typedef check> right_angle_brackets; ++ template <> ++ struct sum<> ++ { ++ static constexpr auto value = 0; ++ }; + +- int a; +- decltype(a) b; ++ static_assert(sum<>::value == 0, ""); ++ static_assert(sum<1>::value == 1, ""); ++ static_assert(sum<23>::value == 23, ""); ++ static_assert(sum<1, 2>::value == 3, ""); ++ static_assert(sum<5, 5, 11>::value == 21, ""); ++ static_assert(sum<2, 3, 5, 7, 11, 13>::value == 41, ""); + +- typedef check check_type; +- check_type c; +- check_type&& cr = static_cast(c); ++ } + +- auto d = a; +- auto l = [](){}; ++ // http://stackoverflow.com/questions/13728184/template-aliases-and-sfinae ++ // Clang 3.1 fails with headers of libstd++ 4.8.3 when using std::function ++ // because of this. ++ namespace test_template_alias_sfinae ++ { + +- // http://stackoverflow.com/questions/13728184/template-aliases-and-sfinae +- // Clang 3.1 fails with headers of libstd++ 4.8.3 when using std::function because of this +- namespace test_template_alias_sfinae { +- struct foo {}; ++ struct foo {}; + +- template +- using member = typename T::member_type; ++ template ++ using member = typename T::member_type; + +- template +- void func(...) {} ++ template ++ void func(...) {} + +- template +- void func(member*) {} ++ template ++ void func(member*) {} ++ ++ void test(); ++ ++ void test() { func(0); } ++ ++ } ++ ++} // namespace cxx11 ++ ++#endif // __cplusplus >= 201103L + +- void test(); + +- void test() { +- func(0); +- } +- } + + _ACEOF + if ac_fn_cxx_try_compile "$LINENO" +@@ -6447,14 +6627,21 @@ else $as_nop + eval $cachevar=no + fi + rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +- CXXFLAGS="$ac_save_CXXFLAGS" ++ CXX="$ac_save_CXX" + fi + eval ac_res=\$$cachevar + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 + printf "%s\n" "$ac_res" >&6; } +- if eval test x\$$cachevar = xyes; then +- CXXFLAGS="$CXXFLAGS $switch" +- ac_success=yes ++ if eval test x\$$cachevar = xyes; then ++ CXX="$CXX $switch" ++ if test -n "$CXXCPP" ; then ++ CXXCPP="$CXXCPP $switch" ++ fi ++ ac_success=yes ++ break ++ fi ++ done ++ if test x$ac_success = xyes; then + break + fi + done +@@ -6469,22 +6656,20 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu + if test x$ac_success = xno; then + as_fn_error $? "*** A compiler with support for C++11 language features is required." "$LINENO" 5 + fi +- else +- if test x$ac_success = xno; then +- HAVE_CXX11=0 +- { printf "%s\n" "$as_me:${as_lineno-$LINENO}: No compiler with C++11 support was found" >&5 ++ fi ++ if test x$ac_success = xno; then ++ HAVE_CXX11=0 ++ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: No compiler with C++11 support was found" >&5 + printf "%s\n" "$as_me: No compiler with C++11 support was found" >&6;} +- else +- HAVE_CXX11=1 ++ else ++ HAVE_CXX11=1 + + printf "%s\n" "#define HAVE_CXX11 1" >>confdefs.h + +- fi +- +- + fi + + ++ + am__api_version='1.16' + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether build environment is sane" >&5 +@@ -6875,7 +7060,7 @@ fi + + # Define the identity of the package. + PACKAGE='c-ares' +- VERSION='1.18.1' ++ VERSION='1.19.1' + + + printf "%s\n" "#define PACKAGE \"$PACKAGE\"" >>confdefs.h +@@ -8733,8 +8918,8 @@ esac + + + +-macro_version='2.4.6' +-macro_revision='2.4.6' ++macro_version='2.4.7' ++macro_revision='2.4.7' + + + +@@ -9145,13 +9330,13 @@ else + mingw*) lt_bad_file=conftest.nm/nofile ;; + *) lt_bad_file=/dev/null ;; + esac +- case `"$tmp_nm" -B $lt_bad_file 2>&1 | sed '1q'` in ++ case `"$tmp_nm" -B $lt_bad_file 2>&1 | $SED '1q'` in + *$lt_bad_file* | *'Invalid file or object type'*) + lt_cv_path_NM="$tmp_nm -B" + break 2 + ;; + *) +- case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in ++ case `"$tmp_nm" -p /dev/null 2>&1 | $SED '1q'` in + */dev/null*) + lt_cv_path_NM="$tmp_nm -p" + break 2 +@@ -9289,7 +9474,7 @@ esac + fi + fi + +- case `$DUMPBIN -symbols -headers /dev/null 2>&1 | sed '1q'` in ++ case `$DUMPBIN -symbols -headers /dev/null 2>&1 | $SED '1q'` in + *COFF*) + DUMPBIN="$DUMPBIN -symbols -headers" + ;; +@@ -9393,7 +9578,7 @@ else $as_nop + lt_cv_sys_max_cmd_len=8192; + ;; + +- bitrig* | darwin* | dragonfly* | freebsd* | netbsd* | openbsd*) ++ bitrig* | darwin* | dragonfly* | freebsd* | midnightbsd* | netbsd* | openbsd*) + # This has been around since 386BSD, at least. Likely further. + if test -x /sbin/sysctl; then + lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax` +@@ -9436,7 +9621,7 @@ else $as_nop + sysv5* | sco5v6* | sysv4.2uw2*) + kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null` + if test -n "$kargmax"; then +- lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[ ]//'` ++ lt_cv_sys_max_cmd_len=`echo $kargmax | $SED 's/.*[ ]//'` + else + lt_cv_sys_max_cmd_len=32768 + fi +@@ -9641,6 +9826,114 @@ esac + + + ++if test -n "$ac_tool_prefix"; then ++ # Extract the first word of "${ac_tool_prefix}file", so it can be a program name with args. ++set dummy ${ac_tool_prefix}file; ac_word=$2 ++{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 ++printf %s "checking for $ac_word... " >&6; } ++if test ${ac_cv_prog_FILECMD+y} ++then : ++ printf %s "(cached) " >&6 ++else $as_nop ++ if test -n "$FILECMD"; then ++ ac_cv_prog_FILECMD="$FILECMD" # Let the user override the test. ++else ++as_save_IFS=$IFS; IFS=$PATH_SEPARATOR ++for as_dir in $PATH ++do ++ IFS=$as_save_IFS ++ case $as_dir in #((( ++ '') as_dir=./ ;; ++ */) ;; ++ *) as_dir=$as_dir/ ;; ++ esac ++ for ac_exec_ext in '' $ac_executable_extensions; do ++ if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ++ ac_cv_prog_FILECMD="${ac_tool_prefix}file" ++ printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 ++ break 2 ++ fi ++done ++ done ++IFS=$as_save_IFS ++ ++fi ++fi ++FILECMD=$ac_cv_prog_FILECMD ++if test -n "$FILECMD"; then ++ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $FILECMD" >&5 ++printf "%s\n" "$FILECMD" >&6; } ++else ++ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++printf "%s\n" "no" >&6; } ++fi ++ ++ ++fi ++if test -z "$ac_cv_prog_FILECMD"; then ++ ac_ct_FILECMD=$FILECMD ++ # Extract the first word of "file", so it can be a program name with args. ++set dummy file; ac_word=$2 ++{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 ++printf %s "checking for $ac_word... " >&6; } ++if test ${ac_cv_prog_ac_ct_FILECMD+y} ++then : ++ printf %s "(cached) " >&6 ++else $as_nop ++ if test -n "$ac_ct_FILECMD"; then ++ ac_cv_prog_ac_ct_FILECMD="$ac_ct_FILECMD" # Let the user override the test. ++else ++as_save_IFS=$IFS; IFS=$PATH_SEPARATOR ++for as_dir in $PATH ++do ++ IFS=$as_save_IFS ++ case $as_dir in #((( ++ '') as_dir=./ ;; ++ */) ;; ++ *) as_dir=$as_dir/ ;; ++ esac ++ for ac_exec_ext in '' $ac_executable_extensions; do ++ if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ++ ac_cv_prog_ac_ct_FILECMD="file" ++ printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 ++ break 2 ++ fi ++done ++ done ++IFS=$as_save_IFS ++ ++fi ++fi ++ac_ct_FILECMD=$ac_cv_prog_ac_ct_FILECMD ++if test -n "$ac_ct_FILECMD"; then ++ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_FILECMD" >&5 ++printf "%s\n" "$ac_ct_FILECMD" >&6; } ++else ++ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++printf "%s\n" "no" >&6; } ++fi ++ ++ if test "x$ac_ct_FILECMD" = x; then ++ FILECMD=":" ++ else ++ case $cross_compiling:$ac_tool_warned in ++yes:) ++{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 ++printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ++ac_tool_warned=yes ;; ++esac ++ FILECMD=$ac_ct_FILECMD ++ fi ++else ++ FILECMD="$ac_cv_prog_FILECMD" ++fi ++ ++ ++ ++ ++ ++ ++ + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}objdump", so it can be a program name with args. + set dummy ${ac_tool_prefix}objdump; ac_word=$2 +@@ -9781,7 +10074,7 @@ beos*) + + bsdi[45]*) + lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib)' +- lt_cv_file_magic_cmd='/usr/bin/file -L' ++ lt_cv_file_magic_cmd='$FILECMD -L' + lt_cv_file_magic_test_file=/shlib/libc.so + ;; + +@@ -9815,14 +10108,14 @@ darwin* | rhapsody*) + lt_cv_deplibs_check_method=pass_all + ;; + +-freebsd* | dragonfly*) ++freebsd* | dragonfly* | midnightbsd*) + if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then + case $host_cpu in + i*86 ) + # Not sure whether the presence of OpenBSD here was a mistake. + # Let's accept both of them until this is cleared up. + lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[3-9]86 (compact )?demand paged shared library' +- lt_cv_file_magic_cmd=/usr/bin/file ++ lt_cv_file_magic_cmd=$FILECMD + lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` + ;; + esac +@@ -9836,7 +10129,7 @@ haiku*) + ;; + + hpux10.20* | hpux11*) +- lt_cv_file_magic_cmd=/usr/bin/file ++ lt_cv_file_magic_cmd=$FILECMD + case $host_cpu in + ia64*) + lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - IA64' +@@ -9883,7 +10176,7 @@ netbsd* | netbsdelf*-gnu) + + newos6*) + lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (executable|dynamic lib)' +- lt_cv_file_magic_cmd=/usr/bin/file ++ lt_cv_file_magic_cmd=$FILECMD + lt_cv_file_magic_test_file=/usr/lib/libnls.so + ;; + +@@ -10253,13 +10546,29 @@ esac + fi + + : ${AR=ar} +-: ${AR_FLAGS=cr} + + + + + + ++# Use ARFLAGS variable as AR's operation code to sync the variable naming with ++# Automake. If both AR_FLAGS and ARFLAGS are specified, AR_FLAGS should have ++# higher priority because thats what people were doing historically (setting ++# ARFLAGS for automake and AR_FLAGS for libtool). FIXME: Make the AR_FLAGS ++# variable obsoleted/removed. ++ ++test ${AR_FLAGS+y} || AR_FLAGS=${ARFLAGS-cr} ++lt_ar_flags=$AR_FLAGS ++ ++ ++ ++ ++ ++ ++# Make AR_FLAGS overridable by 'make ARFLAGS='. Don't try to run-time override ++# by AR_FLAGS because that was never working and AR_FLAGS is about to die. ++ + + + +@@ -10676,7 +10985,7 @@ esac + + if test "$lt_cv_nm_interface" = "MS dumpbin"; then + # Gets list of data symbols to import. +- lt_cv_sys_global_symbol_to_import="sed -n -e 's/^I .* \(.*\)$/\1/p'" ++ lt_cv_sys_global_symbol_to_import="$SED -n -e 's/^I .* \(.*\)$/\1/p'" + # Adjust the below global symbol transforms to fixup imported variables. + lt_cdecl_hook=" -e 's/^I .* \(.*\)$/extern __declspec(dllimport) char \1;/p'" + lt_c_name_hook=" -e 's/^I .* \(.*\)$/ {\"\1\", (void *) 0},/p'" +@@ -10694,20 +11003,20 @@ fi + # Transform an extracted symbol line into a proper C declaration. + # Some systems (esp. on ia64) link data and code symbols differently, + # so use this general approach. +-lt_cv_sys_global_symbol_to_cdecl="sed -n"\ ++lt_cv_sys_global_symbol_to_cdecl="$SED -n"\ + $lt_cdecl_hook\ + " -e 's/^T .* \(.*\)$/extern int \1();/p'"\ + " -e 's/^$symcode$symcode* .* \(.*\)$/extern char \1;/p'" + + # Transform an extracted symbol line into symbol name and symbol address +-lt_cv_sys_global_symbol_to_c_name_address="sed -n"\ ++lt_cv_sys_global_symbol_to_c_name_address="$SED -n"\ + $lt_c_name_hook\ + " -e 's/^: \(.*\) .*$/ {\"\1\", (void *) 0},/p'"\ + " -e 's/^$symcode$symcode* .* \(.*\)$/ {\"\1\", (void *) \&\1},/p'" + + # Transform an extracted symbol line into symbol name with lib prefix and + # symbol address. +-lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n"\ ++lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="$SED -n"\ + $lt_c_name_lib_hook\ + " -e 's/^: \(.*\) .*$/ {\"\1\", (void *) 0},/p'"\ + " -e 's/^$symcode$symcode* .* \(lib.*\)$/ {\"\1\", (void *) \&\1},/p'"\ +@@ -10731,7 +11040,7 @@ for ac_symprfx in "" "_"; do + if test "$lt_cv_nm_interface" = "MS dumpbin"; then + # Fake it for dumpbin and say T for any non-static function, + # D for any global variable and I for any imported variable. +- # Also find C++ and __fastcall symbols from MSVC++, ++ # Also find C++ and __fastcall symbols from MSVC++ or ICC, + # which start with @ or ?. + lt_cv_sys_global_symbol_pipe="$AWK '"\ + " {last_section=section; section=\$ 3};"\ +@@ -10749,9 +11058,9 @@ for ac_symprfx in "" "_"; do + " s[1]~prfx {split(s[1],t,\"@\"); print f,t[1],substr(t[1],length(prfx))}"\ + " ' prfx=^$ac_symprfx" + else +- lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[ ]\($symcode$symcode*\)[ ][ ]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'" ++ lt_cv_sys_global_symbol_pipe="$SED -n -e 's/^.*[ ]\($symcode$symcode*\)[ ][ ]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'" + fi +- lt_cv_sys_global_symbol_pipe="$lt_cv_sys_global_symbol_pipe | sed '/ __gnu_lto/d'" ++ lt_cv_sys_global_symbol_pipe="$lt_cv_sys_global_symbol_pipe | $SED '/ __gnu_lto/d'" + + # Check to see that the pipe works correctly. + pipe_works=no +@@ -10951,7 +11260,7 @@ case $with_sysroot in #( + fi + ;; #( + /*) +- lt_sysroot=`echo "$with_sysroot" | sed -e "$sed_quote_subst"` ++ lt_sysroot=`echo "$with_sysroot" | $SED -e "$sed_quote_subst"` + ;; #( + no|'') + ;; #( +@@ -11076,7 +11385,7 @@ ia64-*-hpux*) + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then +- case `/usr/bin/file conftest.$ac_objext` in ++ case `$FILECMD conftest.$ac_objext` in + *ELF-32*) + HPUX_IA64_MODE=32 + ;; +@@ -11097,7 +11406,7 @@ ia64-*-hpux*) + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + if test yes = "$lt_cv_prog_gnu_ld"; then +- case `/usr/bin/file conftest.$ac_objext` in ++ case `$FILECMD conftest.$ac_objext` in + *32-bit*) + LD="${LD-ld} -melf32bsmip" + ;; +@@ -11109,7 +11418,7 @@ ia64-*-hpux*) + ;; + esac + else +- case `/usr/bin/file conftest.$ac_objext` in ++ case `$FILECMD conftest.$ac_objext` in + *32-bit*) + LD="${LD-ld} -32" + ;; +@@ -11135,7 +11444,7 @@ mips64*-*linux*) + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + emul=elf +- case `/usr/bin/file conftest.$ac_objext` in ++ case `$FILECMD conftest.$ac_objext` in + *32-bit*) + emul="${emul}32" + ;; +@@ -11143,7 +11452,7 @@ mips64*-*linux*) + emul="${emul}64" + ;; + esac +- case `/usr/bin/file conftest.$ac_objext` in ++ case `$FILECMD conftest.$ac_objext` in + *MSB*) + emul="${emul}btsmip" + ;; +@@ -11151,7 +11460,7 @@ mips64*-*linux*) + emul="${emul}ltsmip" + ;; + esac +- case `/usr/bin/file conftest.$ac_objext` in ++ case `$FILECMD conftest.$ac_objext` in + *N32*) + emul="${emul}n32" + ;; +@@ -11175,14 +11484,14 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*) + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then +- case `/usr/bin/file conftest.o` in ++ case `$FILECMD conftest.o` in + *32-bit*) + case $host in + x86_64-*kfreebsd*-gnu) + LD="${LD-ld} -m elf_i386_fbsd" + ;; + x86_64-*linux*) +- case `/usr/bin/file conftest.o` in ++ case `$FILECMD conftest.o` in + *x86-64*) + LD="${LD-ld} -m elf32_x86_64" + ;; +@@ -11290,7 +11599,7 @@ printf "%s\n" "$lt_cv_cc_needs_belf" >&6; } + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then +- case `/usr/bin/file conftest.o` in ++ case `$FILECMD conftest.o` in + *64-bit*) + case $lt_cv_prog_gnu_ld in + yes*) +@@ -12073,8 +12382,8 @@ int forced_loaded() { return 2;} + _LT_EOF + echo "$LTCC $LTCFLAGS -c -o conftest.o conftest.c" >&5 + $LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>&5 +- echo "$AR cr libconftest.a conftest.o" >&5 +- $AR cr libconftest.a conftest.o 2>&5 ++ echo "$AR $AR_FLAGS libconftest.a conftest.o" >&5 ++ $AR $AR_FLAGS libconftest.a conftest.o 2>&5 + echo "$RANLIB libconftest.a" >&5 + $RANLIB libconftest.a 2>&5 + cat > conftest.c << _LT_EOF +@@ -12101,17 +12410,12 @@ printf "%s\n" "$lt_cv_ld_force_load" >&6; } + _lt_dar_allow_undefined='$wl-undefined ${wl}suppress' ;; + darwin1.*) + _lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;; +- darwin*) # darwin 5.x on +- # if running on 10.5 or later, the deployment target defaults +- # to the OS version, if on x86, and 10.4, the deployment +- # target defaults to 10.4. Don't you love it? +- case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in +- 10.0,*86*-darwin8*|10.0,*-darwin[912]*) +- _lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;; +- 10.[012][,.]*) +- _lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;; +- 10.*|11.*) +- _lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;; ++ darwin*) ++ case $MACOSX_DEPLOYMENT_TARGET,$host in ++ 10.[012],*|,*powerpc*-darwin[5-8]*) ++ _lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;; ++ *) ++ _lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;; + esac + ;; + esac +@@ -12944,8 +13248,8 @@ esac + ofile=libtool + can_build_shared=yes + +-# All known linkers require a '.a' archive for static linking (except MSVC, +-# which needs '.lib'). ++# All known linkers require a '.a' archive for static linking (except MSVC and ++# ICC, which need '.lib'). + libext=a + + with_gnu_ld=$lt_cv_prog_gnu_ld +@@ -13463,7 +13767,7 @@ lt_prog_compiler_static= + lt_prog_compiler_static='-qstaticlink' + ;; + *) +- case `$CC -V 2>&1 | sed 5q` in ++ case `$CC -V 2>&1 | $SED 5q` in + *Sun\ Ceres\ Fortran* | *Sun*Fortran*\ [1-7].* | *Sun*Fortran*\ 8.[0-3]*) + # Sun Fortran 8.3 passes all unrecognized flags to the linker + lt_prog_compiler_pic='-KPIC' +@@ -13886,15 +14190,15 @@ printf %s "checking whether the $compiler linker ($LD) supports shared libraries + + case $host_os in + cygwin* | mingw* | pw32* | cegcc*) +- # FIXME: the MSVC++ port hasn't been tested in a loooong time ++ # FIXME: the MSVC++ and ICC port hasn't been tested in a loooong time + # When not using gcc, we currently assume that we are using +- # Microsoft Visual C++. ++ # Microsoft Visual C++ or Intel C++ Compiler. + if test yes != "$GCC"; then + with_gnu_ld=no + fi + ;; + interix*) +- # we just hope/assume this is gcc and not c89 (= MSVC++) ++ # we just hope/assume this is gcc and not c89 (= MSVC++ or ICC) + with_gnu_ld=yes + ;; + openbsd* | bitrig*) +@@ -13949,7 +14253,7 @@ printf %s "checking whether the $compiler linker ($LD) supports shared libraries + whole_archive_flag_spec= + fi + supports_anon_versioning=no +- case `$LD -v | $SED -e 's/(^)\+)\s\+//' 2>&1` in ++ case `$LD -v | $SED -e 's/([^)]\+)\s\+//' 2>&1` in + *GNU\ gold*) supports_anon_versioning=yes ;; + *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11 + *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... +@@ -14061,6 +14365,7 @@ _LT_EOF + emximp -o $lib $output_objdir/$libname.def' + old_archive_From_new_cmds='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def' + enable_shared_with_static_runtimes=yes ++ file_list_spec='@' + ;; + + interix[3-9]*) +@@ -14075,7 +14380,7 @@ _LT_EOF + # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link + # time. Moving up from 0x10000000 also allows more sbrk(2) space. + archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' +- archive_expsym_cmds='sed "s|^|_|" $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--retain-symbols-file,$output_objdir/$soname.expsym $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' ++ archive_expsym_cmds='$SED "s|^|_|" $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--retain-symbols-file,$output_objdir/$soname.expsym $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + ;; + + gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu) +@@ -14118,7 +14423,7 @@ _LT_EOF + compiler_needs_object=yes + ;; + esac +- case `$CC -V 2>&1 | sed 5q` in ++ case `$CC -V 2>&1 | $SED 5q` in + *Sun\ C*) # Sun C 5.9 + whole_archive_flag_spec='$wl--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' + compiler_needs_object=yes +@@ -14130,13 +14435,14 @@ _LT_EOF + + if test yes = "$supports_anon_versioning"; then + archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~ +- cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ ++ cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ + echo "local: *; };" >> $output_objdir/$libname.ver~ + $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-version-script $wl$output_objdir/$libname.ver -o $lib' + fi + + case $cc_basename in + tcc*) ++ hardcode_libdir_flag_spec='$wl-rpath $wl$libdir' + export_dynamic_flag_spec='-rdynamic' + ;; + xlf* | bgf* | bgxlf* | mpixlf*) +@@ -14146,7 +14452,7 @@ _LT_EOF + archive_cmds='$LD -shared $libobjs $deplibs $linker_flags -soname $soname -o $lib' + if test yes = "$supports_anon_versioning"; then + archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~ +- cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ ++ cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ + echo "local: *; };" >> $output_objdir/$libname.ver~ + $LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib' + fi +@@ -14278,7 +14584,7 @@ _LT_EOF + if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then + export_symbols_cmds='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && (substr(\$ 3,1,1) != ".")) { if (\$ 2 == "W") { print \$ 3 " weak" } else { print \$ 3 } } }'\'' | sort -u > $export_symbols' + else +- export_symbols_cmds='`func_echo_all $NM | $SED -e '\''s/B\([^B]*\)$/P\1/'\''` -PCpgl $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) && (substr(\$ 1,1,1) != ".")) { if ((\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) { print \$ 1 " weak" } else { print \$ 1 } } }'\'' | sort -u > $export_symbols' ++ export_symbols_cmds='`func_echo_all $NM | $SED -e '\''s/B\([^B]*\)$/P\1/'\''` -PCpgl $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "L") || (\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) && (substr(\$ 1,1,1) != ".")) { if ((\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) { print \$ 1 " weak" } else { print \$ 1 } } }'\'' | sort -u > $export_symbols' + fi + aix_use_runtimelinking=no + +@@ -14549,12 +14855,12 @@ fi + + cygwin* | mingw* | pw32* | cegcc*) + # When not using gcc, we currently assume that we are using +- # Microsoft Visual C++. ++ # Microsoft Visual C++ or Intel C++ Compiler. + # hardcode_libdir_flag_spec is actually meaningless, as there is + # no search path for DLLs. + case $cc_basename in +- cl*) +- # Native MSVC ++ cl* | icl*) ++ # Native MSVC or ICC + hardcode_libdir_flag_spec=' ' + allow_undefined_flag=unsupported + always_export_symbols=yes +@@ -14595,7 +14901,7 @@ fi + fi' + ;; + *) +- # Assume MSVC wrapper ++ # Assume MSVC and ICC wrapper + hardcode_libdir_flag_spec=' ' + allow_undefined_flag=unsupported + # Tell ltmain to make .lib files, not .a files. +@@ -14636,8 +14942,8 @@ fi + output_verbose_link_cmd=func_echo_all + archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dsymutil" + module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dsymutil" +- archive_expsym_cmds="sed 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dar_export_syms$_lt_dsymutil" +- module_expsym_cmds="sed -e 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dar_export_syms$_lt_dsymutil" ++ archive_expsym_cmds="$SED 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dar_export_syms$_lt_dsymutil" ++ module_expsym_cmds="$SED -e 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dar_export_syms$_lt_dsymutil" + + else + ld_shlibs=no +@@ -14671,7 +14977,7 @@ fi + ;; + + # FreeBSD 3 and greater uses gcc -shared to do shared libraries. +- freebsd* | dragonfly*) ++ freebsd* | dragonfly* | midnightbsd*) + archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' + hardcode_libdir_flag_spec='-R$libdir' + hardcode_direct=yes +@@ -14852,6 +15158,7 @@ printf "%s\n" "$lt_cv_irix_exported_symbol" >&6; } + # Fabrice Bellard et al's Tiny C Compiler + ld_shlibs=yes + archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' ++ hardcode_libdir_flag_spec='$wl-rpath $wl$libdir' + ;; + esac + ;; +@@ -14923,6 +15230,7 @@ printf "%s\n" "$lt_cv_irix_exported_symbol" >&6; } + emximp -o $lib $output_objdir/$libname.def' + old_archive_From_new_cmds='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def' + enable_shared_with_static_runtimes=yes ++ file_list_spec='@' + ;; + + osf3*) +@@ -15615,7 +15923,7 @@ cygwin* | mingw* | pw32* | cegcc*) + case $host_os in + cygwin*) + # Cygwin DLLs use 'cyg' prefix rather than 'lib' +- soname_spec='`echo $libname | sed -e 's/^lib/cyg/'``echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext' ++ soname_spec='`echo $libname | $SED -e 's/^lib/cyg/'``echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext' + + sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api" + ;; +@@ -15625,14 +15933,14 @@ cygwin* | mingw* | pw32* | cegcc*) + ;; + pw32*) + # pw32 DLLs use 'pw' prefix rather than 'lib' +- library_names_spec='`echo $libname | sed -e 's/^lib/pw/'``echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext' ++ library_names_spec='`echo $libname | $SED -e 's/^lib/pw/'``echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext' + ;; + esac + dynamic_linker='Win32 ld.exe' + ;; + +- *,cl*) +- # Native MSVC ++ *,cl* | *,icl*) ++ # Native MSVC or ICC + libname_spec='$name' + soname_spec='$libname`echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext' + library_names_spec='$libname.dll.lib' +@@ -15651,7 +15959,7 @@ cygwin* | mingw* | pw32* | cegcc*) + done + IFS=$lt_save_ifs + # Convert to MSYS style. +- sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | sed -e 's|\\\\|/|g' -e 's| \\([a-zA-Z]\\):| /\\1|g' -e 's|^ ||'` ++ sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's|\\\\|/|g' -e 's| \\([a-zA-Z]\\):| /\\1|g' -e 's|^ ||'` + ;; + cygwin*) + # Convert to unix form, then to dos form, then back to unix form +@@ -15688,7 +15996,7 @@ cygwin* | mingw* | pw32* | cegcc*) + ;; + + *) +- # Assume MSVC wrapper ++ # Assume MSVC and ICC wrapper + library_names_spec='$libname`echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext $libname.lib' + dynamic_linker='Win32 ld.exe' + ;; +@@ -15721,7 +16029,7 @@ dgux*) + shlibpath_var=LD_LIBRARY_PATH + ;; + +-freebsd* | dragonfly*) ++freebsd* | dragonfly* | midnightbsd*) + # DragonFly does not have aout. When/if they implement a new + # versioning mechanism, adjust this. + if test -x /usr/bin/objformat; then +@@ -16886,30 +17194,41 @@ striplib= + old_striplib= + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether stripping libraries is possible" >&5 + printf %s "checking whether stripping libraries is possible... " >&6; } +-if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then +- test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" +- test -z "$striplib" && striplib="$STRIP --strip-unneeded" +- { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +-printf "%s\n" "yes" >&6; } ++if test -z "$STRIP"; then ++ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++printf "%s\n" "no" >&6; } + else +-# FIXME - insert some real tests, host_os isn't really good enough +- case $host_os in +- darwin*) +- if test -n "$STRIP"; then ++ if $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then ++ old_striplib="$STRIP --strip-debug" ++ striplib="$STRIP --strip-unneeded" ++ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 ++printf "%s\n" "yes" >&6; } ++ else ++ case $host_os in ++ darwin*) ++ # FIXME - insert some real tests, host_os isn't really good enough + striplib="$STRIP -x" + old_striplib="$STRIP -S" + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 + printf "%s\n" "yes" >&6; } +- else +- { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++ ;; ++ freebsd*) ++ if $STRIP -V 2>&1 | $GREP "elftoolchain" >/dev/null; then ++ old_striplib="$STRIP --strip-debug" ++ striplib="$STRIP --strip-unneeded" ++ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 ++printf "%s\n" "yes" >&6; } ++ else ++ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 + printf "%s\n" "no" >&6; } +- fi +- ;; +- *) +- { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++ fi ++ ;; ++ *) ++ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 + printf "%s\n" "no" >&6; } +- ;; +- esac ++ ;; ++ esac ++ fi + fi + + +@@ -17679,8 +17998,8 @@ fi + + cygwin* | mingw* | pw32* | cegcc*) + case $GXX,$cc_basename in +- ,cl* | no,cl*) +- # Native MSVC ++ ,cl* | no,cl* | ,icl* | no,icl*) ++ # Native MSVC or ICC + # hardcode_libdir_flag_spec is actually meaningless, as there is + # no search path for DLLs. + hardcode_libdir_flag_spec_CXX=' ' +@@ -17771,11 +18090,11 @@ fi + output_verbose_link_cmd=func_echo_all + archive_cmds_CXX="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dsymutil" + module_cmds_CXX="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dsymutil" +- archive_expsym_cmds_CXX="sed 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dar_export_syms$_lt_dsymutil" +- module_expsym_cmds_CXX="sed -e 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dar_export_syms$_lt_dsymutil" ++ archive_expsym_cmds_CXX="$SED 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dar_export_syms$_lt_dsymutil" ++ module_expsym_cmds_CXX="$SED -e 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dar_export_syms$_lt_dsymutil" + if test yes != "$lt_cv_apple_cc_single_mod"; then + archive_cmds_CXX="\$CC -r -keep_private_externs -nostdlib -o \$lib-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$lib-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring$_lt_dsymutil" +- archive_expsym_cmds_CXX="sed 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \$lib-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$lib-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring$_lt_dar_export_syms$_lt_dsymutil" ++ archive_expsym_cmds_CXX="$SED 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \$lib-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$lib-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring$_lt_dar_export_syms$_lt_dsymutil" + fi + + else +@@ -17810,6 +18129,7 @@ fi + emximp -o $lib $output_objdir/$libname.def' + old_archive_From_new_cmds_CXX='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def' + enable_shared_with_static_runtimes_CXX=yes ++ file_list_spec_CXX='@' + ;; + + dgux*) +@@ -17840,7 +18160,7 @@ fi + archive_cmds_need_lc_CXX=no + ;; + +- freebsd* | dragonfly*) ++ freebsd* | dragonfly* | midnightbsd*) + # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF + # conventions + ld_shlibs_CXX=yes +@@ -17977,7 +18297,7 @@ fi + # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link + # time. Moving up from 0x10000000 also allows more sbrk(2) space. + archive_cmds_CXX='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' +- archive_expsym_cmds_CXX='sed "s|^|_|" $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--retain-symbols-file,$output_objdir/$soname.expsym $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' ++ archive_expsym_cmds_CXX='$SED "s|^|_|" $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--retain-symbols-file,$output_objdir/$soname.expsym $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + ;; + irix5* | irix6*) + case $cc_basename in +@@ -18117,13 +18437,13 @@ fi + archive_cmds_CXX='$CC -qmkshrobj $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + if test yes = "$supports_anon_versioning"; then + archive_expsym_cmds_CXX='echo "{ global:" > $output_objdir/$libname.ver~ +- cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ ++ cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ + echo "local: *; };" >> $output_objdir/$libname.ver~ + $CC -qmkshrobj $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-version-script $wl$output_objdir/$libname.ver -o $lib' + fi + ;; + *) +- case `$CC -V 2>&1 | sed 5q` in ++ case `$CC -V 2>&1 | $SED 5q` in + *Sun\ C*) + # Sun C++ 5.9 + no_undefined_flag_CXX=' -zdefs' +@@ -18780,7 +19100,7 @@ lt_prog_compiler_static_CXX= + ;; + esac + ;; +- freebsd* | dragonfly*) ++ freebsd* | dragonfly* | midnightbsd*) + # FreeBSD uses GNU C++ + ;; + hpux9* | hpux10* | hpux11*) +@@ -18863,7 +19183,7 @@ lt_prog_compiler_static_CXX= + lt_prog_compiler_static_CXX='-qstaticlink' + ;; + *) +- case `$CC -V 2>&1 | sed 5q` in ++ case `$CC -V 2>&1 | $SED 5q` in + *Sun\ C*) + # Sun C++ 5.9 + lt_prog_compiler_pic_CXX='-KPIC' +@@ -19250,7 +19570,7 @@ printf %s "checking whether the $compiler linker ($LD) supports shared libraries + if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then + export_symbols_cmds_CXX='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && (substr(\$ 3,1,1) != ".")) { if (\$ 2 == "W") { print \$ 3 " weak" } else { print \$ 3 } } }'\'' | sort -u > $export_symbols' + else +- export_symbols_cmds_CXX='`func_echo_all $NM | $SED -e '\''s/B\([^B]*\)$/P\1/'\''` -PCpgl $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) && (substr(\$ 1,1,1) != ".")) { if ((\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) { print \$ 1 " weak" } else { print \$ 1 } } }'\'' | sort -u > $export_symbols' ++ export_symbols_cmds_CXX='`func_echo_all $NM | $SED -e '\''s/B\([^B]*\)$/P\1/'\''` -PCpgl $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "L") || (\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) && (substr(\$ 1,1,1) != ".")) { if ((\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) { print \$ 1 " weak" } else { print \$ 1 } } }'\'' | sort -u > $export_symbols' + fi + ;; + pw32*) +@@ -19258,7 +19578,7 @@ printf %s "checking whether the $compiler linker ($LD) supports shared libraries + ;; + cygwin* | mingw* | cegcc*) + case $cc_basename in +- cl*) ++ cl* | icl*) + exclude_expsyms_CXX='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' + ;; + *) +@@ -19609,7 +19929,7 @@ cygwin* | mingw* | pw32* | cegcc*) + case $host_os in + cygwin*) + # Cygwin DLLs use 'cyg' prefix rather than 'lib' +- soname_spec='`echo $libname | sed -e 's/^lib/cyg/'``echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext' ++ soname_spec='`echo $libname | $SED -e 's/^lib/cyg/'``echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext' + + ;; + mingw* | cegcc*) +@@ -19618,14 +19938,14 @@ cygwin* | mingw* | pw32* | cegcc*) + ;; + pw32*) + # pw32 DLLs use 'pw' prefix rather than 'lib' +- library_names_spec='`echo $libname | sed -e 's/^lib/pw/'``echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext' ++ library_names_spec='`echo $libname | $SED -e 's/^lib/pw/'``echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext' + ;; + esac + dynamic_linker='Win32 ld.exe' + ;; + +- *,cl*) +- # Native MSVC ++ *,cl* | *,icl*) ++ # Native MSVC or ICC + libname_spec='$name' + soname_spec='$libname`echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext' + library_names_spec='$libname.dll.lib' +@@ -19644,7 +19964,7 @@ cygwin* | mingw* | pw32* | cegcc*) + done + IFS=$lt_save_ifs + # Convert to MSYS style. +- sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | sed -e 's|\\\\|/|g' -e 's| \\([a-zA-Z]\\):| /\\1|g' -e 's|^ ||'` ++ sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's|\\\\|/|g' -e 's| \\([a-zA-Z]\\):| /\\1|g' -e 's|^ ||'` + ;; + cygwin*) + # Convert to unix form, then to dos form, then back to unix form +@@ -19681,7 +20001,7 @@ cygwin* | mingw* | pw32* | cegcc*) + ;; + + *) +- # Assume MSVC wrapper ++ # Assume MSVC and ICC wrapper + library_names_spec='$libname`echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext $libname.lib' + dynamic_linker='Win32 ld.exe' + ;; +@@ -19713,7 +20033,7 @@ dgux*) + shlibpath_var=LD_LIBRARY_PATH + ;; + +-freebsd* | dragonfly*) ++freebsd* | dragonfly* | midnightbsd*) + # DragonFly does not have aout. When/if they implement a new + # versioning mechanism, adjust this. + if test -x /usr/bin/objformat; then +@@ -21736,8 +22056,8 @@ squeeze() { + INTEL_UNIX_C) + # + tmp_CFLAGS="$tmp_CFLAGS -std=gnu89" +- tmp_CPPFLAGS="$tmp_CPPFLAGS -we 140,147,165,266" +- tmp_CPPFLAGS="$tmp_CPPFLAGS -wd 279,981,1469" ++ tmp_CPPFLAGS="$tmp_CPPFLAGS -diag-error 140,147,165,266" ++ tmp_CPPFLAGS="$tmp_CPPFLAGS -diag-disable 279,981,1469" + ;; + # + INTEL_WINDOWS_C) +@@ -24543,7 +24863,83 @@ fi + + + +-STDC_HEADERS ++# Autoupdate added the next two lines to ensure that your configure ++# script's behavior did not change. They are probably safe to remove. ++ ++{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 ++printf %s "checking for egrep... " >&6; } ++if test ${ac_cv_path_EGREP+y} ++then : ++ printf %s "(cached) " >&6 ++else $as_nop ++ if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 ++ then ac_cv_path_EGREP="$GREP -E" ++ else ++ if test -z "$EGREP"; then ++ ac_path_EGREP_found=false ++ # Loop through the user's path and test for each of PROGNAME-LIST ++ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR ++for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin ++do ++ IFS=$as_save_IFS ++ case $as_dir in #((( ++ '') as_dir=./ ;; ++ */) ;; ++ *) as_dir=$as_dir/ ;; ++ esac ++ for ac_prog in egrep ++ do ++ for ac_exec_ext in '' $ac_executable_extensions; do ++ ac_path_EGREP="$as_dir$ac_prog$ac_exec_ext" ++ as_fn_executable_p "$ac_path_EGREP" || continue ++# Check for GNU ac_path_EGREP and select it if it is found. ++ # Check for GNU $ac_path_EGREP ++case `"$ac_path_EGREP" --version 2>&1` in ++*GNU*) ++ ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; ++*) ++ ac_count=0 ++ printf %s 0123456789 >"conftest.in" ++ while : ++ do ++ cat "conftest.in" "conftest.in" >"conftest.tmp" ++ mv "conftest.tmp" "conftest.in" ++ cp "conftest.in" "conftest.nl" ++ printf "%s\n" 'EGREP' >> "conftest.nl" ++ "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break ++ diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break ++ as_fn_arith $ac_count + 1 && ac_count=$as_val ++ if test $ac_count -gt ${ac_path_EGREP_max-0}; then ++ # Best one so far, save it but keep looking for a better one ++ ac_cv_path_EGREP="$ac_path_EGREP" ++ ac_path_EGREP_max=$ac_count ++ fi ++ # 10*(2^10) chars as input seems more than enough ++ test $ac_count -gt 10 && break ++ done ++ rm -f conftest.in conftest.tmp conftest.nl conftest.out;; ++esac ++ ++ $ac_path_EGREP_found && break 3 ++ done ++ done ++ done ++IFS=$as_save_IFS ++ if test -z "$ac_cv_path_EGREP"; then ++ as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 ++ fi ++else ++ ac_cv_path_EGREP=$EGREP ++fi ++ ++ fi ++fi ++{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 ++printf "%s\n" "$ac_cv_path_EGREP" >&6; } ++ EGREP="$ac_cv_path_EGREP" ++ ++ ++ + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 + printf %s "checking for egrep... " >&6; } +@@ -32800,6 +33196,166 @@ printf "%s\n" "no" >&6; } + fi + + ++ # ++ tst_links_arc4random_buf="unknown" ++ tst_proto_arc4random_buf="unknown" ++ tst_compi_arc4random_buf="unknown" ++ tst_allow_arc4random_buf="unknown" ++ # ++ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if arc4random_buf can be linked" >&5 ++printf %s "checking if arc4random_buf can be linked... " >&6; } ++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ ++ ++ /* Define arc4random_buf to an innocuous variant, in case declares arc4random_buf. ++ For example, HP-UX 11i declares gettimeofday. */ ++#define arc4random_buf innocuous_arc4random_buf ++ ++/* System header to define __stub macros and hopefully few prototypes, ++ which can conflict with char arc4random_buf (); below. */ ++ ++#include ++#undef arc4random_buf ++ ++/* Override any GCC internal prototype to avoid an error. ++ Use char because int might match the return type of a GCC ++ builtin and then its argument prototype would still apply. */ ++#ifdef __cplusplus ++extern "C" ++#endif ++char arc4random_buf (); ++/* The GNU C library defines this for functions which it implements ++ to always fail with ENOSYS. Some functions are actually named ++ something starting with __ and the normal name is an alias. */ ++#if defined __stub_arc4random_buf || defined __stub___arc4random_buf ++choke me ++#endif ++ ++int ++main (void) ++{ ++return arc4random_buf (); ++ ; ++ return 0; ++} ++ ++_ACEOF ++if ac_fn_c_try_link "$LINENO" ++then : ++ ++ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 ++printf "%s\n" "yes" >&6; } ++ tst_links_arc4random_buf="yes" ++ ++else $as_nop ++ ++ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++printf "%s\n" "no" >&6; } ++ tst_links_arc4random_buf="no" ++ ++fi ++rm -f core conftest.err conftest.$ac_objext conftest.beam \ ++ conftest$ac_exeext conftest.$ac_ext ++ # ++ if test "$tst_links_arc4random_buf" = "yes"; then ++ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if arc4random_buf is prototyped" >&5 ++printf %s "checking if arc4random_buf is prototyped... " >&6; } ++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ ++ ++ $cares_includes_stdlib ++ ++_ACEOF ++if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | ++ $EGREP "arc4random_buf" >/dev/null 2>&1 ++then : ++ ++ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 ++printf "%s\n" "yes" >&6; } ++ tst_proto_arc4random_buf="yes" ++ ++else $as_nop ++ ++ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++printf "%s\n" "no" >&6; } ++ tst_proto_arc4random_buf="no" ++ ++fi ++rm -rf conftest* ++ ++ fi ++ # ++ if test "$tst_proto_arc4random_buf" = "yes"; then ++ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if arc4random_buf is compilable" >&5 ++printf %s "checking if arc4random_buf is compilable... " >&6; } ++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ ++ ++ ++ $cares_includes_stdlib ++ ++int ++main (void) ++{ ++ ++ arc4random_buf(NULL, 0); ++ return 1; ++ ++ ; ++ return 0; ++} ++ ++_ACEOF ++if ac_fn_c_try_compile "$LINENO" ++then : ++ ++ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 ++printf "%s\n" "yes" >&6; } ++ tst_compi_arc4random_buf="yes" ++ ++else $as_nop ++ ++ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++printf "%s\n" "no" >&6; } ++ tst_compi_arc4random_buf="no" ++ ++fi ++rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext ++ fi ++ # ++ if test "$tst_compi_arc4random_buf" = "yes"; then ++ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if arc4random_buf usage allowed" >&5 ++printf %s "checking if arc4random_buf usage allowed... " >&6; } ++ if test "x$cares_disallow_arc4random_buf" != "xyes"; then ++ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 ++printf "%s\n" "yes" >&6; } ++ tst_allow_arc4random_buf="yes" ++ else ++ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++printf "%s\n" "no" >&6; } ++ tst_allow_arc4random_buf="no" ++ fi ++ fi ++ # ++ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if arc4random_buf might be used" >&5 ++printf %s "checking if arc4random_buf might be used... " >&6; } ++ if test "$tst_links_arc4random_buf" = "yes" && ++ test "$tst_proto_arc4random_buf" = "yes" && ++ test "$tst_compi_arc4random_buf" = "yes" && ++ test "$tst_allow_arc4random_buf" = "yes"; then ++ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 ++printf "%s\n" "yes" >&6; } ++ ++printf "%s\n" "#define HAVE_ARC4RANDOM_BUF 1" >>confdefs.h ++ ++ ac_cv_func_arc4random_buf="yes" ++ else ++ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++printf "%s\n" "no" >&6; } ++ ac_cv_func_arc4random_buf="no" ++ fi ++ ++ + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for PF_INET6" >&5 +@@ -33738,37 +34294,7 @@ if test ${with_random+y} + then : + withval=$with_random; CARES_RANDOM_FILE="$withval" + else $as_nop +- +- if test "$cross_compiling" = "no"; then +- as_ac_File=`printf "%s\n" "ac_cv_file_"/dev/urandom"" | $as_tr_sh` +-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for \"/dev/urandom\"" >&5 +-printf %s "checking for \"/dev/urandom\"... " >&6; } +-if eval test \${$as_ac_File+y} +-then : +- printf %s "(cached) " >&6 +-else $as_nop +- test "$cross_compiling" = yes && +- as_fn_error $? "cannot check for file existence when cross compiling" "$LINENO" 5 +-if test -r ""/dev/urandom""; then +- eval "$as_ac_File=yes" +-else +- eval "$as_ac_File=no" +-fi +-fi +-eval ac_res=\$$as_ac_File +- { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +-printf "%s\n" "$ac_res" >&6; } +-if eval test \"x\$"$as_ac_File"\" = x"yes" +-then : + CARES_RANDOM_FILE="/dev/urandom" +-fi +- +- else +- { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: cannot check for /dev/urandom while cross compiling; assuming none" >&5 +-printf "%s\n" "$as_me: WARNING: cannot check for /dev/urandom while cross compiling; assuming none" >&2;} +- fi +- +- + + fi + +@@ -34652,7 +35178,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 + # report actual input values of CONFIG_FILES etc. instead of their + # values after options handling. + ac_log=" +-This file was extended by c-ares $as_me 1.18.1, which was ++This file was extended by c-ares $as_me 1.19.1, which was + generated by GNU Autoconf 2.71. Invocation command line was + + CONFIG_FILES = $CONFIG_FILES +@@ -34720,7 +35246,7 @@ ac_cs_config_escaped=`printf "%s\n" "$ac_cs_config" | sed "s/^ //; s/'/'\\\\\\\\ + cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 + ac_cs_config='$ac_cs_config_escaped' + ac_cs_version="\\ +-c-ares config.status 1.18.1 ++c-ares config.status 1.19.1 + configured by $0, generated by GNU Autoconf 2.71, + with options \\"\$ac_cs_config\\" + +@@ -34886,12 +35412,14 @@ lt_cv_to_host_file_cmd='`$ECHO "$lt_cv_to_host_file_cmd" | $SED "$delay_single_q + lt_cv_to_tool_file_cmd='`$ECHO "$lt_cv_to_tool_file_cmd" | $SED "$delay_single_quote_subst"`' + reload_flag='`$ECHO "$reload_flag" | $SED "$delay_single_quote_subst"`' + reload_cmds='`$ECHO "$reload_cmds" | $SED "$delay_single_quote_subst"`' ++FILECMD='`$ECHO "$FILECMD" | $SED "$delay_single_quote_subst"`' + deplibs_check_method='`$ECHO "$deplibs_check_method" | $SED "$delay_single_quote_subst"`' + file_magic_cmd='`$ECHO "$file_magic_cmd" | $SED "$delay_single_quote_subst"`' + file_magic_glob='`$ECHO "$file_magic_glob" | $SED "$delay_single_quote_subst"`' + want_nocaseglob='`$ECHO "$want_nocaseglob" | $SED "$delay_single_quote_subst"`' + sharedlib_from_linklib_cmd='`$ECHO "$sharedlib_from_linklib_cmd" | $SED "$delay_single_quote_subst"`' + AR='`$ECHO "$AR" | $SED "$delay_single_quote_subst"`' ++lt_ar_flags='`$ECHO "$lt_ar_flags" | $SED "$delay_single_quote_subst"`' + AR_FLAGS='`$ECHO "$AR_FLAGS" | $SED "$delay_single_quote_subst"`' + archiver_list_spec='`$ECHO "$archiver_list_spec" | $SED "$delay_single_quote_subst"`' + STRIP='`$ECHO "$STRIP" | $SED "$delay_single_quote_subst"`' +@@ -35069,13 +35597,13 @@ LN_S \ + lt_SP2NL \ + lt_NL2SP \ + reload_flag \ ++FILECMD \ + deplibs_check_method \ + file_magic_cmd \ + file_magic_glob \ + want_nocaseglob \ + sharedlib_from_linklib_cmd \ + AR \ +-AR_FLAGS \ + archiver_list_spec \ + STRIP \ + RANLIB \ +@@ -36077,6 +36605,9 @@ to_host_file_cmd=$lt_cv_to_host_file_cmd + # convert \$build files to toolchain format. + to_tool_file_cmd=$lt_cv_to_tool_file_cmd + ++# A file(cmd) program that detects file types. ++FILECMD=$lt_FILECMD ++ + # Method to check whether dependent libraries are shared objects. + deplibs_check_method=$lt_deplibs_check_method + +@@ -36095,8 +36626,11 @@ sharedlib_from_linklib_cmd=$lt_sharedlib_from_linklib_cmd + # The archiver. + AR=$lt_AR + ++# Flags to create an archive (by configure). ++lt_ar_flags=$lt_ar_flags ++ + # Flags to create an archive. +-AR_FLAGS=$lt_AR_FLAGS ++AR_FLAGS=\${ARFLAGS-"\$lt_ar_flags"} + + # How to feed a file listing to the archiver. + archiver_list_spec=$lt_archiver_list_spec +@@ -36486,7 +37020,7 @@ ltmain=$ac_aux_dir/ltmain.sh + # if finds mixed CR/LF and LF-only lines. Since sed operates in + # text mode, it properly converts lines to CR/LF. This bash problem + # is reportedly fixed, but why not run on old versions too? +- sed '$q' "$ltmain" >> "$cfgfile" \ ++ $SED '$q' "$ltmain" >> "$cfgfile" \ + || (rm -f "$cfgfile"; exit 1) + + mv -f "$cfgfile" "$ofile" || +diff --git a/deps/cares/configure.ac b/deps/cares/configure.ac +index 1d0fb5c..54e79d6 100644 +--- a/deps/cares/configure.ac ++++ b/deps/cares/configure.ac +@@ -1,9 +1,9 @@ + AC_PREREQ([2.60]) + +-AC_INIT([c-ares], [1.18.1], ++AC_INIT([c-ares], [1.19.1], + [c-ares mailing list: http://lists.haxx.se/listinfo/c-ares]) + +-CARES_VERSION_INFO="7:1:5" ++CARES_VERSION_INFO="8:1:6" + dnl This flag accepts an argument of the form current[:revision[:age]]. So, + dnl passing -version-info 3:12:1 sets current to 3, revision to 12, and age to + dnl 1. +@@ -493,7 +493,7 @@ dnl Back to "normal" configuring + dnl ********************************************************************** + + dnl Checks for header files. +-STDC_HEADERS ++AC_HEADER_STDC + + AC_PROG_EGREP + +@@ -683,6 +683,7 @@ CARES_CHECK_FUNC_STRNCASECMP + CARES_CHECK_FUNC_STRNCMPI + CARES_CHECK_FUNC_STRNICMP + CARES_CHECK_FUNC_WRITEV ++CARES_CHECK_FUNC_ARC4RANDOM_BUF + + + dnl check for AF_INET6 +@@ -896,17 +897,7 @@ AC_ARG_WITH(random, + AS_HELP_STRING([--with-random=FILE], + [read randomness from FILE (default=/dev/urandom)]), + [ CARES_RANDOM_FILE="$withval" ], +- [ +- dnl Check for random device. If we're cross compiling, we can't +- dnl check, and it's better to assume it doesn't exist than it is +- dnl to fail on AC_CHECK_FILE or later. +- if test "$cross_compiling" = "no"; then +- AC_CHECK_FILE("/dev/urandom", [ CARES_RANDOM_FILE="/dev/urandom"] ) +- else +- AC_MSG_WARN([cannot check for /dev/urandom while cross compiling; assuming none]) +- fi +- +- ] ++ [ CARES_RANDOM_FILE="/dev/urandom" ] + ) + if test -n "$CARES_RANDOM_FILE" && test X"$CARES_RANDOM_FILE" != Xno ; then + AC_SUBST(CARES_RANDOM_FILE) +diff --git a/deps/cares/docs/Makefile.in b/deps/cares/docs/Makefile.in +index b4e656e..b169b2a 100644 +--- a/deps/cares/docs/Makefile.in ++++ b/deps/cares/docs/Makefile.in +@@ -99,6 +99,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_ac_append_to_file.m4 \ + $(top_srcdir)/m4/ax_am_macros_static.m4 \ + $(top_srcdir)/m4/ax_check_gnu_make.m4 \ + $(top_srcdir)/m4/ax_code_coverage.m4 \ ++ $(top_srcdir)/m4/ax_cxx_compile_stdcxx.m4 \ + $(top_srcdir)/m4/ax_cxx_compile_stdcxx_11.m4 \ + $(top_srcdir)/m4/ax_file_escapes.m4 \ + $(top_srcdir)/m4/ax_require_defined.m4 \ +@@ -224,6 +225,7 @@ EGREP = @EGREP@ + ETAGS = @ETAGS@ + EXEEXT = @EXEEXT@ + FGREP = @FGREP@ ++FILECMD = @FILECMD@ + GCOV = @GCOV@ + GENHTML = @GENHTML@ + GREP = @GREP@ +diff --git a/deps/cares/docs/acountry.1 b/deps/cares/docs/acountry.1 +index 8c3aaea..ab5ab3d 100644 +--- a/deps/cares/docs/acountry.1 ++++ b/deps/cares/docs/acountry.1 +@@ -17,7 +17,7 @@ This utility comes with the \fBc\-ares\fR asynchronous resolver library. + \fB\-d\fR + Print some extra debugging output. + .TP +-\fB\-h\fR, \fB\-\-help\fR ++\fB\-h\fR, \fB\-?\fR + Display this help and exit. + .TP + \fB\-v\fR +diff --git a/deps/cares/docs/adig.1 b/deps/cares/docs/adig.1 +index 2056b95..52ff49b 100644 +--- a/deps/cares/docs/adig.1 ++++ b/deps/cares/docs/adig.1 +@@ -18,34 +18,40 @@ This utility comes with the \fBc\-ares\fR asynchronous resolver library. + \fB\-c\fR class + Set the query class. + Possible values for class are +-NY, CHAOS, HS, IN (default). ++ANY, CHAOS, HS and IN (default). + .TP + \fB\-d\fR + Print some extra debugging output. + .TP + \fB\-f\fR flag +-Add a flag. ++Add a behavior control flag. + Possible values for flag are +-igntc, noaliases, norecurse, primary, stayopen, usevc. ++ igntc - ignore to query in TCP to get truncated UDP answer, ++ noaliases - don't honor the HOSTALIASES environment variable, ++ norecurse - don't query upstream servers recursively, ++ primary - use the first server, ++ stayopen - don't close the communication sockets, and ++ usevc - always use TCP. + .TP +-\fB\-h\fR, \fB\-\-help\fR ++\fB\-h\fR, \fB\-?\fR + Display this help and exit. + .TP +-\fB\-T\fR port +-Use specified TCP port to connect to DNS server. +-.TP + \fB\-s\fR server + Connect to specified DNS server, instead of the system's default one(s). ++Servers are tried in round-robin, if the previous one failed. + .TP + \fB\-t\fR type + Query records of specified type. + Possible values for type are + A (default), AAAA, AFSDB, ANY, AXFR, CNAME, GPOS, HINFO, ISDN, KEY, LOC, MAILA, + MAILB, MB, MD, MF, MG, MINFO, MR, MX, NAPTR, NS, NSAP, NSAP_PTR, NULL, +-PTR, PX, RP, RT, SIG, SOA, SRV, TXT, URI, WKS, X25, ++PTR, PX, RP, RT, SIG, SOA, SRV, TXT, URI, WKS and X25. ++.TP ++\fB\-T\fR port ++Connect to the specified TCP port of DNS server. + .TP + \fB\-U\fR port +-Use specified UDP port to connect to DNS server. ++Connect to the specified UDP port of DNS server. + .TP + \fB\-x\fR + For an IPv4 \fB-t PTR a.b.c.d\fR lookup, query for +diff --git a/deps/cares/docs/ahost.1 b/deps/cares/docs/ahost.1 +index 430af82..07d9d1d 100644 +--- a/deps/cares/docs/ahost.1 ++++ b/deps/cares/docs/ahost.1 +@@ -17,7 +17,7 @@ This utility comes with the \fBc\-ares\fR asynchronous resolver library. + \fB\-d\fR + Print some extra debugging output. + .TP +-\fB\-h\fR, \fB\-\-help\fR ++\fB\-h\fR, \fB\-?\fR + Display this help and exit. + .TP + \fB\-t\fR type +diff --git a/deps/cares/docs/ares_destroy_options.3 b/deps/cares/docs/ares_destroy_options.3 +index 31e346b..d3779b6 100644 +--- a/deps/cares/docs/ares_destroy_options.3 ++++ b/deps/cares/docs/ares_destroy_options.3 +@@ -18,9 +18,9 @@ + ares_destroy_options \- Destroy options initialized with ares_save_options + .SH SYNOPSIS + .nf +-.B #include +-.PP +-.B void ares_destroy_options(struct ares_options *\fIoptions\fP) ++#include ++ ++void ares_destroy_options(struct ares_options *\fIoptions\fP) + .fi + .SH DESCRIPTION + The \fBares_destroy_options(3)\fP function destroys the options struct +diff --git a/deps/cares/docs/ares_dup.3 b/deps/cares/docs/ares_dup.3 +index e64c104..925c0cd 100644 +--- a/deps/cares/docs/ares_dup.3 ++++ b/deps/cares/docs/ares_dup.3 +@@ -18,9 +18,9 @@ + ares_dup \- Duplicate a resolver channel + .SH SYNOPSIS + .nf +-.B #include +-.PP +-.B int ares_dup(ares_channel *\fIdest\fP, ares_channel \fIsource\fP) ++#include ++ ++int ares_dup(ares_channel *\fIdest\fP, ares_channel \fIsource\fP) + .fi + .SH DESCRIPTION + The \fBares_dup(3)\fP function duplicates an existing communications channel +diff --git a/deps/cares/docs/ares_expand_name.3 b/deps/cares/docs/ares_expand_name.3 +index fc18df3..e750ab8 100644 +--- a/deps/cares/docs/ares_expand_name.3 ++++ b/deps/cares/docs/ares_expand_name.3 +@@ -18,11 +18,11 @@ + ares_expand_name \- Expand a DNS-encoded domain name + .SH SYNOPSIS + .nf +-.B #include +-.PP +-.B int ares_expand_name(const unsigned char *\fIencoded\fP, +-.B const unsigned char *\fIabuf\fP, int \fIalen\fP, char **\fIs\fP, +-.B long *\fIenclen\fP) ++#include ++ ++int ares_expand_name(const unsigned char *\fIencoded\fP, ++ const unsigned char *\fIabuf\fP, int \fIalen\fP, ++ char **\fIs\fP, long *\fIenclen\fP) + .fi + .SH DESCRIPTION + The +diff --git a/deps/cares/docs/ares_expand_string.3 b/deps/cares/docs/ares_expand_string.3 +index 33dd7bd..8903742 100644 +--- a/deps/cares/docs/ares_expand_string.3 ++++ b/deps/cares/docs/ares_expand_string.3 +@@ -18,11 +18,11 @@ + ares_expand_string \- Expand a length encoded string + .SH SYNOPSIS + .nf +-.B #include +-.PP +-.B int ares_expand_string(const unsigned char *\fIencoded\fP, +-.B const unsigned char *\fIabuf\fP, int \fIalen\fP, unsigned char **\fIs\fP, +-.B long *\fIenclen\fP) ++#include ++ ++int ares_expand_string(const unsigned char *\fIencoded\fP, ++ const unsigned char *\fIabuf\fP, int \fIalen\fP, ++ unsigned char **\fIs\fP, long *\fIenclen\fP) + .fi + .SH DESCRIPTION + The +diff --git a/deps/cares/docs/ares_free_data.3 b/deps/cares/docs/ares_free_data.3 +index 18e83ce..a6f3938 100644 +--- a/deps/cares/docs/ares_free_data.3 ++++ b/deps/cares/docs/ares_free_data.3 +@@ -19,11 +19,9 @@ + ares_free_data \- Free data allocated by several c-ares functions + .SH SYNOPSIS + .nf +-.B #include +-.PP +-.B void ares_free_data(void *\fIdataptr\fP) +-.PP +-.B cc file.c -lcares ++#include ++ ++void ares_free_data(void *\fIdataptr\fP) + .fi + .SH DESCRIPTION + .PP +diff --git a/deps/cares/docs/ares_free_hostent.3 b/deps/cares/docs/ares_free_hostent.3 +index d692801..7c92724 100644 +--- a/deps/cares/docs/ares_free_hostent.3 ++++ b/deps/cares/docs/ares_free_hostent.3 +@@ -18,9 +18,9 @@ + ares_free_hostent \- Free host structure allocated by ares functions + .SH SYNOPSIS + .nf +-.B #include +-.PP +-.B void ares_free_hostent(struct hostent *\fIhost\fP) ++#include ++ ++void ares_free_hostent(struct hostent *\fIhost\fP) + .fi + .SH DESCRIPTION + The +diff --git a/deps/cares/docs/ares_free_string.3 b/deps/cares/docs/ares_free_string.3 +index 61d88aa..d8a8e46 100644 +--- a/deps/cares/docs/ares_free_string.3 ++++ b/deps/cares/docs/ares_free_string.3 +@@ -18,9 +18,9 @@ + ares_free_string \- Free strings allocated by ares functions + .SH SYNOPSIS + .nf +-.B #include +-.PP +-.B void ares_free_string(void *\fIstr\fP) ++#include ++ ++void ares_free_string(void *\fIstr\fP) + .fi + .SH DESCRIPTION + The \fIares_free_string(3)\fP function frees a string allocated by an ares +diff --git a/deps/cares/docs/ares_get_servers.3 b/deps/cares/docs/ares_get_servers.3 +index d606428..eb5861b 100644 +--- a/deps/cares/docs/ares_get_servers.3 ++++ b/deps/cares/docs/ares_get_servers.3 +@@ -19,10 +19,13 @@ + ares_get_servers, ares_get_servers_ports \- Retrieve name servers from an initialized ares_channel + .SH SYNOPSIS + .nf +-.B #include +-.PP +-.B int ares_get_servers(ares_channel \fIchannel\fP, struct ares_addr_node **\fIservers\fP) +-.B int ares_get_servers_ports(ares_channel \fIchannel\fP, struct ares_addr_port_node **\fIservers\fP) ++#include ++ ++int ares_get_servers(ares_channel \fIchannel\fP, ++ struct ares_addr_node **\fIservers\fP) ++ ++int ares_get_servers_ports(ares_channel \fIchannel\fP, ++ struct ares_addr_port_node **\fIservers\fP) + .fi + .SH DESCRIPTION + The \fBares_get_servers(3)\fP function retrieves name servers configuration +diff --git a/deps/cares/docs/ares_getaddrinfo.3 b/deps/cares/docs/ares_getaddrinfo.3 +index 33c8a50..eb085e5 100644 +--- a/deps/cares/docs/ares_getaddrinfo.3 ++++ b/deps/cares/docs/ares_getaddrinfo.3 +@@ -18,14 +18,16 @@ + ares_getaddrinfo \- Initiate a host query by name and service + .SH SYNOPSIS + .nf +-.B #include +-.PP +-.B typedef void (*ares_addrinfo_callback)(void *\fIarg\fP, int \fIstatus\fP, +-.B int \fItimeouts\fP, struct ares_addrinfo *\fIresult\fP) +-.PP +-.B void ares_getaddrinfo(ares_channel \fIchannel\fP, const char *\fIname\fP, +-.B const char* \fIservice\fP, const struct ares_addrinfo_hints *\fIhints\fP, +-.B ares_addrinfo_callback \fIcallback\fP, void *\fIarg\fP) ++#include ++ ++typedef void (*ares_addrinfo_callback)(void *\fIarg\fP, int \fIstatus\fP, ++ int \fItimeouts\fP, ++ struct ares_addrinfo *\fIresult\fP) ++ ++void ares_getaddrinfo(ares_channel \fIchannel\fP, const char *\fIname\fP, ++ const char* \fIservice\fP, ++ const struct ares_addrinfo_hints *\fIhints\fP, ++ ares_addrinfo_callback \fIcallback\fP, void *\fIarg\fP) + .fi + .SH DESCRIPTION + The +diff --git a/deps/cares/docs/ares_gethostbyaddr.3 b/deps/cares/docs/ares_gethostbyaddr.3 +index 7727307..c58ca50 100644 +--- a/deps/cares/docs/ares_gethostbyaddr.3 ++++ b/deps/cares/docs/ares_gethostbyaddr.3 +@@ -18,14 +18,15 @@ + ares_gethostbyaddr \- Initiate a host query by address + .SH SYNOPSIS + .nf +-.B #include +-.PP +-.B typedef void (*ares_host_callback)(void *\fIarg\fP, int \fIstatus\fP, +-.B int \fItimeouts\fP, struct hostent *\fIhostent\fP) +-.PP +-.B void ares_gethostbyaddr(ares_channel \fIchannel\fP, const void *\fIaddr\fP, +-.B int \fIaddrlen\fP, int \fIfamily\fP, ares_host_callback \fIcallback\fP, +-.B void *\fIarg\fP) ++#include ++ ++typedef void (*ares_host_callback)(void *\fIarg\fP, int \fIstatus\fP, ++ int \fItimeouts\fP, ++ struct hostent *\fIhostent\fP) ++ ++void ares_gethostbyaddr(ares_channel \fIchannel\fP, const void *\fIaddr\fP, ++ int \fIaddrlen\fP, int \fIfamily\fP, ++ ares_host_callback \fIcallback\fP, void *\fIarg\fP) + .fi + .SH DESCRIPTION + The +diff --git a/deps/cares/docs/ares_gethostbyname.3 b/deps/cares/docs/ares_gethostbyname.3 +index cfd6a0a..5b4d970 100644 +--- a/deps/cares/docs/ares_gethostbyname.3 ++++ b/deps/cares/docs/ares_gethostbyname.3 +@@ -18,13 +18,15 @@ + ares_gethostbyname \- Initiate a host query by name + .SH SYNOPSIS + .nf +-.B #include +-.PP +-.B typedef void (*ares_host_callback)(void *\fIarg\fP, int \fIstatus\fP, +-.B int \fItimeouts\fP, struct hostent *\fIhostent\fP) +-.PP +-.B void ares_gethostbyname(ares_channel \fIchannel\fP, const char *\fIname\fP, +-.B int \fIfamily\fP, ares_host_callback \fIcallback\fP, void *\fIarg\fP) ++#include ++ ++typedef void (*ares_host_callback)(void *\fIarg\fP, int \fIstatus\fP, ++ int \fItimeouts\fP, ++ struct hostent *\fIhostent\fP) ++ ++void ares_gethostbyname(ares_channel \fIchannel\fP, const char *\fIname\fP, ++ int \fIfamily\fP, ares_host_callback \fIcallback\fP, ++ void *\fIarg\fP) + .fi + .SH DESCRIPTION + The +diff --git a/deps/cares/docs/ares_gethostbyname_file.3 b/deps/cares/docs/ares_gethostbyname_file.3 +index 8f59b41..ab127fc 100644 +--- a/deps/cares/docs/ares_gethostbyname_file.3 ++++ b/deps/cares/docs/ares_gethostbyname_file.3 +@@ -18,10 +18,10 @@ + ares_gethostbyname_file \- Lookup a name in the system's hosts file + .SH SYNOPSIS + .nf +-.B #include +-.PP +-.B int ares_gethostbyname_file(ares_channel \fIchannel\fP, const char *\fIname\fP, +-.B int \fIfamily\fP, struct hostent **host) ++#include ++ ++int ares_gethostbyname_file(ares_channel \fIchannel\fP, const char *\fIname\fP, ++ int \fIfamily\fP, struct hostent **host) + .fi + .SH DESCRIPTION + The +diff --git a/deps/cares/docs/ares_getnameinfo.3 b/deps/cares/docs/ares_getnameinfo.3 +index 1017432..d10d841 100644 +--- a/deps/cares/docs/ares_getnameinfo.3 ++++ b/deps/cares/docs/ares_getnameinfo.3 +@@ -18,14 +18,15 @@ + ares_getnameinfo \- Address-to-nodename translation in protocol-independent manner + .SH SYNOPSIS + .nf +-.B #include +-.PP +-.B typedef void (*ares_nameinfo_callback)(void *\fIarg\fP, int \fIstatus\fP, +-.B int \fItimeouts\fP, char *\fInode\fP, char *\fIservice\fP) +-.PP +-.B void ares_getnameinfo(ares_channel \fIchannel\fP, const struct sockaddr *\fIsa\fP, +-.B ares_socklen_t \fIsalen\fP, int \fIflags\fP, ares_nameinfo_callback \fIcallback\fP, +-.B void *\fIarg\fP) ++#include ++ ++typedef void (*ares_nameinfo_callback)(void *\fIarg\fP, int \fIstatus\fP, ++ int \fItimeouts\fP, char *\fInode\fP, ++ char *\fIservice\fP) ++ ++void ares_getnameinfo(ares_channel \fIchannel\fP, const struct sockaddr *\fIsa\fP, ++ ares_socklen_t \fIsalen\fP, int \fIflags\fP, ++ ares_nameinfo_callback \fIcallback\fP, void *\fIarg\fP) + .fi + .SH DESCRIPTION + The +diff --git a/deps/cares/docs/ares_getsock.3 b/deps/cares/docs/ares_getsock.3 +index 1373291..7908dae 100644 +--- a/deps/cares/docs/ares_getsock.3 ++++ b/deps/cares/docs/ares_getsock.3 +@@ -18,10 +18,10 @@ + ares_getsock \- get socket descriptors to wait on + .SH SYNOPSIS + .nf +-.B #include +-.PP +-.B int ares_getsock(ares_channel \fIchannel\fP, ares_socket_t *\fIsocks\fP, +-.B int \fInumsocks\fP); ++#include ++ ++int ares_getsock(ares_channel \fIchannel\fP, ares_socket_t *\fIsocks\fP, ++ int \fInumsocks\fP); + .fi + .SH DESCRIPTION + The +diff --git a/deps/cares/docs/ares_inet_ntop.3 b/deps/cares/docs/ares_inet_ntop.3 +index 93ee09c..d0d0b59 100644 +--- a/deps/cares/docs/ares_inet_ntop.3 ++++ b/deps/cares/docs/ares_inet_ntop.3 +@@ -18,10 +18,10 @@ + ares_inet_ntop \- convert a network format address to presentation format + .SH SYNOPSIS + .nf +-.B #include +-.PP +-.B const char * +-.B ares_inet_ntop(int af, const void *src, char *dst, ares_socklen_t size); ++#include ++ ++const char *ares_inet_ntop(int \fIaf\fP, const void *\fIsrc\fP, char *\fIdst\fP, ++ ares_socklen_t \fIsize\fP); + .fi + .SH DESCRIPTION + This is a portable version with the identical functionality of the commonly +diff --git a/deps/cares/docs/ares_inet_pton.3 b/deps/cares/docs/ares_inet_pton.3 +index b7d86bb..bf7140d 100644 +--- a/deps/cares/docs/ares_inet_pton.3 ++++ b/deps/cares/docs/ares_inet_pton.3 +@@ -18,9 +18,9 @@ + ares_inet_pton \- convert an IPv4 or IPv6 address from text to binary form + .SH SYNOPSIS + .nf +-.B #include +-.PP +-.B const char *ares_inet_pton(int af, const char *src, void *dst); ++#include ++ ++const char *ares_inet_pton(int \fIaf\fP, const char *\fIsrc\fP, void *\fIdst\fP); + .fi + .SH DESCRIPTION + This is a portable version with the identical functionality of the commonly +diff --git a/deps/cares/docs/ares_init_options.3 b/deps/cares/docs/ares_init_options.3 +index b9d52a8..b31f663 100644 +--- a/deps/cares/docs/ares_init_options.3 ++++ b/deps/cares/docs/ares_init_options.3 +@@ -41,6 +41,7 @@ struct ares_options { + int nsort; + int ednspsz; + char *resolvconf_path; ++ char *hosts_path; + }; + + int ares_init_options(ares_channel *\fIchannelptr\fP, +@@ -101,16 +102,14 @@ resolv.conf or the RES_OPTIONS environment variable. + .B ARES_OPT_UDP_PORT + .B unsigned short \fIudp_port\fP; + .br +-The port to use for queries over UDP, in network byte order. +-The default value is 53 (in network byte order), the standard name +-service port. ++The port to use for queries over UDP, in host byte order. ++The default value is 53, the standard name service port. + .TP 18 + .B ARES_OPT_TCP_PORT + .B unsigned short \fItcp_port\fP; + .br +-The port to use for queries over TCP, in network byte order. +-The default value is 53 (in network byte order), the standard name +-service port. ++The port to use for queries over TCP, in host byte order. ++The default value is 53, the standard name service port. + .TP 18 + .B ARES_OPT_SERVERS + .B struct in_addr *\fIservers\fP; +@@ -195,6 +194,16 @@ should be set to a path string, and will be honoured on *nix like systems. The + default is + .B /etc/resolv.conf + .br ++.TP 18 ++.B ARES_OPT_HOSTS_FILE ++.B char *\fIhosts_path\fP; ++.br ++The path to use for reading the hosts file. The ++.I hosts_path ++should be set to a path string, and will be honoured on *nix like systems. The ++default is ++.B /etc/hosts ++.br + .PP + The \fIoptmask\fP parameter also includes options without a corresponding + field in the +@@ -274,7 +283,7 @@ When initializing from + path location) + \fBares_init_options(3)\fP reads the \fIdomain\fP and \fIsearch\fP directives + to allow lookups of short names relative to the domains specified. The +-\fIdomain\fP and \fIsearch\fP directives override one another. If more that ++\fIdomain\fP and \fIsearch\fP directives override one another. If more than + one instance of either \fIdomain\fP or \fIsearch\fP directives is specified, + the last occurrence wins. For more information, please see the + .BR resolv.conf (5) +diff --git a/deps/cares/docs/ares_library_init.3 b/deps/cares/docs/ares_library_init.3 +index b38cf32..21fc3ec 100644 +--- a/deps/cares/docs/ares_library_init.3 ++++ b/deps/cares/docs/ares_library_init.3 +@@ -79,7 +79,8 @@ DllMain function. Doing so will produce deadlocks and other problems. + Initialize everything possible. This sets all known bits. + .TP + .B ARES_LIB_INIT_WIN32 +-Initialize Win32/64 specific libraries. ++Initialize Win32/64 specific libraries. As of c-ares 1.19.0, this is ignored ++as there are no currently dynamically loaded libraries. + .TP + .B ARES_LIB_INIT_NONE + Initialize nothing extra. This sets no bit. +diff --git a/deps/cares/docs/ares_mkquery.3 b/deps/cares/docs/ares_mkquery.3 +index c8afad8..e394fe2 100644 +--- a/deps/cares/docs/ares_mkquery.3 ++++ b/deps/cares/docs/ares_mkquery.3 +@@ -18,11 +18,11 @@ + ares_mkquery \- Compose a single-question DNS query buffer + .SH SYNOPSIS + .nf +-.B #include +-.PP +-.B int ares_mkquery(const char *\fIname\fP, int \fIdnsclass\fP, int \fItype\fP, +-.B unsigned short \fIid\fP, int \fIrd\fP, unsigned char **\fIbuf\fP, +-.B int *\fIbuflen\fP) ++#include ++ ++int ares_mkquery(const char *\fIname\fP, int \fIdnsclass\fP, int \fItype\fP, ++ unsigned short \fIid\fP, int \fIrd\fP, unsigned char **\fIbuf\fP, ++ int *\fIbuflen\fP) + .fi + .SH DESCRIPTION + Deprecated function. See \fIares_create_query(3)\fP instead! +diff --git a/deps/cares/docs/ares_parse_a_reply.3 b/deps/cares/docs/ares_parse_a_reply.3 +index 8e4908a..6038f68 100644 +--- a/deps/cares/docs/ares_parse_a_reply.3 ++++ b/deps/cares/docs/ares_parse_a_reply.3 +@@ -18,11 +18,11 @@ + ares_parse_a_reply \- Parse a reply to a DNS query of type A + .SH SYNOPSIS + .nf +-.B #include +-.PP +-.B int ares_parse_a_reply(const unsigned char *\fIabuf\fP, int \fIalen\fP, +-.B struct hostent **\fIhost\fP, +-.B struct ares_addrttl *\fIaddrttls\fP, int *\fInaddrttls\fP); ++#include ++ ++int ares_parse_a_reply(const unsigned char *\fIabuf\fP, int \fIalen\fP, ++ struct hostent **\fIhost\fP, ++ struct ares_addrttl *\fIaddrttls\fP, int *\fInaddrttls\fP); + .fi + .SH DESCRIPTION + The +diff --git a/deps/cares/docs/ares_parse_aaaa_reply.3 b/deps/cares/docs/ares_parse_aaaa_reply.3 +index 674acc5..bddd3c2 100644 +--- a/deps/cares/docs/ares_parse_aaaa_reply.3 ++++ b/deps/cares/docs/ares_parse_aaaa_reply.3 +@@ -18,11 +18,11 @@ + ares_parse_aaaa_reply \- Parse a reply to a DNS query of type AAAA + .SH SYNOPSIS + .nf +-.B #include +-.PP +-.B int ares_parse_aaaa_reply(const unsigned char *\fIabuf\fP, int \fIalen\fP, +-.B struct hostent **\fIhost\fP, +-.B struct ares_addr6ttl *\fIaddrttls\fP, int *\fInaddrttls\fP); ++#include ++ ++int ares_parse_aaaa_reply(const unsigned char *\fIabuf\fP, int \fIalen\fP, ++ struct hostent **\fIhost\fP, ++ struct ares_addr6ttl *\fIaddrttls\fP, int *\fInaddrttls\fP); + .fi + .SH DESCRIPTION + The +diff --git a/deps/cares/docs/ares_parse_mx_reply.3 b/deps/cares/docs/ares_parse_mx_reply.3 +index 87df459..6c5c902 100644 +--- a/deps/cares/docs/ares_parse_mx_reply.3 ++++ b/deps/cares/docs/ares_parse_mx_reply.3 +@@ -17,11 +17,10 @@ + .SH NAME + ares_parse_mx_reply \- Parse a reply to a DNS query of type MX + .SH SYNOPSIS +-.nf +-.B #include +-.PP +-.B int ares_parse_mx_reply(const unsigned char* \fIabuf\fP, int \fIalen\fP, +-.B struct ares_mx_reply** \fImx_out\fP); ++#include ++ ++int ares_parse_mx_reply(const unsigned char* \fIabuf\fP, int \fIalen\fP, ++ struct ares_mx_reply** \fImx_out\fP); + .fi + .SH DESCRIPTION + The +diff --git a/deps/cares/docs/ares_parse_naptr_reply.3 b/deps/cares/docs/ares_parse_naptr_reply.3 +index 2a5f1e5..b98f8fd 100644 +--- a/deps/cares/docs/ares_parse_naptr_reply.3 ++++ b/deps/cares/docs/ares_parse_naptr_reply.3 +@@ -18,10 +18,10 @@ + ares_parse_naptr_reply \- Parse a reply to a DNS query of type NAPTR + .SH SYNOPSIS + .nf +-.B #include +-.PP +-.B int ares_parse_naptr_reply(const unsigned char* \fIabuf\fP, int \fIalen\fP, +-.B struct ares_naptr_reply** \fInaptr_out\fP); ++#include ++ ++int ares_parse_naptr_reply(const unsigned char* \fIabuf\fP, int \fIalen\fP, ++ struct ares_naptr_reply** \fInaptr_out\fP); + .fi + .SH DESCRIPTION + The +diff --git a/deps/cares/docs/ares_parse_ns_reply.3 b/deps/cares/docs/ares_parse_ns_reply.3 +index b6340ac..b767e04 100644 +--- a/deps/cares/docs/ares_parse_ns_reply.3 ++++ b/deps/cares/docs/ares_parse_ns_reply.3 +@@ -18,10 +18,10 @@ + ares_parse_ns_reply \- Parse a reply to a DNS query of type NS into a hostent + .SH SYNOPSIS + .nf +-.B #include +-.PP +-.B int ares_parse_ns_reply(const unsigned char *\fIabuf\fP, int \fIalen\fP, +-.B struct hostent **\fIhost\fP); ++#include ++ ++int ares_parse_ns_reply(const unsigned char *\fIabuf\fP, int \fIalen\fP, ++ struct hostent **\fIhost\fP); + .fi + .SH DESCRIPTION + The +diff --git a/deps/cares/docs/ares_parse_ptr_reply.3 b/deps/cares/docs/ares_parse_ptr_reply.3 +index 1016a68..e3eb4d0 100644 +--- a/deps/cares/docs/ares_parse_ptr_reply.3 ++++ b/deps/cares/docs/ares_parse_ptr_reply.3 +@@ -18,11 +18,11 @@ + ares_parse_ptr_reply \- Parse a reply to a DNS query of type PTR into a hostent + .SH SYNOPSIS + .nf +-.B #include +-.PP +-.B int ares_parse_ptr_reply(const unsigned char *\fIabuf\fP, int \fIalen\fP, +-.B const void *\fIaddr\fP, int \fIaddrlen\fP, int \fIfamily\fP, +-.B struct hostent **\fIhost\fP); ++#include ++ ++int ares_parse_ptr_reply(const unsigned char *\fIabuf\fP, int \fIalen\fP, ++ const void *\fIaddr\fP, int \fIaddrlen\fP, ++ int \fIfamily\fP, struct hostent **\fIhost\fP); + .fi + .SH DESCRIPTION + The +diff --git a/deps/cares/docs/ares_parse_soa_reply.3 b/deps/cares/docs/ares_parse_soa_reply.3 +index 1c4456f..c43f9be 100644 +--- a/deps/cares/docs/ares_parse_soa_reply.3 ++++ b/deps/cares/docs/ares_parse_soa_reply.3 +@@ -18,10 +18,10 @@ + ares_parse_soa_reply \- Parse a reply to a DNS query of type SOA + .SH SYNOPSIS + .nf +-.B #include +-.PP +-.B int ares_parse_soa_reply(const unsigned char* \fIabuf\fP, int \fIalen\fP, +-.B struct ares_soa_reply** \fIsoa_out\fP); ++#include ++ ++int ares_parse_soa_reply(const unsigned char* \fIabuf\fP, int \fIalen\fP, ++ struct ares_soa_reply** \fIsoa_out\fP); + .fi + .SH DESCRIPTION + The +diff --git a/deps/cares/docs/ares_parse_srv_reply.3 b/deps/cares/docs/ares_parse_srv_reply.3 +index 9b561ff..d3c26db 100644 +--- a/deps/cares/docs/ares_parse_srv_reply.3 ++++ b/deps/cares/docs/ares_parse_srv_reply.3 +@@ -18,10 +18,10 @@ + ares_parse_srv_reply \- Parse a reply to a DNS query of type SRV + .SH SYNOPSIS + .nf +-.B #include +-.PP +-.B int ares_parse_srv_reply(const unsigned char* \fIabuf\fP, int \fIalen\fP, +-.B struct ares_srv_reply** \fIsrv_out\fP); ++#include ++ ++int ares_parse_srv_reply(const unsigned char* \fIabuf\fP, int \fIalen\fP, ++ struct ares_srv_reply** \fIsrv_out\fP); + .fi + .SH DESCRIPTION + The +diff --git a/deps/cares/docs/ares_parse_txt_reply.3 b/deps/cares/docs/ares_parse_txt_reply.3 +index e15d0ea..6eeb04c 100644 +--- a/deps/cares/docs/ares_parse_txt_reply.3 ++++ b/deps/cares/docs/ares_parse_txt_reply.3 +@@ -18,13 +18,13 @@ + ares_parse_txt_reply \- Parse a reply to a DNS query of type TXT + .SH SYNOPSIS + .nf +-.B #include +-.PP +-.B int ares_parse_txt_reply(const unsigned char* \fIabuf\fP, int \fIalen\fP, +-.B struct ares_txt_reply **\fItxt_out\fP); +-.PP +-.B int ares_parse_txt_reply_ext(const unsigned char* \fIabuf\fP, int \fIalen\fP, +-.B struct ares_txt_ext **\fItxt_out\fP); ++#include ++ ++int ares_parse_txt_reply(const unsigned char* \fIabuf\fP, int \fIalen\fP, ++ struct ares_txt_reply **\fItxt_out\fP); ++ ++int ares_parse_txt_reply_ext(const unsigned char* \fIabuf\fP, int \fIalen\fP, ++ struct ares_txt_ext **\fItxt_out\fP); + .fi + .SH DESCRIPTION + The +diff --git a/deps/cares/docs/ares_parse_uri_reply.3 b/deps/cares/docs/ares_parse_uri_reply.3 +index 09da1a9..60bc228 100644 +--- a/deps/cares/docs/ares_parse_uri_reply.3 ++++ b/deps/cares/docs/ares_parse_uri_reply.3 +@@ -18,10 +18,10 @@ + ares_parse_uri_reply \- Parse a reply to a DNS query of type URI + .SH SYNOPSIS + .nf +-.B #include +-.PP +-.B int ares_parse_uri_reply(const unsigned char* \fIabuf\fP, int \fIalen\fP, +-.B struct ares_uri_reply** \fIuri_out\fP); ++#include ++ ++int ares_parse_uri_reply(const unsigned char* \fIabuf\fP, int \fIalen\fP, ++ struct ares_uri_reply** \fIuri_out\fP); + .fi + .SH DESCRIPTION + The +diff --git a/deps/cares/docs/ares_process.3 b/deps/cares/docs/ares_process.3 +index caabbf1..28666f2 100644 +--- a/deps/cares/docs/ares_process.3 ++++ b/deps/cares/docs/ares_process.3 +@@ -44,7 +44,7 @@ if they complete successfully or fail. + \fBares_process_fd(3)\fP works the same way but acts and operates only on the + specific file descriptors (sockets) you pass in to the function. Use + ARES_SOCKET_BAD for "no action". This function is provided to allow users of +-c-ares to void \fIselect(3)\fP in their applications and within c-ares. ++c-ares to avoid \fIselect(3)\fP in their applications and within c-ares. + + To only process possible timeout conditions without a socket event occurring, + one may pass NULL as the values for both \fIread_fds\fP and \fIwrite_fds\fP for +diff --git a/deps/cares/docs/ares_query.3 b/deps/cares/docs/ares_query.3 +index 733fbc9..1055baa 100644 +--- a/deps/cares/docs/ares_query.3 ++++ b/deps/cares/docs/ares_query.3 +@@ -18,14 +18,15 @@ + ares_query \- Initiate a single-question DNS query + .SH SYNOPSIS + .nf +-.B #include +-.PP +-.B typedef void (*ares_callback)(void *\fIarg\fP, int \fIstatus\fP, +-.B int \fItimeouts\fP, unsigned char *\fIabuf\fP, int \fIalen\fP) +-.PP +-.B void ares_query(ares_channel \fIchannel\fP, const char *\fIname\fP, +-.B int \fIdnsclass\fP, int \fItype\fP, ares_callback \fIcallback\fP, +-.B void *\fIarg\fP) ++#include ++ ++typedef void (*ares_callback)(void *\fIarg\fP, int \fIstatus\fP, ++ int \fItimeouts\fP, unsigned char *\fIabuf\fP, ++ int \fIalen\fP) ++ ++void ares_query(ares_channel \fIchannel\fP, const char *\fIname\fP, ++ int \fIdnsclass\fP, int \fItype\fP, ++ ares_callback \fIcallback\fP, void *\fIarg\fP) + .fi + .SH DESCRIPTION + The +diff --git a/deps/cares/docs/ares_save_options.3 b/deps/cares/docs/ares_save_options.3 +index bddae04..b5fcf17 100644 +--- a/deps/cares/docs/ares_save_options.3 ++++ b/deps/cares/docs/ares_save_options.3 +@@ -18,9 +18,10 @@ + ares_save_options \- Save configuration values obtained from initialized ares_channel + .SH SYNOPSIS + .nf +-.B #include +-.PP +-.B int ares_save_options(ares_channel \fIchannel\fP, struct ares_options *\fIoptions\fP, int *\fIoptmask\fP) ++#include ++ ++int ares_save_options(ares_channel \fIchannel\fP, ++ struct ares_options *\fIoptions\fP, int *\fIoptmask\fP) + .fi + .SH DESCRIPTION + The \fBares_save_options(3)\fP function saves the channel data identified by +diff --git a/deps/cares/docs/ares_search.3 b/deps/cares/docs/ares_search.3 +index 2c85d20..6b30187 100644 +--- a/deps/cares/docs/ares_search.3 ++++ b/deps/cares/docs/ares_search.3 +@@ -18,14 +18,15 @@ + ares_search \- Initiate a DNS query with domain search + .SH SYNOPSIS + .nf +-.B #include +-.PP +-.B typedef void (*ares_callback)(void *\fIarg\fP, int \fIstatus\fP, +-.B int \fItimeouts\fP, unsigned char *\fIabuf\fP, int \fIalen\fP) +-.PP +-.B void ares_search(ares_channel \fIchannel\fP, const char *\fIname\fP, +-.B int \fIdnsclass\fP, int \fItype\fP, ares_callback \fIcallback\fP, +-.B void *\fIarg\fP) ++#include ++ ++typedef void (*ares_callback)(void *\fIarg\fP, int \fIstatus\fP, ++ int \fItimeouts\fP, unsigned char *\fIabuf\fP, ++ int \fIalen\fP) ++ ++void ares_search(ares_channel \fIchannel\fP, const char *\fIname\fP, ++ int \fIdnsclass\fP, int \fItype\fP, ++ ares_callback \fIcallback\fP, void *\fIarg\fP) + .fi + .SH DESCRIPTION + The +diff --git a/deps/cares/docs/ares_send.3 b/deps/cares/docs/ares_send.3 +index b89abfe..bcd55b3 100644 +--- a/deps/cares/docs/ares_send.3 ++++ b/deps/cares/docs/ares_send.3 +@@ -18,13 +18,14 @@ + ares_send \- Initiate a DNS query + .SH SYNOPSIS + .nf +-.B #include +-.PP +-.B typedef void (*ares_callback)(void *\fIarg\fP, int \fIstatus\fP, +-.B int \fItimeouts\fP, unsigned char *\fIabuf\fP, int \fIalen\fP) +-.PP +-.B void ares_send(ares_channel \fIchannel\fP, const unsigned char *\fIqbuf\fP, +-.B int \fIqlen\fP, ares_callback \fIcallback\fP, void *\fIarg\fP) ++#include ++ ++typedef void (*ares_callback)(void *\fIarg\fP, int \fIstatus\fP, ++ int \fItimeouts\fP, unsigned char *\fIabuf\fP, ++ int \fIalen\fP) ++ ++void ares_send(ares_channel \fIchannel\fP, const unsigned char *\fIqbuf\fP, ++ int \fIqlen\fP, ares_callback \fIcallback\fP, void *\fIarg\fP) + .fi + .SH DESCRIPTION + The +diff --git a/deps/cares/docs/ares_set_local_dev.3 b/deps/cares/docs/ares_set_local_dev.3 +index 7d82133..059eae5 100644 +--- a/deps/cares/docs/ares_set_local_dev.3 ++++ b/deps/cares/docs/ares_set_local_dev.3 +@@ -18,9 +18,9 @@ + ares_set_local_dev \- Bind to a specific network device when creating sockets. + .SH SYNOPSIS + .nf +-.B #include +-.PP +-.B void ares_set_local_dev(ares_channel \fIchannel\fP, const char* \fIlocal_dev_name\fP) ++#include ++ ++void ares_set_local_dev(ares_channel \fIchannel\fP, const char* \fIlocal_dev_name\fP) + .fi + .SH DESCRIPTION + The \fBares_set_local_dev\fP function causes all future sockets +diff --git a/deps/cares/docs/ares_set_local_ip4.3 b/deps/cares/docs/ares_set_local_ip4.3 +index e68e80e..8425f5b 100644 +--- a/deps/cares/docs/ares_set_local_ip4.3 ++++ b/deps/cares/docs/ares_set_local_ip4.3 +@@ -18,9 +18,9 @@ + ares_set_local_ip4 \- Set local IPv4 address outgoing requests. + .SH SYNOPSIS + .nf +-.B #include +-.PP +-.B void ares_set_local_ip4(ares_channel \fIchannel\fP, unsigned int \fIlocal_ip\fP) ++#include ++ ++void ares_set_local_ip4(ares_channel \fIchannel\fP, unsigned int \fIlocal_ip\fP) + .fi + .SH DESCRIPTION + The \fBares_set_local_ip4\fP function sets the IP address for outbound +diff --git a/deps/cares/docs/ares_set_local_ip6.3 b/deps/cares/docs/ares_set_local_ip6.3 +index e659f5c..6719ad3 100644 +--- a/deps/cares/docs/ares_set_local_ip6.3 ++++ b/deps/cares/docs/ares_set_local_ip6.3 +@@ -18,15 +18,15 @@ + ares_set_local_ip6 \- Set local IPv6 address outgoing requests. + .SH SYNOPSIS + .nf +-.B #include +-.PP +-.B void ares_set_local_ip6(ares_channel \fIchannel\fP, const unsigned char* \fIlocal_ip6\fP) ++#include ++ ++void ares_set_local_ip6(ares_channel \fIchannel\fP, const unsigned char* \fIlocal_ip6\fP) + .fi + .SH DESCRIPTION +-The \fBares_set_local_ip6\fP function sets the IPv6 address for outbound +-IPv6 requests. The parameter \fIlocal_ip6\fP is specified in network byte +-order. This allows users to specify outbound interfaces when used on +-multi-homed systems. The local_ip6 argument must be 16 bytes in length. ++The \fBares_set_local_ip6\fP function sets the IPv6 address for outbound IPv6 ++requests. The parameter \fIlocal_ip6\fP is specified in network byte order. ++This allows users to specify outbound interfaces when used on multi-homed ++systems. The \fIlocal_ip6\fP argument must be 16 bytes in length. + .SH SEE ALSO + .BR ares_set_local_ip4 (3) + .SH NOTES +diff --git a/deps/cares/docs/ares_set_servers.3 b/deps/cares/docs/ares_set_servers.3 +index 65ad1e1..aeed0a5 100644 +--- a/deps/cares/docs/ares_set_servers.3 ++++ b/deps/cares/docs/ares_set_servers.3 +@@ -18,10 +18,13 @@ + ares_set_servers, ares_set_servers_ports \- Initialize an ares_channel name servers configuration + .SH SYNOPSIS + .nf +-.B #include +-.PP +-.B int ares_set_servers(ares_channel \fIchannel\fP, struct ares_addr_node *\fIservers\fP) +-.B int ares_set_servers_ports(ares_channel \fIchannel\fP, struct ares_addr_port_node *\fIservers\fP) ++#include ++ ++int ares_set_servers(ares_channel \fIchannel\fP, ++ struct ares_addr_node *\fIservers\fP) ++ ++int ares_set_servers_ports(ares_channel \fIchannel\fP, ++ struct ares_addr_port_node *\fIservers\fP) + .fi + .SH DESCRIPTION + The \fBares_set_servers(3)\fP function initializes name servers configuration +diff --git a/deps/cares/docs/ares_set_servers_csv.3 b/deps/cares/docs/ares_set_servers_csv.3 +index 638d269..a729281 100644 +--- a/deps/cares/docs/ares_set_servers_csv.3 ++++ b/deps/cares/docs/ares_set_servers_csv.3 +@@ -18,10 +18,11 @@ + ares_set_servers_csv, ares_set_servers_ports_csv \- Set list of DNS servers to be used. + .SH SYNOPSIS + .nf +-.B #include +-.PP +-.B int ares_set_servers_csv(ares_channel \fIchannel\fP, const char* \fIservers\fP) +-.B int ares_set_servers_ports_csv(ares_channel \fIchannel\fP, const char* \fIservers\fP) ++#include ++ ++int ares_set_servers_csv(ares_channel \fIchannel\fP, const char* \fIservers\fP) ++ ++int ares_set_servers_ports_csv(ares_channel \fIchannel\fP, const char* \fIservers\fP) + .fi + .SH DESCRIPTION + The \fBares_set_servers_csv\fP and \fBares_set_servers_ports_csv\fPfunctions set +diff --git a/deps/cares/docs/ares_set_socket_callback.3 b/deps/cares/docs/ares_set_socket_callback.3 +index 14a5ad2..70d7cf7 100644 +--- a/deps/cares/docs/ares_set_socket_callback.3 ++++ b/deps/cares/docs/ares_set_socket_callback.3 +@@ -4,15 +4,15 @@ + ares_set_socket_callback \- Set a socket creation callback + .SH SYNOPSIS + .nf +-.B #include +-.PP +-.B typedef int (*ares_sock_create_callback)(ares_socket_t \fIsocket_fd\fP, ++#include ++ ++typedef int (*ares_sock_create_callback)(ares_socket_t \fIsocket_fd\fP, + int \fItype\fP, + void *\fIuserdata\fP) +-.PP +-.B void ares_set_socket_callback(ares_channel \fIchannel\fP, +- ares_sock_create_callback \fIcallback\fP, +- void *\fIuserdata\fP) ++ ++void ares_set_socket_callback(ares_channel \fIchannel\fP, ++ ares_sock_create_callback \fIcallback\fP, ++ void *\fIuserdata\fP) + .PP + .B cc file.c -lcares + .fi +diff --git a/deps/cares/docs/ares_set_socket_configure_callback.3 b/deps/cares/docs/ares_set_socket_configure_callback.3 +index d3b2f93..89188a6 100644 +--- a/deps/cares/docs/ares_set_socket_configure_callback.3 ++++ b/deps/cares/docs/ares_set_socket_configure_callback.3 +@@ -4,17 +4,15 @@ + ares_set_socket_configure_callback \- Set a socket configuration callback + .SH SYNOPSIS + .nf +-.B #include +-.PP +-.B typedef int (*ares_sock_config_callback)(ares_socket_t \fIsocket_fd\fP, ++#include ++ ++typedef int (*ares_sock_config_callback)(ares_socket_t \fIsocket_fd\fP, + int \fItype\fP, + void *\fIuserdata\fP) +-.PP +-.B void ares_set_socket_configure_callback(ares_channel \fIchannel\fP, +- ares_sock_config_callback \fIcallback\fP, +- void *\fIuserdata\fP) +-.PP +-.B cc file.c -lcares ++ ++void ares_set_socket_configure_callback(ares_channel \fIchannel\fP, ++ ares_sock_config_callback \fIcallback\fP, ++ void *\fIuserdata\fP) + .fi + .SH DESCRIPTION + .PP +diff --git a/deps/cares/docs/ares_set_socket_functions.3 b/deps/cares/docs/ares_set_socket_functions.3 +index 1cb0b85..0c33a49 100644 +--- a/deps/cares/docs/ares_set_socket_functions.3 ++++ b/deps/cares/docs/ares_set_socket_functions.3 +@@ -4,21 +4,20 @@ + ares_set_socket_functions \- Set socket io callbacks + .SH SYNOPSIS + .nf +-.B #include +-.PP +-.B struct ares_socket_functions { +- ares_socket_t(*\fIasocket\fP)(int, int, int, void *); +- int(*\fIaclose\fP)(ares_socket_t, void *); +- int(*\fIaconnect\fP)(ares_socket_t, const struct sockaddr *, ares_socklen_t, void *); +- ares_ssize_t(*\fIarecvfrom\fP)(ares_socket_t, void *, size_t, int, struct sockaddr *, ares_socklen_t *, void *); +- ares_ssize_t(*\fIasendv\fP)(ares_socket_t, const struct iovec *, int, void *); +- }; ++#include + +-.PP +-.B void ares_set_socket_functions(ares_channel \fIchannel\fP, +- const struct ares_socket_functions * \fIfunctions\fP, +- void *\fIuser_data\fP); ++struct ares_socket_functions { ++ ares_socket_t (*\fIasocket\fP)(int, int, int, void *); ++ int (*\fIaclose\fP)(ares_socket_t, void *); ++ int (*\fIaconnect\fP)(ares_socket_t, const struct sockaddr *, ares_socklen_t, void *); ++ ares_ssize_t (*\fIarecvfrom\fP)(ares_socket_t, void *, size_t, int, ++ struct sockaddr *, ares_socklen_t *, void *); ++ ares_ssize_t (*\fIasendv\fP)(ares_socket_t, const struct iovec *, int, void *); ++}; + ++void ares_set_socket_functions(ares_channel \fIchannel\fP, ++ const struct ares_socket_functions * \fIfunctions\fP, ++ void *\fIuser_data\fP); + .fi + .SH DESCRIPTION + .PP +diff --git a/deps/cares/docs/ares_set_sortlist.3 b/deps/cares/docs/ares_set_sortlist.3 +index 24a9790..50e99e8 100644 +--- a/deps/cares/docs/ares_set_sortlist.3 ++++ b/deps/cares/docs/ares_set_sortlist.3 +@@ -16,9 +16,9 @@ + ares_set_sortlist \- Initialize an ares_channel sortlist configuration + .SH SYNOPSIS + .nf +-.B #include +-.PP +-.B int ares_set_sortlist(ares_channel \fIchannel\fP, const char *\fIsortstr\fP) ++#include ++ ++int ares_set_sortlist(ares_channel \fIchannel\fP, const char *\fIsortstr\fP) + .fi + .SH DESCRIPTION + The \fBares_set_sortlist(3)\fP function initializes an address sortlist configuration +diff --git a/deps/cares/docs/ares_strerror.3 b/deps/cares/docs/ares_strerror.3 +index 4b50d5b..6369fcc 100644 +--- a/deps/cares/docs/ares_strerror.3 ++++ b/deps/cares/docs/ares_strerror.3 +@@ -18,9 +18,9 @@ + ares_strerror \- Get the description of an ares library error code + .SH SYNOPSIS + .nf +-.B #include +-.PP +-.B const char *ares_strerror(int \fIcode\fP) ++#include ++ ++const char *ares_strerror(int \fIcode\fP) + .fi + .SH DESCRIPTION + The +diff --git a/deps/cares/include/Makefile.in b/deps/cares/include/Makefile.in +index fad83f2..8586bd5 100644 +--- a/deps/cares/include/Makefile.in ++++ b/deps/cares/include/Makefile.in +@@ -96,6 +96,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_ac_append_to_file.m4 \ + $(top_srcdir)/m4/ax_am_macros_static.m4 \ + $(top_srcdir)/m4/ax_check_gnu_make.m4 \ + $(top_srcdir)/m4/ax_code_coverage.m4 \ ++ $(top_srcdir)/m4/ax_cxx_compile_stdcxx.m4 \ + $(top_srcdir)/m4/ax_cxx_compile_stdcxx_11.m4 \ + $(top_srcdir)/m4/ax_file_escapes.m4 \ + $(top_srcdir)/m4/ax_require_defined.m4 \ +@@ -234,6 +235,7 @@ EGREP = @EGREP@ + ETAGS = @ETAGS@ + EXEEXT = @EXEEXT@ + FGREP = @FGREP@ ++FILECMD = @FILECMD@ + GCOV = @GCOV@ + GENHTML = @GENHTML@ + GREP = @GREP@ +diff --git a/deps/cares/include/ares.h b/deps/cares/include/ares.h +index cf8a855..8c7520e 100644 +--- a/deps/cares/include/ares.h ++++ b/deps/cares/include/ares.h +@@ -63,6 +63,13 @@ + # include + # include + # include ++/* To aid with linking against a static c-ares build, lets tell the microsoft ++ * compiler to pull in needed dependencies */ ++# ifdef _MSC_VER ++# pragma comment(lib, "ws2_32") ++# pragma comment(lib, "advapi32") ++# pragma comment(lib, "iphlpapi") ++# endif + #else + # include + # include +@@ -168,6 +175,7 @@ extern "C" { + #define ARES_OPT_EDNSPSZ (1 << 15) + #define ARES_OPT_NOROTATE (1 << 16) + #define ARES_OPT_RESOLVCONF (1 << 17) ++#define ARES_OPT_HOSTS_FILE (1 << 18) + + /* Nameinfo flag values */ + #define ARES_NI_NOFQDN (1 << 0) +@@ -277,6 +285,7 @@ struct ares_options { + int nsort; + int ednspsz; + char *resolvconf_path; ++ char *hosts_path; + }; + + struct hostent; +diff --git a/deps/cares/include/ares_version.h b/deps/cares/include/ares_version.h +index 22c6f62..35a1ed1 100644 +--- a/deps/cares/include/ares_version.h ++++ b/deps/cares/include/ares_version.h +@@ -6,12 +6,12 @@ + #define ARES_COPYRIGHT "2004 - 2021 Daniel Stenberg, ." + + #define ARES_VERSION_MAJOR 1 +-#define ARES_VERSION_MINOR 18 ++#define ARES_VERSION_MINOR 19 + #define ARES_VERSION_PATCH 1 + #define ARES_VERSION ((ARES_VERSION_MAJOR<<16)|\ + (ARES_VERSION_MINOR<<8)|\ + (ARES_VERSION_PATCH)) +-#define ARES_VERSION_STR "1.18.1" ++#define ARES_VERSION_STR "1.19.1" + + #if (ARES_VERSION >= 0x010700) + # define CARES_HAVE_ARES_LIBRARY_INIT 1 +diff --git a/deps/cares/libcares.pc.cmake b/deps/cares/libcares.pc.cmake +index 67fd301..f1213cf 100644 +--- a/deps/cares/libcares.pc.cmake ++++ b/deps/cares/libcares.pc.cmake +@@ -4,10 +4,9 @@ + # | (_|_____| (_| | | | __/\__ \ + # \___| \__,_|_| \___||___/ + # +-prefix=@CMAKE_INSTALL_PREFIX@ +-exec_prefix=${prefix}/@CMAKE_INSTALL_BINDIR@ +-libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@ +-includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@ ++exec_prefix=@CMAKE_INSTALL_FULL_BINDIR@ ++libdir=@CMAKE_INSTALL_FULL_LIBDIR@ ++includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@ + + Name: c-ares + URL: https://c-ares.org/ +diff --git a/deps/cares/ltmain.sh b/deps/cares/ltmain.sh +index 21e5e07..8fb8700 100755 +--- a/deps/cares/ltmain.sh ++++ b/deps/cares/ltmain.sh +@@ -1,12 +1,12 @@ +-#! /bin/sh ++#! /usr/bin/env sh + ## DO NOT EDIT - This file generated from ./build-aux/ltmain.in +-## by inline-source v2014-01-03.01 ++## by inline-source v2019-02-19.15 + +-# libtool (GNU libtool) 2.4.6 ++# libtool (GNU libtool) 2.4.7 + # Provide generalized library-building support services. + # Written by Gordon Matzigkeit , 1996 + +-# Copyright (C) 1996-2015 Free Software Foundation, Inc. ++# Copyright (C) 1996-2019, 2021-2022 Free Software Foundation, Inc. + # This is free software; see the source for copying conditions. There is NO + # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +@@ -31,8 +31,8 @@ + + PROGRAM=libtool + PACKAGE=libtool +-VERSION="2.4.6 Debian-2.4.6-15" +-package_revision=2.4.6 ++VERSION="2.4.7 Debian-2.4.7-4" ++package_revision=2.4.7 + + + ## ------ ## +@@ -64,34 +64,25 @@ package_revision=2.4.6 + # libraries, which are installed to $pkgauxdir. + + # Set a version string for this script. +-scriptversion=2015-01-20.17; # UTC ++scriptversion=2019-02-19.15; # UTC + + # General shell script boiler plate, and helper functions. + # Written by Gary V. Vaughan, 2004 + +-# Copyright (C) 2004-2015 Free Software Foundation, Inc. +-# This is free software; see the source for copying conditions. There is NO +-# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +- +-# This program is free software; you can redistribute it and/or modify +-# it under the terms of the GNU General Public License as published by +-# the Free Software Foundation; either version 3 of the License, or +-# (at your option) any later version. +- +-# As a special exception to the GNU General Public License, if you distribute +-# this file as part of a program or library that is built using GNU Libtool, +-# you may include this file under the same distribution terms that you use +-# for the rest of that program. +- +-# This program is distributed in the hope that it will be useful, +-# but WITHOUT ANY WARRANTY; without even the implied warranty of +-# MERCHANTABILITY or FITNES FOR A PARTICULAR PURPOSE. See the GNU +-# General Public License for more details. +- +-# You should have received a copy of the GNU General Public License +-# along with this program. If not, see . ++# This is free software. There is NO warranty; not even for ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ++# ++# Copyright (C) 2004-2019, 2021 Bootstrap Authors ++# ++# This file is dual licensed under the terms of the MIT license ++# , and GPL version 2 or later ++# . You must apply one of ++# these licenses when using or redistributing this software or any of ++# the files within it. See the URLs above, or the file `LICENSE` ++# included in the Bootstrap distribution for the full license texts. + +-# Please report bugs or propose patches to gary@gnu.org. ++# Please report bugs or propose patches to: ++# + + + ## ------ ## +@@ -139,9 +130,12 @@ do + _G_safe_locale=\"$_G_var=C; \$_G_safe_locale\" + fi" + done +- +-# CDPATH. +-(unset CDPATH) >/dev/null 2>&1 && unset CDPATH ++# These NLS vars are set unconditionally (bootstrap issue #24). Unset those ++# in case the environment reset is needed later and the $save_* variant is not ++# defined (see the code above). ++LC_ALL=C ++LANGUAGE=C ++export LANGUAGE LC_ALL + + # Make sure IFS has a sensible default + sp=' ' +@@ -159,6 +153,26 @@ if test "${PATH_SEPARATOR+set}" != set; then + fi + + ++# func_unset VAR ++# -------------- ++# Portably unset VAR. ++# In some shells, an 'unset VAR' statement leaves a non-zero return ++# status if VAR is already unset, which might be problematic if the ++# statement is used at the end of a function (thus poisoning its return ++# value) or when 'set -e' is active (causing even a spurious abort of ++# the script in this case). ++func_unset () ++{ ++ { eval $1=; (eval unset $1) >/dev/null 2>&1 && eval unset $1 || : ; } ++} ++ ++ ++# Make sure CDPATH doesn't cause `cd` commands to output the target dir. ++func_unset CDPATH ++ ++# Make sure ${,E,F}GREP behave sanely. ++func_unset GREP_OPTIONS ++ + + ## ------------------------- ## + ## Locate command utilities. ## +@@ -259,7 +273,7 @@ test -z "$SED" && { + rm -f conftest.in conftest.tmp conftest.nl conftest.out + } + +- func_path_progs "sed gsed" func_check_prog_sed $PATH:/usr/xpg4/bin ++ func_path_progs "sed gsed" func_check_prog_sed "$PATH:/usr/xpg4/bin" + rm -f conftest.sed + SED=$func_path_progs_result + } +@@ -295,7 +309,7 @@ test -z "$GREP" && { + rm -f conftest.in conftest.tmp conftest.nl conftest.out + } + +- func_path_progs "grep ggrep" func_check_prog_grep $PATH:/usr/xpg4/bin ++ func_path_progs "grep ggrep" func_check_prog_grep "$PATH:/usr/xpg4/bin" + GREP=$func_path_progs_result + } + +@@ -360,6 +374,35 @@ sed_double_backslash="\ + s/\\([^$_G_bs]\\)$_G_bs2$_G_dollar/\\1$_G_bs2$_G_bs$_G_dollar/g + s/\n//g" + ++# require_check_ifs_backslash ++# --------------------------- ++# Check if we can use backslash as IFS='\' separator, and set ++# $check_ifs_backshlash_broken to ':' or 'false'. ++require_check_ifs_backslash=func_require_check_ifs_backslash ++func_require_check_ifs_backslash () ++{ ++ _G_save_IFS=$IFS ++ IFS='\' ++ _G_check_ifs_backshlash='a\\b' ++ for _G_i in $_G_check_ifs_backshlash ++ do ++ case $_G_i in ++ a) ++ check_ifs_backshlash_broken=false ++ ;; ++ '') ++ break ++ ;; ++ *) ++ check_ifs_backshlash_broken=: ++ break ++ ;; ++ esac ++ done ++ IFS=$_G_save_IFS ++ require_check_ifs_backslash=: ++} ++ + + ## ----------------- ## + ## Global variables. ## +@@ -580,16 +623,16 @@ if test yes = "$_G_HAVE_PLUSEQ_OP"; then + { + $debug_cmd + +- func_quote_for_eval "$2" +- eval "$1+=\\ \$func_quote_for_eval_result" ++ func_quote_arg pretty "$2" ++ eval "$1+=\\ \$func_quote_arg_result" + }' + else + func_append_quoted () + { + $debug_cmd + +- func_quote_for_eval "$2" +- eval "$1=\$$1\\ \$func_quote_for_eval_result" ++ func_quote_arg pretty "$2" ++ eval "$1=\$$1\\ \$func_quote_arg_result" + } + fi + +@@ -1091,85 +1134,203 @@ func_relative_path () + } + + +-# func_quote_for_eval ARG... +-# -------------------------- +-# Aesthetically quote ARGs to be evaled later. +-# This function returns two values: +-# i) func_quote_for_eval_result +-# double-quoted, suitable for a subsequent eval +-# ii) func_quote_for_eval_unquoted_result +-# has all characters that are still active within double +-# quotes backslashified. +-func_quote_for_eval () ++# func_quote_portable EVAL ARG ++# ---------------------------- ++# Internal function to portably implement func_quote_arg. Note that we still ++# keep attention to performance here so we as much as possible try to avoid ++# calling sed binary (so far O(N) complexity as long as func_append is O(1)). ++func_quote_portable () + { + $debug_cmd + +- func_quote_for_eval_unquoted_result= +- func_quote_for_eval_result= +- while test 0 -lt $#; do +- case $1 in +- *[\\\`\"\$]*) +- _G_unquoted_arg=`printf '%s\n' "$1" |$SED "$sed_quote_subst"` ;; +- *) +- _G_unquoted_arg=$1 ;; +- esac +- if test -n "$func_quote_for_eval_unquoted_result"; then +- func_append func_quote_for_eval_unquoted_result " $_G_unquoted_arg" +- else +- func_append func_quote_for_eval_unquoted_result "$_G_unquoted_arg" ++ $require_check_ifs_backslash ++ ++ func_quote_portable_result=$2 ++ ++ # one-time-loop (easy break) ++ while true ++ do ++ if $1; then ++ func_quote_portable_result=`$ECHO "$2" | $SED \ ++ -e "$sed_double_quote_subst" -e "$sed_double_backslash"` ++ break + fi + +- case $_G_unquoted_arg in +- # Double-quote args containing shell metacharacters to delay +- # word splitting, command substitution and variable expansion +- # for a subsequent eval. +- # Many Bourne shells cannot handle close brackets correctly +- # in scan sets, so we specify it separately. +- *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") +- _G_quoted_arg=\"$_G_unquoted_arg\" ++ # Quote for eval. ++ case $func_quote_portable_result in ++ *[\\\`\"\$]*) ++ # Fallback to sed for $func_check_bs_ifs_broken=:, or when the string ++ # contains the shell wildcard characters. ++ case $check_ifs_backshlash_broken$func_quote_portable_result in ++ :*|*[\[\*\?]*) ++ func_quote_portable_result=`$ECHO "$func_quote_portable_result" \ ++ | $SED "$sed_quote_subst"` ++ break ++ ;; ++ esac ++ ++ func_quote_portable_old_IFS=$IFS ++ for _G_char in '\' '`' '"' '$' ++ do ++ # STATE($1) PREV($2) SEPARATOR($3) ++ set start "" "" ++ func_quote_portable_result=dummy"$_G_char$func_quote_portable_result$_G_char"dummy ++ IFS=$_G_char ++ for _G_part in $func_quote_portable_result ++ do ++ case $1 in ++ quote) ++ func_append func_quote_portable_result "$3$2" ++ set quote "$_G_part" "\\$_G_char" ++ ;; ++ start) ++ set first "" "" ++ func_quote_portable_result= ++ ;; ++ first) ++ set quote "$_G_part" "" ++ ;; ++ esac ++ done ++ done ++ IFS=$func_quote_portable_old_IFS + ;; +- *) +- _G_quoted_arg=$_G_unquoted_arg +- ;; ++ *) ;; + esac +- +- if test -n "$func_quote_for_eval_result"; then +- func_append func_quote_for_eval_result " $_G_quoted_arg" +- else +- func_append func_quote_for_eval_result "$_G_quoted_arg" +- fi +- shift ++ break + done ++ ++ func_quote_portable_unquoted_result=$func_quote_portable_result ++ case $func_quote_portable_result in ++ # double-quote args containing shell metacharacters to delay ++ # word splitting, command substitution and variable expansion ++ # for a subsequent eval. ++ # many bourne shells cannot handle close brackets correctly ++ # in scan sets, so we specify it separately. ++ *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") ++ func_quote_portable_result=\"$func_quote_portable_result\" ++ ;; ++ esac + } + + +-# func_quote_for_expand ARG +-# ------------------------- +-# Aesthetically quote ARG to be evaled later; same as above, +-# but do not quote variable references. +-func_quote_for_expand () +-{ +- $debug_cmd ++# func_quotefast_eval ARG ++# ----------------------- ++# Quote one ARG (internal). This is equivalent to 'func_quote_arg eval ARG', ++# but optimized for speed. Result is stored in $func_quotefast_eval. ++if test xyes = `(x=; printf -v x %q yes; echo x"$x") 2>/dev/null`; then ++ printf -v _GL_test_printf_tilde %q '~' ++ if test '\~' = "$_GL_test_printf_tilde"; then ++ func_quotefast_eval () ++ { ++ printf -v func_quotefast_eval_result %q "$1" ++ } ++ else ++ # Broken older Bash implementations. Make those faster too if possible. ++ func_quotefast_eval () ++ { ++ case $1 in ++ '~'*) ++ func_quote_portable false "$1" ++ func_quotefast_eval_result=$func_quote_portable_result ++ ;; ++ *) ++ printf -v func_quotefast_eval_result %q "$1" ++ ;; ++ esac ++ } ++ fi ++else ++ func_quotefast_eval () ++ { ++ func_quote_portable false "$1" ++ func_quotefast_eval_result=$func_quote_portable_result ++ } ++fi + +- case $1 in +- *[\\\`\"]*) +- _G_arg=`$ECHO "$1" | $SED \ +- -e "$sed_double_quote_subst" -e "$sed_double_backslash"` ;; +- *) +- _G_arg=$1 ;; ++ ++# func_quote_arg MODEs ARG ++# ------------------------ ++# Quote one ARG to be evaled later. MODEs argument may contain zero or more ++# specifiers listed below separated by ',' character. This function returns two ++# values: ++# i) func_quote_arg_result ++# double-quoted (when needed), suitable for a subsequent eval ++# ii) func_quote_arg_unquoted_result ++# has all characters that are still active within double ++# quotes backslashified. Available only if 'unquoted' is specified. ++# ++# Available modes: ++# ---------------- ++# 'eval' (default) ++# - escape shell special characters ++# 'expand' ++# - the same as 'eval'; but do not quote variable references ++# 'pretty' ++# - request aesthetic output, i.e. '"a b"' instead of 'a\ b'. This might ++# be used later in func_quote to get output like: 'echo "a b"' instead ++# of 'echo a\ b'. This is slower than default on some shells. ++# 'unquoted' ++# - produce also $func_quote_arg_unquoted_result which does not contain ++# wrapping double-quotes. ++# ++# Examples for 'func_quote_arg pretty,unquoted string': ++# ++# string | *_result | *_unquoted_result ++# ------------+-----------------------+------------------- ++# " | \" | \" ++# a b | "a b" | a b ++# "a b" | "\"a b\"" | \"a b\" ++# * | "*" | * ++# z="${x-$y}" | "z=\"\${x-\$y}\"" | z=\"\${x-\$y}\" ++# ++# Examples for 'func_quote_arg pretty,unquoted,expand string': ++# ++# string | *_result | *_unquoted_result ++# --------------+---------------------+-------------------- ++# z="${x-$y}" | "z=\"${x-$y}\"" | z=\"${x-$y}\" ++func_quote_arg () ++{ ++ _G_quote_expand=false ++ case ,$1, in ++ *,expand,*) ++ _G_quote_expand=: ++ ;; + esac + +- case $_G_arg in +- # Double-quote args containing shell metacharacters to delay +- # word splitting and command substitution for a subsequent eval. +- # Many Bourne shells cannot handle close brackets correctly +- # in scan sets, so we specify it separately. +- *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") +- _G_arg=\"$_G_arg\" ++ case ,$1, in ++ *,pretty,*|*,expand,*|*,unquoted,*) ++ func_quote_portable $_G_quote_expand "$2" ++ func_quote_arg_result=$func_quote_portable_result ++ func_quote_arg_unquoted_result=$func_quote_portable_unquoted_result ++ ;; ++ *) ++ # Faster quote-for-eval for some shells. ++ func_quotefast_eval "$2" ++ func_quote_arg_result=$func_quotefast_eval_result + ;; + esac ++} ++ + +- func_quote_for_expand_result=$_G_arg ++# func_quote MODEs ARGs... ++# ------------------------ ++# Quote all ARGs to be evaled later and join them into single command. See ++# func_quote_arg's description for more info. ++func_quote () ++{ ++ $debug_cmd ++ _G_func_quote_mode=$1 ; shift ++ func_quote_result= ++ while test 0 -lt $#; do ++ func_quote_arg "$_G_func_quote_mode" "$1" ++ if test -n "$func_quote_result"; then ++ func_append func_quote_result " $func_quote_arg_result" ++ else ++ func_append func_quote_result "$func_quote_arg_result" ++ fi ++ shift ++ done + } + + +@@ -1215,8 +1376,8 @@ func_show_eval () + _G_cmd=$1 + _G_fail_exp=${2-':'} + +- func_quote_for_expand "$_G_cmd" +- eval "func_notquiet $func_quote_for_expand_result" ++ func_quote_arg pretty,expand "$_G_cmd" ++ eval "func_notquiet $func_quote_arg_result" + + $opt_dry_run || { + eval "$_G_cmd" +@@ -1241,8 +1402,8 @@ func_show_eval_locale () + _G_fail_exp=${2-':'} + + $opt_quiet || { +- func_quote_for_expand "$_G_cmd" +- eval "func_echo $func_quote_for_expand_result" ++ func_quote_arg expand,pretty "$_G_cmd" ++ eval "func_echo $func_quote_arg_result" + } + + $opt_dry_run || { +@@ -1369,30 +1530,26 @@ func_lt_ver () + # End: + #! /bin/sh + +-# Set a version string for this script. +-scriptversion=2015-10-07.11; # UTC +- + # A portable, pluggable option parser for Bourne shell. + # Written by Gary V. Vaughan, 2010 + +-# Copyright (C) 2010-2015 Free Software Foundation, Inc. +-# This is free software; see the source for copying conditions. There is NO +-# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +- +-# This program is free software: you can redistribute it and/or modify +-# it under the terms of the GNU General Public License as published by +-# the Free Software Foundation, either version 3 of the License, or +-# (at your option) any later version. ++# This is free software. There is NO warranty; not even for ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ++# ++# Copyright (C) 2010-2019, 2021 Bootstrap Authors ++# ++# This file is dual licensed under the terms of the MIT license ++# , and GPL version 2 or later ++# . You must apply one of ++# these licenses when using or redistributing this software or any of ++# the files within it. See the URLs above, or the file `LICENSE` ++# included in the Bootstrap distribution for the full license texts. + +-# This program is distributed in the hope that it will be useful, +-# but WITHOUT ANY WARRANTY; without even the implied warranty of +-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-# GNU General Public License for more details. ++# Please report bugs or propose patches to: ++# + +-# You should have received a copy of the GNU General Public License +-# along with this program. If not, see . +- +-# Please report bugs or propose patches to gary@gnu.org. ++# Set a version string for this script. ++scriptversion=2019-02-19.15; # UTC + + + ## ------ ## +@@ -1415,7 +1572,7 @@ scriptversion=2015-10-07.11; # UTC + # + # In order for the '--version' option to work, you will need to have a + # suitably formatted comment like the one at the top of this file +-# starting with '# Written by ' and ending with '# warranty; '. ++# starting with '# Written by ' and ending with '# Copyright'. + # + # For '-h' and '--help' to work, you will also need a one line + # description of your script's purpose in a comment directly above the +@@ -1427,7 +1584,7 @@ scriptversion=2015-10-07.11; # UTC + # to display verbose messages only when your user has specified + # '--verbose'. + # +-# After sourcing this file, you can plug processing for additional ++# After sourcing this file, you can plug in processing for additional + # options by amending the variables from the 'Configuration' section + # below, and following the instructions in the 'Option parsing' + # section further down. +@@ -1476,8 +1633,8 @@ fatal_help="Try '\$progname --help' for more information." + ## ------------------------- ## + + # This section contains functions for adding, removing, and running hooks +-# to the main code. A hook is just a named list of of function, that can +-# be run in order later on. ++# in the main code. A hook is just a list of function names that can be ++# run in order later on. + + # func_hookable FUNC_NAME + # ----------------------- +@@ -1510,7 +1667,8 @@ func_add_hook () + + # func_remove_hook FUNC_NAME HOOK_FUNC + # ------------------------------------ +-# Remove HOOK_FUNC from the list of functions called by FUNC_NAME. ++# Remove HOOK_FUNC from the list of hook functions to be called by ++# FUNC_NAME. + func_remove_hook () + { + $debug_cmd +@@ -1519,10 +1677,28 @@ func_remove_hook () + } + + ++# func_propagate_result FUNC_NAME_A FUNC_NAME_B ++# --------------------------------------------- ++# If the *_result variable of FUNC_NAME_A _is set_, assign its value to ++# *_result variable of FUNC_NAME_B. ++func_propagate_result () ++{ ++ $debug_cmd ++ ++ func_propagate_result_result=: ++ if eval "test \"\${${1}_result+set}\" = set" ++ then ++ eval "${2}_result=\$${1}_result" ++ else ++ func_propagate_result_result=false ++ fi ++} ++ ++ + # func_run_hooks FUNC_NAME [ARG]... + # --------------------------------- + # Run all hook functions registered to FUNC_NAME. +-# It is assumed that the list of hook functions contains nothing more ++# It's assumed that the list of hook functions contains nothing more + # than a whitespace-delimited list of legal shell function names, and + # no effort is wasted trying to catch shell meta-characters or preserve + # whitespace. +@@ -1534,22 +1710,19 @@ func_run_hooks () + + case " $hookable_fns " in + *" $1 "*) ;; +- *) func_fatal_error "'$1' does not support hook funcions.n" ;; ++ *) func_fatal_error "'$1' does not support hook functions." ;; + esac + + eval _G_hook_fns=\$$1_hooks; shift + + for _G_hook in $_G_hook_fns; do +- if eval $_G_hook '"$@"'; then +- # store returned options list back into positional +- # parameters for next 'cmd' execution. +- eval _G_hook_result=\$${_G_hook}_result +- eval set dummy "$_G_hook_result"; shift +- _G_rc_run_hooks=: ++ func_unset "${_G_hook}_result" ++ eval $_G_hook '${1+"$@"}' ++ func_propagate_result $_G_hook func_run_hooks ++ if $func_propagate_result_result; then ++ eval set dummy "$func_run_hooks_result"; shift + fi + done +- +- $_G_rc_run_hooks && func_run_hooks_result=$_G_hook_result + } + + +@@ -1559,14 +1732,16 @@ func_run_hooks () + ## --------------- ## + + # In order to add your own option parsing hooks, you must accept the +-# full positional parameter list in your hook function, you may remove/edit +-# any options that you action, and then pass back the remaining unprocessed +-# options in '_result', escaped suitably for +-# 'eval'. In this case you also must return $EXIT_SUCCESS to let the +-# hook's caller know that it should pay attention to +-# '_result'. Returning $EXIT_FAILURE signalizes that +-# arguments are left untouched by the hook and therefore caller will ignore the +-# result variable. ++# full positional parameter list from your hook function. You may remove ++# or edit any options that you action, and then pass back the remaining ++# unprocessed options in '_result', escaped ++# suitably for 'eval'. ++# ++# The '_result' variable is automatically unset ++# before your hook gets called; for best performance, only set the ++# *_result variable when necessary (i.e. don't call the 'func_quote' ++# function unnecessarily because it can be an expensive operation on some ++# machines). + # + # Like this: + # +@@ -1578,11 +1753,8 @@ func_run_hooks () + # usage_message=$usage_message' + # -s, --silent don'\''t print informational messages + # ' +-# # No change in '$@' (ignored completely by this hook). There is +-# # no need to do the equivalent (but slower) action: +-# # func_quote_for_eval ${1+"$@"} +-# # my_options_prep_result=$func_quote_for_eval_result +-# false ++# # No change in '$@' (ignored completely by this hook). Leave ++# # my_options_prep_result variable intact. + # } + # func_add_hook func_options_prep my_options_prep + # +@@ -1593,7 +1765,7 @@ func_run_hooks () + # + # args_changed=false + # +-# # Note that for efficiency, we parse as many options as we can ++# # Note that, for efficiency, we parse as many options as we can + # # recognise in a loop before passing the remainder back to the + # # caller on the first unrecognised argument we encounter. + # while test $# -gt 0; do +@@ -1610,18 +1782,17 @@ func_run_hooks () + # args_changed=: + # ;; + # *) # Make sure the first unrecognised option "$_G_opt" +-# # is added back to "$@", we could need that later +-# # if $args_changed is true. ++# # is added back to "$@" in case we need it later, ++# # if $args_changed was set to 'true'. + # set dummy "$_G_opt" ${1+"$@"}; shift; break ;; + # esac + # done + # ++# # Only call 'func_quote' here if we processed at least one argument. + # if $args_changed; then +-# func_quote_for_eval ${1+"$@"} +-# my_silent_option_result=$func_quote_for_eval_result ++# func_quote eval ${1+"$@"} ++# my_silent_option_result=$func_quote_result + # fi +-# +-# $args_changed + # } + # func_add_hook func_parse_options my_silent_option + # +@@ -1632,8 +1803,6 @@ func_run_hooks () + # + # $opt_silent && $opt_verbose && func_fatal_help "\ + # '--silent' and '--verbose' options are mutually exclusive." +-# +-# false + # } + # func_add_hook func_validate_options my_option_validation + # +@@ -1649,13 +1818,8 @@ func_options_finish () + { + $debug_cmd + +- _G_func_options_finish_exit=false +- if func_run_hooks func_options ${1+"$@"}; then +- func_options_finish_result=$func_run_hooks_result +- _G_func_options_finish_exit=: +- fi +- +- $_G_func_options_finish_exit ++ func_run_hooks func_options ${1+"$@"} ++ func_propagate_result func_run_hooks func_options_finish + } + + +@@ -1668,28 +1832,27 @@ func_options () + { + $debug_cmd + +- _G_rc_options=false ++ _G_options_quoted=false + + for my_func in options_prep parse_options validate_options options_finish + do +- if eval func_$my_func '${1+"$@"}'; then +- eval _G_res_var='$'"func_${my_func}_result" +- eval set dummy "$_G_res_var" ; shift +- _G_rc_options=: ++ func_unset func_${my_func}_result ++ func_unset func_run_hooks_result ++ eval func_$my_func '${1+"$@"}' ++ func_propagate_result func_$my_func func_options ++ if $func_propagate_result_result; then ++ eval set dummy "$func_options_result"; shift ++ _G_options_quoted=: + fi + done + +- # Save modified positional parameters for caller. As a top-level +- # options-parser function we always need to set the 'func_options_result' +- # variable (regardless the $_G_rc_options value). +- if $_G_rc_options; then +- func_options_result=$_G_res_var +- else +- func_quote_for_eval ${1+"$@"} +- func_options_result=$func_quote_for_eval_result +- fi +- +- $_G_rc_options ++ $_G_options_quoted || { ++ # As we (func_options) are top-level options-parser function and ++ # nobody quoted "$@" for us yet, we need to do it explicitly for ++ # caller. ++ func_quote eval ${1+"$@"} ++ func_options_result=$func_quote_result ++ } + } + + +@@ -1699,8 +1862,7 @@ func_options () + # Note that when calling hook functions, we pass through the list of + # positional parameters. If a hook function modifies that list, and + # needs to propagate that back to rest of this script, then the complete +-# modified list must be put in 'func_run_hooks_result' before +-# returning $EXIT_SUCCESS (otherwise $EXIT_FAILURE is returned). ++# modified list must be put in 'func_run_hooks_result' before returning. + func_hookable func_options_prep + func_options_prep () + { +@@ -1710,14 +1872,8 @@ func_options_prep () + opt_verbose=false + opt_warning_types= + +- _G_rc_options_prep=false +- if func_run_hooks func_options_prep ${1+"$@"}; then +- _G_rc_options_prep=: +- # save modified positional parameters for caller +- func_options_prep_result=$func_run_hooks_result +- fi +- +- $_G_rc_options_prep ++ func_run_hooks func_options_prep ${1+"$@"} ++ func_propagate_result func_run_hooks func_options_prep + } + + +@@ -1729,27 +1885,32 @@ func_parse_options () + { + $debug_cmd + +- func_parse_options_result= +- +- _G_rc_parse_options=false ++ _G_parse_options_requote=false + # this just eases exit handling + while test $# -gt 0; do + # Defer to hook functions for initial option parsing, so they + # get priority in the event of reusing an option name. +- if func_run_hooks func_parse_options ${1+"$@"}; then +- eval set dummy "$func_run_hooks_result"; shift +- _G_rc_parse_options=: ++ func_run_hooks func_parse_options ${1+"$@"} ++ func_propagate_result func_run_hooks func_parse_options ++ if $func_propagate_result_result; then ++ eval set dummy "$func_parse_options_result"; shift ++ # Even though we may have changed "$@", we passed the "$@" array ++ # down into the hook and it quoted it for us (because we are in ++ # this if-branch). No need to quote it again. ++ _G_parse_options_requote=false + fi + + # Break out of the loop if we already parsed every option. + test $# -gt 0 || break + ++ # We expect that one of the options parsed in this function matches ++ # and thus we remove _G_opt from "$@" and need to re-quote. + _G_match_parse_options=: + _G_opt=$1 + shift + case $_G_opt in + --debug|-x) debug_cmd='set -x' +- func_echo "enabling shell trace mode" ++ func_echo "enabling shell trace mode" >&2 + $debug_cmd + ;; + +@@ -1760,7 +1921,7 @@ func_parse_options () + + --warnings|--warning|-W) + if test $# = 0 && func_missing_arg $_G_opt; then +- _G_rc_parse_options=: ++ _G_parse_options_requote=: + break + fi + case " $warning_categories $1" in +@@ -1815,7 +1976,7 @@ func_parse_options () + shift + ;; + +- --) _G_rc_parse_options=: ; break ;; ++ --) _G_parse_options_requote=: ; break ;; + -*) func_fatal_help "unrecognised option: '$_G_opt'" ;; + *) set dummy "$_G_opt" ${1+"$@"}; shift + _G_match_parse_options=false +@@ -1823,17 +1984,16 @@ func_parse_options () + ;; + esac + +- $_G_match_parse_options && _G_rc_parse_options=: ++ if $_G_match_parse_options; then ++ _G_parse_options_requote=: ++ fi + done + +- +- if $_G_rc_parse_options; then ++ if $_G_parse_options_requote; then + # save modified positional parameters for caller +- func_quote_for_eval ${1+"$@"} +- func_parse_options_result=$func_quote_for_eval_result ++ func_quote eval ${1+"$@"} ++ func_parse_options_result=$func_quote_result + fi +- +- $_G_rc_parse_options + } + + +@@ -1846,21 +2006,14 @@ func_validate_options () + { + $debug_cmd + +- _G_rc_validate_options=false +- + # Display all warnings if -W was not given. + test -n "$opt_warning_types" || opt_warning_types=" $warning_categories" + +- if func_run_hooks func_validate_options ${1+"$@"}; then +- # save modified positional parameters for caller +- func_validate_options_result=$func_run_hooks_result +- _G_rc_validate_options=: +- fi ++ func_run_hooks func_validate_options ${1+"$@"} ++ func_propagate_result func_run_hooks func_validate_options + + # Bail if the options were screwed! + $exit_cmd $EXIT_FAILURE +- +- $_G_rc_validate_options + } + + +@@ -1916,8 +2069,8 @@ func_missing_arg () + + # func_split_equals STRING + # ------------------------ +-# Set func_split_equals_lhs and func_split_equals_rhs shell variables after +-# splitting STRING at the '=' sign. ++# Set func_split_equals_lhs and func_split_equals_rhs shell variables ++# after splitting STRING at the '=' sign. + test -z "$_G_HAVE_XSI_OPS" \ + && (eval 'x=a/b/c; + test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ +@@ -1932,8 +2085,9 @@ then + + func_split_equals_lhs=${1%%=*} + func_split_equals_rhs=${1#*=} +- test "x$func_split_equals_lhs" = "x$1" \ +- && func_split_equals_rhs= ++ if test "x$func_split_equals_lhs" = "x$1"; then ++ func_split_equals_rhs= ++ fi + }' + else + # ...otherwise fall back to using expr, which is often a shell builtin. +@@ -1943,7 +2097,7 @@ else + + func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'` + func_split_equals_rhs= +- test "x$func_split_equals_lhs" = "x$1" \ ++ test "x$func_split_equals_lhs=" = "x$1" \ + || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'` + } + fi #func_split_equals +@@ -1969,7 +2123,7 @@ else + { + $debug_cmd + +- func_split_short_opt_name=`expr "x$1" : 'x-\(.\)'` ++ func_split_short_opt_name=`expr "x$1" : 'x\(-.\)'` + func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'` + } + fi #func_split_short_opt +@@ -2011,31 +2165,44 @@ func_usage_message () + # func_version + # ------------ + # Echo version message to standard output and exit. ++# The version message is extracted from the calling file's header ++# comments, with leading '# ' stripped: ++# 1. First display the progname and version ++# 2. Followed by the header comment line matching /^# Written by / ++# 3. Then a blank line followed by the first following line matching ++# /^# Copyright / ++# 4. Immediately followed by any lines between the previous matches, ++# except lines preceding the intervening completely blank line. ++# For example, see the header comments of this file. + func_version () + { + $debug_cmd + + printf '%s\n' "$progname $scriptversion" + $SED -n ' +- /(C)/!b go +- :more +- /\./!{ +- N +- s|\n# | | +- b more +- } +- :go +- /^# Written by /,/# warranty; / { +- s|^# || +- s|^# *$|| +- s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2| +- p ++ /^# Written by /!b ++ s|^# ||; p; n ++ ++ :fwd2blnk ++ /./ { ++ n ++ b fwd2blnk + } +- /^# Written by / { +- s|^# || +- p ++ p; n ++ ++ :holdwrnt ++ s|^# || ++ s|^# *$|| ++ /^Copyright /!{ ++ /./H ++ n ++ b holdwrnt + } +- /^warranty; /q' < "$progpath" ++ ++ s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2| ++ G ++ s|\(\n\)\n*|\1|g ++ p; q' < "$progpath" + + exit $? + } +@@ -2045,12 +2212,12 @@ func_version () + # mode: shell-script + # sh-indentation: 2 + # eval: (add-hook 'before-save-hook 'time-stamp) +-# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC" ++# time-stamp-pattern: "30/scriptversion=%:y-%02m-%02d.%02H; # UTC" + # time-stamp-time-zone: "UTC" + # End: + + # Set a version string. +-scriptversion='(GNU libtool) 2.4.6' ++scriptversion='(GNU libtool) 2.4.7' + + + # func_echo ARG... +@@ -2141,7 +2308,7 @@ include the following information: + compiler: $LTCC + compiler flags: $LTCFLAGS + linker: $LD (gnu? $with_gnu_ld) +- version: $progname $scriptversion Debian-2.4.6-15 ++ version: $progname $scriptversion Debian-2.4.7-4 + automake: `($AUTOMAKE --version) 2>/dev/null |$SED 1q` + autoconf: `($AUTOCONF --version) 2>/dev/null |$SED 1q` + +@@ -2197,7 +2364,7 @@ fi + # a configuration failure hint, and exit. + func_fatal_configuration () + { +- func__fatal_error ${1+"$@"} \ ++ func_fatal_error ${1+"$@"} \ + "See the $PACKAGE documentation for more information." \ + "Fatal configuration error." + } +@@ -2345,6 +2512,8 @@ libtool_options_prep () + + _G_rc_lt_options_prep=: + ++ _G_rc_lt_options_prep=: ++ + # Shorthand for --mode=foo, only valid as the first argument + case $1 in + clean|clea|cle|cl) +@@ -2375,11 +2544,9 @@ libtool_options_prep () + + if $_G_rc_lt_options_prep; then + # Pass back the list of options. +- func_quote_for_eval ${1+"$@"} +- libtool_options_prep_result=$func_quote_for_eval_result ++ func_quote eval ${1+"$@"} ++ libtool_options_prep_result=$func_quote_result + fi +- +- $_G_rc_lt_options_prep + } + func_add_hook func_options_prep libtool_options_prep + +@@ -2482,11 +2649,9 @@ libtool_parse_options () + + if $_G_rc_lt_parse_options; then + # save modified positional parameters for caller +- func_quote_for_eval ${1+"$@"} +- libtool_parse_options_result=$func_quote_for_eval_result ++ func_quote eval ${1+"$@"} ++ libtool_parse_options_result=$func_quote_result + fi +- +- $_G_rc_lt_parse_options + } + func_add_hook func_parse_options libtool_parse_options + +@@ -2543,8 +2708,8 @@ libtool_validate_options () + } + + # Pass back the unparsed argument list +- func_quote_for_eval ${1+"$@"} +- libtool_validate_options_result=$func_quote_for_eval_result ++ func_quote eval ${1+"$@"} ++ libtool_validate_options_result=$func_quote_result + } + func_add_hook func_validate_options libtool_validate_options + +@@ -3510,8 +3675,8 @@ func_mode_compile () + esac + done + +- func_quote_for_eval "$libobj" +- test "X$libobj" != "X$func_quote_for_eval_result" \ ++ func_quote_arg pretty "$libobj" ++ test "X$libobj" != "X$func_quote_arg_result" \ + && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ + && func_warning "libobj name '$libobj' may not contain shell special characters." + func_dirname_and_basename "$obj" "/" "" +@@ -3584,8 +3749,8 @@ compiler." + + func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 + srcfile=$func_to_tool_file_result +- func_quote_for_eval "$srcfile" +- qsrcfile=$func_quote_for_eval_result ++ func_quote_arg pretty "$srcfile" ++ qsrcfile=$func_quote_arg_result + + # Only build a PIC object if we are building libtool libraries. + if test yes = "$build_libtool_libs"; then +@@ -3740,7 +3905,8 @@ This mode accepts the following additional options: + -prefer-non-pic try to build non-PIC objects only + -shared do not build a '.o' file suitable for static linking + -static only build a '.o' file suitable for static linking +- -Wc,FLAG pass FLAG directly to the compiler ++ -Wc,FLAG ++ -Xcompiler FLAG pass FLAG directly to the compiler + + COMPILE-COMMAND is a command to be used in creating a 'standard' object file + from the given SOURCEFILE. +@@ -3846,6 +4012,8 @@ The following components of LINK-COMMAND are treated specially: + -weak LIBNAME declare that the target provides the LIBNAME interface + -Wc,FLAG + -Xcompiler FLAG pass linker-specific FLAG directly to the compiler ++ -Wa,FLAG ++ -Xassembler FLAG pass linker-specific FLAG directly to the assembler + -Wl,FLAG + -Xlinker FLAG pass linker-specific FLAG directly to the linker + -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) +@@ -4188,8 +4356,8 @@ func_mode_install () + case $nonopt in *shtool*) :;; *) false;; esac + then + # Aesthetically quote it. +- func_quote_for_eval "$nonopt" +- install_prog="$func_quote_for_eval_result " ++ func_quote_arg pretty "$nonopt" ++ install_prog="$func_quote_arg_result " + arg=$1 + shift + else +@@ -4199,8 +4367,8 @@ func_mode_install () + + # The real first argument should be the name of the installation program. + # Aesthetically quote it. +- func_quote_for_eval "$arg" +- func_append install_prog "$func_quote_for_eval_result" ++ func_quote_arg pretty "$arg" ++ func_append install_prog "$func_quote_arg_result" + install_shared_prog=$install_prog + case " $install_prog " in + *[\\\ /]cp\ *) install_cp=: ;; +@@ -4257,12 +4425,12 @@ func_mode_install () + esac + + # Aesthetically quote the argument. +- func_quote_for_eval "$arg" +- func_append install_prog " $func_quote_for_eval_result" ++ func_quote_arg pretty "$arg" ++ func_append install_prog " $func_quote_arg_result" + if test -n "$arg2"; then +- func_quote_for_eval "$arg2" ++ func_quote_arg pretty "$arg2" + fi +- func_append install_shared_prog " $func_quote_for_eval_result" ++ func_append install_shared_prog " $func_quote_arg_result" + done + + test -z "$install_prog" && \ +@@ -4273,8 +4441,8 @@ func_mode_install () + + if test -n "$install_override_mode" && $no_mode; then + if $install_cp; then :; else +- func_quote_for_eval "$install_override_mode" +- func_append install_shared_prog " -m $func_quote_for_eval_result" ++ func_quote_arg pretty "$install_override_mode" ++ func_append install_shared_prog " -m $func_quote_arg_result" + fi + fi + +@@ -4570,8 +4738,8 @@ func_mode_install () + relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` + + $opt_quiet || { +- func_quote_for_expand "$relink_command" +- eval "func_echo $func_quote_for_expand_result" ++ func_quote_arg expand,pretty "$relink_command" ++ eval "func_echo $func_quote_arg_result" + } + if eval "$relink_command"; then : + else +@@ -5350,7 +5518,8 @@ else + if test \"\$libtool_execute_magic\" != \"$magic\"; then + file=\"\$0\"" + +- qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"` ++ func_quote_arg pretty "$ECHO" ++ qECHO=$func_quote_arg_result + $ECHO "\ + + # A function that is used when there is no print builtin or printf. +@@ -5360,7 +5529,7 @@ func_fallback_echo () + \$1 + _LTECHO_EOF' + } +- ECHO=\"$qECHO\" ++ ECHO=$qECHO + fi + + # Very basic option parsing. These options are (a) specific to +@@ -6703,9 +6872,9 @@ func_mode_link () + while test "$#" -gt 0; do + arg=$1 + shift +- func_quote_for_eval "$arg" +- qarg=$func_quote_for_eval_unquoted_result +- func_append libtool_args " $func_quote_for_eval_result" ++ func_quote_arg pretty,unquoted "$arg" ++ qarg=$func_quote_arg_unquoted_result ++ func_append libtool_args " $func_quote_arg_result" + + # If the previous option needs an argument, assign it. + if test -n "$prev"; then +@@ -6941,6 +7110,13 @@ func_mode_link () + prev= + continue + ;; ++ xassembler) ++ func_append compiler_flags " -Xassembler $qarg" ++ prev= ++ func_append compile_command " -Xassembler $qarg" ++ func_append finalize_command " -Xassembler $qarg" ++ continue ++ ;; + xcclinker) + func_append linker_flags " $qarg" + func_append compiler_flags " $qarg" +@@ -7111,7 +7287,7 @@ func_mode_link () + # These systems don't actually have a C library (as such) + test X-lc = "X$arg" && continue + ;; +- *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*) ++ *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig* | *-*-midnightbsd*) + # Do not include libc due to us having libc/libc_r. + test X-lc = "X$arg" && continue + ;; +@@ -7131,7 +7307,7 @@ func_mode_link () + esac + elif test X-lc_r = "X$arg"; then + case $host in +- *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*) ++ *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig* | *-*-midnightbsd*) + # Do not include libc_r directly, use -pthread flag. + continue + ;; +@@ -7161,8 +7337,20 @@ func_mode_link () + prev=xcompiler + continue + ;; +- +- -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ ++ # Solaris ld rejects as of 11.4. Refer to Oracle bug 22985199. ++ -pthread) ++ case $host in ++ *solaris2*) ;; ++ *) ++ case "$new_inherited_linker_flags " in ++ *" $arg "*) ;; ++ * ) func_append new_inherited_linker_flags " $arg" ;; ++ esac ++ ;; ++ esac ++ continue ++ ;; ++ -mt|-mthreads|-kthread|-Kthread|-pthreads|--thread-safe \ + |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) + func_append compiler_flags " $arg" + func_append compile_command " $arg" +@@ -7303,9 +7491,9 @@ func_mode_link () + save_ifs=$IFS; IFS=, + for flag in $args; do + IFS=$save_ifs +- func_quote_for_eval "$flag" +- func_append arg " $func_quote_for_eval_result" +- func_append compiler_flags " $func_quote_for_eval_result" ++ func_quote_arg pretty "$flag" ++ func_append arg " $func_quote_arg_result" ++ func_append compiler_flags " $func_quote_arg_result" + done + IFS=$save_ifs + func_stripname ' ' '' "$arg" +@@ -7319,16 +7507,21 @@ func_mode_link () + save_ifs=$IFS; IFS=, + for flag in $args; do + IFS=$save_ifs +- func_quote_for_eval "$flag" +- func_append arg " $wl$func_quote_for_eval_result" +- func_append compiler_flags " $wl$func_quote_for_eval_result" +- func_append linker_flags " $func_quote_for_eval_result" ++ func_quote_arg pretty "$flag" ++ func_append arg " $wl$func_quote_arg_result" ++ func_append compiler_flags " $wl$func_quote_arg_result" ++ func_append linker_flags " $func_quote_arg_result" + done + IFS=$save_ifs + func_stripname ' ' '' "$arg" + arg=$func_stripname_result + ;; + ++ -Xassembler) ++ prev=xassembler ++ continue ++ ;; ++ + -Xcompiler) + prev=xcompiler + continue +@@ -7346,8 +7539,8 @@ func_mode_link () + + # -msg_* for osf cc + -msg_*) +- func_quote_for_eval "$arg" +- arg=$func_quote_for_eval_result ++ func_quote_arg pretty "$arg" ++ arg=$func_quote_arg_result + ;; + + # Flags to be passed through unchanged, with rationale: +@@ -7370,12 +7563,13 @@ func_mode_link () + # -fuse-ld=* Linker select flags for GCC + # -static-* direct GCC to link specific libraries statically + # -fcilkplus Cilk Plus language extension features for C/C++ ++ # -Wa,* Pass flags directly to the assembler + -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ + -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ + -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*| \ +- -specs=*|-fsanitize=*|-fuse-ld=*|-static-*|-fcilkplus) +- func_quote_for_eval "$arg" +- arg=$func_quote_for_eval_result ++ -specs=*|-fsanitize=*|-fuse-ld=*|-static-*|-fcilkplus|-Wa,*) ++ func_quote_arg pretty "$arg" ++ arg=$func_quote_arg_result + func_append compile_command " $arg" + func_append finalize_command " $arg" + func_append compiler_flags " $arg" +@@ -7396,15 +7590,15 @@ func_mode_link () + continue + else + # Otherwise treat like 'Some other compiler flag' below +- func_quote_for_eval "$arg" +- arg=$func_quote_for_eval_result ++ func_quote_arg pretty "$arg" ++ arg=$func_quote_arg_result + fi + ;; + + # Some other compiler flag. + -* | +*) +- func_quote_for_eval "$arg" +- arg=$func_quote_for_eval_result ++ func_quote_arg pretty "$arg" ++ arg=$func_quote_arg_result + ;; + + *.$objext) +@@ -7524,8 +7718,8 @@ func_mode_link () + *) + # Unknown arguments in both finalize_command and compile_command need + # to be aesthetically quoted because they are evaled later. +- func_quote_for_eval "$arg" +- arg=$func_quote_for_eval_result ++ func_quote_arg pretty "$arg" ++ arg=$func_quote_arg_result + ;; + esac # arg + +@@ -8733,7 +8927,7 @@ func_mode_link () + test CXX = "$tagname" && { + case $host_os in + linux*) +- case `$CC -V 2>&1 | sed 5q` in ++ case `$CC -V 2>&1 | $SED 5q` in + *Sun\ C*) # Sun C++ 5.9 + func_suncc_cstd_abi + +@@ -8906,7 +9100,7 @@ func_mode_link () + # + case $version_type in + # correct linux to gnu/linux during the next big refactor +- darwin|freebsd-elf|linux|osf|windows|none) ++ darwin|freebsd-elf|linux|midnightbsd-elf|osf|windows|none) + func_arith $number_major + $number_minor + current=$func_arith_result + age=$number_minor +@@ -9000,7 +9194,7 @@ func_mode_link () + versuffix=.$current.$revision + ;; + +- freebsd-elf) ++ freebsd-elf | midnightbsd-elf) + func_arith $current - $age + major=.$func_arith_result + versuffix=$major.$age.$revision +@@ -9226,7 +9420,7 @@ func_mode_link () + *-*-netbsd*) + # Don't link with libc until the a.out ld.so is fixed. + ;; +- *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) ++ *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-midnightbsd*) + # Do not include libc due to us having libc/libc_r. + ;; + *-*-sco3.2v5* | *-*-sco5v6*) +@@ -10037,8 +10231,8 @@ EOF + for cmd in $concat_cmds; do + IFS=$save_ifs + $opt_quiet || { +- func_quote_for_expand "$cmd" +- eval "func_echo $func_quote_for_expand_result" ++ func_quote_arg expand,pretty "$cmd" ++ eval "func_echo $func_quote_arg_result" + } + $opt_dry_run || eval "$cmd" || { + lt_exit=$? +@@ -10131,8 +10325,8 @@ EOF + eval cmd=\"$cmd\" + IFS=$save_ifs + $opt_quiet || { +- func_quote_for_expand "$cmd" +- eval "func_echo $func_quote_for_expand_result" ++ func_quote_arg expand,pretty "$cmd" ++ eval "func_echo $func_quote_arg_result" + } + $opt_dry_run || eval "$cmd" || { + lt_exit=$? +@@ -10606,12 +10800,13 @@ EOF + elif eval var_value=\$$var; test -z "$var_value"; then + relink_command="$var=; export $var; $relink_command" + else +- func_quote_for_eval "$var_value" +- relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" ++ func_quote_arg pretty "$var_value" ++ relink_command="$var=$func_quote_arg_result; export $var; $relink_command" + fi + done +- relink_command="(cd `pwd`; $relink_command)" +- relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` ++ func_quote eval cd "`pwd`" ++ func_quote_arg pretty,unquoted "($func_quote_result; $relink_command)" ++ relink_command=$func_quote_arg_unquoted_result + fi + + # Only actually do things if not in dry run mode. +@@ -10851,13 +11046,15 @@ EOF + elif eval var_value=\$$var; test -z "$var_value"; then + relink_command="$var=; export $var; $relink_command" + else +- func_quote_for_eval "$var_value" +- relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" ++ func_quote_arg pretty,unquoted "$var_value" ++ relink_command="$var=$func_quote_arg_unquoted_result; export $var; $relink_command" + fi + done + # Quote the link command for shipping. +- relink_command="(cd `pwd`; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" +- relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` ++ func_quote eval cd "`pwd`" ++ relink_command="($func_quote_result; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" ++ func_quote_arg pretty,unquoted "$relink_command" ++ relink_command=$func_quote_arg_unquoted_result + if test yes = "$hardcode_automatic"; then + relink_command= + fi +diff --git a/deps/cares/m4/ax_cxx_compile_stdcxx.m4 b/deps/cares/m4/ax_cxx_compile_stdcxx.m4 +new file mode 100644 +index 0000000..a3d964c +--- /dev/null ++++ b/deps/cares/m4/ax_cxx_compile_stdcxx.m4 +@@ -0,0 +1,1009 @@ ++# =========================================================================== ++# https://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx.html ++# =========================================================================== ++# ++# SYNOPSIS ++# ++# AX_CXX_COMPILE_STDCXX(VERSION, [ext|noext], [mandatory|optional]) ++# ++# DESCRIPTION ++# ++# Check for baseline language coverage in the compiler for the specified ++# version of the C++ standard. If necessary, add switches to CXX and ++# CXXCPP to enable support. VERSION may be '11', '14', '17', or '20' for ++# the respective C++ standard version. ++# ++# The second argument, if specified, indicates whether you insist on an ++# extended mode (e.g. -std=gnu++11) or a strict conformance mode (e.g. ++# -std=c++11). If neither is specified, you get whatever works, with ++# preference for no added switch, and then for an extended mode. ++# ++# The third argument, if specified 'mandatory' or if left unspecified, ++# indicates that baseline support for the specified C++ standard is ++# required and that the macro should error out if no mode with that ++# support is found. If specified 'optional', then configuration proceeds ++# regardless, after defining HAVE_CXX${VERSION} if and only if a ++# supporting mode is found. ++# ++# LICENSE ++# ++# Copyright (c) 2008 Benjamin Kosnik ++# Copyright (c) 2012 Zack Weinberg ++# Copyright (c) 2013 Roy Stogner ++# Copyright (c) 2014, 2015 Google Inc.; contributed by Alexey Sokolov ++# Copyright (c) 2015 Paul Norman ++# Copyright (c) 2015 Moritz Klammler ++# Copyright (c) 2016, 2018 Krzesimir Nowak ++# Copyright (c) 2019 Enji Cooper ++# Copyright (c) 2020 Jason Merrill ++# Copyright (c) 2021 Jörn Heusipp ++# ++# Copying and distribution of this file, with or without modification, are ++# permitted in any medium without royalty provided the copyright notice ++# and this notice are preserved. This file is offered as-is, without any ++# warranty. ++ ++#serial 15 ++ ++dnl This macro is based on the code from the AX_CXX_COMPILE_STDCXX_11 macro ++dnl (serial version number 13). ++ ++AC_DEFUN([AX_CXX_COMPILE_STDCXX], [dnl ++ m4_if([$1], [11], [ax_cxx_compile_alternatives="11 0x"], ++ [$1], [14], [ax_cxx_compile_alternatives="14 1y"], ++ [$1], [17], [ax_cxx_compile_alternatives="17 1z"], ++ [$1], [20], [ax_cxx_compile_alternatives="20"], ++ [m4_fatal([invalid first argument `$1' to AX_CXX_COMPILE_STDCXX])])dnl ++ m4_if([$2], [], [], ++ [$2], [ext], [], ++ [$2], [noext], [], ++ [m4_fatal([invalid second argument `$2' to AX_CXX_COMPILE_STDCXX])])dnl ++ m4_if([$3], [], [ax_cxx_compile_cxx$1_required=true], ++ [$3], [mandatory], [ax_cxx_compile_cxx$1_required=true], ++ [$3], [optional], [ax_cxx_compile_cxx$1_required=false], ++ [m4_fatal([invalid third argument `$3' to AX_CXX_COMPILE_STDCXX])]) ++ AC_LANG_PUSH([C++])dnl ++ ac_success=no ++ ++ m4_if([$2], [], [dnl ++ AC_CACHE_CHECK(whether $CXX supports C++$1 features by default, ++ ax_cv_cxx_compile_cxx$1, ++ [AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testbody_$1])], ++ [ax_cv_cxx_compile_cxx$1=yes], ++ [ax_cv_cxx_compile_cxx$1=no])]) ++ if test x$ax_cv_cxx_compile_cxx$1 = xyes; then ++ ac_success=yes ++ fi]) ++ ++ m4_if([$2], [noext], [], [dnl ++ if test x$ac_success = xno; then ++ for alternative in ${ax_cxx_compile_alternatives}; do ++ switch="-std=gnu++${alternative}" ++ cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx$1_$switch]) ++ AC_CACHE_CHECK(whether $CXX supports C++$1 features with $switch, ++ $cachevar, ++ [ac_save_CXX="$CXX" ++ CXX="$CXX $switch" ++ AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testbody_$1])], ++ [eval $cachevar=yes], ++ [eval $cachevar=no]) ++ CXX="$ac_save_CXX"]) ++ if eval test x\$$cachevar = xyes; then ++ CXX="$CXX $switch" ++ if test -n "$CXXCPP" ; then ++ CXXCPP="$CXXCPP $switch" ++ fi ++ ac_success=yes ++ break ++ fi ++ done ++ fi]) ++ ++ m4_if([$2], [ext], [], [dnl ++ if test x$ac_success = xno; then ++ dnl HP's aCC needs +std=c++11 according to: ++ dnl http://h21007.www2.hp.com/portal/download/files/unprot/aCxx/PDF_Release_Notes/769149-001.pdf ++ dnl Cray's crayCC needs "-h std=c++11" ++ for alternative in ${ax_cxx_compile_alternatives}; do ++ for switch in -std=c++${alternative} +std=c++${alternative} "-h std=c++${alternative}"; do ++ cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx$1_$switch]) ++ AC_CACHE_CHECK(whether $CXX supports C++$1 features with $switch, ++ $cachevar, ++ [ac_save_CXX="$CXX" ++ CXX="$CXX $switch" ++ AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testbody_$1])], ++ [eval $cachevar=yes], ++ [eval $cachevar=no]) ++ CXX="$ac_save_CXX"]) ++ if eval test x\$$cachevar = xyes; then ++ CXX="$CXX $switch" ++ if test -n "$CXXCPP" ; then ++ CXXCPP="$CXXCPP $switch" ++ fi ++ ac_success=yes ++ break ++ fi ++ done ++ if test x$ac_success = xyes; then ++ break ++ fi ++ done ++ fi]) ++ AC_LANG_POP([C++]) ++ if test x$ax_cxx_compile_cxx$1_required = xtrue; then ++ if test x$ac_success = xno; then ++ AC_MSG_ERROR([*** A compiler with support for C++$1 language features is required.]) ++ fi ++ fi ++ if test x$ac_success = xno; then ++ HAVE_CXX$1=0 ++ AC_MSG_NOTICE([No compiler with C++$1 support was found]) ++ else ++ HAVE_CXX$1=1 ++ AC_DEFINE(HAVE_CXX$1,1, ++ [define if the compiler supports basic C++$1 syntax]) ++ fi ++ AC_SUBST(HAVE_CXX$1) ++]) ++ ++ ++dnl Test body for checking C++11 support ++ ++m4_define([_AX_CXX_COMPILE_STDCXX_testbody_11], ++ _AX_CXX_COMPILE_STDCXX_testbody_new_in_11 ++) ++ ++dnl Test body for checking C++14 support ++ ++m4_define([_AX_CXX_COMPILE_STDCXX_testbody_14], ++ _AX_CXX_COMPILE_STDCXX_testbody_new_in_11 ++ _AX_CXX_COMPILE_STDCXX_testbody_new_in_14 ++) ++ ++dnl Test body for checking C++17 support ++ ++m4_define([_AX_CXX_COMPILE_STDCXX_testbody_17], ++ _AX_CXX_COMPILE_STDCXX_testbody_new_in_11 ++ _AX_CXX_COMPILE_STDCXX_testbody_new_in_14 ++ _AX_CXX_COMPILE_STDCXX_testbody_new_in_17 ++) ++ ++dnl Test body for checking C++20 support ++ ++m4_define([_AX_CXX_COMPILE_STDCXX_testbody_20], ++ _AX_CXX_COMPILE_STDCXX_testbody_new_in_11 ++ _AX_CXX_COMPILE_STDCXX_testbody_new_in_14 ++ _AX_CXX_COMPILE_STDCXX_testbody_new_in_17 ++ _AX_CXX_COMPILE_STDCXX_testbody_new_in_20 ++) ++ ++ ++dnl Tests for new features in C++11 ++ ++m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_11], [[ ++ ++// If the compiler admits that it is not ready for C++11, why torture it? ++// Hopefully, this will speed up the test. ++ ++#ifndef __cplusplus ++ ++#error "This is not a C++ compiler" ++ ++// MSVC always sets __cplusplus to 199711L in older versions; newer versions ++// only set it correctly if /Zc:__cplusplus is specified as well as a ++// /std:c++NN switch: ++// https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/ ++#elif __cplusplus < 201103L && !defined _MSC_VER ++ ++#error "This is not a C++11 compiler" ++ ++#else ++ ++namespace cxx11 ++{ ++ ++ namespace test_static_assert ++ { ++ ++ template ++ struct check ++ { ++ static_assert(sizeof(int) <= sizeof(T), "not big enough"); ++ }; ++ ++ } ++ ++ namespace test_final_override ++ { ++ ++ struct Base ++ { ++ virtual ~Base() {} ++ virtual void f() {} ++ }; ++ ++ struct Derived : public Base ++ { ++ virtual ~Derived() override {} ++ virtual void f() override {} ++ }; ++ ++ } ++ ++ namespace test_double_right_angle_brackets ++ { ++ ++ template < typename T > ++ struct check {}; ++ ++ typedef check single_type; ++ typedef check> double_type; ++ typedef check>> triple_type; ++ typedef check>>> quadruple_type; ++ ++ } ++ ++ namespace test_decltype ++ { ++ ++ int ++ f() ++ { ++ int a = 1; ++ decltype(a) b = 2; ++ return a + b; ++ } ++ ++ } ++ ++ namespace test_type_deduction ++ { ++ ++ template < typename T1, typename T2 > ++ struct is_same ++ { ++ static const bool value = false; ++ }; ++ ++ template < typename T > ++ struct is_same ++ { ++ static const bool value = true; ++ }; ++ ++ template < typename T1, typename T2 > ++ auto ++ add(T1 a1, T2 a2) -> decltype(a1 + a2) ++ { ++ return a1 + a2; ++ } ++ ++ int ++ test(const int c, volatile int v) ++ { ++ static_assert(is_same::value == true, ""); ++ static_assert(is_same::value == false, ""); ++ static_assert(is_same::value == false, ""); ++ auto ac = c; ++ auto av = v; ++ auto sumi = ac + av + 'x'; ++ auto sumf = ac + av + 1.0; ++ static_assert(is_same::value == true, ""); ++ static_assert(is_same::value == true, ""); ++ static_assert(is_same::value == true, ""); ++ static_assert(is_same::value == false, ""); ++ static_assert(is_same::value == true, ""); ++ return (sumf > 0.0) ? sumi : add(c, v); ++ } ++ ++ } ++ ++ namespace test_noexcept ++ { ++ ++ int f() { return 0; } ++ int g() noexcept { return 0; } ++ ++ static_assert(noexcept(f()) == false, ""); ++ static_assert(noexcept(g()) == true, ""); ++ ++ } ++ ++ namespace test_constexpr ++ { ++ ++ template < typename CharT > ++ unsigned long constexpr ++ strlen_c_r(const CharT *const s, const unsigned long acc) noexcept ++ { ++ return *s ? strlen_c_r(s + 1, acc + 1) : acc; ++ } ++ ++ template < typename CharT > ++ unsigned long constexpr ++ strlen_c(const CharT *const s) noexcept ++ { ++ return strlen_c_r(s, 0UL); ++ } ++ ++ static_assert(strlen_c("") == 0UL, ""); ++ static_assert(strlen_c("1") == 1UL, ""); ++ static_assert(strlen_c("example") == 7UL, ""); ++ static_assert(strlen_c("another\0example") == 7UL, ""); ++ ++ } ++ ++ namespace test_rvalue_references ++ { ++ ++ template < int N > ++ struct answer ++ { ++ static constexpr int value = N; ++ }; ++ ++ answer<1> f(int&) { return answer<1>(); } ++ answer<2> f(const int&) { return answer<2>(); } ++ answer<3> f(int&&) { return answer<3>(); } ++ ++ void ++ test() ++ { ++ int i = 0; ++ const int c = 0; ++ static_assert(decltype(f(i))::value == 1, ""); ++ static_assert(decltype(f(c))::value == 2, ""); ++ static_assert(decltype(f(0))::value == 3, ""); ++ } ++ ++ } ++ ++ namespace test_uniform_initialization ++ { ++ ++ struct test ++ { ++ static const int zero {}; ++ static const int one {1}; ++ }; ++ ++ static_assert(test::zero == 0, ""); ++ static_assert(test::one == 1, ""); ++ ++ } ++ ++ namespace test_lambdas ++ { ++ ++ void ++ test1() ++ { ++ auto lambda1 = [](){}; ++ auto lambda2 = lambda1; ++ lambda1(); ++ lambda2(); ++ } ++ ++ int ++ test2() ++ { ++ auto a = [](int i, int j){ return i + j; }(1, 2); ++ auto b = []() -> int { return '0'; }(); ++ auto c = [=](){ return a + b; }(); ++ auto d = [&](){ return c; }(); ++ auto e = [a, &b](int x) mutable { ++ const auto identity = [](int y){ return y; }; ++ for (auto i = 0; i < a; ++i) ++ a += b--; ++ return x + identity(a + b); ++ }(0); ++ return a + b + c + d + e; ++ } ++ ++ int ++ test3() ++ { ++ const auto nullary = [](){ return 0; }; ++ const auto unary = [](int x){ return x; }; ++ using nullary_t = decltype(nullary); ++ using unary_t = decltype(unary); ++ const auto higher1st = [](nullary_t f){ return f(); }; ++ const auto higher2nd = [unary](nullary_t f1){ ++ return [unary, f1](unary_t f2){ return f2(unary(f1())); }; ++ }; ++ return higher1st(nullary) + higher2nd(nullary)(unary); ++ } ++ ++ } ++ ++ namespace test_variadic_templates ++ { ++ ++ template ++ struct sum; ++ ++ template ++ struct sum ++ { ++ static constexpr auto value = N0 + sum::value; ++ }; ++ ++ template <> ++ struct sum<> ++ { ++ static constexpr auto value = 0; ++ }; ++ ++ static_assert(sum<>::value == 0, ""); ++ static_assert(sum<1>::value == 1, ""); ++ static_assert(sum<23>::value == 23, ""); ++ static_assert(sum<1, 2>::value == 3, ""); ++ static_assert(sum<5, 5, 11>::value == 21, ""); ++ static_assert(sum<2, 3, 5, 7, 11, 13>::value == 41, ""); ++ ++ } ++ ++ // http://stackoverflow.com/questions/13728184/template-aliases-and-sfinae ++ // Clang 3.1 fails with headers of libstd++ 4.8.3 when using std::function ++ // because of this. ++ namespace test_template_alias_sfinae ++ { ++ ++ struct foo {}; ++ ++ template ++ using member = typename T::member_type; ++ ++ template ++ void func(...) {} ++ ++ template ++ void func(member*) {} ++ ++ void test(); ++ ++ void test() { func(0); } ++ ++ } ++ ++} // namespace cxx11 ++ ++#endif // __cplusplus >= 201103L ++ ++]]) ++ ++ ++dnl Tests for new features in C++14 ++ ++m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_14], [[ ++ ++// If the compiler admits that it is not ready for C++14, why torture it? ++// Hopefully, this will speed up the test. ++ ++#ifndef __cplusplus ++ ++#error "This is not a C++ compiler" ++ ++#elif __cplusplus < 201402L && !defined _MSC_VER ++ ++#error "This is not a C++14 compiler" ++ ++#else ++ ++namespace cxx14 ++{ ++ ++ namespace test_polymorphic_lambdas ++ { ++ ++ int ++ test() ++ { ++ const auto lambda = [](auto&&... args){ ++ const auto istiny = [](auto x){ ++ return (sizeof(x) == 1UL) ? 1 : 0; ++ }; ++ const int aretiny[] = { istiny(args)... }; ++ return aretiny[0]; ++ }; ++ return lambda(1, 1L, 1.0f, '1'); ++ } ++ ++ } ++ ++ namespace test_binary_literals ++ { ++ ++ constexpr auto ivii = 0b0000000000101010; ++ static_assert(ivii == 42, "wrong value"); ++ ++ } ++ ++ namespace test_generalized_constexpr ++ { ++ ++ template < typename CharT > ++ constexpr unsigned long ++ strlen_c(const CharT *const s) noexcept ++ { ++ auto length = 0UL; ++ for (auto p = s; *p; ++p) ++ ++length; ++ return length; ++ } ++ ++ static_assert(strlen_c("") == 0UL, ""); ++ static_assert(strlen_c("x") == 1UL, ""); ++ static_assert(strlen_c("test") == 4UL, ""); ++ static_assert(strlen_c("another\0test") == 7UL, ""); ++ ++ } ++ ++ namespace test_lambda_init_capture ++ { ++ ++ int ++ test() ++ { ++ auto x = 0; ++ const auto lambda1 = [a = x](int b){ return a + b; }; ++ const auto lambda2 = [a = lambda1(x)](){ return a; }; ++ return lambda2(); ++ } ++ ++ } ++ ++ namespace test_digit_separators ++ { ++ ++ constexpr auto ten_million = 100'000'000; ++ static_assert(ten_million == 100000000, ""); ++ ++ } ++ ++ namespace test_return_type_deduction ++ { ++ ++ auto f(int& x) { return x; } ++ decltype(auto) g(int& x) { return x; } ++ ++ template < typename T1, typename T2 > ++ struct is_same ++ { ++ static constexpr auto value = false; ++ }; ++ ++ template < typename T > ++ struct is_same ++ { ++ static constexpr auto value = true; ++ }; ++ ++ int ++ test() ++ { ++ auto x = 0; ++ static_assert(is_same::value, ""); ++ static_assert(is_same::value, ""); ++ return x; ++ } ++ ++ } ++ ++} // namespace cxx14 ++ ++#endif // __cplusplus >= 201402L ++ ++]]) ++ ++ ++dnl Tests for new features in C++17 ++ ++m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_17], [[ ++ ++// If the compiler admits that it is not ready for C++17, why torture it? ++// Hopefully, this will speed up the test. ++ ++#ifndef __cplusplus ++ ++#error "This is not a C++ compiler" ++ ++#elif __cplusplus < 201703L && !defined _MSC_VER ++ ++#error "This is not a C++17 compiler" ++ ++#else ++ ++#include ++#include ++#include ++ ++namespace cxx17 ++{ ++ ++ namespace test_constexpr_lambdas ++ { ++ ++ constexpr int foo = [](){return 42;}(); ++ ++ } ++ ++ namespace test::nested_namespace::definitions ++ { ++ ++ } ++ ++ namespace test_fold_expression ++ { ++ ++ template ++ int multiply(Args... args) ++ { ++ return (args * ... * 1); ++ } ++ ++ template ++ bool all(Args... args) ++ { ++ return (args && ...); ++ } ++ ++ } ++ ++ namespace test_extended_static_assert ++ { ++ ++ static_assert (true); ++ ++ } ++ ++ namespace test_auto_brace_init_list ++ { ++ ++ auto foo = {5}; ++ auto bar {5}; ++ ++ static_assert(std::is_same, decltype(foo)>::value); ++ static_assert(std::is_same::value); ++ } ++ ++ namespace test_typename_in_template_template_parameter ++ { ++ ++ template typename X> struct D; ++ ++ } ++ ++ namespace test_fallthrough_nodiscard_maybe_unused_attributes ++ { ++ ++ int f1() ++ { ++ return 42; ++ } ++ ++ [[nodiscard]] int f2() ++ { ++ [[maybe_unused]] auto unused = f1(); ++ ++ switch (f1()) ++ { ++ case 17: ++ f1(); ++ [[fallthrough]]; ++ case 42: ++ f1(); ++ } ++ return f1(); ++ } ++ ++ } ++ ++ namespace test_extended_aggregate_initialization ++ { ++ ++ struct base1 ++ { ++ int b1, b2 = 42; ++ }; ++ ++ struct base2 ++ { ++ base2() { ++ b3 = 42; ++ } ++ int b3; ++ }; ++ ++ struct derived : base1, base2 ++ { ++ int d; ++ }; ++ ++ derived d1 {{1, 2}, {}, 4}; // full initialization ++ derived d2 {{}, {}, 4}; // value-initialized bases ++ ++ } ++ ++ namespace test_general_range_based_for_loop ++ { ++ ++ struct iter ++ { ++ int i; ++ ++ int& operator* () ++ { ++ return i; ++ } ++ ++ const int& operator* () const ++ { ++ return i; ++ } ++ ++ iter& operator++() ++ { ++ ++i; ++ return *this; ++ } ++ }; ++ ++ struct sentinel ++ { ++ int i; ++ }; ++ ++ bool operator== (const iter& i, const sentinel& s) ++ { ++ return i.i == s.i; ++ } ++ ++ bool operator!= (const iter& i, const sentinel& s) ++ { ++ return !(i == s); ++ } ++ ++ struct range ++ { ++ iter begin() const ++ { ++ return {0}; ++ } ++ ++ sentinel end() const ++ { ++ return {5}; ++ } ++ }; ++ ++ void f() ++ { ++ range r {}; ++ ++ for (auto i : r) ++ { ++ [[maybe_unused]] auto v = i; ++ } ++ } ++ ++ } ++ ++ namespace test_lambda_capture_asterisk_this_by_value ++ { ++ ++ struct t ++ { ++ int i; ++ int foo() ++ { ++ return [*this]() ++ { ++ return i; ++ }(); ++ } ++ }; ++ ++ } ++ ++ namespace test_enum_class_construction ++ { ++ ++ enum class byte : unsigned char ++ {}; ++ ++ byte foo {42}; ++ ++ } ++ ++ namespace test_constexpr_if ++ { ++ ++ template ++ int f () ++ { ++ if constexpr(cond) ++ { ++ return 13; ++ } ++ else ++ { ++ return 42; ++ } ++ } ++ ++ } ++ ++ namespace test_selection_statement_with_initializer ++ { ++ ++ int f() ++ { ++ return 13; ++ } ++ ++ int f2() ++ { ++ if (auto i = f(); i > 0) ++ { ++ return 3; ++ } ++ ++ switch (auto i = f(); i + 4) ++ { ++ case 17: ++ return 2; ++ ++ default: ++ return 1; ++ } ++ } ++ ++ } ++ ++ namespace test_template_argument_deduction_for_class_templates ++ { ++ ++ template ++ struct pair ++ { ++ pair (T1 p1, T2 p2) ++ : m1 {p1}, ++ m2 {p2} ++ {} ++ ++ T1 m1; ++ T2 m2; ++ }; ++ ++ void f() ++ { ++ [[maybe_unused]] auto p = pair{13, 42u}; ++ } ++ ++ } ++ ++ namespace test_non_type_auto_template_parameters ++ { ++ ++ template ++ struct B ++ {}; ++ ++ B<5> b1; ++ B<'a'> b2; ++ ++ } ++ ++ namespace test_structured_bindings ++ { ++ ++ int arr[2] = { 1, 2 }; ++ std::pair pr = { 1, 2 }; ++ ++ auto f1() -> int(&)[2] ++ { ++ return arr; ++ } ++ ++ auto f2() -> std::pair& ++ { ++ return pr; ++ } ++ ++ struct S ++ { ++ int x1 : 2; ++ volatile double y1; ++ }; ++ ++ S f3() ++ { ++ return {}; ++ } ++ ++ auto [ x1, y1 ] = f1(); ++ auto& [ xr1, yr1 ] = f1(); ++ auto [ x2, y2 ] = f2(); ++ auto& [ xr2, yr2 ] = f2(); ++ const auto [ x3, y3 ] = f3(); ++ ++ } ++ ++ namespace test_exception_spec_type_system ++ { ++ ++ struct Good {}; ++ struct Bad {}; ++ ++ void g1() noexcept; ++ void g2(); ++ ++ template ++ Bad ++ f(T*, T*); ++ ++ template ++ Good ++ f(T1*, T2*); ++ ++ static_assert (std::is_same_v); ++ ++ } ++ ++ namespace test_inline_variables ++ { ++ ++ template void f(T) ++ {} ++ ++ template inline T g(T) ++ { ++ return T{}; ++ } ++ ++ template<> inline void f<>(int) ++ {} ++ ++ template<> int g<>(int) ++ { ++ return 5; ++ } ++ ++ } ++ ++} // namespace cxx17 ++ ++#endif // __cplusplus < 201703L && !defined _MSC_VER ++ ++]]) ++ ++ ++dnl Tests for new features in C++20 ++ ++m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_20], [[ ++ ++#ifndef __cplusplus ++ ++#error "This is not a C++ compiler" ++ ++#elif __cplusplus < 202002L && !defined _MSC_VER ++ ++#error "This is not a C++20 compiler" ++ ++#else ++ ++#include ++ ++namespace cxx20 ++{ ++ ++// As C++20 supports feature test macros in the standard, there is no ++// immediate need to actually test for feature availability on the ++// Autoconf side. ++ ++} // namespace cxx20 ++ ++#endif // __cplusplus < 202002L && !defined _MSC_VER ++ ++]]) +diff --git a/deps/cares/m4/ax_cxx_compile_stdcxx_11.m4 b/deps/cares/m4/ax_cxx_compile_stdcxx_11.m4 +index 229de30..1733fd8 100644 +--- a/deps/cares/m4/ax_cxx_compile_stdcxx_11.m4 ++++ b/deps/cares/m4/ax_cxx_compile_stdcxx_11.m4 +@@ -1,26 +1,23 @@ +-# ============================================================================ +-# http://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx_11.html +-# ============================================================================ ++# ============================================================================= ++# https://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx_11.html ++# ============================================================================= + # + # SYNOPSIS + # +-# AX_CXX_COMPILE_STDCXX_11([ext|noext],[mandatory|optional]) ++# AX_CXX_COMPILE_STDCXX_11([ext|noext], [mandatory|optional]) + # + # DESCRIPTION + # + # Check for baseline language coverage in the compiler for the C++11 +-# standard; if necessary, add switches to CXXFLAGS to enable support. ++# standard; if necessary, add switches to CXX and CXXCPP to enable ++# support. + # +-# The first argument, if specified, indicates whether you insist on an +-# extended mode (e.g. -std=gnu++11) or a strict conformance mode (e.g. +-# -std=c++11). If neither is specified, you get whatever works, with +-# preference for an extended mode. +-# +-# The second argument, if specified 'mandatory' or if left unspecified, +-# indicates that baseline C++11 support is required and that the macro +-# should error out if no mode with that support is found. If specified +-# 'optional', then configuration proceeds regardless, after defining +-# HAVE_CXX11 if and only if a supporting mode is found. ++# This macro is a convenience alias for calling the AX_CXX_COMPILE_STDCXX ++# macro with the version set to C++11. The two optional arguments are ++# forwarded literally as the second and third argument respectively. ++# Please see the documentation for the AX_CXX_COMPILE_STDCXX macro for ++# more information. If you want to use this macro, you also need to ++# download the ax_cxx_compile_stdcxx.m4 file. + # + # LICENSE + # +@@ -28,136 +25,15 @@ + # Copyright (c) 2012 Zack Weinberg + # Copyright (c) 2013 Roy Stogner + # Copyright (c) 2014, 2015 Google Inc.; contributed by Alexey Sokolov ++# Copyright (c) 2015 Paul Norman ++# Copyright (c) 2015 Moritz Klammler + # + # Copying and distribution of this file, with or without modification, are + # permitted in any medium without royalty provided the copyright notice + # and this notice are preserved. This file is offered as-is, without any + # warranty. + +-#serial 9 +- +-m4_define([_AX_CXX_COMPILE_STDCXX_11_testbody], [[ +- template +- struct check +- { +- static_assert(sizeof(int) <= sizeof(T), "not big enough"); +- }; +- +- struct Base { +- virtual void f() {} +- }; +- struct Child : public Base { +- virtual void f() override {} +- }; +- +- typedef check> right_angle_brackets; +- +- int a; +- decltype(a) b; +- +- typedef check check_type; +- check_type c; +- check_type&& cr = static_cast(c); +- +- auto d = a; +- auto l = [](){}; +- +- // http://stackoverflow.com/questions/13728184/template-aliases-and-sfinae +- // Clang 3.1 fails with headers of libstd++ 4.8.3 when using std::function because of this +- namespace test_template_alias_sfinae { +- struct foo {}; +- +- template +- using member = typename T::member_type; +- +- template +- void func(...) {} +- +- template +- void func(member*) {} +- +- void test(); +- +- void test() { +- func(0); +- } +- } +-]]) +- +-AC_DEFUN([AX_CXX_COMPILE_STDCXX_11], [dnl +- m4_if([$1], [], [], +- [$1], [ext], [], +- [$1], [noext], [], +- [m4_fatal([invalid argument `$1' to AX_CXX_COMPILE_STDCXX_11])])dnl +- m4_if([$2], [], [ax_cxx_compile_cxx11_required=true], +- [$2], [mandatory], [ax_cxx_compile_cxx11_required=true], +- [$2], [optional], [ax_cxx_compile_cxx11_required=false], +- [m4_fatal([invalid second argument `$2' to AX_CXX_COMPILE_STDCXX_11])]) +- AC_LANG_PUSH([C++])dnl +- ac_success=no +- AC_CACHE_CHECK(whether $CXX supports C++11 features by default, +- ax_cv_cxx_compile_cxx11, +- [AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_11_testbody])], +- [ax_cv_cxx_compile_cxx11=yes], +- [ax_cv_cxx_compile_cxx11=no])]) +- if test x$ax_cv_cxx_compile_cxx11 = xyes; then +- ac_success=yes +- fi +- +- m4_if([$1], [noext], [], [dnl +- if test x$ac_success = xno; then +- for switch in -std=gnu++11 -std=gnu++0x; do +- cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx11_$switch]) +- AC_CACHE_CHECK(whether $CXX supports C++11 features with $switch, +- $cachevar, +- [ac_save_CXXFLAGS="$CXXFLAGS" +- CXXFLAGS="$CXXFLAGS $switch" +- AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_11_testbody])], +- [eval $cachevar=yes], +- [eval $cachevar=no]) +- CXXFLAGS="$ac_save_CXXFLAGS"]) +- if eval test x\$$cachevar = xyes; then +- CXXFLAGS="$CXXFLAGS $switch" +- ac_success=yes +- break +- fi +- done +- fi]) +- +- m4_if([$1], [ext], [], [dnl +- if test x$ac_success = xno; then +- for switch in -std=c++11 -std=c++0x; do +- cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx11_$switch]) +- AC_CACHE_CHECK(whether $CXX supports C++11 features with $switch, +- $cachevar, +- [ac_save_CXXFLAGS="$CXXFLAGS" +- CXXFLAGS="$CXXFLAGS $switch" +- AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_11_testbody])], +- [eval $cachevar=yes], +- [eval $cachevar=no]) +- CXXFLAGS="$ac_save_CXXFLAGS"]) +- if eval test x\$$cachevar = xyes; then +- CXXFLAGS="$CXXFLAGS $switch" +- ac_success=yes +- break +- fi +- done +- fi]) +- AC_LANG_POP([C++]) +- if test x$ax_cxx_compile_cxx11_required = xtrue; then +- if test x$ac_success = xno; then +- AC_MSG_ERROR([*** A compiler with support for C++11 language features is required.]) +- fi +- else +- if test x$ac_success = xno; then +- HAVE_CXX11=0 +- AC_MSG_NOTICE([No compiler with C++11 support was found]) +- else +- HAVE_CXX11=1 +- AC_DEFINE(HAVE_CXX11,1, +- [define if the compiler supports basic C++11 syntax]) +- fi ++#serial 18 + +- AC_SUBST(HAVE_CXX11) +- fi +-]) ++AX_REQUIRE_DEFINED([AX_CXX_COMPILE_STDCXX]) ++AC_DEFUN([AX_CXX_COMPILE_STDCXX_11], [AX_CXX_COMPILE_STDCXX([11], [$1], [$2])]) +diff --git a/deps/cares/m4/ax_pthread.m4 b/deps/cares/m4/ax_pthread.m4 +index d383ad5..9f35d13 100644 +--- a/deps/cares/m4/ax_pthread.m4 ++++ b/deps/cares/m4/ax_pthread.m4 +@@ -1,5 +1,5 @@ + # =========================================================================== +-# http://www.gnu.org/software/autoconf-archive/ax_pthread.html ++# https://www.gnu.org/software/autoconf-archive/ax_pthread.html + # =========================================================================== + # + # SYNOPSIS +@@ -14,24 +14,28 @@ + # flags that are needed. (The user can also force certain compiler + # flags/libs to be tested by setting these environment variables.) + # +-# Also sets PTHREAD_CC to any special C compiler that is needed for +-# multi-threaded programs (defaults to the value of CC otherwise). (This +-# is necessary on AIX to use the special cc_r compiler alias.) ++# Also sets PTHREAD_CC and PTHREAD_CXX to any special C compiler that is ++# needed for multi-threaded programs (defaults to the value of CC ++# respectively CXX otherwise). (This is necessary on e.g. AIX to use the ++# special cc_r/CC_r compiler alias.) + # + # NOTE: You are assumed to not only compile your program with these flags, +-# but also link it with them as well. e.g. you should link with ++# but also to link with them as well. For example, you might link with + # $PTHREAD_CC $CFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS $LIBS ++# $PTHREAD_CXX $CXXFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS $LIBS + # +-# If you are only building threads programs, you may wish to use these ++# If you are only building threaded programs, you may wish to use these + # variables in your default LIBS, CFLAGS, and CC: + # + # LIBS="$PTHREAD_LIBS $LIBS" + # CFLAGS="$CFLAGS $PTHREAD_CFLAGS" ++# CXXFLAGS="$CXXFLAGS $PTHREAD_CFLAGS" + # CC="$PTHREAD_CC" ++# CXX="$PTHREAD_CXX" + # + # In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute constant +-# has a nonstandard name, defines PTHREAD_CREATE_JOINABLE to that name +-# (e.g. PTHREAD_CREATE_UNDETACHED on AIX). ++# has a nonstandard name, this macro defines PTHREAD_CREATE_JOINABLE to ++# that name (e.g. PTHREAD_CREATE_UNDETACHED on AIX). + # + # Also HAVE_PTHREAD_PRIO_INHERIT is defined if pthread is found and the + # PTHREAD_PRIO_INHERIT symbol is defined when compiling with +@@ -55,6 +59,7 @@ + # + # Copyright (c) 2008 Steven G. Johnson + # Copyright (c) 2011 Daniel Richard G. ++# Copyright (c) 2019 Marc Stevens + # + # This program is free software: you can redistribute it and/or modify it + # under the terms of the GNU General Public License as published by the +@@ -67,7 +72,7 @@ + # Public License for more details. + # + # You should have received a copy of the GNU General Public License along +-# with this program. If not, see . ++# with this program. If not, see . + # + # As a special exception, the respective Autoconf Macro's copyright owner + # gives unlimited permission to copy, distribute and modify the configure +@@ -82,35 +87,41 @@ + # modified version of the Autoconf Macro, you may extend this special + # exception to the GPL to apply to your modified version as well. + +-#serial 21 ++#serial 31 + + AU_ALIAS([ACX_PTHREAD], [AX_PTHREAD]) + AC_DEFUN([AX_PTHREAD], [ + AC_REQUIRE([AC_CANONICAL_HOST]) ++AC_REQUIRE([AC_PROG_CC]) ++AC_REQUIRE([AC_PROG_SED]) + AC_LANG_PUSH([C]) + ax_pthread_ok=no + + # We used to check for pthread.h first, but this fails if pthread.h +-# requires special compiler flags (e.g. on True64 or Sequent). ++# requires special compiler flags (e.g. on Tru64 or Sequent). + # It gets checked for in the link test anyway. + + # First of all, check if the user has set any of the PTHREAD_LIBS, + # etcetera environment variables, and if threads linking works using + # them: +-if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then +- save_CFLAGS="$CFLAGS" ++if test "x$PTHREAD_CFLAGS$PTHREAD_LIBS" != "x"; then ++ ax_pthread_save_CC="$CC" ++ ax_pthread_save_CFLAGS="$CFLAGS" ++ ax_pthread_save_LIBS="$LIBS" ++ AS_IF([test "x$PTHREAD_CC" != "x"], [CC="$PTHREAD_CC"]) ++ AS_IF([test "x$PTHREAD_CXX" != "x"], [CXX="$PTHREAD_CXX"]) + CFLAGS="$CFLAGS $PTHREAD_CFLAGS" +- save_LIBS="$LIBS" + LIBS="$PTHREAD_LIBS $LIBS" +- AC_MSG_CHECKING([for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS]) +- AC_TRY_LINK_FUNC([pthread_join], [ax_pthread_ok=yes]) ++ AC_MSG_CHECKING([for pthread_join using $CC $PTHREAD_CFLAGS $PTHREAD_LIBS]) ++ AC_LINK_IFELSE([AC_LANG_CALL([], [pthread_join])], [ax_pthread_ok=yes]) + AC_MSG_RESULT([$ax_pthread_ok]) +- if test x"$ax_pthread_ok" = xno; then ++ if test "x$ax_pthread_ok" = "xno"; then + PTHREAD_LIBS="" + PTHREAD_CFLAGS="" + fi +- LIBS="$save_LIBS" +- CFLAGS="$save_CFLAGS" ++ CC="$ax_pthread_save_CC" ++ CFLAGS="$ax_pthread_save_CFLAGS" ++ LIBS="$ax_pthread_save_LIBS" + fi + + # We must check for the threads library under a number of different +@@ -118,12 +129,14 @@ fi + # (e.g. DEC) have both -lpthread and -lpthreads, where one of the + # libraries is broken (non-POSIX). + +-# Create a list of thread flags to try. Items starting with a "-" are +-# C compiler flags, and other items are library names, except for "none" +-# which indicates that we try without any flags at all, and "pthread-config" +-# which is a program returning the flags for the Pth emulation library. ++# Create a list of thread flags to try. Items with a "," contain both ++# C compiler flags (before ",") and linker flags (after ","). Other items ++# starting with a "-" are C compiler flags, and remaining items are ++# library names, except for "none" which indicates that we try without ++# any flags at all, and "pthread-config" which is a program returning ++# the flags for the Pth emulation library. + +-ax_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config" ++ax_pthread_flags="pthreads none -Kthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config" + + # The ordering *is* (sometimes) important. Some notes on the + # individual items follow: +@@ -132,82 +145,163 @@ ax_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mt + # none: in case threads are in libc; should be tried before -Kthread and + # other compiler flags to prevent continual compiler warnings + # -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h) +-# -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able) +-# lthread: LinuxThreads port on FreeBSD (also preferred to -pthread) +-# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads) +-# -pthreads: Solaris/gcc +-# -mthreads: Mingw32/gcc, Lynx/gcc ++# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads), Tru64 ++# (Note: HP C rejects this with "bad form for `-t' option") ++# -pthreads: Solaris/gcc (Note: HP C also rejects) + # -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it +-# doesn't hurt to check since this sometimes defines pthreads too; +-# also defines -D_REENTRANT) +-# ... -mt is also the pthreads flag for HP/aCC ++# doesn't hurt to check since this sometimes defines pthreads and ++# -D_REENTRANT too), HP C (must be checked before -lpthread, which ++# is present but should not be used directly; and before -mthreads, ++# because the compiler interprets this as "-mt" + "-hreads") ++# -mthreads: Mingw32/gcc, Lynx/gcc + # pthread: Linux, etcetera + # --thread-safe: KAI C++ + # pthread-config: use pthread-config program (for GNU Pth library) + +-case ${host_os} in ++case $host_os in ++ ++ freebsd*) ++ ++ # -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able) ++ # lthread: LinuxThreads port on FreeBSD (also preferred to -pthread) ++ ++ ax_pthread_flags="-kthread lthread $ax_pthread_flags" ++ ;; ++ ++ hpux*) ++ ++ # From the cc(1) man page: "[-mt] Sets various -D flags to enable ++ # multi-threading and also sets -lpthread." ++ ++ ax_pthread_flags="-mt -pthread pthread $ax_pthread_flags" ++ ;; ++ ++ openedition*) ++ ++ # IBM z/OS requires a feature-test macro to be defined in order to ++ # enable POSIX threads at all, so give the user a hint if this is ++ # not set. (We don't define these ourselves, as they can affect ++ # other portions of the system API in unpredictable ways.) ++ ++ AC_EGREP_CPP([AX_PTHREAD_ZOS_MISSING], ++ [ ++# if !defined(_OPEN_THREADS) && !defined(_UNIX03_THREADS) ++ AX_PTHREAD_ZOS_MISSING ++# endif ++ ], ++ [AC_MSG_WARN([IBM z/OS requires -D_OPEN_THREADS or -D_UNIX03_THREADS to enable pthreads support.])]) ++ ;; ++ + solaris*) + + # On Solaris (at least, for some versions), libc contains stubbed + # (non-functional) versions of the pthreads routines, so link-based +- # tests will erroneously succeed. (We need to link with -pthreads/-mt/ +- # -lpthread.) (The stubs are missing pthread_cleanup_push, or rather +- # a function called by this macro, so we could check for that, but +- # who knows whether they'll stub that too in a future libc.) So, +- # we'll just look for -pthreads and -lpthread first: ++ # tests will erroneously succeed. (N.B.: The stubs are missing ++ # pthread_cleanup_push, or rather a function called by this macro, ++ # so we could check for that, but who knows whether they'll stub ++ # that too in a future libc.) So we'll check first for the ++ # standard Solaris way of linking pthreads (-mt -lpthread). ++ ++ ax_pthread_flags="-mt,-lpthread pthread $ax_pthread_flags" ++ ;; ++esac ++ ++# Are we compiling with Clang? ++ ++AC_CACHE_CHECK([whether $CC is Clang], ++ [ax_cv_PTHREAD_CLANG], ++ [ax_cv_PTHREAD_CLANG=no ++ # Note that Autoconf sets GCC=yes for Clang as well as GCC ++ if test "x$GCC" = "xyes"; then ++ AC_EGREP_CPP([AX_PTHREAD_CC_IS_CLANG], ++ [/* Note: Clang 2.7 lacks __clang_[a-z]+__ */ ++# if defined(__clang__) && defined(__llvm__) ++ AX_PTHREAD_CC_IS_CLANG ++# endif ++ ], ++ [ax_cv_PTHREAD_CLANG=yes]) ++ fi ++ ]) ++ax_pthread_clang="$ax_cv_PTHREAD_CLANG" ++ ++ ++# GCC generally uses -pthread, or -pthreads on some platforms (e.g. SPARC) ++ ++# Note that for GCC and Clang -pthread generally implies -lpthread, ++# except when -nostdlib is passed. ++# This is problematic using libtool to build C++ shared libraries with pthread: ++# [1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=25460 ++# [2] https://bugzilla.redhat.com/show_bug.cgi?id=661333 ++# [3] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=468555 ++# To solve this, first try -pthread together with -lpthread for GCC ++ ++AS_IF([test "x$GCC" = "xyes"], ++ [ax_pthread_flags="-pthread,-lpthread -pthread -pthreads $ax_pthread_flags"]) ++ ++# Clang takes -pthread (never supported any other flag), but we'll try with -lpthread first ++ ++AS_IF([test "x$ax_pthread_clang" = "xyes"], ++ [ax_pthread_flags="-pthread,-lpthread -pthread"]) + +- ax_pthread_flags="-pthreads pthread -mt -pthread $ax_pthread_flags" ++ ++# The presence of a feature test macro requesting re-entrant function ++# definitions is, on some systems, a strong hint that pthreads support is ++# correctly enabled ++ ++case $host_os in ++ darwin* | hpux* | linux* | osf* | solaris*) ++ ax_pthread_check_macro="_REENTRANT" + ;; + +- darwin*) +- ax_pthread_flags="-pthread $ax_pthread_flags" ++ aix*) ++ ax_pthread_check_macro="_THREAD_SAFE" + ;; +-esac + +-# Clang doesn't consider unrecognized options an error unless we specify +-# -Werror. We throw in some extra Clang-specific options to ensure that +-# this doesn't happen for GCC, which also accepts -Werror. ++ *) ++ ax_pthread_check_macro="--" ++ ;; ++esac ++AS_IF([test "x$ax_pthread_check_macro" = "x--"], ++ [ax_pthread_check_cond=0], ++ [ax_pthread_check_cond="!defined($ax_pthread_check_macro)"]) + +-AC_MSG_CHECKING([if compiler needs -Werror to reject unknown flags]) +-save_CFLAGS="$CFLAGS" +-ax_pthread_extra_flags="-Werror" +-CFLAGS="$CFLAGS $ax_pthread_extra_flags -Wunknown-warning-option -Wsizeof-array-argument" +-AC_COMPILE_IFELSE([AC_LANG_PROGRAM([int foo(void);],[foo()])], +- [AC_MSG_RESULT([yes])], +- [ax_pthread_extra_flags= +- AC_MSG_RESULT([no])]) +-CFLAGS="$save_CFLAGS" + +-if test x"$ax_pthread_ok" = xno; then +-for flag in $ax_pthread_flags; do ++if test "x$ax_pthread_ok" = "xno"; then ++for ax_pthread_try_flag in $ax_pthread_flags; do + +- case $flag in ++ case $ax_pthread_try_flag in + none) + AC_MSG_CHECKING([whether pthreads work without any flags]) + ;; + ++ *,*) ++ PTHREAD_CFLAGS=`echo $ax_pthread_try_flag | sed "s/^\(.*\),\(.*\)$/\1/"` ++ PTHREAD_LIBS=`echo $ax_pthread_try_flag | sed "s/^\(.*\),\(.*\)$/\2/"` ++ AC_MSG_CHECKING([whether pthreads work with "$PTHREAD_CFLAGS" and "$PTHREAD_LIBS"]) ++ ;; ++ + -*) +- AC_MSG_CHECKING([whether pthreads work with $flag]) +- PTHREAD_CFLAGS="$flag" ++ AC_MSG_CHECKING([whether pthreads work with $ax_pthread_try_flag]) ++ PTHREAD_CFLAGS="$ax_pthread_try_flag" + ;; + + pthread-config) + AC_CHECK_PROG([ax_pthread_config], [pthread-config], [yes], [no]) +- if test x"$ax_pthread_config" = xno; then continue; fi ++ AS_IF([test "x$ax_pthread_config" = "xno"], [continue]) + PTHREAD_CFLAGS="`pthread-config --cflags`" + PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`" + ;; + + *) +- AC_MSG_CHECKING([for the pthreads library -l$flag]) +- PTHREAD_LIBS="-l$flag" ++ AC_MSG_CHECKING([for the pthreads library -l$ax_pthread_try_flag]) ++ PTHREAD_LIBS="-l$ax_pthread_try_flag" + ;; + esac + +- save_LIBS="$LIBS" +- save_CFLAGS="$CFLAGS" ++ ax_pthread_save_CFLAGS="$CFLAGS" ++ ax_pthread_save_LIBS="$LIBS" ++ CFLAGS="$CFLAGS $PTHREAD_CFLAGS" + LIBS="$PTHREAD_LIBS $LIBS" +- CFLAGS="$CFLAGS $PTHREAD_CFLAGS $ax_pthread_extra_flags" + + # Check for various functions. We must include pthread.h, + # since some functions may be macros. (On the Sequent, we +@@ -218,8 +312,18 @@ for flag in $ax_pthread_flags; do + # pthread_cleanup_push because it is one of the few pthread + # functions on Solaris that doesn't have a non-functional libc stub. + # We try pthread_create on general principles. ++ + AC_LINK_IFELSE([AC_LANG_PROGRAM([#include +- static void routine(void *a) { a = 0; } ++# if $ax_pthread_check_cond ++# error "$ax_pthread_check_macro must be defined" ++# endif ++ static void *some_global = NULL; ++ static void routine(void *a) ++ { ++ /* To avoid any unused-parameter or ++ unused-but-set-parameter warning. */ ++ some_global = a; ++ } + static void *start_routine(void *a) { return a; }], + [pthread_t th; pthread_attr_t attr; + pthread_create(&th, 0, start_routine, 0); +@@ -227,101 +331,187 @@ for flag in $ax_pthread_flags; do + pthread_attr_init(&attr); + pthread_cleanup_push(routine, 0); + pthread_cleanup_pop(0) /* ; */])], +- [ax_pthread_ok=yes], +- []) ++ [ax_pthread_ok=yes], ++ []) + +- LIBS="$save_LIBS" +- CFLAGS="$save_CFLAGS" ++ CFLAGS="$ax_pthread_save_CFLAGS" ++ LIBS="$ax_pthread_save_LIBS" + + AC_MSG_RESULT([$ax_pthread_ok]) +- if test "x$ax_pthread_ok" = xyes; then +- break; +- fi ++ AS_IF([test "x$ax_pthread_ok" = "xyes"], [break]) + + PTHREAD_LIBS="" + PTHREAD_CFLAGS="" + done + fi + ++ ++# Clang needs special handling, because older versions handle the -pthread ++# option in a rather... idiosyncratic way ++ ++if test "x$ax_pthread_clang" = "xyes"; then ++ ++ # Clang takes -pthread; it has never supported any other flag ++ ++ # (Note 1: This will need to be revisited if a system that Clang ++ # supports has POSIX threads in a separate library. This tends not ++ # to be the way of modern systems, but it's conceivable.) ++ ++ # (Note 2: On some systems, notably Darwin, -pthread is not needed ++ # to get POSIX threads support; the API is always present and ++ # active. We could reasonably leave PTHREAD_CFLAGS empty. But ++ # -pthread does define _REENTRANT, and while the Darwin headers ++ # ignore this macro, third-party headers might not.) ++ ++ # However, older versions of Clang make a point of warning the user ++ # that, in an invocation where only linking and no compilation is ++ # taking place, the -pthread option has no effect ("argument unused ++ # during compilation"). They expect -pthread to be passed in only ++ # when source code is being compiled. ++ # ++ # Problem is, this is at odds with the way Automake and most other ++ # C build frameworks function, which is that the same flags used in ++ # compilation (CFLAGS) are also used in linking. Many systems ++ # supported by AX_PTHREAD require exactly this for POSIX threads ++ # support, and in fact it is often not straightforward to specify a ++ # flag that is used only in the compilation phase and not in ++ # linking. Such a scenario is extremely rare in practice. ++ # ++ # Even though use of the -pthread flag in linking would only print ++ # a warning, this can be a nuisance for well-run software projects ++ # that build with -Werror. So if the active version of Clang has ++ # this misfeature, we search for an option to squash it. ++ ++ AC_CACHE_CHECK([whether Clang needs flag to prevent "argument unused" warning when linking with -pthread], ++ [ax_cv_PTHREAD_CLANG_NO_WARN_FLAG], ++ [ax_cv_PTHREAD_CLANG_NO_WARN_FLAG=unknown ++ # Create an alternate version of $ac_link that compiles and ++ # links in two steps (.c -> .o, .o -> exe) instead of one ++ # (.c -> exe), because the warning occurs only in the second ++ # step ++ ax_pthread_save_ac_link="$ac_link" ++ ax_pthread_sed='s/conftest\.\$ac_ext/conftest.$ac_objext/g' ++ ax_pthread_link_step=`AS_ECHO(["$ac_link"]) | sed "$ax_pthread_sed"` ++ ax_pthread_2step_ac_link="($ac_compile) && (echo ==== >&5) && ($ax_pthread_link_step)" ++ ax_pthread_save_CFLAGS="$CFLAGS" ++ for ax_pthread_try in '' -Qunused-arguments -Wno-unused-command-line-argument unknown; do ++ AS_IF([test "x$ax_pthread_try" = "xunknown"], [break]) ++ CFLAGS="-Werror -Wunknown-warning-option $ax_pthread_try -pthread $ax_pthread_save_CFLAGS" ++ ac_link="$ax_pthread_save_ac_link" ++ AC_LINK_IFELSE([AC_LANG_SOURCE([[int main(void){return 0;}]])], ++ [ac_link="$ax_pthread_2step_ac_link" ++ AC_LINK_IFELSE([AC_LANG_SOURCE([[int main(void){return 0;}]])], ++ [break]) ++ ]) ++ done ++ ac_link="$ax_pthread_save_ac_link" ++ CFLAGS="$ax_pthread_save_CFLAGS" ++ AS_IF([test "x$ax_pthread_try" = "x"], [ax_pthread_try=no]) ++ ax_cv_PTHREAD_CLANG_NO_WARN_FLAG="$ax_pthread_try" ++ ]) ++ ++ case "$ax_cv_PTHREAD_CLANG_NO_WARN_FLAG" in ++ no | unknown) ;; ++ *) PTHREAD_CFLAGS="$ax_cv_PTHREAD_CLANG_NO_WARN_FLAG $PTHREAD_CFLAGS" ;; ++ esac ++ ++fi # $ax_pthread_clang = yes ++ ++ ++ + # Various other checks: +-if test "x$ax_pthread_ok" = xyes; then +- save_LIBS="$LIBS" +- LIBS="$PTHREAD_LIBS $LIBS" +- save_CFLAGS="$CFLAGS" ++if test "x$ax_pthread_ok" = "xyes"; then ++ ax_pthread_save_CFLAGS="$CFLAGS" ++ ax_pthread_save_LIBS="$LIBS" + CFLAGS="$CFLAGS $PTHREAD_CFLAGS" ++ LIBS="$PTHREAD_LIBS $LIBS" + + # Detect AIX lossage: JOINABLE attribute is called UNDETACHED. +- AC_MSG_CHECKING([for joinable pthread attribute]) +- attr_name=unknown +- for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do +- AC_LINK_IFELSE([AC_LANG_PROGRAM([#include ], +- [int attr = $attr; return attr /* ; */])], +- [attr_name=$attr; break], +- []) +- done +- AC_MSG_RESULT([$attr_name]) +- if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then +- AC_DEFINE_UNQUOTED([PTHREAD_CREATE_JOINABLE], [$attr_name], +- [Define to necessary symbol if this constant +- uses a non-standard name on your system.]) +- fi +- +- AC_MSG_CHECKING([if more special flags are required for pthreads]) +- flag=no +- case ${host_os} in +- aix* | freebsd* | darwin*) flag="-D_THREAD_SAFE";; +- osf* | hpux*) flag="-D_REENTRANT";; +- solaris*) +- if test "$GCC" = "yes"; then +- flag="-D_REENTRANT" +- else +- # TODO: What about Clang on Solaris? +- flag="-mt -D_REENTRANT" +- fi +- ;; +- esac +- AC_MSG_RESULT([$flag]) +- if test "x$flag" != xno; then +- PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS" +- fi ++ AC_CACHE_CHECK([for joinable pthread attribute], ++ [ax_cv_PTHREAD_JOINABLE_ATTR], ++ [ax_cv_PTHREAD_JOINABLE_ATTR=unknown ++ for ax_pthread_attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do ++ AC_LINK_IFELSE([AC_LANG_PROGRAM([#include ], ++ [int attr = $ax_pthread_attr; return attr /* ; */])], ++ [ax_cv_PTHREAD_JOINABLE_ATTR=$ax_pthread_attr; break], ++ []) ++ done ++ ]) ++ AS_IF([test "x$ax_cv_PTHREAD_JOINABLE_ATTR" != "xunknown" && \ ++ test "x$ax_cv_PTHREAD_JOINABLE_ATTR" != "xPTHREAD_CREATE_JOINABLE" && \ ++ test "x$ax_pthread_joinable_attr_defined" != "xyes"], ++ [AC_DEFINE_UNQUOTED([PTHREAD_CREATE_JOINABLE], ++ [$ax_cv_PTHREAD_JOINABLE_ATTR], ++ [Define to necessary symbol if this constant ++ uses a non-standard name on your system.]) ++ ax_pthread_joinable_attr_defined=yes ++ ]) ++ ++ AC_CACHE_CHECK([whether more special flags are required for pthreads], ++ [ax_cv_PTHREAD_SPECIAL_FLAGS], ++ [ax_cv_PTHREAD_SPECIAL_FLAGS=no ++ case $host_os in ++ solaris*) ++ ax_cv_PTHREAD_SPECIAL_FLAGS="-D_POSIX_PTHREAD_SEMANTICS" ++ ;; ++ esac ++ ]) ++ AS_IF([test "x$ax_cv_PTHREAD_SPECIAL_FLAGS" != "xno" && \ ++ test "x$ax_pthread_special_flags_added" != "xyes"], ++ [PTHREAD_CFLAGS="$ax_cv_PTHREAD_SPECIAL_FLAGS $PTHREAD_CFLAGS" ++ ax_pthread_special_flags_added=yes]) + + AC_CACHE_CHECK([for PTHREAD_PRIO_INHERIT], +- [ax_cv_PTHREAD_PRIO_INHERIT], [ +- AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include ]], +- [[int i = PTHREAD_PRIO_INHERIT;]])], +- [ax_cv_PTHREAD_PRIO_INHERIT=yes], +- [ax_cv_PTHREAD_PRIO_INHERIT=no]) ++ [ax_cv_PTHREAD_PRIO_INHERIT], ++ [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include ]], ++ [[int i = PTHREAD_PRIO_INHERIT; ++ return i;]])], ++ [ax_cv_PTHREAD_PRIO_INHERIT=yes], ++ [ax_cv_PTHREAD_PRIO_INHERIT=no]) + ]) +- AS_IF([test "x$ax_cv_PTHREAD_PRIO_INHERIT" = "xyes"], +- [AC_DEFINE([HAVE_PTHREAD_PRIO_INHERIT], [1], [Have PTHREAD_PRIO_INHERIT.])]) ++ AS_IF([test "x$ax_cv_PTHREAD_PRIO_INHERIT" = "xyes" && \ ++ test "x$ax_pthread_prio_inherit_defined" != "xyes"], ++ [AC_DEFINE([HAVE_PTHREAD_PRIO_INHERIT], [1], [Have PTHREAD_PRIO_INHERIT.]) ++ ax_pthread_prio_inherit_defined=yes ++ ]) + +- LIBS="$save_LIBS" +- CFLAGS="$save_CFLAGS" ++ CFLAGS="$ax_pthread_save_CFLAGS" ++ LIBS="$ax_pthread_save_LIBS" + + # More AIX lossage: compile with *_r variant +- if test "x$GCC" != xyes; then ++ if test "x$GCC" != "xyes"; then + case $host_os in + aix*) + AS_CASE(["x/$CC"], +- [x*/c89|x*/c89_128|x*/c99|x*/c99_128|x*/cc|x*/cc128|x*/xlc|x*/xlc_v6|x*/xlc128|x*/xlc128_v6], +- [#handle absolute path differently from PATH based program lookup +- AS_CASE(["x$CC"], +- [x/*], +- [AS_IF([AS_EXECUTABLE_P([${CC}_r])],[PTHREAD_CC="${CC}_r"])], +- [AC_CHECK_PROGS([PTHREAD_CC],[${CC}_r],[$CC])])]) ++ [x*/c89|x*/c89_128|x*/c99|x*/c99_128|x*/cc|x*/cc128|x*/xlc|x*/xlc_v6|x*/xlc128|x*/xlc128_v6], ++ [#handle absolute path differently from PATH based program lookup ++ AS_CASE(["x$CC"], ++ [x/*], ++ [ ++ AS_IF([AS_EXECUTABLE_P([${CC}_r])],[PTHREAD_CC="${CC}_r"]) ++ AS_IF([test "x${CXX}" != "x"], [AS_IF([AS_EXECUTABLE_P([${CXX}_r])],[PTHREAD_CXX="${CXX}_r"])]) ++ ], ++ [ ++ AC_CHECK_PROGS([PTHREAD_CC],[${CC}_r],[$CC]) ++ AS_IF([test "x${CXX}" != "x"], [AC_CHECK_PROGS([PTHREAD_CXX],[${CXX}_r],[$CXX])]) ++ ] ++ ) ++ ]) + ;; + esac + fi + fi + + test -n "$PTHREAD_CC" || PTHREAD_CC="$CC" ++test -n "$PTHREAD_CXX" || PTHREAD_CXX="$CXX" + + AC_SUBST([PTHREAD_LIBS]) + AC_SUBST([PTHREAD_CFLAGS]) + AC_SUBST([PTHREAD_CC]) ++AC_SUBST([PTHREAD_CXX]) + + # Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND: +-if test x"$ax_pthread_ok" = xyes; then ++if test "x$ax_pthread_ok" = "xyes"; then + ifelse([$1],,[AC_DEFINE([HAVE_PTHREAD],[1],[Define if you have POSIX threads libraries and header files.])],[$1]) + : + else +diff --git a/deps/cares/m4/cares-compilers.m4 b/deps/cares/m4/cares-compilers.m4 +index 5ae6b90..a5b1e2b 100644 +--- a/deps/cares/m4/cares-compilers.m4 ++++ b/deps/cares/m4/cares-compilers.m4 +@@ -609,12 +609,12 @@ AC_DEFUN([CARES_SET_COMPILER_BASIC_OPTS], [ + dnl #147: declaration is incompatible with 'previous one' + dnl #165: too few arguments in function call + dnl #266: function declared implicitly +- tmp_CPPFLAGS="$tmp_CPPFLAGS -we 140,147,165,266" ++ tmp_CPPFLAGS="$tmp_CPPFLAGS -diag-error 140,147,165,266" + dnl Disable some remarks + dnl #279: controlling expression is constant + dnl #981: operands are evaluated in unspecified order + dnl #1469: "cc" clobber ignored +- tmp_CPPFLAGS="$tmp_CPPFLAGS -wd 279,981,1469" ++ tmp_CPPFLAGS="$tmp_CPPFLAGS -diag-disable 279,981,1469" + ;; + # + INTEL_WINDOWS_C) +diff --git a/deps/cares/m4/cares-functions.m4 b/deps/cares/m4/cares-functions.m4 +index 0f3992c..d4f4f99 100644 +--- a/deps/cares/m4/cares-functions.m4 ++++ b/deps/cares/m4/cares-functions.m4 +@@ -3753,3 +3753,88 @@ AC_DEFUN([CARES_CHECK_FUNC_WRITEV], [ + ac_cv_func_writev="no" + fi + ]) ++ ++dnl CARES_CHECK_FUNC_ARC4RANDOM_BUF ++dnl ------------------------------------------------- ++dnl Verify if arc4random_buf is available, prototyped, and ++dnl can be compiled. If all of these are true, and ++dnl usage has not been previously disallowed with ++dnl shell variable cares_disallow_arc4random_buf, then ++dnl HAVE_ARC4RANDOM_BUF will be defined. ++ ++AC_DEFUN([CARES_CHECK_FUNC_ARC4RANDOM_BUF], [ ++ AC_REQUIRE([CARES_INCLUDES_STDLIB])dnl ++ # ++ tst_links_arc4random_buf="unknown" ++ tst_proto_arc4random_buf="unknown" ++ tst_compi_arc4random_buf="unknown" ++ tst_allow_arc4random_buf="unknown" ++ # ++ AC_MSG_CHECKING([if arc4random_buf can be linked]) ++ AC_LINK_IFELSE([ ++ AC_LANG_FUNC_LINK_TRY([arc4random_buf]) ++ ],[ ++ AC_MSG_RESULT([yes]) ++ tst_links_arc4random_buf="yes" ++ ],[ ++ AC_MSG_RESULT([no]) ++ tst_links_arc4random_buf="no" ++ ]) ++ # ++ if test "$tst_links_arc4random_buf" = "yes"; then ++ AC_MSG_CHECKING([if arc4random_buf is prototyped]) ++ AC_EGREP_CPP([arc4random_buf],[ ++ $cares_includes_stdlib ++ ],[ ++ AC_MSG_RESULT([yes]) ++ tst_proto_arc4random_buf="yes" ++ ],[ ++ AC_MSG_RESULT([no]) ++ tst_proto_arc4random_buf="no" ++ ]) ++ fi ++ # ++ if test "$tst_proto_arc4random_buf" = "yes"; then ++ AC_MSG_CHECKING([if arc4random_buf is compilable]) ++ AC_COMPILE_IFELSE([ ++ AC_LANG_PROGRAM([[ ++ $cares_includes_stdlib ++ ]],[[ ++ arc4random_buf(NULL, 0); ++ return 1; ++ ]]) ++ ],[ ++ AC_MSG_RESULT([yes]) ++ tst_compi_arc4random_buf="yes" ++ ],[ ++ AC_MSG_RESULT([no]) ++ tst_compi_arc4random_buf="no" ++ ]) ++ fi ++ # ++ if test "$tst_compi_arc4random_buf" = "yes"; then ++ AC_MSG_CHECKING([if arc4random_buf usage allowed]) ++ if test "x$cares_disallow_arc4random_buf" != "xyes"; then ++ AC_MSG_RESULT([yes]) ++ tst_allow_arc4random_buf="yes" ++ else ++ AC_MSG_RESULT([no]) ++ tst_allow_arc4random_buf="no" ++ fi ++ fi ++ # ++ AC_MSG_CHECKING([if arc4random_buf might be used]) ++ if test "$tst_links_arc4random_buf" = "yes" && ++ test "$tst_proto_arc4random_buf" = "yes" && ++ test "$tst_compi_arc4random_buf" = "yes" && ++ test "$tst_allow_arc4random_buf" = "yes"; then ++ AC_MSG_RESULT([yes]) ++ AC_DEFINE_UNQUOTED(HAVE_ARC4RANDOM_BUF, 1, ++ [Define to 1 if you have the arc4random_buf function.]) ++ ac_cv_func_arc4random_buf="yes" ++ else ++ AC_MSG_RESULT([no]) ++ ac_cv_func_arc4random_buf="no" ++ fi ++]) ++ +diff --git a/deps/cares/m4/libtool.m4 b/deps/cares/m4/libtool.m4 +index c4c0294..e7b6833 100644 +--- a/deps/cares/m4/libtool.m4 ++++ b/deps/cares/m4/libtool.m4 +@@ -1,6 +1,7 @@ + # libtool.m4 - Configure libtool for the host system. -*-Autoconf-*- + # +-# Copyright (C) 1996-2001, 2003-2015 Free Software Foundation, Inc. ++# Copyright (C) 1996-2001, 2003-2019, 2021-2022 Free Software ++# Foundation, Inc. + # Written by Gordon Matzigkeit, 1996 + # + # This file is free software; the Free Software Foundation gives +@@ -31,7 +32,7 @@ m4_define([_LT_COPYING], [dnl + # along with this program. If not, see . + ]) + +-# serial 58 LT_INIT ++# serial 59 LT_INIT + + + # LT_PREREQ(VERSION) +@@ -181,6 +182,7 @@ m4_require([_LT_FILEUTILS_DEFAULTS])dnl + m4_require([_LT_CHECK_SHELL_FEATURES])dnl + m4_require([_LT_PATH_CONVERSION_FUNCTIONS])dnl + m4_require([_LT_CMD_RELOAD])dnl ++m4_require([_LT_DECL_FILECMD])dnl + m4_require([_LT_CHECK_MAGIC_METHOD])dnl + m4_require([_LT_CHECK_SHAREDLIB_FROM_LINKLIB])dnl + m4_require([_LT_CMD_OLD_ARCHIVE])dnl +@@ -219,8 +221,8 @@ esac + ofile=libtool + can_build_shared=yes + +-# All known linkers require a '.a' archive for static linking (except MSVC, +-# which needs '.lib'). ++# All known linkers require a '.a' archive for static linking (except MSVC and ++# ICC, which need '.lib'). + libext=a + + with_gnu_ld=$lt_cv_prog_gnu_ld +@@ -777,7 +779,7 @@ _LT_EOF + # if finds mixed CR/LF and LF-only lines. Since sed operates in + # text mode, it properly converts lines to CR/LF. This bash problem + # is reportedly fixed, but why not run on old versions too? +- sed '$q' "$ltmain" >> "$cfgfile" \ ++ $SED '$q' "$ltmain" >> "$cfgfile" \ + || (rm -f "$cfgfile"; exit 1) + + mv -f "$cfgfile" "$ofile" || +@@ -1041,8 +1043,8 @@ int forced_loaded() { return 2;} + _LT_EOF + echo "$LTCC $LTCFLAGS -c -o conftest.o conftest.c" >&AS_MESSAGE_LOG_FD + $LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>&AS_MESSAGE_LOG_FD +- echo "$AR cr libconftest.a conftest.o" >&AS_MESSAGE_LOG_FD +- $AR cr libconftest.a conftest.o 2>&AS_MESSAGE_LOG_FD ++ echo "$AR $AR_FLAGS libconftest.a conftest.o" >&AS_MESSAGE_LOG_FD ++ $AR $AR_FLAGS libconftest.a conftest.o 2>&AS_MESSAGE_LOG_FD + echo "$RANLIB libconftest.a" >&AS_MESSAGE_LOG_FD + $RANLIB libconftest.a 2>&AS_MESSAGE_LOG_FD + cat > conftest.c << _LT_EOF +@@ -1066,17 +1068,12 @@ _LT_EOF + _lt_dar_allow_undefined='$wl-undefined ${wl}suppress' ;; + darwin1.*) + _lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;; +- darwin*) # darwin 5.x on +- # if running on 10.5 or later, the deployment target defaults +- # to the OS version, if on x86, and 10.4, the deployment +- # target defaults to 10.4. Don't you love it? +- case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in +- 10.0,*86*-darwin8*|10.0,*-darwin[[912]]*) +- _lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;; +- 10.[[012]][[,.]]*) +- _lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;; +- 10.*|11.*) +- _lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;; ++ darwin*) ++ case $MACOSX_DEPLOYMENT_TARGET,$host in ++ 10.[[012]],*|,*powerpc*-darwin[[5-8]]*) ++ _lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;; ++ *) ++ _lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;; + esac + ;; + esac +@@ -1125,12 +1122,12 @@ m4_defun([_LT_DARWIN_LINKER_FEATURES], + output_verbose_link_cmd=func_echo_all + _LT_TAGVAR(archive_cmds, $1)="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dsymutil" + _LT_TAGVAR(module_cmds, $1)="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dsymutil" +- _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dar_export_syms$_lt_dsymutil" +- _LT_TAGVAR(module_expsym_cmds, $1)="sed -e 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dar_export_syms$_lt_dsymutil" ++ _LT_TAGVAR(archive_expsym_cmds, $1)="$SED 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dar_export_syms$_lt_dsymutil" ++ _LT_TAGVAR(module_expsym_cmds, $1)="$SED -e 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dar_export_syms$_lt_dsymutil" + m4_if([$1], [CXX], + [ if test yes != "$lt_cv_apple_cc_single_mod"; then + _LT_TAGVAR(archive_cmds, $1)="\$CC -r -keep_private_externs -nostdlib -o \$lib-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$lib-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring$_lt_dsymutil" +- _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \$lib-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$lib-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring$_lt_dar_export_syms$_lt_dsymutil" ++ _LT_TAGVAR(archive_expsym_cmds, $1)="$SED 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \$lib-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$lib-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring$_lt_dar_export_syms$_lt_dsymutil" + fi + ],[]) + else +@@ -1244,7 +1241,8 @@ _LT_DECL([], [ECHO], [1], [An echo program that protects backslashes]) + # _LT_WITH_SYSROOT + # ---------------- + AC_DEFUN([_LT_WITH_SYSROOT], +-[AC_MSG_CHECKING([for sysroot]) ++[m4_require([_LT_DECL_SED])dnl ++AC_MSG_CHECKING([for sysroot]) + AC_ARG_WITH([sysroot], + [AS_HELP_STRING([--with-sysroot@<:@=DIR@:>@], + [Search for dependent libraries within DIR (or the compiler's sysroot +@@ -1261,7 +1259,7 @@ case $with_sysroot in #( + fi + ;; #( + /*) +- lt_sysroot=`echo "$with_sysroot" | sed -e "$sed_quote_subst"` ++ lt_sysroot=`echo "$with_sysroot" | $SED -e "$sed_quote_subst"` + ;; #( + no|'') + ;; #( +@@ -1291,7 +1289,7 @@ ia64-*-hpux*) + # options accordingly. + echo 'int i;' > conftest.$ac_ext + if AC_TRY_EVAL(ac_compile); then +- case `/usr/bin/file conftest.$ac_objext` in ++ case `$FILECMD conftest.$ac_objext` in + *ELF-32*) + HPUX_IA64_MODE=32 + ;; +@@ -1308,7 +1306,7 @@ ia64-*-hpux*) + echo '[#]line '$LINENO' "configure"' > conftest.$ac_ext + if AC_TRY_EVAL(ac_compile); then + if test yes = "$lt_cv_prog_gnu_ld"; then +- case `/usr/bin/file conftest.$ac_objext` in ++ case `$FILECMD conftest.$ac_objext` in + *32-bit*) + LD="${LD-ld} -melf32bsmip" + ;; +@@ -1320,7 +1318,7 @@ ia64-*-hpux*) + ;; + esac + else +- case `/usr/bin/file conftest.$ac_objext` in ++ case `$FILECMD conftest.$ac_objext` in + *32-bit*) + LD="${LD-ld} -32" + ;; +@@ -1342,7 +1340,7 @@ mips64*-*linux*) + echo '[#]line '$LINENO' "configure"' > conftest.$ac_ext + if AC_TRY_EVAL(ac_compile); then + emul=elf +- case `/usr/bin/file conftest.$ac_objext` in ++ case `$FILECMD conftest.$ac_objext` in + *32-bit*) + emul="${emul}32" + ;; +@@ -1350,7 +1348,7 @@ mips64*-*linux*) + emul="${emul}64" + ;; + esac +- case `/usr/bin/file conftest.$ac_objext` in ++ case `$FILECMD conftest.$ac_objext` in + *MSB*) + emul="${emul}btsmip" + ;; +@@ -1358,7 +1356,7 @@ mips64*-*linux*) + emul="${emul}ltsmip" + ;; + esac +- case `/usr/bin/file conftest.$ac_objext` in ++ case `$FILECMD conftest.$ac_objext` in + *N32*) + emul="${emul}n32" + ;; +@@ -1378,14 +1376,14 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*) + # not appear in the list. + echo 'int i;' > conftest.$ac_ext + if AC_TRY_EVAL(ac_compile); then +- case `/usr/bin/file conftest.o` in ++ case `$FILECMD conftest.o` in + *32-bit*) + case $host in + x86_64-*kfreebsd*-gnu) + LD="${LD-ld} -m elf_i386_fbsd" + ;; + x86_64-*linux*) +- case `/usr/bin/file conftest.o` in ++ case `$FILECMD conftest.o` in + *x86-64*) + LD="${LD-ld} -m elf32_x86_64" + ;; +@@ -1453,7 +1451,7 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*) + # options accordingly. + echo 'int i;' > conftest.$ac_ext + if AC_TRY_EVAL(ac_compile); then +- case `/usr/bin/file conftest.o` in ++ case `$FILECMD conftest.o` in + *64-bit*) + case $lt_cv_prog_gnu_ld in + yes*) +@@ -1492,9 +1490,22 @@ need_locks=$enable_libtool_lock + m4_defun([_LT_PROG_AR], + [AC_CHECK_TOOLS(AR, [ar], false) + : ${AR=ar} +-: ${AR_FLAGS=cr} + _LT_DECL([], [AR], [1], [The archiver]) +-_LT_DECL([], [AR_FLAGS], [1], [Flags to create an archive]) ++ ++# Use ARFLAGS variable as AR's operation code to sync the variable naming with ++# Automake. If both AR_FLAGS and ARFLAGS are specified, AR_FLAGS should have ++# higher priority because thats what people were doing historically (setting ++# ARFLAGS for automake and AR_FLAGS for libtool). FIXME: Make the AR_FLAGS ++# variable obsoleted/removed. ++ ++test ${AR_FLAGS+y} || AR_FLAGS=${ARFLAGS-cr} ++lt_ar_flags=$AR_FLAGS ++_LT_DECL([], [lt_ar_flags], [0], [Flags to create an archive (by configure)]) ++ ++# Make AR_FLAGS overridable by 'make ARFLAGS='. Don't try to run-time override ++# by AR_FLAGS because that was never working and AR_FLAGS is about to die. ++_LT_DECL([], [AR_FLAGS], [\@S|@{ARFLAGS-"\@S|@lt_ar_flags"}], ++ [Flags to create an archive]) + + AC_CACHE_CHECK([for archiver @FILE support], [lt_cv_ar_at_file], + [lt_cv_ar_at_file=no +@@ -1713,7 +1724,7 @@ AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl + lt_cv_sys_max_cmd_len=8192; + ;; + +- bitrig* | darwin* | dragonfly* | freebsd* | netbsd* | openbsd*) ++ bitrig* | darwin* | dragonfly* | freebsd* | midnightbsd* | netbsd* | openbsd*) + # This has been around since 386BSD, at least. Likely further. + if test -x /sbin/sysctl; then + lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax` +@@ -1756,7 +1767,7 @@ AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl + sysv5* | sco5v6* | sysv4.2uw2*) + kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null` + if test -n "$kargmax"; then +- lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[[ ]]//'` ++ lt_cv_sys_max_cmd_len=`echo $kargmax | $SED 's/.*[[ ]]//'` + else + lt_cv_sys_max_cmd_len=32768 + fi +@@ -2206,26 +2217,35 @@ m4_defun([_LT_CMD_STRIPLIB], + striplib= + old_striplib= + AC_MSG_CHECKING([whether stripping libraries is possible]) +-if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then +- test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" +- test -z "$striplib" && striplib="$STRIP --strip-unneeded" +- AC_MSG_RESULT([yes]) ++if test -z "$STRIP"; then ++ AC_MSG_RESULT([no]) + else +-# FIXME - insert some real tests, host_os isn't really good enough +- case $host_os in +- darwin*) +- if test -n "$STRIP"; then ++ if $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then ++ old_striplib="$STRIP --strip-debug" ++ striplib="$STRIP --strip-unneeded" ++ AC_MSG_RESULT([yes]) ++ else ++ case $host_os in ++ darwin*) ++ # FIXME - insert some real tests, host_os isn't really good enough + striplib="$STRIP -x" + old_striplib="$STRIP -S" + AC_MSG_RESULT([yes]) +- else ++ ;; ++ freebsd*) ++ if $STRIP -V 2>&1 | $GREP "elftoolchain" >/dev/null; then ++ old_striplib="$STRIP --strip-debug" ++ striplib="$STRIP --strip-unneeded" ++ AC_MSG_RESULT([yes]) ++ else ++ AC_MSG_RESULT([no]) ++ fi ++ ;; ++ *) + AC_MSG_RESULT([no]) +- fi +- ;; +- *) +- AC_MSG_RESULT([no]) +- ;; +- esac ++ ;; ++ esac ++ fi + fi + _LT_DECL([], [old_striplib], [1], [Commands to strip libraries]) + _LT_DECL([], [striplib], [1]) +@@ -2548,7 +2568,7 @@ cygwin* | mingw* | pw32* | cegcc*) + case $host_os in + cygwin*) + # Cygwin DLLs use 'cyg' prefix rather than 'lib' +- soname_spec='`echo $libname | sed -e 's/^lib/cyg/'``echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext' ++ soname_spec='`echo $libname | $SED -e 's/^lib/cyg/'``echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext' + m4_if([$1], [],[ + sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api"]) + ;; +@@ -2558,14 +2578,14 @@ m4_if([$1], [],[ + ;; + pw32*) + # pw32 DLLs use 'pw' prefix rather than 'lib' +- library_names_spec='`echo $libname | sed -e 's/^lib/pw/'``echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext' ++ library_names_spec='`echo $libname | $SED -e 's/^lib/pw/'``echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext' + ;; + esac + dynamic_linker='Win32 ld.exe' + ;; + +- *,cl*) +- # Native MSVC ++ *,cl* | *,icl*) ++ # Native MSVC or ICC + libname_spec='$name' + soname_spec='$libname`echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext' + library_names_spec='$libname.dll.lib' +@@ -2584,7 +2604,7 @@ m4_if([$1], [],[ + done + IFS=$lt_save_ifs + # Convert to MSYS style. +- sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | sed -e 's|\\\\|/|g' -e 's| \\([[a-zA-Z]]\\):| /\\1|g' -e 's|^ ||'` ++ sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's|\\\\|/|g' -e 's| \\([[a-zA-Z]]\\):| /\\1|g' -e 's|^ ||'` + ;; + cygwin*) + # Convert to unix form, then to dos form, then back to unix form +@@ -2621,7 +2641,7 @@ m4_if([$1], [],[ + ;; + + *) +- # Assume MSVC wrapper ++ # Assume MSVC and ICC wrapper + library_names_spec='$libname`echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext $libname.lib' + dynamic_linker='Win32 ld.exe' + ;; +@@ -2654,7 +2674,7 @@ dgux*) + shlibpath_var=LD_LIBRARY_PATH + ;; + +-freebsd* | dragonfly*) ++freebsd* | dragonfly* | midnightbsd*) + # DragonFly does not have aout. When/if they implement a new + # versioning mechanism, adjust this. + if test -x /usr/bin/objformat; then +@@ -3465,7 +3485,7 @@ beos*) + + bsdi[[45]]*) + lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib)' +- lt_cv_file_magic_cmd='/usr/bin/file -L' ++ lt_cv_file_magic_cmd='$FILECMD -L' + lt_cv_file_magic_test_file=/shlib/libc.so + ;; + +@@ -3499,14 +3519,14 @@ darwin* | rhapsody*) + lt_cv_deplibs_check_method=pass_all + ;; + +-freebsd* | dragonfly*) ++freebsd* | dragonfly* | midnightbsd*) + if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then + case $host_cpu in + i*86 ) + # Not sure whether the presence of OpenBSD here was a mistake. + # Let's accept both of them until this is cleared up. + lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[[3-9]]86 (compact )?demand paged shared library' +- lt_cv_file_magic_cmd=/usr/bin/file ++ lt_cv_file_magic_cmd=$FILECMD + lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` + ;; + esac +@@ -3520,7 +3540,7 @@ haiku*) + ;; + + hpux10.20* | hpux11*) +- lt_cv_file_magic_cmd=/usr/bin/file ++ lt_cv_file_magic_cmd=$FILECMD + case $host_cpu in + ia64*) + lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|ELF-[[0-9]][[0-9]]) shared object file - IA64' +@@ -3567,7 +3587,7 @@ netbsd* | netbsdelf*-gnu) + + newos6*) + lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (executable|dynamic lib)' +- lt_cv_file_magic_cmd=/usr/bin/file ++ lt_cv_file_magic_cmd=$FILECMD + lt_cv_file_magic_test_file=/usr/lib/libnls.so + ;; + +@@ -3694,13 +3714,13 @@ else + mingw*) lt_bad_file=conftest.nm/nofile ;; + *) lt_bad_file=/dev/null ;; + esac +- case `"$tmp_nm" -B $lt_bad_file 2>&1 | sed '1q'` in ++ case `"$tmp_nm" -B $lt_bad_file 2>&1 | $SED '1q'` in + *$lt_bad_file* | *'Invalid file or object type'*) + lt_cv_path_NM="$tmp_nm -B" + break 2 + ;; + *) +- case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in ++ case `"$tmp_nm" -p /dev/null 2>&1 | $SED '1q'` in + */dev/null*) + lt_cv_path_NM="$tmp_nm -p" + break 2 +@@ -3726,7 +3746,7 @@ else + # Let the user override the test. + else + AC_CHECK_TOOLS(DUMPBIN, [dumpbin "link -dump"], :) +- case `$DUMPBIN -symbols -headers /dev/null 2>&1 | sed '1q'` in ++ case `$DUMPBIN -symbols -headers /dev/null 2>&1 | $SED '1q'` in + *COFF*) + DUMPBIN="$DUMPBIN -symbols -headers" + ;; +@@ -3966,7 +3986,7 @@ esac + + if test "$lt_cv_nm_interface" = "MS dumpbin"; then + # Gets list of data symbols to import. +- lt_cv_sys_global_symbol_to_import="sed -n -e 's/^I .* \(.*\)$/\1/p'" ++ lt_cv_sys_global_symbol_to_import="$SED -n -e 's/^I .* \(.*\)$/\1/p'" + # Adjust the below global symbol transforms to fixup imported variables. + lt_cdecl_hook=" -e 's/^I .* \(.*\)$/extern __declspec(dllimport) char \1;/p'" + lt_c_name_hook=" -e 's/^I .* \(.*\)$/ {\"\1\", (void *) 0},/p'" +@@ -3984,20 +4004,20 @@ fi + # Transform an extracted symbol line into a proper C declaration. + # Some systems (esp. on ia64) link data and code symbols differently, + # so use this general approach. +-lt_cv_sys_global_symbol_to_cdecl="sed -n"\ ++lt_cv_sys_global_symbol_to_cdecl="$SED -n"\ + $lt_cdecl_hook\ + " -e 's/^T .* \(.*\)$/extern int \1();/p'"\ + " -e 's/^$symcode$symcode* .* \(.*\)$/extern char \1;/p'" + + # Transform an extracted symbol line into symbol name and symbol address +-lt_cv_sys_global_symbol_to_c_name_address="sed -n"\ ++lt_cv_sys_global_symbol_to_c_name_address="$SED -n"\ + $lt_c_name_hook\ + " -e 's/^: \(.*\) .*$/ {\"\1\", (void *) 0},/p'"\ + " -e 's/^$symcode$symcode* .* \(.*\)$/ {\"\1\", (void *) \&\1},/p'" + + # Transform an extracted symbol line into symbol name with lib prefix and + # symbol address. +-lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n"\ ++lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="$SED -n"\ + $lt_c_name_lib_hook\ + " -e 's/^: \(.*\) .*$/ {\"\1\", (void *) 0},/p'"\ + " -e 's/^$symcode$symcode* .* \(lib.*\)$/ {\"\1\", (void *) \&\1},/p'"\ +@@ -4021,7 +4041,7 @@ for ac_symprfx in "" "_"; do + if test "$lt_cv_nm_interface" = "MS dumpbin"; then + # Fake it for dumpbin and say T for any non-static function, + # D for any global variable and I for any imported variable. +- # Also find C++ and __fastcall symbols from MSVC++, ++ # Also find C++ and __fastcall symbols from MSVC++ or ICC, + # which start with @ or ?. + lt_cv_sys_global_symbol_pipe="$AWK ['"\ + " {last_section=section; section=\$ 3};"\ +@@ -4039,9 +4059,9 @@ for ac_symprfx in "" "_"; do + " s[1]~prfx {split(s[1],t,\"@\"); print f,t[1],substr(t[1],length(prfx))}"\ + " ' prfx=^$ac_symprfx]" + else +- lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[[ ]]\($symcode$symcode*\)[[ ]][[ ]]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'" ++ lt_cv_sys_global_symbol_pipe="$SED -n -e 's/^.*[[ ]]\($symcode$symcode*\)[[ ]][[ ]]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'" + fi +- lt_cv_sys_global_symbol_pipe="$lt_cv_sys_global_symbol_pipe | sed '/ __gnu_lto/d'" ++ lt_cv_sys_global_symbol_pipe="$lt_cv_sys_global_symbol_pipe | $SED '/ __gnu_lto/d'" + + # Check to see that the pipe works correctly. + pipe_works=no +@@ -4329,7 +4349,7 @@ m4_if([$1], [CXX], [ + ;; + esac + ;; +- freebsd* | dragonfly*) ++ freebsd* | dragonfly* | midnightbsd*) + # FreeBSD uses GNU C++ + ;; + hpux9* | hpux10* | hpux11*) +@@ -4412,7 +4432,7 @@ m4_if([$1], [CXX], [ + _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink' + ;; + *) +- case `$CC -V 2>&1 | sed 5q` in ++ case `$CC -V 2>&1 | $SED 5q` in + *Sun\ C*) + # Sun C++ 5.9 + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' +@@ -4754,7 +4774,7 @@ m4_if([$1], [CXX], [ + _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink' + ;; + *) +- case `$CC -V 2>&1 | sed 5q` in ++ case `$CC -V 2>&1 | $SED 5q` in + *Sun\ Ceres\ Fortran* | *Sun*Fortran*\ [[1-7]].* | *Sun*Fortran*\ 8.[[0-3]]*) + # Sun Fortran 8.3 passes all unrecognized flags to the linker + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' +@@ -4937,7 +4957,7 @@ m4_if([$1], [CXX], [ + if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then + _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && ([substr](\$ 3,1,1) != ".")) { if (\$ 2 == "W") { print \$ 3 " weak" } else { print \$ 3 } } }'\'' | sort -u > $export_symbols' + else +- _LT_TAGVAR(export_symbols_cmds, $1)='`func_echo_all $NM | $SED -e '\''s/B\([[^B]]*\)$/P\1/'\''` -PCpgl $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) && ([substr](\$ 1,1,1) != ".")) { if ((\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) { print \$ 1 " weak" } else { print \$ 1 } } }'\'' | sort -u > $export_symbols' ++ _LT_TAGVAR(export_symbols_cmds, $1)='`func_echo_all $NM | $SED -e '\''s/B\([[^B]]*\)$/P\1/'\''` -PCpgl $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "L") || (\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) && ([substr](\$ 1,1,1) != ".")) { if ((\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) { print \$ 1 " weak" } else { print \$ 1 } } }'\'' | sort -u > $export_symbols' + fi + ;; + pw32*) +@@ -4945,7 +4965,7 @@ m4_if([$1], [CXX], [ + ;; + cygwin* | mingw* | cegcc*) + case $cc_basename in +- cl*) ++ cl* | icl*) + _LT_TAGVAR(exclude_expsyms, $1)='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' + ;; + *) +@@ -5005,15 +5025,15 @@ dnl Note also adjust exclude_expsyms for C++ above. + + case $host_os in + cygwin* | mingw* | pw32* | cegcc*) +- # FIXME: the MSVC++ port hasn't been tested in a loooong time ++ # FIXME: the MSVC++ and ICC port hasn't been tested in a loooong time + # When not using gcc, we currently assume that we are using +- # Microsoft Visual C++. ++ # Microsoft Visual C++ or Intel C++ Compiler. + if test yes != "$GCC"; then + with_gnu_ld=no + fi + ;; + interix*) +- # we just hope/assume this is gcc and not c89 (= MSVC++) ++ # we just hope/assume this is gcc and not c89 (= MSVC++ or ICC) + with_gnu_ld=yes + ;; + openbsd* | bitrig*) +@@ -5068,7 +5088,7 @@ dnl Note also adjust exclude_expsyms for C++ above. + _LT_TAGVAR(whole_archive_flag_spec, $1)= + fi + supports_anon_versioning=no +- case `$LD -v | $SED -e 's/([^)]\+)\s\+//' 2>&1` in ++ case `$LD -v | $SED -e 's/([[^)]]\+)\s\+//' 2>&1` in + *GNU\ gold*) supports_anon_versioning=yes ;; + *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.10.*) ;; # catch versions < 2.11 + *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... +@@ -5180,6 +5200,7 @@ _LT_EOF + emximp -o $lib $output_objdir/$libname.def' + _LT_TAGVAR(old_archive_From_new_cmds, $1)='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def' + _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes ++ _LT_TAGVAR(file_list_spec, $1)='@' + ;; + + interix[[3-9]]*) +@@ -5194,7 +5215,7 @@ _LT_EOF + # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link + # time. Moving up from 0x10000000 also allows more sbrk(2) space. + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' +- _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s|^|_|" $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--retain-symbols-file,$output_objdir/$soname.expsym $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' ++ _LT_TAGVAR(archive_expsym_cmds, $1)='$SED "s|^|_|" $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--retain-symbols-file,$output_objdir/$soname.expsym $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + ;; + + gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu) +@@ -5237,7 +5258,7 @@ _LT_EOF + _LT_TAGVAR(compiler_needs_object, $1)=yes + ;; + esac +- case `$CC -V 2>&1 | sed 5q` in ++ case `$CC -V 2>&1 | $SED 5q` in + *Sun\ C*) # Sun C 5.9 + _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' + _LT_TAGVAR(compiler_needs_object, $1)=yes +@@ -5249,13 +5270,14 @@ _LT_EOF + + if test yes = "$supports_anon_versioning"; then + _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ +- cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ ++ cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ + echo "local: *; };" >> $output_objdir/$libname.ver~ + $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-version-script $wl$output_objdir/$libname.ver -o $lib' + fi + + case $cc_basename in + tcc*) ++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='-rdynamic' + ;; + xlf* | bgf* | bgxlf* | mpixlf*) +@@ -5265,7 +5287,7 @@ _LT_EOF + _LT_TAGVAR(archive_cmds, $1)='$LD -shared $libobjs $deplibs $linker_flags -soname $soname -o $lib' + if test yes = "$supports_anon_versioning"; then + _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ +- cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ ++ cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ + echo "local: *; };" >> $output_objdir/$libname.ver~ + $LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib' + fi +@@ -5397,7 +5419,7 @@ _LT_EOF + if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then + _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && ([substr](\$ 3,1,1) != ".")) { if (\$ 2 == "W") { print \$ 3 " weak" } else { print \$ 3 } } }'\'' | sort -u > $export_symbols' + else +- _LT_TAGVAR(export_symbols_cmds, $1)='`func_echo_all $NM | $SED -e '\''s/B\([[^B]]*\)$/P\1/'\''` -PCpgl $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) && ([substr](\$ 1,1,1) != ".")) { if ((\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) { print \$ 1 " weak" } else { print \$ 1 } } }'\'' | sort -u > $export_symbols' ++ _LT_TAGVAR(export_symbols_cmds, $1)='`func_echo_all $NM | $SED -e '\''s/B\([[^B]]*\)$/P\1/'\''` -PCpgl $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "L") || (\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) && ([substr](\$ 1,1,1) != ".")) { if ((\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) { print \$ 1 " weak" } else { print \$ 1 } } }'\'' | sort -u > $export_symbols' + fi + aix_use_runtimelinking=no + +@@ -5580,12 +5602,12 @@ _LT_EOF + + cygwin* | mingw* | pw32* | cegcc*) + # When not using gcc, we currently assume that we are using +- # Microsoft Visual C++. ++ # Microsoft Visual C++ or Intel C++ Compiler. + # hardcode_libdir_flag_spec is actually meaningless, as there is + # no search path for DLLs. + case $cc_basename in +- cl*) +- # Native MSVC ++ cl* | icl*) ++ # Native MSVC or ICC + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' + _LT_TAGVAR(allow_undefined_flag, $1)=unsupported + _LT_TAGVAR(always_export_symbols, $1)=yes +@@ -5626,7 +5648,7 @@ _LT_EOF + fi' + ;; + *) +- # Assume MSVC wrapper ++ # Assume MSVC and ICC wrapper + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' + _LT_TAGVAR(allow_undefined_flag, $1)=unsupported + # Tell ltmain to make .lib files, not .a files. +@@ -5674,7 +5696,7 @@ _LT_EOF + ;; + + # FreeBSD 3 and greater uses gcc -shared to do shared libraries. +- freebsd* | dragonfly*) ++ freebsd* | dragonfly* | midnightbsd*) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_TAGVAR(hardcode_direct, $1)=yes +@@ -5815,6 +5837,7 @@ _LT_EOF + # Fabrice Bellard et al's Tiny C Compiler + _LT_TAGVAR(ld_shlibs, $1)=yes + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' ++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' + ;; + esac + ;; +@@ -5886,6 +5909,7 @@ _LT_EOF + emximp -o $lib $output_objdir/$libname.def' + _LT_TAGVAR(old_archive_From_new_cmds, $1)='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def' + _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes ++ _LT_TAGVAR(file_list_spec, $1)='@' + ;; + + osf3*) +@@ -6656,8 +6680,8 @@ if test yes != "$_lt_caught_CXX_error"; then + + cygwin* | mingw* | pw32* | cegcc*) + case $GXX,$cc_basename in +- ,cl* | no,cl*) +- # Native MSVC ++ ,cl* | no,cl* | ,icl* | no,icl*) ++ # Native MSVC or ICC + # hardcode_libdir_flag_spec is actually meaningless, as there is + # no search path for DLLs. + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' +@@ -6755,6 +6779,7 @@ if test yes != "$_lt_caught_CXX_error"; then + emximp -o $lib $output_objdir/$libname.def' + _LT_TAGVAR(old_archive_From_new_cmds, $1)='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def' + _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes ++ _LT_TAGVAR(file_list_spec, $1)='@' + ;; + + dgux*) +@@ -6785,7 +6810,7 @@ if test yes != "$_lt_caught_CXX_error"; then + _LT_TAGVAR(archive_cmds_need_lc, $1)=no + ;; + +- freebsd* | dragonfly*) ++ freebsd* | dragonfly* | midnightbsd*) + # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF + # conventions + _LT_TAGVAR(ld_shlibs, $1)=yes +@@ -6922,7 +6947,7 @@ if test yes != "$_lt_caught_CXX_error"; then + # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link + # time. Moving up from 0x10000000 also allows more sbrk(2) space. + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' +- _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s|^|_|" $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--retain-symbols-file,$output_objdir/$soname.expsym $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' ++ _LT_TAGVAR(archive_expsym_cmds, $1)='$SED "s|^|_|" $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--retain-symbols-file,$output_objdir/$soname.expsym $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + ;; + irix5* | irix6*) + case $cc_basename in +@@ -7062,13 +7087,13 @@ if test yes != "$_lt_caught_CXX_error"; then + _LT_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + if test yes = "$supports_anon_versioning"; then + _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ +- cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ ++ cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ + echo "local: *; };" >> $output_objdir/$libname.ver~ + $CC -qmkshrobj $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-version-script $wl$output_objdir/$libname.ver -o $lib' + fi + ;; + *) +- case `$CC -V 2>&1 | sed 5q` in ++ case `$CC -V 2>&1 | $SED 5q` in + *Sun\ C*) + # Sun C++ 5.9 + _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs' +@@ -8214,6 +8239,14 @@ _LT_DECL([], [DLLTOOL], [1], [DLL creation program]) + AC_SUBST([DLLTOOL]) + ]) + ++# _LT_DECL_FILECMD ++# ---------------- ++# Check for a file(cmd) program that can be used to detect file type and magic ++m4_defun([_LT_DECL_FILECMD], ++[AC_CHECK_TOOL([FILECMD], [file], [:]) ++_LT_DECL([], [FILECMD], [1], [A file(cmd) program that detects file types]) ++])# _LD_DECL_FILECMD ++ + # _LT_DECL_SED + # ------------ + # Check for a fully-functional sed program, that truncates +diff --git a/deps/cares/m4/ltoptions.m4 b/deps/cares/m4/ltoptions.m4 +index 94b0829..b0b5e9c 100644 +--- a/deps/cares/m4/ltoptions.m4 ++++ b/deps/cares/m4/ltoptions.m4 +@@ -1,7 +1,7 @@ + # Helper functions for option handling. -*- Autoconf -*- + # +-# Copyright (C) 2004-2005, 2007-2009, 2011-2015 Free Software +-# Foundation, Inc. ++# Copyright (C) 2004-2005, 2007-2009, 2011-2019, 2021-2022 Free ++# Software Foundation, Inc. + # Written by Gary V. Vaughan, 2004 + # + # This file is free software; the Free Software Foundation gives +diff --git a/deps/cares/m4/ltsugar.m4 b/deps/cares/m4/ltsugar.m4 +index 48bc934..902508b 100644 +--- a/deps/cares/m4/ltsugar.m4 ++++ b/deps/cares/m4/ltsugar.m4 +@@ -1,6 +1,6 @@ + # ltsugar.m4 -- libtool m4 base layer. -*-Autoconf-*- + # +-# Copyright (C) 2004-2005, 2007-2008, 2011-2015 Free Software ++# Copyright (C) 2004-2005, 2007-2008, 2011-2019, 2021-2022 Free Software + # Foundation, Inc. + # Written by Gary V. Vaughan, 2004 + # +diff --git a/deps/cares/m4/ltversion.m4 b/deps/cares/m4/ltversion.m4 +index fa04b52..b155d0a 100644 +--- a/deps/cares/m4/ltversion.m4 ++++ b/deps/cares/m4/ltversion.m4 +@@ -1,6 +1,7 @@ + # ltversion.m4 -- version numbers -*- Autoconf -*- + # +-# Copyright (C) 2004, 2011-2015 Free Software Foundation, Inc. ++# Copyright (C) 2004, 2011-2019, 2021-2022 Free Software Foundation, ++# Inc. + # Written by Scott James Remnant, 2004 + # + # This file is free software; the Free Software Foundation gives +@@ -9,15 +10,15 @@ + + # @configure_input@ + +-# serial 4179 ltversion.m4 ++# serial 4245 ltversion.m4 + # This file is part of GNU Libtool + +-m4_define([LT_PACKAGE_VERSION], [2.4.6]) +-m4_define([LT_PACKAGE_REVISION], [2.4.6]) ++m4_define([LT_PACKAGE_VERSION], [2.4.7]) ++m4_define([LT_PACKAGE_REVISION], [2.4.7]) + + AC_DEFUN([LTVERSION_VERSION], +-[macro_version='2.4.6' +-macro_revision='2.4.6' ++[macro_version='2.4.7' ++macro_revision='2.4.7' + _LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?]) + _LT_DECL(, macro_revision, 0) + ]) +diff --git a/deps/cares/m4/lt~obsolete.m4 b/deps/cares/m4/lt~obsolete.m4 +index c6b26f8..0f7a875 100644 +--- a/deps/cares/m4/lt~obsolete.m4 ++++ b/deps/cares/m4/lt~obsolete.m4 +@@ -1,7 +1,7 @@ + # lt~obsolete.m4 -- aclocal satisfying obsolete definitions. -*-Autoconf-*- + # +-# Copyright (C) 2004-2005, 2007, 2009, 2011-2015 Free Software +-# Foundation, Inc. ++# Copyright (C) 2004-2005, 2007, 2009, 2011-2019, 2021-2022 Free ++# Software Foundation, Inc. + # Written by Scott James Remnant, 2004. + # + # This file is free software; the Free Software Foundation gives +diff --git a/deps/cares/src/Makefile.in b/deps/cares/src/Makefile.in +index 999e965..6aa63b0 100644 +--- a/deps/cares/src/Makefile.in ++++ b/deps/cares/src/Makefile.in +@@ -95,6 +95,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_ac_append_to_file.m4 \ + $(top_srcdir)/m4/ax_am_macros_static.m4 \ + $(top_srcdir)/m4/ax_check_gnu_make.m4 \ + $(top_srcdir)/m4/ax_code_coverage.m4 \ ++ $(top_srcdir)/m4/ax_cxx_compile_stdcxx.m4 \ + $(top_srcdir)/m4/ax_cxx_compile_stdcxx_11.m4 \ + $(top_srcdir)/m4/ax_file_escapes.m4 \ + $(top_srcdir)/m4/ax_require_defined.m4 \ +@@ -245,6 +246,7 @@ EGREP = @EGREP@ + ETAGS = @ETAGS@ + EXEEXT = @EXEEXT@ + FGREP = @FGREP@ ++FILECMD = @FILECMD@ + GCOV = @GCOV@ + GENHTML = @GENHTML@ + GREP = @GREP@ +diff --git a/deps/cares/src/lib/CMakeLists.txt b/deps/cares/src/lib/CMakeLists.txt +index 7d37be2..5cea076 100644 +--- a/deps/cares/src/lib/CMakeLists.txt ++++ b/deps/cares/src/lib/CMakeLists.txt +@@ -10,6 +10,11 @@ CONFIGURE_FILE (ares_config.h.cmake ${PROJECT_BINARY_DIR}/ares_config.h) + IF (CARES_SHARED) + ADD_LIBRARY (${PROJECT_NAME} SHARED ${CSOURCES}) + ++ # Include resource file in windows builds for versioned DLLs ++ IF (WIN32) ++ TARGET_SOURCES (${PROJECT_NAME} PRIVATE cares.rc) ++ ENDIF() ++ + # Convert CARES_LIB_VERSIONINFO libtool version format into VERSION and SOVERSION + # Convert from ":" separated into CMake list format using ";" + STRING (REPLACE ":" ";" CARES_LIB_VERSIONINFO ${CARES_LIB_VERSIONINFO}) +diff --git a/deps/cares/src/lib/Makefile.in b/deps/cares/src/lib/Makefile.in +index 6b42bb8..f1ed8a0 100644 +--- a/deps/cares/src/lib/Makefile.in ++++ b/deps/cares/src/lib/Makefile.in +@@ -15,7 +15,7 @@ + @SET_MAKE@ + + # aminclude_static.am generated automatically by Autoconf +-# from AX_AM_MACROS_STATIC on Wed Oct 27 08:01:08 CEST 2021 ++# from AX_AM_MACROS_STATIC on Mon May 22 13:34:17 CEST 2023 + + VPATH = @srcdir@ + am__is_gnu_make = { \ +@@ -106,6 +106,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_ac_append_to_file.m4 \ + $(top_srcdir)/m4/ax_am_macros_static.m4 \ + $(top_srcdir)/m4/ax_check_gnu_make.m4 \ + $(top_srcdir)/m4/ax_code_coverage.m4 \ ++ $(top_srcdir)/m4/ax_cxx_compile_stdcxx.m4 \ + $(top_srcdir)/m4/ax_cxx_compile_stdcxx_11.m4 \ + $(top_srcdir)/m4/ax_file_escapes.m4 \ + $(top_srcdir)/m4/ax_require_defined.m4 \ +@@ -194,13 +195,14 @@ am__objects_1 = libcares_la-ares__addrinfo2hostent.lo \ + libcares_la-ares_parse_txt_reply.lo \ + libcares_la-ares_parse_uri_reply.lo \ + libcares_la-ares_platform.lo libcares_la-ares_process.lo \ +- libcares_la-ares_query.lo libcares_la-ares_search.lo \ +- libcares_la-ares_send.lo libcares_la-ares_strcasecmp.lo \ +- libcares_la-ares_strdup.lo libcares_la-ares_strerror.lo \ +- libcares_la-ares_strsplit.lo libcares_la-ares_timeout.lo \ +- libcares_la-ares_version.lo libcares_la-ares_writev.lo \ +- libcares_la-bitncmp.lo libcares_la-inet_net_pton.lo \ +- libcares_la-inet_ntop.lo libcares_la-windows_port.lo ++ libcares_la-ares_query.lo libcares_la-ares_rand.lo \ ++ libcares_la-ares_search.lo libcares_la-ares_send.lo \ ++ libcares_la-ares_strcasecmp.lo libcares_la-ares_strdup.lo \ ++ libcares_la-ares_strerror.lo libcares_la-ares_strsplit.lo \ ++ libcares_la-ares_timeout.lo libcares_la-ares_version.lo \ ++ libcares_la-ares_writev.lo libcares_la-bitncmp.lo \ ++ libcares_la-inet_net_pton.lo libcares_la-inet_ntop.lo \ ++ libcares_la-windows_port.lo + am__objects_2 = + am_libcares_la_OBJECTS = $(am__objects_1) $(am__objects_2) + libcares_la_OBJECTS = $(am_libcares_la_OBJECTS) +@@ -273,6 +275,7 @@ am__depfiles_remade = \ + ./$(DEPDIR)/libcares_la-ares_platform.Plo \ + ./$(DEPDIR)/libcares_la-ares_process.Plo \ + ./$(DEPDIR)/libcares_la-ares_query.Plo \ ++ ./$(DEPDIR)/libcares_la-ares_rand.Plo \ + ./$(DEPDIR)/libcares_la-ares_search.Plo \ + ./$(DEPDIR)/libcares_la-ares_send.Plo \ + ./$(DEPDIR)/libcares_la-ares_strcasecmp.Plo \ +@@ -422,6 +425,7 @@ EGREP = @EGREP@ + ETAGS = @ETAGS@ + EXEEXT = @EXEEXT@ + FGREP = @FGREP@ ++FILECMD = @FILECMD@ + GCOV = @GCOV@ + GENHTML = @GENHTML@ + GREP = @GREP@ +@@ -616,6 +620,7 @@ CSOURCES = ares__addrinfo2hostent.c \ + ares_platform.c \ + ares_process.c \ + ares_query.c \ ++ ares_rand.c \ + ares_search.c \ + ares_send.c \ + ares_strcasecmp.c \ +@@ -636,7 +641,6 @@ HHEADERS = ares_android.h \ + ares_inet_net_pton.h \ + ares_iphlpapi.h \ + ares_ipv6.h \ +- ares_library_init.h \ + ares_llist.h \ + ares_nowarn.h \ + ares_platform.h \ +@@ -793,6 +797,7 @@ distclean-compile: + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares_platform.Plo@am__quote@ # am--include-marker + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares_process.Plo@am__quote@ # am--include-marker + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares_query.Plo@am__quote@ # am--include-marker ++@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares_rand.Plo@am__quote@ # am--include-marker + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares_search.Plo@am__quote@ # am--include-marker + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares_send.Plo@am__quote@ # am--include-marker + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares_strcasecmp.Plo@am__quote@ # am--include-marker +@@ -1159,6 +1164,13 @@ libcares_la-ares_query.lo: ares_query.c + @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ + @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o libcares_la-ares_query.lo `test -f 'ares_query.c' || echo '$(srcdir)/'`ares_query.c + ++libcares_la-ares_rand.lo: ares_rand.c ++@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT libcares_la-ares_rand.lo -MD -MP -MF $(DEPDIR)/libcares_la-ares_rand.Tpo -c -o libcares_la-ares_rand.lo `test -f 'ares_rand.c' || echo '$(srcdir)/'`ares_rand.c ++@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libcares_la-ares_rand.Tpo $(DEPDIR)/libcares_la-ares_rand.Plo ++@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ares_rand.c' object='libcares_la-ares_rand.lo' libtool=yes @AMDEPBACKSLASH@ ++@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ ++@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o libcares_la-ares_rand.lo `test -f 'ares_rand.c' || echo '$(srcdir)/'`ares_rand.c ++ + libcares_la-ares_search.lo: ares_search.c + @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT libcares_la-ares_search.lo -MD -MP -MF $(DEPDIR)/libcares_la-ares_search.Tpo -c -o libcares_la-ares_search.lo `test -f 'ares_search.c' || echo '$(srcdir)/'`ares_search.c + @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libcares_la-ares_search.Tpo $(DEPDIR)/libcares_la-ares_search.Plo +@@ -1503,6 +1515,7 @@ distclean: distclean-recursive + -rm -f ./$(DEPDIR)/libcares_la-ares_platform.Plo + -rm -f ./$(DEPDIR)/libcares_la-ares_process.Plo + -rm -f ./$(DEPDIR)/libcares_la-ares_query.Plo ++ -rm -f ./$(DEPDIR)/libcares_la-ares_rand.Plo + -rm -f ./$(DEPDIR)/libcares_la-ares_search.Plo + -rm -f ./$(DEPDIR)/libcares_la-ares_send.Plo + -rm -f ./$(DEPDIR)/libcares_la-ares_strcasecmp.Plo +@@ -1607,6 +1620,7 @@ maintainer-clean: maintainer-clean-recursive + -rm -f ./$(DEPDIR)/libcares_la-ares_platform.Plo + -rm -f ./$(DEPDIR)/libcares_la-ares_process.Plo + -rm -f ./$(DEPDIR)/libcares_la-ares_query.Plo ++ -rm -f ./$(DEPDIR)/libcares_la-ares_rand.Plo + -rm -f ./$(DEPDIR)/libcares_la-ares_search.Plo + -rm -f ./$(DEPDIR)/libcares_la-ares_send.Plo + -rm -f ./$(DEPDIR)/libcares_la-ares_strcasecmp.Plo +diff --git a/deps/cares/src/lib/Makefile.inc b/deps/cares/src/lib/Makefile.inc +index a3b060c..02d8d58 100644 +--- a/deps/cares/src/lib/Makefile.inc ++++ b/deps/cares/src/lib/Makefile.inc +@@ -45,6 +45,7 @@ CSOURCES = ares__addrinfo2hostent.c \ + ares_platform.c \ + ares_process.c \ + ares_query.c \ ++ ares_rand.c \ + ares_search.c \ + ares_send.c \ + ares_strcasecmp.c \ +@@ -59,13 +60,12 @@ CSOURCES = ares__addrinfo2hostent.c \ + inet_ntop.c \ + windows_port.c + +-HHEADERS = ares_android.h \ ++HHEADERS = ares_android.h \ + ares_data.h \ + ares_getenv.h \ + ares_inet_net_pton.h \ + ares_iphlpapi.h \ + ares_ipv6.h \ +- ares_library_init.h \ + ares_llist.h \ + ares_nowarn.h \ + ares_platform.h \ +diff --git a/deps/cares/src/lib/ares__addrinfo_localhost.c b/deps/cares/src/lib/ares__addrinfo_localhost.c +index 7940ecd..5bc1e0b 100644 +--- a/deps/cares/src/lib/ares__addrinfo_localhost.c ++++ b/deps/cares/src/lib/ares__addrinfo_localhost.c +@@ -131,7 +131,7 @@ static int ares__system_loopback_addrs(int aftype, + unsigned short port, + struct ares_addrinfo_node **nodes) + { +-#if defined(_WIN32) && defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x0600 ++#if defined(_WIN32) && defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x0600 && !defined(__WATCOMC__) + PMIB_UNICASTIPADDRESS_TABLE table; + unsigned int i; + int status; +diff --git a/deps/cares/src/lib/ares__readaddrinfo.c b/deps/cares/src/lib/ares__readaddrinfo.c +index 673de87..2315df9 100644 +--- a/deps/cares/src/lib/ares__readaddrinfo.c ++++ b/deps/cares/src/lib/ares__readaddrinfo.c +@@ -234,12 +234,19 @@ int ares__readaddrinfo(FILE *fp, + goto fail; + } + ++ /* If no results, its a failure */ ++ if (!nodes) ++ { ++ status = ARES_ENOTFOUND; ++ goto fail; ++ } ++ + /* Free line buffer. */ + ares_free(line); + ares__addrinfo_cat_cnames(&ai->cnames, cnames); + ares__addrinfo_cat_nodes(&ai->nodes, nodes); + +- return nodes ? ARES_SUCCESS : ARES_ENOTFOUND; ++ return ARES_SUCCESS; + + fail: + ares_free(line); +diff --git a/deps/cares/src/lib/ares_config.h.cmake b/deps/cares/src/lib/ares_config.h.cmake +index fddb785..798820a 100644 +--- a/deps/cares/src/lib/ares_config.h.cmake ++++ b/deps/cares/src/lib/ares_config.h.cmake +@@ -346,6 +346,9 @@ + /* Define to 1 if you need the memory.h header file even with stdlib.h */ + #cmakedefine NEED_MEMORY_H + ++/* Define if have arc4random_buf() */ ++#cmakedefine HAVE_ARC4RANDOM_BUF ++ + /* a suitable file/device to read random data from */ + #cmakedefine CARES_RANDOM_FILE "@CARES_RANDOM_FILE@" + +diff --git a/deps/cares/src/lib/ares_config.h.in b/deps/cares/src/lib/ares_config.h.in +index b260c08..3f6954a 100644 +--- a/deps/cares/src/lib/ares_config.h.in ++++ b/deps/cares/src/lib/ares_config.h.in +@@ -54,6 +54,9 @@ + /* Define to 1 if you have AF_INET6. */ + #undef HAVE_AF_INET6 + ++/* Define to 1 if you have the arc4random_buf function. */ ++#undef HAVE_ARC4RANDOM_BUF ++ + /* Define to 1 if you have the header file. */ + #undef HAVE_ARPA_INET_H + +diff --git a/deps/cares/src/lib/ares_data.h b/deps/cares/src/lib/ares_data.h +index 6b9dd9f..a682ad5 100644 +--- a/deps/cares/src/lib/ares_data.h ++++ b/deps/cares/src/lib/ares_data.h +@@ -1,3 +1,6 @@ ++#ifndef __ARES_DATA_H ++#define __ARES_DATA_H ++ + + /* Copyright (C) 2009-2013 by Daniel Stenberg + * +@@ -74,3 +77,5 @@ struct ares_data { + + void *ares_malloc_data(ares_datatype type); + ++ ++#endif /* __ARES_DATA_H */ +diff --git a/deps/cares/src/lib/ares_destroy.c b/deps/cares/src/lib/ares_destroy.c +index fed2009..62c899f 100644 +--- a/deps/cares/src/lib/ares_destroy.c ++++ b/deps/cares/src/lib/ares_destroy.c +@@ -38,6 +38,8 @@ void ares_destroy_options(struct ares_options *options) + ares_free(options->lookups); + if(options->resolvconf_path) + ares_free(options->resolvconf_path); ++ if(options->hosts_path) ++ ares_free(options->hosts_path); + } + + void ares_destroy(ares_channel channel) +@@ -90,6 +92,12 @@ void ares_destroy(ares_channel channel) + if (channel->resolvconf_path) + ares_free(channel->resolvconf_path); + ++ if (channel->hosts_path) ++ ares_free(channel->hosts_path); ++ ++ if (channel->rand_state) ++ ares__destroy_rand_state(channel->rand_state); ++ + ares_free(channel); + } + +diff --git a/deps/cares/src/lib/ares_expand_name.c b/deps/cares/src/lib/ares_expand_name.c +index fcd88a2..ad1c97f 100644 +--- a/deps/cares/src/lib/ares_expand_name.c ++++ b/deps/cares/src/lib/ares_expand_name.c +@@ -64,6 +64,8 @@ static int ares__isprint(int ch) + * - underscores which are used in SRV records. + * - Forward slashes such as are used for classless in-addr.arpa + * delegation (CNAMEs) ++ * - Asterisks may be used for wildcard domains in CNAMEs as seen in the ++ * real world. + * While RFC 2181 section 11 does state not to do validation, + * that applies to servers, not clients. Vulnerabilities have been + * reported when this validation is not performed. Security is more +@@ -71,7 +73,7 @@ static int ares__isprint(int ch) + * anyhow). */ + static int is_hostnamech(int ch) + { +- /* [A-Za-z0-9-._/] ++ /* [A-Za-z0-9-*._/] + * Don't use isalnum() as it is locale-specific + */ + if (ch >= 'A' && ch <= 'Z') +@@ -80,7 +82,7 @@ static int is_hostnamech(int ch) + return 1; + if (ch >= '0' && ch <= '9') + return 1; +- if (ch == '-' || ch == '.' || ch == '_' || ch == '/') ++ if (ch == '-' || ch == '.' || ch == '_' || ch == '/' || ch == '*') + return 1; + + return 0; +@@ -177,9 +179,9 @@ int ares__expand_name_validated(const unsigned char *encoded, + if (!ares__isprint(*p) && !(name_len == 1 && *p == 0)) + { + *q++ = '\\'; +- *q++ = '0' + *p / 100; +- *q++ = '0' + (*p % 100) / 10; +- *q++ = '0' + (*p % 10); ++ *q++ = (char)('0' + *p / 100); ++ *q++ = (char)('0' + (*p % 100) / 10); ++ *q++ = (char)('0' + (*p % 10)); + } + else if (is_reservedch(*p)) + { +diff --git a/deps/cares/src/lib/ares_getaddrinfo.c b/deps/cares/src/lib/ares_getaddrinfo.c +index 0a0225a..cb49424 100644 +--- a/deps/cares/src/lib/ares_getaddrinfo.c ++++ b/deps/cares/src/lib/ares_getaddrinfo.c +@@ -326,7 +326,7 @@ static int fake_addrinfo(const char *name, + } + } + +- if (family == AF_INET6 || family == AF_UNSPEC) ++ if (!result && (family == AF_INET6 || family == AF_UNSPEC)) + { + struct ares_in6_addr addr6; + result = ares_inet_pton(AF_INET6, name, &addr6) < 1 ? 0 : 1; +@@ -404,16 +404,46 @@ static void end_hquery(struct host_query *hquery, int status) + ares_free(hquery); + } + ++static int is_localhost(const char *name) ++{ ++ /* RFC6761 6.3 says : The domain "localhost." and any names falling within ".localhost." */ ++ size_t len; ++ ++ if (name == NULL) ++ return 0; ++ ++ if (strcmp(name, "localhost") == 0) ++ return 1; ++ ++ len = strlen(name); ++ if (len < 10 /* strlen(".localhost") */) ++ return 0; ++ ++ if (strcmp(name + (len - 10 /* strlen(".localhost") */), ".localhost") == 0) ++ return 1; ++ ++ return 0; ++} ++ + static int file_lookup(struct host_query *hquery) + { + FILE *fp; + int error; + int status; +- const char *path_hosts = NULL; ++ char *path_hosts = NULL; + + if (hquery->hints.ai_flags & ARES_AI_ENVHOSTS) + { +- path_hosts = getenv("CARES_HOSTS"); ++ path_hosts = ares_strdup(getenv("CARES_HOSTS")); ++ if (!path_hosts) ++ return ARES_ENOMEM; ++ } ++ ++ if (hquery->channel->hosts_path) ++ { ++ path_hosts = ares_strdup(hquery->channel->hosts_path); ++ if (!path_hosts) ++ return ARES_ENOMEM; + } + + if (!path_hosts) +@@ -447,15 +477,15 @@ static int file_lookup(struct host_query *hquery) + return ARES_ENOTFOUND; + + strcat(PATH_HOSTS, WIN_PATH_HOSTS); +- path_hosts = PATH_HOSTS; +- + #elif defined(WATT32) + const char *PATH_HOSTS = _w32_GetHostsFile(); + + if (!PATH_HOSTS) + return ARES_ENOTFOUND; + #endif +- path_hosts = PATH_HOSTS; ++ path_hosts = ares_strdup(PATH_HOSTS); ++ if (!path_hosts) ++ return ARES_ENOMEM; + } + + fp = fopen(path_hosts, "r"); +@@ -466,21 +496,29 @@ static int file_lookup(struct host_query *hquery) + { + case ENOENT: + case ESRCH: +- return ARES_ENOTFOUND; ++ status = ARES_ENOTFOUND; ++ break; + default: + DEBUGF(fprintf(stderr, "fopen() failed with error: %d %s\n", error, + strerror(error))); + DEBUGF(fprintf(stderr, "Error opening file: %s\n", path_hosts)); +- return ARES_EFILE; ++ status = ARES_EFILE; ++ break; + } + } +- status = ares__readaddrinfo(fp, hquery->name, hquery->port, &hquery->hints, hquery->ai); +- fclose(fp); ++ else ++ { ++ status = ares__readaddrinfo(fp, hquery->name, hquery->port, &hquery->hints, hquery->ai); ++ fclose(fp); ++ } ++ ares_free(path_hosts); + + /* RFC6761 section 6.3 #3 states that "Name resolution APIs and libraries + * SHOULD recognize localhost names as special and SHOULD always return the +- * IP loopback address for address queries" */ +- if (status == ARES_ENOTFOUND && strcmp(hquery->name, "localhost") == 0) ++ * IP loopback address for address queries". ++ * We will also ignore ALL errors when trying to resolve localhost, such ++ * as permissions errors reading /etc/hosts or a malformed /etc/hosts */ ++ if (status != ARES_SUCCESS && is_localhost(hquery->name)) + { + return ares__addrinfo_localhost(hquery->name, hquery->port, + &hquery->hints, hquery->ai); +@@ -497,7 +535,7 @@ static void next_lookup(struct host_query *hquery, int status) + /* RFC6761 section 6.3 #3 says "Name resolution APIs SHOULD NOT send + * queries for localhost names to their configured caching DNS + * server(s)." */ +- if (strcmp(hquery->name, "localhost") != 0) ++ if (!is_localhost(hquery->name)) + { + /* DNS lookup */ + if (next_dns_lookup(hquery)) +@@ -543,7 +581,16 @@ static void host_callback(void *arg, int status, int timeouts, + if (addinfostatus != ARES_SUCCESS && addinfostatus != ARES_ENODATA) + { + /* error in parsing result e.g. no memory */ +- end_hquery(hquery, addinfostatus); ++ if (addinfostatus == ARES_EBADRESP && hquery->ai->nodes) ++ { ++ /* We got a bad response from server, but at least one query ++ * ended with ARES_SUCCESS */ ++ end_hquery(hquery, ARES_SUCCESS); ++ } ++ else ++ { ++ end_hquery(hquery, addinfostatus); ++ } + } + else if (hquery->ai->nodes) + { +@@ -623,26 +670,32 @@ void ares_getaddrinfo(ares_channel channel, + { + if (hints->ai_flags & ARES_AI_NUMERICSERV) + { +- port = (unsigned short)strtoul(service, NULL, 0); +- if (!port) ++ unsigned long val; ++ errno = 0; ++ val = strtoul(service, NULL, 0); ++ if ((val == 0 && errno != 0) || val > 65535) + { + ares_free(alias_name); + callback(arg, ARES_ESERVICE, 0, NULL); + return; + } ++ port = (unsigned short)val; + } + else + { + port = lookup_service(service, 0); + if (!port) + { +- port = (unsigned short)strtoul(service, NULL, 0); +- if (!port) ++ unsigned long val; ++ errno = 0; ++ val = strtoul(service, NULL, 0); ++ if ((val == 0 && errno != 0) || val > 65535) + { + ares_free(alias_name); + callback(arg, ARES_ESERVICE, 0, NULL); + return; + } ++ port = (unsigned short)val; + } + } + } +diff --git a/deps/cares/src/lib/ares_init.c b/deps/cares/src/lib/ares_init.c +index de5d86c..918a926 100644 +--- a/deps/cares/src/lib/ares_init.c ++++ b/deps/cares/src/lib/ares_init.c +@@ -47,9 +47,12 @@ + #include + #endif + ++#if defined(USE_WINSOCK) ++# include ++#endif ++ + #include "ares.h" + #include "ares_inet_net_pton.h" +-#include "ares_library_init.h" + #include "ares_nowarn.h" + #include "ares_platform.h" + #include "ares_private.h" +@@ -58,6 +61,7 @@ + #undef WIN32 /* Redefined in MingW/MSVC headers */ + #endif + ++ + static int init_by_options(ares_channel channel, + const struct ares_options *options, + int optmask); +@@ -72,7 +76,6 @@ static int config_nameserver(struct server_state **servers, int *nservers, + static int set_search(ares_channel channel, const char *str); + static int set_options(ares_channel channel, const char *str); + static const char *try_option(const char *p, const char *q, const char *opt); +-static int init_id_key(rc4_key* key,int key_data_len); + + static int config_sortlist(struct apattern **sortlist, int *nsort, + const char *str); +@@ -149,6 +152,8 @@ int ares_init_options(ares_channel *channelptr, struct ares_options *options, + channel->sock_funcs = NULL; + channel->sock_func_cb_data = NULL; + channel->resolvconf_path = NULL; ++ channel->hosts_path = NULL; ++ channel->rand_state = NULL; + + channel->last_server = 0; + channel->last_timeout_processed = (time_t)now.tv_sec; +@@ -202,9 +207,13 @@ int ares_init_options(ares_channel *channelptr, struct ares_options *options, + /* Generate random key */ + + if (status == ARES_SUCCESS) { +- status = init_id_key(&channel->id_key, ARES_ID_KEY_LEN); ++ channel->rand_state = ares__init_rand_state(); ++ if (channel->rand_state == NULL) { ++ status = ARES_ENOMEM; ++ } ++ + if (status == ARES_SUCCESS) +- channel->next_id = ares__generate_new_id(&channel->id_key); ++ channel->next_id = ares__generate_new_id(channel->rand_state); + else + DEBUGF(fprintf(stderr, "Error: init_id_key failed: %s\n", + ares_strerror(status))); +@@ -217,13 +226,17 @@ done: + if (channel->servers) + ares_free(channel->servers); + if (channel->ndomains != -1) +- ares_strsplit_free(channel->domains, channel->ndomains); ++ ares__strsplit_free(channel->domains, channel->ndomains); + if (channel->sortlist) + ares_free(channel->sortlist); + if(channel->lookups) + ares_free(channel->lookups); + if(channel->resolvconf_path) + ares_free(channel->resolvconf_path); ++ if(channel->hosts_path) ++ ares_free(channel->hosts_path); ++ if (channel->rand_state) ++ ares__destroy_rand_state(channel->rand_state); + ares_free(channel); + return status; + } +@@ -335,6 +348,9 @@ int ares_save_options(ares_channel channel, struct ares_options *options, + if (channel->resolvconf_path) + (*optmask) |= ARES_OPT_RESOLVCONF; + ++ if (channel->hosts_path) ++ (*optmask) |= ARES_OPT_HOSTS_FILE; ++ + /* Copy easy stuff */ + options->flags = channel->flags; + +@@ -414,6 +430,13 @@ int ares_save_options(ares_channel channel, struct ares_options *options, + return ARES_ENOMEM; + } + ++ /* copy path for hosts file */ ++ if (channel->hosts_path) { ++ options->hosts_path = ares_strdup(channel->hosts_path); ++ if (!options->hosts_path) ++ return ARES_ENOMEM; ++ } ++ + return ARES_SUCCESS; + } + +@@ -530,6 +553,14 @@ static int init_by_options(ares_channel channel, + return ARES_ENOMEM; + } + ++ /* Set path for hosts file, if given. */ ++ if ((optmask & ARES_OPT_HOSTS_FILE) && !channel->hosts_path) ++ { ++ channel->hosts_path = ares_strdup(options->hosts_path); ++ if (!channel->hosts_path && options->hosts_path) ++ return ARES_ENOMEM; ++ } ++ + channel->optmask = optmask; + + return ARES_SUCCESS; +@@ -608,227 +639,6 @@ static int get_REG_SZ(HKEY hKey, const char *leafKeyName, char **outptr) + return 1; + } + +-/* +- * get_REG_SZ_9X() +- * +- * Functionally identical to get_REG_SZ() +- * +- * Supported on Windows 95, 98 and ME. +- */ +-static int get_REG_SZ_9X(HKEY hKey, const char *leafKeyName, char **outptr) +-{ +- DWORD dataType = 0; +- DWORD size = 0; +- int res; +- +- *outptr = NULL; +- +- /* Find out size of string stored in registry */ +- res = RegQueryValueExA(hKey, leafKeyName, 0, &dataType, NULL, &size); +- if ((res != ERROR_SUCCESS && res != ERROR_MORE_DATA) || !size) +- return 0; +- +- /* Allocate buffer of indicated size plus one given that string +- might have been stored without null termination */ +- *outptr = ares_malloc(size+1); +- if (!*outptr) +- return 0; +- +- /* Get the value for real */ +- res = RegQueryValueExA(hKey, leafKeyName, 0, &dataType, +- (unsigned char *)*outptr, &size); +- if ((res != ERROR_SUCCESS) || (size == 1)) +- { +- ares_free(*outptr); +- *outptr = NULL; +- return 0; +- } +- +- /* Null terminate buffer allways */ +- *(*outptr + size) = '\0'; +- +- return 1; +-} +- +-/* +- * get_enum_REG_SZ() +- * +- * Given a 'hKeyParent' handle to an open registry key and a 'leafKeyName' +- * pointer to the name of the registry leaf key to be queried, parent key +- * is enumerated searching in child keys for given leaf key name and its +- * associated string value. When located, this returns a pointer in *outptr +- * to a newly allocated memory area holding it as a null-terminated string. +- * +- * Returns 0 and nullifies *outptr upon inability to return a string value. +- * +- * Returns 1 and sets *outptr when returning a dynamically allocated string. +- * +- * Supported on Windows NT 3.5 and newer. +- */ +-static int get_enum_REG_SZ(HKEY hKeyParent, const char *leafKeyName, +- char **outptr) +-{ +- char enumKeyName[256]; +- DWORD enumKeyNameBuffSize; +- DWORD enumKeyIdx = 0; +- HKEY hKeyEnum; +- int gotString; +- int res; +- +- *outptr = NULL; +- +- for(;;) +- { +- enumKeyNameBuffSize = sizeof(enumKeyName); +- res = RegEnumKeyExA(hKeyParent, enumKeyIdx++, enumKeyName, +- &enumKeyNameBuffSize, 0, NULL, NULL, NULL); +- if (res != ERROR_SUCCESS) +- break; +- res = RegOpenKeyExA(hKeyParent, enumKeyName, 0, KEY_QUERY_VALUE, +- &hKeyEnum); +- if (res != ERROR_SUCCESS) +- continue; +- gotString = get_REG_SZ(hKeyEnum, leafKeyName, outptr); +- RegCloseKey(hKeyEnum); +- if (gotString) +- break; +- } +- +- if (!*outptr) +- return 0; +- +- return 1; +-} +- +-/* +- * get_DNS_Registry_9X() +- * +- * Functionally identical to get_DNS_Registry() +- * +- * Implementation supports Windows 95, 98 and ME. +- */ +-static int get_DNS_Registry_9X(char **outptr) +-{ +- HKEY hKey_VxD_MStcp; +- int gotString; +- int res; +- +- *outptr = NULL; +- +- res = RegOpenKeyExA(HKEY_LOCAL_MACHINE, WIN_NS_9X, 0, KEY_READ, +- &hKey_VxD_MStcp); +- if (res != ERROR_SUCCESS) +- return 0; +- +- gotString = get_REG_SZ_9X(hKey_VxD_MStcp, NAMESERVER, outptr); +- RegCloseKey(hKey_VxD_MStcp); +- +- if (!gotString || !*outptr) +- return 0; +- +- return 1; +-} +- +-/* +- * get_DNS_Registry_NT() +- * +- * Functionally identical to get_DNS_Registry() +- * +- * Refs: Microsoft Knowledge Base articles KB120642 and KB314053. +- * +- * Implementation supports Windows NT 3.5 and newer. +- */ +-static int get_DNS_Registry_NT(char **outptr) +-{ +- HKEY hKey_Interfaces = NULL; +- HKEY hKey_Tcpip_Parameters; +- int gotString; +- int res; +- +- *outptr = NULL; +- +- res = RegOpenKeyExA(HKEY_LOCAL_MACHINE, WIN_NS_NT_KEY, 0, KEY_READ, +- &hKey_Tcpip_Parameters); +- if (res != ERROR_SUCCESS) +- return 0; +- +- /* +- ** Global DNS settings override adapter specific parameters when both +- ** are set. Additionally static DNS settings override DHCP-configured +- ** parameters when both are set. +- */ +- +- /* Global DNS static parameters */ +- gotString = get_REG_SZ(hKey_Tcpip_Parameters, NAMESERVER, outptr); +- if (gotString) +- goto done; +- +- /* Global DNS DHCP-configured parameters */ +- gotString = get_REG_SZ(hKey_Tcpip_Parameters, DHCPNAMESERVER, outptr); +- if (gotString) +- goto done; +- +- /* Try adapter specific parameters */ +- res = RegOpenKeyExA(hKey_Tcpip_Parameters, "Interfaces", 0, +- KEY_QUERY_VALUE | KEY_ENUMERATE_SUB_KEYS, +- &hKey_Interfaces); +- if (res != ERROR_SUCCESS) +- { +- hKey_Interfaces = NULL; +- goto done; +- } +- +- /* Adapter specific DNS static parameters */ +- gotString = get_enum_REG_SZ(hKey_Interfaces, NAMESERVER, outptr); +- if (gotString) +- goto done; +- +- /* Adapter specific DNS DHCP-configured parameters */ +- gotString = get_enum_REG_SZ(hKey_Interfaces, DHCPNAMESERVER, outptr); +- +-done: +- if (hKey_Interfaces) +- RegCloseKey(hKey_Interfaces); +- +- RegCloseKey(hKey_Tcpip_Parameters); +- +- if (!gotString || !*outptr) +- return 0; +- +- return 1; +-} +- +-/* +- * get_DNS_Registry() +- * +- * Locates DNS info in the registry. When located, this returns a pointer +- * in *outptr to a newly allocated memory area holding a null-terminated +- * string with a space or comma seperated list of DNS IP addresses. +- * +- * Returns 0 and nullifies *outptr upon inability to return DNSes string. +- * +- * Returns 1 and sets *outptr when returning a dynamically allocated string. +- */ +-static int get_DNS_Registry(char **outptr) +-{ +- win_platform platform; +- int gotString = 0; +- +- *outptr = NULL; +- +- platform = ares__getplatform(); +- +- if (platform == WIN_NT) +- gotString = get_DNS_Registry_NT(outptr); +- else if (platform == WIN_9X) +- gotString = get_DNS_Registry_9X(outptr); +- +- if (!gotString) +- return 0; +- +- return 1; +-} +- + static void commanjoin(char** dst, const char* const src, const size_t len) + { + char *newbuf; +@@ -857,106 +667,6 @@ static void commajoin(char **dst, const char *src) + commanjoin(dst, src, strlen(src)); + } + +-/* +- * get_DNS_NetworkParams() +- * +- * Locates DNS info using GetNetworkParams() function from the Internet +- * Protocol Helper (IP Helper) API. When located, this returns a pointer +- * in *outptr to a newly allocated memory area holding a null-terminated +- * string with a space or comma seperated list of DNS IP addresses. +- * +- * Returns 0 and nullifies *outptr upon inability to return DNSes string. +- * +- * Returns 1 and sets *outptr when returning a dynamically allocated string. +- * +- * Implementation supports Windows 98 and newer. +- * +- * Note: Ancient PSDK required in order to build a W98 target. +- */ +-static int get_DNS_NetworkParams(char **outptr) +-{ +- FIXED_INFO *fi, *newfi; +- struct ares_addr namesrvr; +- char *txtaddr; +- IP_ADDR_STRING *ipAddr; +- int res; +- DWORD size = sizeof (*fi); +- +- *outptr = NULL; +- +- /* Verify run-time availability of GetNetworkParams() */ +- if (ares_fpGetNetworkParams == ZERO_NULL) +- return 0; +- +- fi = ares_malloc(size); +- if (!fi) +- return 0; +- +- res = (*ares_fpGetNetworkParams) (fi, &size); +- if ((res != ERROR_BUFFER_OVERFLOW) && (res != ERROR_SUCCESS)) +- goto done; +- +- newfi = ares_realloc(fi, size); +- if (!newfi) +- goto done; +- +- fi = newfi; +- res = (*ares_fpGetNetworkParams) (fi, &size); +- if (res != ERROR_SUCCESS) +- goto done; +- +- for (ipAddr = &fi->DnsServerList; ipAddr; ipAddr = ipAddr->Next) +- { +- txtaddr = &ipAddr->IpAddress.String[0]; +- +- /* Validate converting textual address to binary format. */ +- if (ares_inet_pton(AF_INET, txtaddr, &namesrvr.addrV4) == 1) +- { +- if ((namesrvr.addrV4.S_un.S_addr == INADDR_ANY) || +- (namesrvr.addrV4.S_un.S_addr == INADDR_NONE)) +- continue; +- } +- else if (ares_inet_pton(AF_INET6, txtaddr, &namesrvr.addrV6) == 1) +- { +- if (memcmp(&namesrvr.addrV6, &ares_in6addr_any, +- sizeof(namesrvr.addrV6)) == 0) +- continue; +- } +- else +- continue; +- +- commajoin(outptr, txtaddr); +- +- if (!*outptr) +- break; +- } +- +-done: +- if (fi) +- ares_free(fi); +- +- if (!*outptr) +- return 0; +- +- return 1; +-} +- +-static BOOL ares_IsWindowsVistaOrGreater(void) +-{ +- OSVERSIONINFO vinfo; +- memset(&vinfo, 0, sizeof(vinfo)); +- vinfo.dwOSVersionInfoSize = sizeof(vinfo); +-#ifdef _MSC_VER +-#pragma warning(push) +-#pragma warning(disable:4996) /* warning C4996: 'GetVersionExW': was declared deprecated */ +-#endif +- if (!GetVersionEx(&vinfo) || vinfo.dwMajorVersion < 6) +- return FALSE; +- return TRUE; +-#ifdef _MSC_VER +-#pragma warning(pop) +-#endif +-} + + /* A structure to hold the string form of IPv4 and IPv6 addresses so we can + * sort them by a metric. +@@ -1031,23 +741,33 @@ static ULONG getBestRouteMetric(IF_LUID * const luid, /* Can't be const :( */ + const ULONG interfaceMetric) + { + /* On this interface, get the best route to that destination. */ ++#if defined(__WATCOMC__) ++ /* OpenWatcom's builtin Windows SDK does not have a definition for ++ * MIB_IPFORWARD_ROW2, and also does not allow the usage of SOCKADDR_INET ++ * as a variable. Let's work around this by returning the worst possible ++ * metric, but only when using the OpenWatcom compiler. ++ * It may be worth investigating using a different version of the Windows ++ * SDK with OpenWatcom in the future, though this may be fixed in OpenWatcom ++ * 2.0. ++ */ ++ return (ULONG)-1; ++#else + MIB_IPFORWARD_ROW2 row; + SOCKADDR_INET ignored; +- if(!ares_fpGetBestRoute2 || +- ares_fpGetBestRoute2(/* The interface to use. The index is ignored since we are +- * passing a LUID. +- */ +- luid, 0, +- /* No specific source address. */ +- NULL, +- /* Our destination address. */ +- dest, +- /* No options. */ +- 0, +- /* The route row. */ +- &row, +- /* The best source address, which we don't need. */ +- &ignored) != NO_ERROR ++ if(GetBestRoute2(/* The interface to use. The index is ignored since we are ++ * passing a LUID. ++ */ ++ luid, 0, ++ /* No specific source address. */ ++ NULL, ++ /* Our destination address. */ ++ dest, ++ /* No options. */ ++ 0, ++ /* The route row. */ ++ &row, ++ /* The best source address, which we don't need. */ ++ &ignored) != NO_ERROR + /* If the metric is "unused" (-1) or too large for us to add the two + * metrics, use the worst possible, thus sorting this last. + */ +@@ -1064,10 +784,11 @@ static ULONG getBestRouteMetric(IF_LUID * const luid, /* Can't be const :( */ + * which describes the combination as a "sum". + */ + return row.Metric + interfaceMetric; ++#endif /* __WATCOMC__ */ + } + + /* +- * get_DNS_AdaptersAddresses() ++ * get_DNS_Windows() + * + * Locates DNS info using GetAdaptersAddresses() function from the Internet + * Protocol Helper (IP Helper) API. When located, this returns a pointer +@@ -1082,7 +803,7 @@ static ULONG getBestRouteMetric(IF_LUID * const luid, /* Can't be const :( */ + */ + #define IPAA_INITIAL_BUF_SZ 15 * 1024 + #define IPAA_MAX_TRIES 3 +-static int get_DNS_AdaptersAddresses(char **outptr) ++static int get_DNS_Windows(char **outptr) + { + IP_ADAPTER_DNS_SERVER_ADDRESS *ipaDNSAddr; + IP_ADAPTER_ADDRESSES *ipaa, *newipaa, *ipaaEntry; +@@ -1107,10 +828,6 @@ static int get_DNS_AdaptersAddresses(char **outptr) + + *outptr = NULL; + +- /* Verify run-time availability of GetAdaptersAddresses() */ +- if (ares_fpGetAdaptersAddresses == ZERO_NULL) +- return 0; +- + ipaa = ares_malloc(Bufsz); + if (!ipaa) + return 0; +@@ -1127,8 +844,7 @@ static int get_DNS_AdaptersAddresses(char **outptr) + } + + /* Usually this call suceeds with initial buffer size */ +- res = (*ares_fpGetAdaptersAddresses) (AF_UNSPEC, AddrFlags, NULL, +- ipaa, &ReqBufsz); ++ res = GetAdaptersAddresses(AF_UNSPEC, AddrFlags, NULL, ipaa, &ReqBufsz); + if ((res != ERROR_BUFFER_OVERFLOW) && (res != ERROR_SUCCESS)) + goto done; + +@@ -1142,8 +858,7 @@ static int get_DNS_AdaptersAddresses(char **outptr) + Bufsz = ReqBufsz; + ipaa = newipaa; + } +- res = (*ares_fpGetAdaptersAddresses) (AF_UNSPEC, AddrFlags, NULL, +- ipaa, &ReqBufsz); ++ res = GetAdaptersAddresses(AF_UNSPEC, AddrFlags, NULL, ipaa, &ReqBufsz); + if (res == ERROR_SUCCESS) + break; + } +@@ -1185,26 +900,17 @@ static int get_DNS_AdaptersAddresses(char **outptr) + addressesSize = newSize; + } + +- /* Vista required for Luid or Ipv4Metric */ +- if (ares_IsWindowsVistaOrGreater()) +- { +- /* Save the address as the next element in addresses. */ +- addresses[addressesIndex].metric = +- getBestRouteMetric(&ipaaEntry->Luid, +- (SOCKADDR_INET*)(namesrvr.sa), +- ipaaEntry->Ipv4Metric); +- } +- else +- { +- addresses[addressesIndex].metric = (ULONG)-1; +- } ++ addresses[addressesIndex].metric = ++ getBestRouteMetric(&ipaaEntry->Luid, ++ (SOCKADDR_INET*)(namesrvr.sa), ++ ipaaEntry->Ipv4Metric); + + /* Record insertion index to make qsort stable */ + addresses[addressesIndex].orig_idx = addressesIndex; + +- if (! ares_inet_ntop(AF_INET, &namesrvr.sa4->sin_addr, +- addresses[addressesIndex].text, +- sizeof(addresses[0].text))) { ++ if (!ares_inet_ntop(AF_INET, &namesrvr.sa4->sin_addr, ++ addresses[addressesIndex].text, ++ sizeof(addresses[0].text))) { + continue; + } + ++addressesIndex; +@@ -1227,26 +933,17 @@ static int get_DNS_AdaptersAddresses(char **outptr) + addressesSize = newSize; + } + +- /* Vista required for Luid or Ipv4Metric */ +- if (ares_IsWindowsVistaOrGreater()) +- { +- /* Save the address as the next element in addresses. */ +- addresses[addressesIndex].metric = +- getBestRouteMetric(&ipaaEntry->Luid, +- (SOCKADDR_INET*)(namesrvr.sa), +- ipaaEntry->Ipv6Metric); +- } +- else +- { +- addresses[addressesIndex].metric = (ULONG)-1; +- } ++ addresses[addressesIndex].metric = ++ getBestRouteMetric(&ipaaEntry->Luid, ++ (SOCKADDR_INET*)(namesrvr.sa), ++ ipaaEntry->Ipv6Metric); + + /* Record insertion index to make qsort stable */ + addresses[addressesIndex].orig_idx = addressesIndex; + +- if (! ares_inet_ntop(AF_INET6, &namesrvr.sa6->sin6_addr, +- addresses[addressesIndex].text, +- sizeof(addresses[0].text))) { ++ if (!ares_inet_ntop(AF_INET6, &namesrvr.sa6->sin6_addr, ++ addresses[addressesIndex].text, ++ sizeof(addresses[0].text))) { + continue; + } + ++addressesIndex; +@@ -1294,35 +991,6 @@ done: + return 1; + } + +-/* +- * get_DNS_Windows() +- * +- * Locates DNS info from Windows employing most suitable methods available at +- * run-time no matter which Windows version it is. When located, this returns +- * a pointer in *outptr to a newly allocated memory area holding a string with +- * a space or comma seperated list of DNS IP addresses, null-terminated. +- * +- * Returns 0 and nullifies *outptr upon inability to return DNSes string. +- * +- * Returns 1 and sets *outptr when returning a dynamically allocated string. +- * +- * Implementation supports Windows 95 and newer. +- */ +-static int get_DNS_Windows(char **outptr) +-{ +- /* Try using IP helper API GetAdaptersAddresses(). IPv4 + IPv6, also sorts +- * DNS servers by interface route metrics to try to use the best DNS server. */ +- if (get_DNS_AdaptersAddresses(outptr)) +- return 1; +- +- /* Try using IP helper API GetNetworkParams(). IPv4 only. */ +- if (get_DNS_NetworkParams(outptr)) +- return 1; +- +- /* Fall-back to registry information */ +- return get_DNS_Registry(outptr); +-} +- + /* + * get_SuffixList_Windows() + * +@@ -1686,8 +1354,12 @@ static int init_by_resolv_conf(ares_channel channel) + channel->tries = res.retry; + if (channel->rotate == -1) + channel->rotate = res.options & RES_ROTATE; +- if (channel->timeout == -1) ++ if (channel->timeout == -1) { + channel->timeout = res.retrans * 1000; ++#ifdef __APPLE__ ++ channel->timeout /= (res.retry + 1) * (res.nscount > 0 ? res.nscount : 1); ++#endif ++ } + + res_ndestroy(&res); + } +@@ -2021,6 +1693,11 @@ static int init_by_defaults(ares_channel channel) + ares_free(channel->resolvconf_path); + channel->resolvconf_path = NULL; + } ++ ++ if(channel->hosts_path) { ++ ares_free(channel->hosts_path); ++ channel->hosts_path = NULL; ++ } + } + + if(hostname) +@@ -2325,12 +2002,12 @@ static int set_search(ares_channel channel, const char *str) + if(channel->ndomains != -1) { + /* LCOV_EXCL_START: all callers check ndomains == -1 */ + /* if we already have some domains present, free them first */ +- ares_strsplit_free(channel->domains, channel->ndomains); ++ ares__strsplit_free(channel->domains, channel->ndomains); + channel->domains = NULL; + channel->ndomains = -1; + } /* LCOV_EXCL_STOP */ + +- channel->domains = ares_strsplit(str, ", ", 1, &cnt); ++ channel->domains = ares__strsplit(str, ", ", &cnt); + channel->ndomains = (int)cnt; + if (channel->domains == NULL || channel->ndomains == 0) { + channel->domains = NULL; +@@ -2495,75 +2172,6 @@ static int sortlist_alloc(struct apattern **sortlist, int *nsort, + return 1; + } + +-/* initialize an rc4 key. If possible a cryptographically secure random key +- is generated using a suitable function (for example win32's RtlGenRandom as +- described in +- http://blogs.msdn.com/michael_howard/archive/2005/01/14/353379.aspx +- otherwise the code defaults to cross-platform albeit less secure mechanism +- using rand +-*/ +-static void randomize_key(unsigned char* key,int key_data_len) +-{ +- int randomized = 0; +- int counter=0; +-#ifdef WIN32 +- BOOLEAN res; +- if (ares_fpSystemFunction036) +- { +- res = (*ares_fpSystemFunction036) (key, key_data_len); +- if (res) +- randomized = 1; +- } +-#else /* !WIN32 */ +-#ifdef CARES_RANDOM_FILE +- FILE *f = fopen(CARES_RANDOM_FILE, "rb"); +- if(f) { +- setvbuf(f, NULL, _IONBF, 0); +- counter = aresx_uztosi(fread(key, 1, key_data_len, f)); +- fclose(f); +- } +-#endif +-#endif /* WIN32 */ +- +- if (!randomized) { +- for (;counterstate[0]; +- for(counter = 0; counter < 256; counter++) +- /* unnecessary AND but it keeps some compilers happier */ +- state[counter] = (unsigned char)(counter & 0xff); +- randomize_key(key->state,key_data_len); +- key->x = 0; +- key->y = 0; +- index1 = 0; +- index2 = 0; +- for(counter = 0; counter < 256; counter++) +- { +- index2 = (unsigned char)((key_data_ptr[index1] + state[counter] + +- index2) % 256); +- ARES_SWAP_BYTE(&state[counter], &state[index2]); +- +- index1 = (unsigned char)((index1 + 1) % key_data_len); +- } +- ares_free(key_data_ptr); +- return ARES_SUCCESS; +-} + + void ares_set_local_ip4(ares_channel channel, unsigned int local_ip) + { +diff --git a/deps/cares/src/lib/ares_library_init.c b/deps/cares/src/lib/ares_library_init.c +index e0055d4..bbfcbee 100644 +--- a/deps/cares/src/lib/ares_library_init.c ++++ b/deps/cares/src/lib/ares_library_init.c +@@ -18,18 +18,10 @@ + #include "ares_setup.h" + + #include "ares.h" +-#include "ares_library_init.h" + #include "ares_private.h" + + /* library-private global and unique instance vars */ + +-#ifdef USE_WINSOCK +-fpGetNetworkParams_t ares_fpGetNetworkParams = ZERO_NULL; +-fpSystemFunction036_t ares_fpSystemFunction036 = ZERO_NULL; +-fpGetAdaptersAddresses_t ares_fpGetAdaptersAddresses = ZERO_NULL; +-fpGetBestRoute2_t ares_fpGetBestRoute2 = ZERO_NULL; +-#endif +- + #if defined(ANDROID) || defined(__ANDROID__) + #include "ares_android.h" + #endif +@@ -59,81 +51,8 @@ void *(*ares_malloc)(size_t size) = default_malloc; + void *(*ares_realloc)(void *ptr, size_t size) = default_realloc; + void (*ares_free)(void *ptr) = default_free; + +-#ifdef USE_WINSOCK +-static HMODULE hnd_iphlpapi; +-static HMODULE hnd_advapi32; +-#endif +- +- +-static int ares_win32_init(void) +-{ +-#ifdef USE_WINSOCK +- +- hnd_iphlpapi = 0; +- hnd_iphlpapi = LoadLibraryW(L"iphlpapi.dll"); +- if (!hnd_iphlpapi) +- return ARES_ELOADIPHLPAPI; +- +- ares_fpGetNetworkParams = (fpGetNetworkParams_t) +- GetProcAddress(hnd_iphlpapi, "GetNetworkParams"); +- if (!ares_fpGetNetworkParams) +- { +- FreeLibrary(hnd_iphlpapi); +- return ARES_EADDRGETNETWORKPARAMS; +- } +- +- ares_fpGetAdaptersAddresses = (fpGetAdaptersAddresses_t) +- GetProcAddress(hnd_iphlpapi, "GetAdaptersAddresses"); +- if (!ares_fpGetAdaptersAddresses) +- { +- /* This can happen on clients before WinXP, I don't +- think it should be an error, unless we don't want to +- support Windows 2000 anymore */ +- } +- +- ares_fpGetBestRoute2 = (fpGetBestRoute2_t) +- GetProcAddress(hnd_iphlpapi, "GetBestRoute2"); +- if (!ares_fpGetBestRoute2) +- { +- /* This can happen on clients before Vista, I don't +- think it should be an error, unless we don't want to +- support Windows XP anymore */ +- } +- +- /* +- * When advapi32.dll is unavailable or advapi32.dll has no SystemFunction036, +- * also known as RtlGenRandom, which is the case for Windows versions prior +- * to WinXP then c-ares uses portable rand() function. Then don't error here. +- */ +- +- hnd_advapi32 = 0; +- hnd_advapi32 = LoadLibraryW(L"advapi32.dll"); +- if (hnd_advapi32) +- { +- ares_fpSystemFunction036 = (fpSystemFunction036_t) +- GetProcAddress(hnd_advapi32, "SystemFunction036"); +- } +- +-#endif +- return ARES_SUCCESS; +-} +- +- +-static void ares_win32_cleanup(void) +-{ +-#ifdef USE_WINSOCK +- if (hnd_advapi32) +- FreeLibrary(hnd_advapi32); +- if (hnd_iphlpapi) +- FreeLibrary(hnd_iphlpapi); +-#endif +-} +- +- + int ares_library_init(int flags) + { +- int res; +- + if (ares_initialized) + { + ares_initialized++; +@@ -141,12 +60,7 @@ int ares_library_init(int flags) + } + ares_initialized++; + +- if (flags & ARES_LIB_INIT_WIN32) +- { +- res = ares_win32_init(); +- if (res != ARES_SUCCESS) +- return res; /* LCOV_EXCL_LINE: can't test Win32 init failure */ +- } ++ /* NOTE: ARES_LIB_INIT_WIN32 flag no longer used */ + + ares_init_flags = flags; + +@@ -176,8 +90,7 @@ void ares_library_cleanup(void) + if (ares_initialized) + return; + +- if (ares_init_flags & ARES_LIB_INIT_WIN32) +- ares_win32_cleanup(); ++ /* NOTE: ARES_LIB_INIT_WIN32 flag no longer used */ + + #if defined(ANDROID) || defined(__ANDROID__) + ares_library_cleanup_android(); +diff --git a/deps/cares/src/lib/ares_library_init.h b/deps/cares/src/lib/ares_library_init.h +deleted file mode 100644 +index b3896d9..0000000 +--- a/deps/cares/src/lib/ares_library_init.h ++++ /dev/null +@@ -1,43 +0,0 @@ +-#ifndef HEADER_CARES_LIBRARY_INIT_H +-#define HEADER_CARES_LIBRARY_INIT_H +- +- +-/* Copyright 1998 by the Massachusetts Institute of Technology. +- * Copyright (C) 2004-2011 by Daniel Stenberg +- * +- * Permission to use, copy, modify, and distribute this +- * software and its documentation for any purpose and without +- * fee is hereby granted, provided that the above copyright +- * notice appear in all copies and that both that copyright +- * notice and this permission notice appear in supporting +- * documentation, and that the name of M.I.T. not be used in +- * advertising or publicity pertaining to distribution of the +- * software without specific, written prior permission. +- * M.I.T. makes no representations about the suitability of +- * this software for any purpose. It is provided "as is" +- * without express or implied warranty. +- */ +- +-#include "ares_setup.h" +- +-#ifdef USE_WINSOCK +- +-#include +-#include "ares_iphlpapi.h" +- +-typedef DWORD (WINAPI *fpGetNetworkParams_t) (FIXED_INFO*, DWORD*); +-typedef BOOLEAN (APIENTRY *fpSystemFunction036_t) (void*, ULONG); +-typedef ULONG (WINAPI *fpGetAdaptersAddresses_t) ( ULONG, ULONG, void*, IP_ADAPTER_ADDRESSES*, ULONG* ); +-typedef NETIO_STATUS (WINAPI *fpGetBestRoute2_t) ( NET_LUID *, NET_IFINDEX, const SOCKADDR_INET *, const SOCKADDR_INET *, ULONG, PMIB_IPFORWARD_ROW2, SOCKADDR_INET * ); +-/* Forward-declaration of variables defined in ares_library_init.c */ +-/* that are global and unique instances for whole c-ares library. */ +- +-extern fpGetNetworkParams_t ares_fpGetNetworkParams; +-extern fpSystemFunction036_t ares_fpSystemFunction036; +-extern fpGetAdaptersAddresses_t ares_fpGetAdaptersAddresses; +-extern fpGetBestRoute2_t ares_fpGetBestRoute2; +- +-#endif /* USE_WINSOCK */ +- +-#endif /* HEADER_CARES_LIBRARY_INIT_H */ +- +diff --git a/deps/cares/src/lib/ares_private.h b/deps/cares/src/lib/ares_private.h +index 60d69e0..b6eab8a 100644 +--- a/deps/cares/src/lib/ares_private.h ++++ b/deps/cares/src/lib/ares_private.h +@@ -101,8 +101,6 @@ W32_FUNC const char *_w32_GetHostsFile (void); + + #endif + +-#define ARES_ID_KEY_LEN 31 +- + #include "ares_ipv6.h" + #include "ares_llist.h" + +@@ -262,12 +260,8 @@ struct apattern { + unsigned short type; + }; + +-typedef struct rc4_key +-{ +- unsigned char state[256]; +- unsigned char x; +- unsigned char y; +-} rc4_key; ++struct ares_rand_state; ++typedef struct ares_rand_state ares_rand_state; + + struct ares_channeldata { + /* Configuration data */ +@@ -302,8 +296,8 @@ struct ares_channeldata { + + /* ID to use for next query */ + unsigned short next_id; +- /* key to use when generating new ids */ +- rc4_key id_key; ++ /* random state to use when generating new ids */ ++ ares_rand_state *rand_state; + + /* Generation number to use for the next TCP socket open/close */ + int tcp_connection_generation; +@@ -339,6 +333,9 @@ struct ares_channeldata { + + /* Path for resolv.conf file, configurable via ares_options */ + char *resolvconf_path; ++ ++ /* Path for hosts file, configurable via ares_options */ ++ char *hosts_path; + }; + + /* Does the domain end in ".onion" or ".onion."? Case-insensitive. */ +@@ -359,7 +356,10 @@ void ares__close_sockets(ares_channel channel, struct server_state *server); + int ares__get_hostent(FILE *fp, int family, struct hostent **host); + int ares__read_line(FILE *fp, char **buf, size_t *bufsize); + void ares__free_query(struct query *query); +-unsigned short ares__generate_new_id(rc4_key* key); ++ ++ares_rand_state *ares__init_rand_state(void); ++void ares__destroy_rand_state(ares_rand_state *state); ++unsigned short ares__generate_new_id(ares_rand_state *state); + struct timeval ares__tvnow(void); + int ares__expand_name_validated(const unsigned char *encoded, + const unsigned char *abuf, +diff --git a/deps/cares/src/lib/ares_process.c b/deps/cares/src/lib/ares_process.c +index 87329e3..6cac0a9 100644 +--- a/deps/cares/src/lib/ares_process.c ++++ b/deps/cares/src/lib/ares_process.c +@@ -209,6 +209,17 @@ static void write_tcp_data(ares_channel channel, + ares_ssize_t scount; + ares_ssize_t wcount; + size_t n; ++ /* From writev manpage: An implementation can advertise its limit by defining ++ IOV_MAX in or at run time via the return value from ++ sysconf(_SC_IOV_MAX). On modern Linux systems, the limit is 1024. Back in ++ Linux 2.0 days, this limit was 16. */ ++#if defined(IOV_MAX) ++ const size_t maxn = IOV_MAX; /* FreeBSD */ ++#elif defined(_SC_IOV_MAX) ++ const size_t maxn = sysconf(_SC_IOV_MAX); /* Linux */ ++#else ++ const size_t maxn = 16; /* Safe default */ ++#endif + + if(!write_fds && (write_fd == ARES_SOCKET_BAD)) + /* no possible action */ +@@ -256,6 +267,8 @@ static void write_tcp_data(ares_channel channel, + vec[n].iov_base = (char *) sendreq->data; + vec[n].iov_len = sendreq->len; + n++; ++ if(n >= maxn) ++ break; + } + wcount = socket_writev(channel, server->tcp_socket, vec, (int)n); + ares_free(vec); +@@ -457,7 +470,7 @@ static void read_udp_packets(ares_channel channel, fd_set *read_fds, + { + struct server_state *server; + int i; +- ares_ssize_t count; ++ ares_ssize_t read_len; + unsigned char buf[MAXENDSSZ + 1]; + #ifdef HAVE_RECVFROM + ares_socklen_t fromlen; +@@ -500,32 +513,41 @@ static void read_udp_packets(ares_channel channel, fd_set *read_fds, + /* To reduce event loop overhead, read and process as many + * packets as we can. */ + do { +- if (server->udp_socket == ARES_SOCKET_BAD) +- count = 0; +- +- else { +- if (server->addr.family == AF_INET) ++ if (server->udp_socket == ARES_SOCKET_BAD) { ++ read_len = -1; ++ } else { ++ if (server->addr.family == AF_INET) { + fromlen = sizeof(from.sa4); +- else ++ } else { + fromlen = sizeof(from.sa6); +- count = socket_recvfrom(channel, server->udp_socket, (void *)buf, +- sizeof(buf), 0, &from.sa, &fromlen); ++ } ++ read_len = socket_recvfrom(channel, server->udp_socket, (void *)buf, ++ sizeof(buf), 0, &from.sa, &fromlen); + } + +- if (count == -1 && try_again(SOCKERRNO)) ++ if (read_len == 0) { ++ /* UDP is connectionless, so result code of 0 is a 0-length UDP ++ * packet, and not an indication the connection is closed like on ++ * tcp */ + continue; +- else if (count <= 0) ++ } else if (read_len < 0) { ++ if (try_again(SOCKERRNO)) ++ continue; ++ + handle_error(channel, i, now); ++ + #ifdef HAVE_RECVFROM +- else if (!same_address(&from.sa, &server->addr)) ++ } else if (!same_address(&from.sa, &server->addr)) { + /* The address the response comes from does not match the address we + * sent the request to. Someone may be attempting to perform a cache + * poisoning attack. */ +- break; ++ continue; + #endif +- else +- process_answer(channel, buf, (int)count, i, 0, now); +- } while (count > 0); ++ ++ } else { ++ process_answer(channel, buf, (int)read_len, i, 0, now); ++ } ++ } while (read_len >= 0); + } + } + +@@ -966,6 +988,22 @@ static int setsocknonblock(ares_socket_t sockfd, /* operate on this */ + #endif + } + ++#if defined(IPV6_V6ONLY) && defined(WIN32) ++/* It makes support for IPv4-mapped IPv6 addresses. ++ * Linux kernel, NetBSD, FreeBSD and Darwin: default is off; ++ * Windows Vista and later: default is on; ++ * DragonFly BSD: acts like off, and dummy setting; ++ * OpenBSD and earlier Windows: unsupported. ++ * Linux: controlled by /proc/sys/net/ipv6/bindv6only. ++ */ ++static void set_ipv6_v6only(ares_socket_t sockfd, int on) ++{ ++ (void)setsockopt(sockfd, IPPROTO_IPV6, IPV6_V6ONLY, (void *)&on, sizeof(on)); ++} ++#else ++#define set_ipv6_v6only(s,v) ++#endif ++ + static int configure_socket(ares_socket_t s, int family, ares_channel channel) + { + union { +@@ -1028,6 +1066,7 @@ static int configure_socket(ares_socket_t s, int family, ares_channel channel) + if (bind(s, &local.sa, sizeof(local.sa6)) < 0) + return -1; + } ++ set_ipv6_v6only(s, 0); + } + + return 0; +diff --git a/deps/cares/src/lib/ares_query.c b/deps/cares/src/lib/ares_query.c +index 508274d..42323be 100644 +--- a/deps/cares/src/lib/ares_query.c ++++ b/deps/cares/src/lib/ares_query.c +@@ -33,32 +33,6 @@ struct qquery { + + static void qcallback(void *arg, int status, int timeouts, unsigned char *abuf, int alen); + +-static void rc4(rc4_key* key, unsigned char *buffer_ptr, int buffer_len) +-{ +- unsigned char x; +- unsigned char y; +- unsigned char* state; +- unsigned char xorIndex; +- int counter; +- +- x = key->x; +- y = key->y; +- +- state = &key->state[0]; +- for(counter = 0; counter < buffer_len; counter ++) +- { +- x = (unsigned char)((x + 1) % 256); +- y = (unsigned char)((state[x] + y) % 256); +- ARES_SWAP_BYTE(&state[x], &state[y]); +- +- xorIndex = (unsigned char)((state[x] + state[y]) % 256); +- +- buffer_ptr[counter] = (unsigned char)(buffer_ptr[counter]^state[xorIndex]); +- } +- key->x = x; +- key->y = y; +-} +- + static struct query* find_query_by_id(ares_channel channel, unsigned short id) + { + unsigned short qid; +@@ -78,7 +52,6 @@ static struct query* find_query_by_id(ares_channel channel, unsigned short id) + return NULL; + } + +- + /* a unique query id is generated using an rc4 key. Since the id may already + be used by a running query (as infrequent as it may be), a lookup is + performed per id generation. In practice this search should happen only +@@ -89,19 +62,12 @@ static unsigned short generate_unique_id(ares_channel channel) + unsigned short id; + + do { +- id = ares__generate_new_id(&channel->id_key); ++ id = ares__generate_new_id(channel->rand_state); + } while (find_query_by_id(channel, id)); + + return (unsigned short)id; + } + +-unsigned short ares__generate_new_id(rc4_key* key) +-{ +- unsigned short r=0; +- rc4(key, (unsigned char *)&r, sizeof(r)); +- return r; +-} +- + void ares_query(ares_channel channel, const char *name, int dnsclass, + int type, ares_callback callback, void *arg) + { +diff --git a/deps/cares/src/lib/ares_rand.c b/deps/cares/src/lib/ares_rand.c +new file mode 100644 +index 0000000..766c1e6 +--- /dev/null ++++ b/deps/cares/src/lib/ares_rand.c +@@ -0,0 +1,279 @@ ++/* Copyright 1998 by the Massachusetts Institute of Technology. ++ * Copyright (C) 2007-2013 by Daniel Stenberg ++ * ++ * Permission to use, copy, modify, and distribute this ++ * software and its documentation for any purpose and without ++ * fee is hereby granted, provided that the above copyright ++ * notice appear in all copies and that both that copyright ++ * notice and this permission notice appear in supporting ++ * documentation, and that the name of M.I.T. not be used in ++ * advertising or publicity pertaining to distribution of the ++ * software without specific, written prior permission. ++ * M.I.T. makes no representations about the suitability of ++ * this software for any purpose. It is provided "as is" ++ * without express or implied warranty. ++ */ ++ ++#include "ares_setup.h" ++#include "ares.h" ++#include "ares_private.h" ++#include "ares_nowarn.h" ++#include ++ ++typedef enum { ++ ARES_RAND_OS = 1, /* OS-provided such as RtlGenRandom or arc4random */ ++ ARES_RAND_FILE = 2, /* OS file-backed random number generator */ ++ ARES_RAND_RC4 = 3 /* Internal RC4 based PRNG */ ++} ares_rand_backend; ++ ++typedef struct ares_rand_rc4 ++{ ++ unsigned char S[256]; ++ size_t i; ++ size_t j; ++} ares_rand_rc4; ++ ++struct ares_rand_state ++{ ++ ares_rand_backend type; ++ union { ++ FILE *rand_file; ++ ares_rand_rc4 rc4; ++ } state; ++}; ++ ++ ++/* Define RtlGenRandom = SystemFunction036. This is in advapi32.dll. There is ++ * no need to dynamically load this, other software used widely does not. ++ * http://blogs.msdn.com/michael_howard/archive/2005/01/14/353379.aspx ++ * https://docs.microsoft.com/en-us/windows/win32/api/ntsecapi/nf-ntsecapi-rtlgenrandom ++ */ ++#ifdef _WIN32 ++BOOLEAN WINAPI SystemFunction036(PVOID RandomBuffer, ULONG RandomBufferLength); ++# ifndef RtlGenRandom ++# define RtlGenRandom(a,b) SystemFunction036(a,b) ++# endif ++#endif ++ ++ ++#define ARES_RC4_KEY_LEN 32 /* 256 bits */ ++ ++#ifdef _MSC_VER ++typedef unsigned __int64 cares_u64; ++#else ++typedef unsigned long long cares_u64; ++#endif ++ ++static unsigned int ares_u32_from_ptr(void *addr) ++{ ++ if (sizeof(void *) == 8) { ++ return (unsigned int)((((cares_u64)addr >> 32) & 0xFFFFFFFF) | ((cares_u64)addr & 0xFFFFFFFF)); ++ } ++ return (unsigned int)((size_t)addr & 0xFFFFFFFF); ++} ++ ++ ++/* initialize an rc4 key as the last possible fallback. */ ++static void ares_rc4_generate_key(ares_rand_rc4 *rc4_state, unsigned char *key, size_t key_len) ++{ ++ size_t i; ++ size_t len = 0; ++ unsigned int data; ++ struct timeval tv; ++ ++ if (key_len != ARES_RC4_KEY_LEN) ++ return; ++ ++ /* Randomness is hard to come by. Maybe the system randomizes heap and stack addresses. ++ * Maybe the current timestamp give us some randomness. ++ * Use rc4_state (heap), &i (stack), and ares__tvnow() ++ */ ++ data = ares_u32_from_ptr(rc4_state); ++ memcpy(key + len, &data, sizeof(data)); ++ len += sizeof(data); ++ ++ data = ares_u32_from_ptr(&i); ++ memcpy(key + len, &data, sizeof(data)); ++ len += sizeof(data); ++ ++ tv = ares__tvnow(); ++ data = (unsigned int)((tv.tv_sec | tv.tv_usec) & 0xFFFFFFFF); ++ memcpy(key + len, &data, sizeof(data)); ++ len += sizeof(data); ++ ++ srand(ares_u32_from_ptr(rc4_state) | ares_u32_from_ptr(&i) | (unsigned int)((tv.tv_sec | tv.tv_usec) & 0xFFFFFFFF)); ++ ++ for (i=len; iS); i++) { ++ rc4_state->S[i] = i & 0xFF; ++ } ++ ++ for(i = 0, j = 0; i < 256; i++) { ++ j = (j + rc4_state->S[i] + key[i % sizeof(key)]) % 256; ++ ARES_SWAP_BYTE(&rc4_state->S[i], &rc4_state->S[j]); ++ } ++ ++ rc4_state->i = 0; ++ rc4_state->j = 0; ++} ++ ++/* Just outputs the key schedule, no need to XOR with any data since we have none */ ++static void ares_rc4_prng(ares_rand_rc4 *rc4_state, unsigned char *buf, size_t len) ++{ ++ unsigned char *S = rc4_state->S; ++ size_t i = rc4_state->i; ++ size_t j = rc4_state->j; ++ size_t cnt; ++ ++ for (cnt=0; cnti = i; ++ rc4_state->j = j; ++} ++ ++ ++static int ares__init_rand_engine(ares_rand_state *state) ++{ ++ memset(state, 0, sizeof(*state)); ++ ++#if defined(HAVE_ARC4RANDOM_BUF) || defined(_WIN32) ++ state->type = ARES_RAND_OS; ++ return 1; ++#elif defined(CARES_RANDOM_FILE) ++ state->type = ARES_RAND_FILE; ++ state->state.rand_file = fopen(CARES_RANDOM_FILE, "rb"); ++ if (state->state.rand_file) { ++ setvbuf(state->state.rand_file, NULL, _IONBF, 0); ++ return 1; ++ } ++ /* Fall-Thru on failure to RC4 */ ++#endif ++ ++ state->type = ARES_RAND_RC4; ++ ares_rc4_init(&state->state.rc4); ++ ++ /* Currently cannot fail */ ++ return 1; ++} ++ ++ ++ares_rand_state *ares__init_rand_state() ++{ ++ ares_rand_state *state = NULL; ++ ++ state = ares_malloc(sizeof(*state)); ++ if (!state) ++ return NULL; ++ ++ if (!ares__init_rand_engine(state)) { ++ ares_free(state); ++ return NULL; ++ } ++ ++ return state; ++} ++ ++ ++static void ares__clear_rand_state(ares_rand_state *state) ++{ ++ if (!state) ++ return; ++ ++ switch (state->type) { ++ case ARES_RAND_OS: ++ break; ++ case ARES_RAND_FILE: ++ fclose(state->state.rand_file); ++ break; ++ case ARES_RAND_RC4: ++ break; ++ } ++} ++ ++ ++static void ares__reinit_rand(ares_rand_state *state) ++{ ++ ares__clear_rand_state(state); ++ ares__init_rand_engine(state); ++} ++ ++ ++void ares__destroy_rand_state(ares_rand_state *state) ++{ ++ if (!state) ++ return; ++ ++ ares__clear_rand_state(state); ++ ares_free(state); ++} ++ ++ ++static void ares__rand_bytes(ares_rand_state *state, unsigned char *buf, size_t len) ++{ ++ ++ while (1) { ++ size_t bytes_read = 0; ++ ++ switch (state->type) { ++ case ARES_RAND_OS: ++#ifdef _WIN32 ++ RtlGenRandom(buf, len); ++ return; ++#elif defined(HAVE_ARC4RANDOM_BUF) ++ arc4random_buf(buf, len); ++ return; ++#else ++ /* Shouldn't be possible to be here */ ++ break; ++#endif ++ ++ case ARES_RAND_FILE: ++ while (1) { ++ size_t rv = fread(buf + bytes_read, 1, len - bytes_read, state->state.rand_file); ++ if (rv == 0) ++ break; /* critical error, will reinit rand state */ ++ ++ bytes_read += rv; ++ if (bytes_read == len) ++ return; ++ } ++ break; ++ ++ case ARES_RAND_RC4: ++ ares_rc4_prng(&state->state.rc4, buf, len); ++ return; ++ } ++ ++ /* If we didn't return before we got here, that means we had a critical rand ++ * failure and need to reinitialized */ ++ ares__reinit_rand(state); ++ } ++} ++ ++unsigned short ares__generate_new_id(ares_rand_state *state) ++{ ++ unsigned short r=0; ++ ++ ares__rand_bytes(state, (unsigned char *)&r, sizeof(r)); ++ return r; ++} ++ +diff --git a/deps/cares/src/lib/ares_send.c b/deps/cares/src/lib/ares_send.c +index 75ba9e4..542cf45 100644 +--- a/deps/cares/src/lib/ares_send.c ++++ b/deps/cares/src/lib/ares_send.c +@@ -39,7 +39,11 @@ void ares_send(ares_channel channel, const unsigned char *qbuf, int qlen, + callback(arg, ARES_EBADQUERY, 0, NULL, 0); + return; + } +- ++ if (channel->nservers < 1) ++ { ++ callback(arg, ARES_ESERVFAIL, 0, NULL, 0); ++ return; ++ } + /* Allocate space for query and allocated fields. */ + query = ares_malloc(sizeof(struct query)); + if (!query) +@@ -54,12 +58,6 @@ void ares_send(ares_channel channel, const unsigned char *qbuf, int qlen, + callback(arg, ARES_ENOMEM, 0, NULL, 0); + return; + } +- if (channel->nservers < 1) +- { +- ares_free(query); +- callback(arg, ARES_ESERVFAIL, 0, NULL, 0); +- return; +- } + query->server_info = ares_malloc(channel->nservers * + sizeof(query->server_info[0])); + if (!query->server_info) +diff --git a/deps/cares/src/lib/ares_strsplit.c b/deps/cares/src/lib/ares_strsplit.c +index 97b4e5d..d3e90c4 100644 +--- a/deps/cares/src/lib/ares_strsplit.c ++++ b/deps/cares/src/lib/ares_strsplit.c +@@ -18,51 +18,10 @@ + #endif + + #include "ares_setup.h" +-#include "ares_strsplit.h" + #include "ares.h" + #include "ares_private.h" + +-static int list_contains(char * const *list, size_t num_elem, const char *str, int insensitive) +-{ +- size_t len; +- size_t i; +- +- len = strlen(str); +- for (i=0; i + * Copyright (c) 1996,1999 by Internet Software Consortium. + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * +- * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES +- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR +- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT +- * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ++ * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS ++ * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE ++ * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL ++ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR ++ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ++ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS ++ * SOFTWARE. + */ + + #include "ares_setup.h" +@@ -35,9 +36,6 @@ + + const struct ares_in6_addr ares_in6addr_any = { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } } }; + +- +-#ifndef HAVE_INET_NET_PTON +- + /* + * static int + * inet_net_pton_ipv4(src, dst, size) +@@ -60,7 +58,7 @@ const struct ares_in6_addr ares_in6addr_any = { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0, + * Paul Vixie (ISC), June 1996 + */ + static int +-inet_net_pton_ipv4(const char *src, unsigned char *dst, size_t size) ++ares_inet_net_pton_ipv4(const char *src, unsigned char *dst, size_t size) + { + static const char xdigits[] = "0123456789abcdef"; + static const char digits[] = "0123456789"; +@@ -216,64 +214,16 @@ getbits(const char *src, int *bitsp) + return (1); + } + +-static int +-getv4(const char *src, unsigned char *dst, int *bitsp) +-{ +- static const char digits[] = "0123456789"; +- unsigned char *odst = dst; +- int n; +- unsigned int val; +- char ch; +- +- val = 0; +- n = 0; +- while ((ch = *src++) != '\0') { +- const char *pch; +- +- pch = strchr(digits, ch); +- if (pch != NULL) { +- if (n++ != 0 && val == 0) /* no leading zeros */ +- return (0); +- val *= 10; +- val += aresx_sztoui(pch - digits); +- if (val > 255) /* range */ +- return (0); +- continue; +- } +- if (ch == '.' || ch == '/') { +- if (dst - odst > 3) /* too many octets? */ +- return (0); +- *dst++ = (unsigned char)val; +- if (ch == '/') +- return (getbits(src, bitsp)); +- val = 0; +- n = 0; +- continue; +- } +- return (0); +- } +- if (n == 0) +- return (0); +- if (dst - odst > 3) /* too many octets? */ +- return (0); +- *dst = (unsigned char)val; +- return 1; +-} + + static int +-inet_net_pton_ipv6(const char *src, unsigned char *dst, size_t size) ++ares_inet_pton6(const char *src, unsigned char *dst) + { + static const char xdigits_l[] = "0123456789abcdef", +- xdigits_u[] = "0123456789ABCDEF"; ++ xdigits_u[] = "0123456789ABCDEF"; + unsigned char tmp[NS_IN6ADDRSZ], *tp, *endp, *colonp; + const char *xdigits, *curtok; +- int ch, saw_xdigit; ++ int ch, saw_xdigit, count_xdigit; + unsigned int val; +- int digits; +- int bits; +- size_t bytes; +- int words; +- int ipv4; + + memset((tp = tmp), '\0', NS_IN6ADDRSZ); + endp = tp + NS_IN6ADDRSZ; +@@ -283,22 +233,22 @@ inet_net_pton_ipv6(const char *src, unsigned char *dst, size_t size) + if (*++src != ':') + goto enoent; + curtok = src; +- saw_xdigit = 0; ++ saw_xdigit = count_xdigit = 0; + val = 0; +- digits = 0; +- bits = -1; +- ipv4 = 0; + while ((ch = *src++) != '\0') { + const char *pch; + + if ((pch = strchr((xdigits = xdigits_l), ch)) == NULL) + pch = strchr((xdigits = xdigits_u), ch); + if (pch != NULL) { ++ if (count_xdigit >= 4) ++ goto enoent; + val <<= 4; +- val |= aresx_sztoui(pch - xdigits); +- if (++digits > 4) ++ val |= (unsigned int)(pch - xdigits); ++ if (val > 0xffff) + goto enoent; + saw_xdigit = 1; ++ count_xdigit++; + continue; + } + if (ch == ':') { +@@ -308,76 +258,99 @@ inet_net_pton_ipv6(const char *src, unsigned char *dst, size_t size) + goto enoent; + colonp = tp; + continue; +- } else if (*src == '\0') ++ } else if (*src == '\0') { + goto enoent; ++ } + if (tp + NS_INT16SZ > endp) +- return (0); +- *tp++ = (unsigned char)((val >> 8) & 0xff); +- *tp++ = (unsigned char)(val & 0xff); ++ goto enoent; ++ *tp++ = (unsigned char) (val >> 8) & 0xff; ++ *tp++ = (unsigned char) val & 0xff; + saw_xdigit = 0; +- digits = 0; ++ count_xdigit = 0; + val = 0; + continue; + } + if (ch == '.' && ((tp + NS_INADDRSZ) <= endp) && +- getv4(curtok, tp, &bits) > 0) { ++ ares_inet_net_pton_ipv4(curtok, tp, NS_INADDRSZ) > 0) { + tp += NS_INADDRSZ; + saw_xdigit = 0; +- ipv4 = 1; + break; /* '\0' was seen by inet_pton4(). */ + } +- if (ch == '/' && getbits(src, &bits) > 0) +- break; + goto enoent; + } + if (saw_xdigit) { + if (tp + NS_INT16SZ > endp) + goto enoent; +- *tp++ = (unsigned char)((val >> 8) & 0xff); +- *tp++ = (unsigned char)(val & 0xff); ++ *tp++ = (unsigned char) (val >> 8) & 0xff; ++ *tp++ = (unsigned char) val & 0xff; + } +- if (bits == -1) +- bits = 128; +- +- words = (bits + 15) / 16; +- if (words < 2) +- words = 2; +- if (ipv4) +- words = 8; +- endp = tmp + 2 * words; +- + if (colonp != NULL) { + /* + * Since some memmove()'s erroneously fail to handle + * overlapping regions, we'll do the shift by hand. + */ +- const ares_ssize_t n = tp - colonp; +- ares_ssize_t i; ++ const int n = (int)(tp - colonp); ++ int i; + + if (tp == endp) + goto enoent; + for (i = 1; i <= n; i++) { +- *(endp - i) = *(colonp + n - i); +- *(colonp + n - i) = 0; ++ endp[- i] = colonp[n - i]; ++ colonp[n - i] = 0; + } + tp = endp; + } + if (tp != endp) + goto enoent; + +- bytes = (bits + 7) / 8; +- if (bytes > size) +- goto emsgsize; +- memcpy(dst, tmp, bytes); +- return (bits); ++ memcpy(dst, tmp, NS_IN6ADDRSZ); ++ return (1); + +- enoent: ++enoent: + SET_ERRNO(ENOENT); + return (-1); ++} + +- emsgsize: +- SET_ERRNO(EMSGSIZE); +- return (-1); ++static int ++ares_inet_net_pton_ipv6(const char *src, unsigned char *dst, size_t size) ++{ ++ struct ares_in6_addr in6; ++ int ret; ++ int bits; ++ size_t bytes; ++ char buf[INET6_ADDRSTRLEN + sizeof("/128")]; ++ char *sep; ++ ++ if (strlen(src) >= sizeof buf) { ++ SET_ERRNO(EMSGSIZE); ++ return (-1); ++ } ++ strncpy(buf, src, sizeof buf); ++ ++ sep = strchr(buf, '/'); ++ if (sep != NULL) ++ *sep++ = '\0'; ++ ++ ret = ares_inet_pton6(buf, (unsigned char *)&in6); ++ if (ret != 1) ++ return (-1); ++ ++ if (sep == NULL) ++ bits = 128; ++ else { ++ if (!getbits(sep, &bits)) { ++ SET_ERRNO(ENOENT); ++ return (-1); ++ } ++ } ++ ++ bytes = (bits + 7) / 8; ++ if (bytes > size) { ++ SET_ERRNO(EMSGSIZE); ++ return (-1); ++ } ++ memcpy(dst, &in6, bytes); ++ return (bits); + } + + /* +@@ -403,18 +376,15 @@ ares_inet_net_pton(int af, const char *src, void *dst, size_t size) + { + switch (af) { + case AF_INET: +- return (inet_net_pton_ipv4(src, dst, size)); ++ return (ares_inet_net_pton_ipv4(src, dst, size)); + case AF_INET6: +- return (inet_net_pton_ipv6(src, dst, size)); ++ return (ares_inet_net_pton_ipv6(src, dst, size)); + default: + SET_ERRNO(EAFNOSUPPORT); + return (-1); + } + } + +-#endif /* HAVE_INET_NET_PTON */ +- +-#ifndef HAVE_INET_PTON + int ares_inet_pton(int af, const char *src, void *dst) + { + int result; +@@ -434,11 +404,3 @@ int ares_inet_pton(int af, const char *src, void *dst) + return 0; + return (result > -1 ? 1 : -1); + } +-#else /* HAVE_INET_PTON */ +-int ares_inet_pton(int af, const char *src, void *dst) +-{ +- /* just relay this to the underlying function */ +- return inet_pton(af, src, dst); +-} +- +-#endif +diff --git a/deps/cares/src/tools/Makefile.am b/deps/cares/src/tools/Makefile.am +index c503723..2ea6376 100644 +--- a/deps/cares/src/tools/Makefile.am ++++ b/deps/cares/src/tools/Makefile.am +@@ -21,7 +21,9 @@ endif + + include Makefile.inc + +-LDADD = $(top_builddir)/src/lib/libcares.la ++# We're not interested in code coverage of the test apps themselves, but need ++# to link with gcov if building with code coverage enabled ++LDADD = $(top_builddir)/src/lib/libcares.la $(CODE_COVERAGE_LIBS) + + ahost_SOURCES = ahost.c $(SAMPLESOURCES) $(SAMPLEHEADERS) + ahost_CFLAGS = $(AM_CFLAGS) +diff --git a/deps/cares/src/tools/Makefile.in b/deps/cares/src/tools/Makefile.in +index e665ac9..9e64462 100644 +--- a/deps/cares/src/tools/Makefile.in ++++ b/deps/cares/src/tools/Makefile.in +@@ -98,6 +98,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_ac_append_to_file.m4 \ + $(top_srcdir)/m4/ax_am_macros_static.m4 \ + $(top_srcdir)/m4/ax_check_gnu_make.m4 \ + $(top_srcdir)/m4/ax_code_coverage.m4 \ ++ $(top_srcdir)/m4/ax_cxx_compile_stdcxx.m4 \ + $(top_srcdir)/m4/ax_cxx_compile_stdcxx_11.m4 \ + $(top_srcdir)/m4/ax_file_escapes.m4 \ + $(top_srcdir)/m4/ax_require_defined.m4 \ +@@ -134,7 +135,9 @@ am_acountry_OBJECTS = acountry-acountry.$(OBJEXT) $(am__objects_1) \ + $(am__objects_2) + acountry_OBJECTS = $(am_acountry_OBJECTS) + acountry_LDADD = $(LDADD) +-acountry_DEPENDENCIES = $(top_builddir)/src/lib/libcares.la ++am__DEPENDENCIES_1 = ++acountry_DEPENDENCIES = $(top_builddir)/src/lib/libcares.la \ ++ $(am__DEPENDENCIES_1) + AM_V_lt = $(am__v_lt_@AM_V@) + am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) + am__v_lt_0 = --silent +@@ -149,7 +152,8 @@ am_adig_OBJECTS = adig-adig.$(OBJEXT) $(am__objects_3) \ + $(am__objects_2) + adig_OBJECTS = $(am_adig_OBJECTS) + adig_LDADD = $(LDADD) +-adig_DEPENDENCIES = $(top_builddir)/src/lib/libcares.la ++adig_DEPENDENCIES = $(top_builddir)/src/lib/libcares.la \ ++ $(am__DEPENDENCIES_1) + adig_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(adig_CFLAGS) $(CFLAGS) \ + $(AM_LDFLAGS) $(LDFLAGS) -o $@ +@@ -160,7 +164,8 @@ am_ahost_OBJECTS = ahost-ahost.$(OBJEXT) $(am__objects_4) \ + $(am__objects_2) + ahost_OBJECTS = $(am_ahost_OBJECTS) + ahost_LDADD = $(LDADD) +-ahost_DEPENDENCIES = $(top_builddir)/src/lib/libcares.la ++ahost_DEPENDENCIES = $(top_builddir)/src/lib/libcares.la \ ++ $(am__DEPENDENCIES_1) + ahost_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(ahost_CFLAGS) $(CFLAGS) \ + $(AM_LDFLAGS) $(LDFLAGS) -o $@ +@@ -280,6 +285,7 @@ EGREP = @EGREP@ + ETAGS = @ETAGS@ + EXEEXT = @EXEEXT@ + FGREP = @FGREP@ ++FILECMD = @FILECMD@ + GCOV = @GCOV@ + GENHTML = @GENHTML@ + GREP = @GREP@ +@@ -399,7 +405,10 @@ SAMPLEHEADERS = ares_getopt.h \ + ../lib/ares_nowarn.h \ + ../lib/ares_strcasecmp.h + +-LDADD = $(top_builddir)/src/lib/libcares.la ++ ++# We're not interested in code coverage of the test apps themselves, but need ++# to link with gcov if building with code coverage enabled ++LDADD = $(top_builddir)/src/lib/libcares.la $(CODE_COVERAGE_LIBS) + ahost_SOURCES = ahost.c $(SAMPLESOURCES) $(SAMPLEHEADERS) + ahost_CFLAGS = $(AM_CFLAGS) + ahost_CPPFLAGS = $(AM_CPPFLAGS) +diff --git a/deps/cares/src/tools/acountry.c b/deps/cares/src/tools/acountry.c +index a86d7cb..00a6e67 100644 +--- a/deps/cares/src/tools/acountry.c ++++ b/deps/cares/src/tools/acountry.c +@@ -155,7 +155,7 @@ int main(int argc, char **argv) + for ( ; *argv; argv++) + { + struct in_addr addr; +- char buf[100]; ++ char *buf; + + /* If this fails, assume '*argv' is a host-name that + * must be resolved first +@@ -171,6 +171,7 @@ int main(int argc, char **argv) + } + } + ++ buf = malloc(100); + sprintf(buf, nerd_fmt, + (unsigned int)(addr.s_addr >> 24), + (unsigned int)((addr.s_addr >> 16) & 255), +@@ -232,6 +233,7 @@ static void callback(void *arg, int status, int timeouts, struct hostent *host) + if (!host || status != ARES_SUCCESS) + { + printf("Failed to lookup %s: %s\n", name, ares_strerror(status)); ++ free(arg); + return; + } + +@@ -244,6 +246,7 @@ static void callback(void *arg, int status, int timeouts, struct hostent *host) + printf("Failed to get CNAME for %s\n", name); + else + find_country_from_cname(cname, *(CARES_INADDR_CAST(struct in_addr *, host->h_addr))); ++ free(arg); + } + + /* +@@ -643,10 +646,10 @@ static void find_country_from_cname(const char *cname, struct in_addr addr) + + /* Information from the man page. Formatting taken from man -h */ + static void print_help_info_acountry(void) { +- printf("acountry, version %s \n\n", ARES_VERSION_STR); +- printf("usage: acountry [-hdv] {host|addr} ...\n\n" +- " d : Print some extra debugging output.\n" ++ printf("acountry, version %s\n\n", ARES_VERSION_STR); ++ printf("usage: acountry [-hdv] host|addr ...\n\n" + " h : Display this help and exit.\n" ++ " d : Print some extra debugging output.\n" + " v : Be more verbose. Print extra information.\n\n"); + exit(0); + } +diff --git a/deps/cares/src/tools/adig.c b/deps/cares/src/tools/adig.c +index 412ad46..cf5bd4d 100644 +--- a/deps/cares/src/tools/adig.c ++++ b/deps/cares/src/tools/adig.c +@@ -296,6 +296,7 @@ int main(int argc, char **argv) + if (!ISDIGIT(*optarg)) + usage(); + options.tcp_port = (unsigned short)strtol(optarg, NULL, 0); ++ options.flags |= ARES_FLAG_USEVC; + optmask |= ARES_OPT_TCP_PORT; + break; + +@@ -959,23 +960,27 @@ static void append_addr_list(struct ares_addr_node **head, + + /* Information from the man page. Formatting taken from man -h */ + static void print_help_info_adig(void) { +- printf("adig, version %s \n\n", ARES_VERSION_STR); +- printf("usage: adig [-h] [-d] [-f flag] [-s server] [-c class] [-t type] [-T|U port] [-x | -xx] name ...\n\n" +- " d : Print some extra debugging output.\n" +- " f : Add a flag. Possible values for flag are igntc, noaliases, norecurse, primary, stayopen, usevc.\n" +- " h : Display this help and exit.\n\n" +- " T port : Use specified TCP port to connect to DNS server.\n" +- " U port : Use specified UDP port to connect to DNS server.\n" +- " c class : Set the query class. Possible values for class are NY, CHAOS, HS, IN (default).\n" +- " s server : Connect to specified DNS server, instead of the system's default one(s).\n" +- " t type : Query records of specified type. \n" +- " Possible values for type are A \n" +- " (default), AAAA, AFSDB, ANY,\n" +- " AXFR, CNAME, GPOS, HINFO, ISDN,\n" +- " KEY, LOC, MAILA, MAILB, MB, MD,\n" +- " MF, MG, MINFO, MR, MX, NAPTR, NS,\n" +- " NSAP, NSAP_PTR, NULL, PTR, PX, RP,\n" +- " RT, SIG, SOA, SRV, TXT, URI, WKS, X25\n\n" ++ printf("adig, version %s\n\n", ARES_VERSION_STR); ++ printf("usage: adig [-h] [-d] [-f flag] [[-s server] ...] [-T|U port] [-c class] [-t type] [-x|-xx] name ...\n\n" ++ " h : Display this help and exit.\n" ++ " d : Print some extra debugging output.\n\n" ++ " f flag : Add a behavior control flag. Possible values are\n" ++ " igntc - ignore to query in TCP to get truncated UDP answer,\n" ++ " noaliases - don't honor the HOSTALIASES environment variable,\n" ++ " norecurse - don't query upstream servers recursively,\n" ++ " primary - use the first server,\n" ++ " stayopen - don't close the communication sockets, and\n" ++ " usevc - use TCP only.\n" ++ " s server : Connect to the specified DNS server, instead of the system's default one(s).\n" ++ " Servers are tried in round-robin, if the previous one failed.\n" ++ " T port : Connect to the specified TCP port of DNS server.\n" ++ " U port : Connect to the specified UDP port of DNS server.\n" ++ " c class : Set the query class. Possible values for class are ANY, CHAOS, HS and IN (default)\n" ++ " t type : Query records of the specified type.\n" ++ " Possible values for type are A (default), AAAA, AFSDB, ANY, AXFR,\n" ++ " CNAME, GPOS, HINFO, ISDN, KEY, LOC, MAILA, MAILB, MB, MD, MF, MG,\n" ++ " MINFO, MR, MX, NAPTR, NS, NSAP, NSAP_PTR, NULL, PTR, PX, RP, RT,\n" ++ " SIG, SOA, SRV, TXT, URI, WKS and X25.\n\n" + " -x : For a '-t PTR a.b.c.d' lookup, query for 'd.c.b.a.in-addr.arpa.'\n" + " -xx : As above, but for IPv6, compact the format into a bitstring like\n" + " '[xabcdef00000000000000000000000000].IP6.ARPA.'\n"); +diff --git a/deps/cares/src/tools/ahost.c b/deps/cares/src/tools/ahost.c +index 77ca7cd..8ac2106 100644 +--- a/deps/cares/src/tools/ahost.c ++++ b/deps/cares/src/tools/ahost.c +@@ -213,19 +213,16 @@ static void usage(void) + + /* Information from the man page. Formatting taken from man -h */ + static void print_help_info_ahost(void) { +- printf("ahost, version %s \n\n", ARES_VERSION_STR); +- printf("usage: ahost [-h] [-d] [-s {domain}] [-t {a|aaaa|u}] {host|addr} ...\n\n" +- " d : Print some extra debugging output.\n" +- " h : Display this help and exit.\n\n" +- " s domain : Specify the domain to search instead of \n" +- " using the default values from \n" +- " /etc/resolv.conf. This option only has an \n" +- " effect on platforms that use /etc/resolv.conf\n" +- " for DNS configuration; it has no effect on other\n" +- " platforms (such as Win32 or Android).\n" ++ printf("ahost, version %s\n\n", ARES_VERSION_STR); ++ printf("usage: ahost [-h] [-d] [[-s domain] ...] [-t a|aaaa|u] host|addr ...\n\n" ++ " h : Display this help and exit.\n" ++ " d : Print some extra debugging output.\n\n" ++ " s domain : Specify the domain to search instead of using the default values\n" ++ " from /etc/resolv.conf. This option only has an effect on\n" ++ " platforms that use /etc/resolv.conf for DNS configuration;\n" ++ " it has no effect on other platforms (such as Win32 or Android).\n\n" + " t type : If type is \"a\", print the A record (default).\n" +- " If type is \"aaaa\", print the AAAA record. If\n" +- " type is \"u\", look for either AAAA or A record\n" +- " (in that order).\n\n"); ++ " If type is \"aaaa\", print the AAAA record.\n" ++ " If type is \"u\", look for either AAAA or A record (in that order).\n\n"); + exit(0); + } +-- +2.40.1 + diff --git a/SOURCES/deps-update-nghttp2-to-1.57.0.patch b/SOURCES/deps-update-nghttp2-to-1.57.0.patch new file mode 100644 index 0000000..8250ac1 --- /dev/null +++ b/SOURCES/deps-update-nghttp2-to-1.57.0.patch @@ -0,0 +1,9929 @@ +From ab6092ed6d6978536e5bc81068bb08e4abaee2dd Mon Sep 17 00:00:00 2001 +From: thunder-coding +Date: Fri, 24 Sep 2021 09:04:23 +0000 +Subject: [PATCH] deps: update nghttp2 to v1.57.0 +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +This is a combination of 9 commits. + +- deps: update `nghttp2` to v1.45.1 + + PR-URL: https://github.com/nodejs/node/pull/40206 + Reviewed-By: Matteo Collina + Reviewed-By: James M Snell + Reviewed-By: Colin Ihrig + Reviewed-By: Jiawen Geng + +- deps: update nghttp2 to 1.47.0 + + Added script to update nghttp2 in future. One can use + ```sh + $ ./tools/update-nghttp2.sh 1.47.0 + ``` + + It will automatically copy and update the nghttps in deps. + + Fixes: https://github.com/nodejs/node/issues/42089 + + PR-URL: https://github.com/nodejs/node/pull/42127 + Reviewed-By: Matteo Collina + Reviewed-By: Michaël Zasso + Reviewed-By: Colin Ihrig + Reviewed-By: Mestery + Reviewed-By: Darshan Sen + +- deps: update nghttp2 to 1.51.0 + + PR-URL: https://github.com/nodejs/node/pull/45537 + Reviewed-By: Rafael Gonzaga + Reviewed-By: Matteo Collina + +- deps: update nghttp2 to 1.52.0 + + Refs: https://github.com/nghttp2/nghttp2/releases/tag/v1.52.0 + PR-URL: https://github.com/nodejs/node/pull/46636 + Reviewed-By: Colin Ihrig + Reviewed-By: Mohammed Keyvanzadeh + Reviewed-By: Rafael Gonzaga + +- deps: update nghttp2 to 1.53.0 + + PR-URL: https://github.com/nodejs/node/pull/47997 + Backport-PR-URL: https://github.com/nodejs/node/pull/50151 + Reviewed-By: Rafael Gonzaga + Reviewed-By: Luigi Pinca + Reviewed-By: Marco Ippolito + +- deps: update nghttp2 to 1.55.0 + + PR-URL: https://github.com/nodejs/node/pull/48746 + Backport-PR-URL: https://github.com/nodejs/node/pull/50151 + Reviewed-By: Luigi Pinca + Reviewed-By: Michaël Zasso + Reviewed-By: Rafael Gonzaga + Reviewed-By: Marco Ippolito + Reviewed-By: Yagiz Nizipli + Reviewed-By: Trivikram Kamat + +- deps: update nghttp2 to 1.55.1 + + PR-URL: https://github.com/nodejs/node/pull/48790 + Backport-PR-URL: https://github.com/nodejs/node/pull/50151 + Reviewed-By: Luigi Pinca + Reviewed-By: Yongsheng Zhang + Reviewed-By: Stephen Belanger + Reviewed-By: Rafael Gonzaga + Reviewed-By: Yagiz Nizipli + +- deps: update nghttp2 to 1.56.0 + + PR-URL: https://github.com/nodejs/node/pull/49582 + Backport-PR-URL: https://github.com/nodejs/node/pull/50151 + Reviewed-By: Luigi Pinca + +- deps: update nghttp2 to 1.57.0 + + PR-URL: https://github.com/nodejs/node/pull/50121 + Backport-PR-URL: https://github.com/nodejs/node/pull/50151 + Reviewed-By: Matteo Collina + Reviewed-By: Michael Dawson + Reviewed-By: Rich Trott + Reviewed-By: Marco Ippolito + Reviewed-By: Tobias Nießen + +Signed-off-by: Jan Staněk +--- + deps/nghttp2/lib/CMakeLists.txt | 5 +- + deps/nghttp2/lib/Makefile.am | 13 +- + deps/nghttp2/lib/Makefile.in | 93 +- + deps/nghttp2/lib/Makefile.msvc | 38 +- + deps/nghttp2/lib/includes/Makefile.in | 44 +- + deps/nghttp2/lib/includes/nghttp2/nghttp2.h | 1144 ++++++++++------ + .../nghttp2/lib/includes/nghttp2/nghttp2ver.h | 4 +- + deps/nghttp2/lib/nghttp2_buf.h | 2 +- + deps/nghttp2/lib/nghttp2_extpri.c | 35 + + deps/nghttp2/lib/nghttp2_extpri.h | 65 + + deps/nghttp2/lib/nghttp2_frame.c | 124 +- + deps/nghttp2/lib/nghttp2_frame.h | 99 +- + deps/nghttp2/lib/nghttp2_hd.c | 14 +- + deps/nghttp2/lib/nghttp2_hd.h | 1 + + deps/nghttp2/lib/nghttp2_helper.c | 174 ++- + deps/nghttp2/lib/nghttp2_http.c | 153 ++- + deps/nghttp2/lib/nghttp2_http.h | 3 + + deps/nghttp2/lib/nghttp2_ksl.c | 707 ---------- + deps/nghttp2/lib/nghttp2_ksl.h | 315 ----- + deps/nghttp2/lib/nghttp2_map.c | 361 +++--- + deps/nghttp2/lib/nghttp2_map.h | 68 +- + deps/nghttp2/lib/nghttp2_net.h | 14 +- + deps/nghttp2/lib/nghttp2_option.c | 24 + + deps/nghttp2/lib/nghttp2_option.h | 16 + + deps/nghttp2/lib/nghttp2_outbound_item.c | 3 + + deps/nghttp2/lib/nghttp2_outbound_item.h | 2 +- + deps/nghttp2/lib/nghttp2_pq.c | 3 +- + deps/nghttp2/lib/nghttp2_pq.h | 10 +- + deps/nghttp2/lib/nghttp2_ratelim.c | 75 ++ + deps/nghttp2/lib/nghttp2_ratelim.h | 57 + + deps/nghttp2/lib/nghttp2_session.c | 889 ++++++++++--- + deps/nghttp2/lib/nghttp2_session.h | 55 +- + deps/nghttp2/lib/nghttp2_stream.c | 33 +- + deps/nghttp2/lib/nghttp2_stream.h | 42 +- + deps/nghttp2/lib/nghttp2_submit.c | 84 +- + deps/nghttp2/lib/nghttp2_time.c | 62 + + deps/nghttp2/lib/nghttp2_time.h | 38 + + deps/nghttp2/lib/sfparse.c | 1146 +++++++++++++++++ + deps/nghttp2/lib/sfparse.h | 409 ++++++ + deps/nghttp2/nghttp2.gyp | 54 +- + test/parallel/test-http2-methods.js | 2 +- + test/parallel/test-http2-multiplex.js | 2 +- + tools/update-nghttp2.sh | 59 + + 43 files changed, 4434 insertions(+), 2107 deletions(-) + create mode 100644 deps/nghttp2/lib/nghttp2_extpri.c + create mode 100644 deps/nghttp2/lib/nghttp2_extpri.h + delete mode 100644 deps/nghttp2/lib/nghttp2_ksl.c + delete mode 100644 deps/nghttp2/lib/nghttp2_ksl.h + create mode 100644 deps/nghttp2/lib/nghttp2_ratelim.c + create mode 100644 deps/nghttp2/lib/nghttp2_ratelim.h + create mode 100644 deps/nghttp2/lib/nghttp2_time.c + create mode 100644 deps/nghttp2/lib/nghttp2_time.h + create mode 100644 deps/nghttp2/lib/sfparse.c + create mode 100644 deps/nghttp2/lib/sfparse.h + create mode 100755 tools/update-nghttp2.sh + +diff --git a/deps/nghttp2/lib/CMakeLists.txt b/deps/nghttp2/lib/CMakeLists.txt +index a02a534b1a..7adba3a3ff 100644 +--- a/deps/nghttp2/lib/CMakeLists.txt ++++ b/deps/nghttp2/lib/CMakeLists.txt +@@ -23,8 +23,11 @@ set(NGHTTP2_SOURCES + nghttp2_mem.c + nghttp2_http.c + nghttp2_rcbuf.c ++ nghttp2_extpri.c ++ nghttp2_ratelim.c ++ nghttp2_time.c + nghttp2_debug.c +- nghttp2_ksl.c ++ sfparse.c + ) + + set(NGHTTP2_RES "") +diff --git a/deps/nghttp2/lib/Makefile.am b/deps/nghttp2/lib/Makefile.am +index 63fa0fa832..c3ace4029a 100644 +--- a/deps/nghttp2/lib/Makefile.am ++++ b/deps/nghttp2/lib/Makefile.am +@@ -27,6 +27,7 @@ EXTRA_DIST = Makefile.msvc CMakeLists.txt version.rc.in + AM_CFLAGS = $(WARNCFLAGS) $(EXTRACFLAG) + AM_CPPFLAGS = -I$(srcdir)/includes -I$(builddir)/includes -DBUILDING_NGHTTP2 \ + @DEFS@ ++AM_LDFLAGS = @LIBTOOL_LDFLAGS@ + + pkgconfigdir = $(libdir)/pkgconfig + pkgconfig_DATA = libnghttp2.pc +@@ -49,8 +50,11 @@ OBJECTS = nghttp2_pq.c nghttp2_map.c nghttp2_queue.c \ + nghttp2_mem.c \ + nghttp2_http.c \ + nghttp2_rcbuf.c \ ++ nghttp2_extpri.c \ ++ nghttp2_ratelim.c \ ++ nghttp2_time.c \ + nghttp2_debug.c \ +- nghttp2_ksl.c ++ sfparse.c + + HFILES = nghttp2_pq.h nghttp2_int.h nghttp2_map.h nghttp2_queue.h \ + nghttp2_frame.h \ +@@ -66,9 +70,12 @@ HFILES = nghttp2_pq.h nghttp2_int.h nghttp2_map.h nghttp2_queue.h \ + nghttp2_mem.h \ + nghttp2_http.h \ + nghttp2_rcbuf.h \ ++ nghttp2_extpri.h \ ++ nghttp2_ratelim.h \ ++ nghttp2_time.h \ + nghttp2_debug.h \ +- nghttp2_ksl.h ++ sfparse.h + + libnghttp2_la_SOURCES = $(HFILES) $(OBJECTS) +-libnghttp2_la_LDFLAGS = -no-undefined \ ++libnghttp2_la_LDFLAGS = $(AM_LDFLAGS) -no-undefined \ + -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) +diff --git a/deps/nghttp2/lib/Makefile.in b/deps/nghttp2/lib/Makefile.in +index 14ec74591b..0b95613bc2 100644 +--- a/deps/nghttp2/lib/Makefile.in ++++ b/deps/nghttp2/lib/Makefile.in +@@ -1,7 +1,7 @@ +-# Makefile.in generated by automake 1.16.2 from Makefile.am. ++# Makefile.in generated by automake 1.16.5 from Makefile.am. + # @configure_input@ + +-# Copyright (C) 1994-2020 Free Software Foundation, Inc. ++# Copyright (C) 1994-2021 Free Software Foundation, Inc. + + # This Makefile.in is free software; the Free Software Foundation + # gives unlimited permission to copy and/or distribute it, +@@ -107,13 +107,8 @@ host_triplet = @host@ + target_triplet = @target@ + subdir = lib + ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +-am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_asio.m4 \ +- $(top_srcdir)/m4/ax_boost_base.m4 \ +- $(top_srcdir)/m4/ax_boost_system.m4 \ +- $(top_srcdir)/m4/ax_boost_thread.m4 \ +- $(top_srcdir)/m4/ax_check_compile_flag.m4 \ ++am__aclocal_m4_deps = $(top_srcdir)/m4/ax_check_compile_flag.m4 \ + $(top_srcdir)/m4/ax_cxx_compile_stdcxx.m4 \ +- $(top_srcdir)/m4/ax_python_devel.m4 \ + $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ + $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ + $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac +@@ -162,7 +157,8 @@ am__objects_2 = nghttp2_pq.lo nghttp2_map.lo nghttp2_queue.lo \ + nghttp2_hd_huffman.lo nghttp2_hd_huffman_data.lo \ + nghttp2_version.lo nghttp2_priority_spec.lo nghttp2_option.lo \ + nghttp2_callbacks.lo nghttp2_mem.lo nghttp2_http.lo \ +- nghttp2_rcbuf.lo nghttp2_debug.lo nghttp2_ksl.lo ++ nghttp2_rcbuf.lo nghttp2_extpri.lo nghttp2_ratelim.lo \ ++ nghttp2_time.lo nghttp2_debug.lo sfparse.lo + am_libnghttp2_la_OBJECTS = $(am__objects_1) $(am__objects_2) + libnghttp2_la_OBJECTS = $(am_libnghttp2_la_OBJECTS) + AM_V_lt = $(am__v_lt_@AM_V@) +@@ -189,19 +185,21 @@ depcomp = $(SHELL) $(top_srcdir)/depcomp + am__maybe_remake_depfiles = depfiles + am__depfiles_remade = ./$(DEPDIR)/nghttp2_buf.Plo \ + ./$(DEPDIR)/nghttp2_callbacks.Plo \ +- ./$(DEPDIR)/nghttp2_debug.Plo ./$(DEPDIR)/nghttp2_frame.Plo \ +- ./$(DEPDIR)/nghttp2_hd.Plo ./$(DEPDIR)/nghttp2_hd_huffman.Plo \ ++ ./$(DEPDIR)/nghttp2_debug.Plo ./$(DEPDIR)/nghttp2_extpri.Plo \ ++ ./$(DEPDIR)/nghttp2_frame.Plo ./$(DEPDIR)/nghttp2_hd.Plo \ ++ ./$(DEPDIR)/nghttp2_hd_huffman.Plo \ + ./$(DEPDIR)/nghttp2_hd_huffman_data.Plo \ + ./$(DEPDIR)/nghttp2_helper.Plo ./$(DEPDIR)/nghttp2_http.Plo \ +- ./$(DEPDIR)/nghttp2_ksl.Plo ./$(DEPDIR)/nghttp2_map.Plo \ +- ./$(DEPDIR)/nghttp2_mem.Plo ./$(DEPDIR)/nghttp2_npn.Plo \ +- ./$(DEPDIR)/nghttp2_option.Plo \ ++ ./$(DEPDIR)/nghttp2_map.Plo ./$(DEPDIR)/nghttp2_mem.Plo \ ++ ./$(DEPDIR)/nghttp2_npn.Plo ./$(DEPDIR)/nghttp2_option.Plo \ + ./$(DEPDIR)/nghttp2_outbound_item.Plo \ + ./$(DEPDIR)/nghttp2_pq.Plo \ + ./$(DEPDIR)/nghttp2_priority_spec.Plo \ +- ./$(DEPDIR)/nghttp2_queue.Plo ./$(DEPDIR)/nghttp2_rcbuf.Plo \ +- ./$(DEPDIR)/nghttp2_session.Plo ./$(DEPDIR)/nghttp2_stream.Plo \ +- ./$(DEPDIR)/nghttp2_submit.Plo ./$(DEPDIR)/nghttp2_version.Plo ++ ./$(DEPDIR)/nghttp2_queue.Plo ./$(DEPDIR)/nghttp2_ratelim.Plo \ ++ ./$(DEPDIR)/nghttp2_rcbuf.Plo ./$(DEPDIR)/nghttp2_session.Plo \ ++ ./$(DEPDIR)/nghttp2_stream.Plo ./$(DEPDIR)/nghttp2_submit.Plo \ ++ ./$(DEPDIR)/nghttp2_time.Plo ./$(DEPDIR)/nghttp2_version.Plo \ ++ ./$(DEPDIR)/sfparse.Plo + am__mv = mv -f + COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +@@ -262,8 +260,6 @@ am__define_uniq_tagged_files = \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | $(am__uniquify_input)` +-ETAGS = etags +-CTAGS = ctags + DIST_SUBDIRS = $(SUBDIRS) + am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/libnghttp2.pc.in \ + $(top_srcdir)/depcomp +@@ -302,16 +298,14 @@ AUTOCONF = @AUTOCONF@ + AUTOHEADER = @AUTOHEADER@ + AUTOMAKE = @AUTOMAKE@ + AWK = @AWK@ +-BOOST_ASIO_LIB = @BOOST_ASIO_LIB@ +-BOOST_CPPFLAGS = @BOOST_CPPFLAGS@ +-BOOST_LDFLAGS = @BOOST_LDFLAGS@ +-BOOST_SYSTEM_LIB = @BOOST_SYSTEM_LIB@ +-BOOST_THREAD_LIB = @BOOST_THREAD_LIB@ ++BPFCFLAGS = @BPFCFLAGS@ + CC = @CC@ + CCDEPMODE = @CCDEPMODE@ + CFLAGS = @CFLAGS@ + CPP = @CPP@ + CPPFLAGS = @CPPFLAGS@ ++CSCOPE = @CSCOPE@ ++CTAGS = @CTAGS@ + CUNIT_CFLAGS = @CUNIT_CFLAGS@ + CUNIT_LIBS = @CUNIT_LIBS@ + CXX = @CXX@ +@@ -320,7 +314,6 @@ CXXCPP = @CXXCPP@ + CXXDEPMODE = @CXXDEPMODE@ + CXXFLAGS = @CXXFLAGS@ + CYGPATH_W = @CYGPATH_W@ +-CYTHON = @CYTHON@ + DEFS = @DEFS@ + DEPDIR = @DEPDIR@ + DLLTOOL = @DLLTOOL@ +@@ -330,9 +323,13 @@ ECHO_C = @ECHO_C@ + ECHO_N = @ECHO_N@ + ECHO_T = @ECHO_T@ + EGREP = @EGREP@ ++ETAGS = @ETAGS@ + EXEEXT = @EXEEXT@ ++EXTRABPFCFLAGS = @EXTRABPFCFLAGS@ + EXTRACFLAG = @EXTRACFLAG@ ++EXTRA_DEFS = @EXTRA_DEFS@ + FGREP = @FGREP@ ++FILECMD = @FILECMD@ + GREP = @GREP@ + HAVE_CXX14 = @HAVE_CXX14@ + INSTALL = @INSTALL@ +@@ -342,9 +339,12 @@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ + INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ + JANSSON_CFLAGS = @JANSSON_CFLAGS@ + JANSSON_LIBS = @JANSSON_LIBS@ ++JEMALLOC_CFLAGS = @JEMALLOC_CFLAGS@ + JEMALLOC_LIBS = @JEMALLOC_LIBS@ + LD = @LD@ + LDFLAGS = @LDFLAGS@ ++LIBBPF_CFLAGS = @LIBBPF_CFLAGS@ ++LIBBPF_LIBS = @LIBBPF_LIBS@ + LIBCARES_CFLAGS = @LIBCARES_CFLAGS@ + LIBCARES_LIBS = @LIBCARES_LIBS@ + LIBEVENT_OPENSSL_CFLAGS = @LIBEVENT_OPENSSL_CFLAGS@ +@@ -353,9 +353,18 @@ LIBEV_CFLAGS = @LIBEV_CFLAGS@ + LIBEV_LIBS = @LIBEV_LIBS@ + LIBMRUBY_CFLAGS = @LIBMRUBY_CFLAGS@ + LIBMRUBY_LIBS = @LIBMRUBY_LIBS@ ++LIBNGHTTP3_CFLAGS = @LIBNGHTTP3_CFLAGS@ ++LIBNGHTTP3_LIBS = @LIBNGHTTP3_LIBS@ ++LIBNGTCP2_CFLAGS = @LIBNGTCP2_CFLAGS@ ++LIBNGTCP2_CRYPTO_BORINGSSL_CFLAGS = @LIBNGTCP2_CRYPTO_BORINGSSL_CFLAGS@ ++LIBNGTCP2_CRYPTO_BORINGSSL_LIBS = @LIBNGTCP2_CRYPTO_BORINGSSL_LIBS@ ++LIBNGTCP2_CRYPTO_QUICTLS_CFLAGS = @LIBNGTCP2_CRYPTO_QUICTLS_CFLAGS@ ++LIBNGTCP2_CRYPTO_QUICTLS_LIBS = @LIBNGTCP2_CRYPTO_QUICTLS_LIBS@ ++LIBNGTCP2_LIBS = @LIBNGTCP2_LIBS@ + LIBOBJS = @LIBOBJS@ + LIBS = @LIBS@ + LIBTOOL = @LIBTOOL@ ++LIBTOOL_LDFLAGS = @LIBTOOL_LDFLAGS@ + LIBXML2_CFLAGS = @LIBXML2_CFLAGS@ + LIBXML2_LIBS = @LIBXML2_LIBS@ + LIPO = @LIPO@ +@@ -389,14 +398,9 @@ PKG_CONFIG = @PKG_CONFIG@ + PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ + PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ + PYTHON = @PYTHON@ +-PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ + PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ +-PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@ +-PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ +-PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ + PYTHON_PLATFORM = @PYTHON_PLATFORM@ + PYTHON_PREFIX = @PYTHON_PREFIX@ +-PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ + PYTHON_VERSION = @PYTHON_VERSION@ + RANLIB = @RANLIB@ + SED = @SED@ +@@ -487,6 +491,7 @@ AM_CFLAGS = $(WARNCFLAGS) $(EXTRACFLAG) + AM_CPPFLAGS = -I$(srcdir)/includes -I$(builddir)/includes -DBUILDING_NGHTTP2 \ + @DEFS@ + ++AM_LDFLAGS = @LIBTOOL_LDFLAGS@ + pkgconfigdir = $(libdir)/pkgconfig + pkgconfig_DATA = libnghttp2.pc + DISTCLEANFILES = $(pkgconfig_DATA) +@@ -506,8 +511,11 @@ OBJECTS = nghttp2_pq.c nghttp2_map.c nghttp2_queue.c \ + nghttp2_mem.c \ + nghttp2_http.c \ + nghttp2_rcbuf.c \ ++ nghttp2_extpri.c \ ++ nghttp2_ratelim.c \ ++ nghttp2_time.c \ + nghttp2_debug.c \ +- nghttp2_ksl.c ++ sfparse.c + + HFILES = nghttp2_pq.h nghttp2_int.h nghttp2_map.h nghttp2_queue.h \ + nghttp2_frame.h \ +@@ -523,11 +531,14 @@ HFILES = nghttp2_pq.h nghttp2_int.h nghttp2_map.h nghttp2_queue.h \ + nghttp2_mem.h \ + nghttp2_http.h \ + nghttp2_rcbuf.h \ ++ nghttp2_extpri.h \ ++ nghttp2_ratelim.h \ ++ nghttp2_time.h \ + nghttp2_debug.h \ +- nghttp2_ksl.h ++ sfparse.h + + libnghttp2_la_SOURCES = $(HFILES) $(OBJECTS) +-libnghttp2_la_LDFLAGS = -no-undefined \ ++libnghttp2_la_LDFLAGS = $(AM_LDFLAGS) -no-undefined \ + -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) + + all: all-recursive +@@ -613,13 +624,13 @@ distclean-compile: + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nghttp2_buf.Plo@am__quote@ # am--include-marker + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nghttp2_callbacks.Plo@am__quote@ # am--include-marker + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nghttp2_debug.Plo@am__quote@ # am--include-marker ++@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nghttp2_extpri.Plo@am__quote@ # am--include-marker + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nghttp2_frame.Plo@am__quote@ # am--include-marker + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nghttp2_hd.Plo@am__quote@ # am--include-marker + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nghttp2_hd_huffman.Plo@am__quote@ # am--include-marker + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nghttp2_hd_huffman_data.Plo@am__quote@ # am--include-marker + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nghttp2_helper.Plo@am__quote@ # am--include-marker + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nghttp2_http.Plo@am__quote@ # am--include-marker +-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nghttp2_ksl.Plo@am__quote@ # am--include-marker + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nghttp2_map.Plo@am__quote@ # am--include-marker + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nghttp2_mem.Plo@am__quote@ # am--include-marker + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nghttp2_npn.Plo@am__quote@ # am--include-marker +@@ -628,11 +639,14 @@ distclean-compile: + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nghttp2_pq.Plo@am__quote@ # am--include-marker + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nghttp2_priority_spec.Plo@am__quote@ # am--include-marker + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nghttp2_queue.Plo@am__quote@ # am--include-marker ++@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nghttp2_ratelim.Plo@am__quote@ # am--include-marker + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nghttp2_rcbuf.Plo@am__quote@ # am--include-marker + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nghttp2_session.Plo@am__quote@ # am--include-marker + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nghttp2_stream.Plo@am__quote@ # am--include-marker + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nghttp2_submit.Plo@am__quote@ # am--include-marker ++@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nghttp2_time.Plo@am__quote@ # am--include-marker + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nghttp2_version.Plo@am__quote@ # am--include-marker ++@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sfparse.Plo@am__quote@ # am--include-marker + + $(am__depfiles_remade): + @$(MKDIR_P) $(@D) +@@ -789,7 +803,6 @@ cscopelist-am: $(am__tagged_files) + + distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags +- + distdir: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) distdir-am + +@@ -896,13 +909,13 @@ distclean: distclean-recursive + -rm -f ./$(DEPDIR)/nghttp2_buf.Plo + -rm -f ./$(DEPDIR)/nghttp2_callbacks.Plo + -rm -f ./$(DEPDIR)/nghttp2_debug.Plo ++ -rm -f ./$(DEPDIR)/nghttp2_extpri.Plo + -rm -f ./$(DEPDIR)/nghttp2_frame.Plo + -rm -f ./$(DEPDIR)/nghttp2_hd.Plo + -rm -f ./$(DEPDIR)/nghttp2_hd_huffman.Plo + -rm -f ./$(DEPDIR)/nghttp2_hd_huffman_data.Plo + -rm -f ./$(DEPDIR)/nghttp2_helper.Plo + -rm -f ./$(DEPDIR)/nghttp2_http.Plo +- -rm -f ./$(DEPDIR)/nghttp2_ksl.Plo + -rm -f ./$(DEPDIR)/nghttp2_map.Plo + -rm -f ./$(DEPDIR)/nghttp2_mem.Plo + -rm -f ./$(DEPDIR)/nghttp2_npn.Plo +@@ -911,11 +924,14 @@ distclean: distclean-recursive + -rm -f ./$(DEPDIR)/nghttp2_pq.Plo + -rm -f ./$(DEPDIR)/nghttp2_priority_spec.Plo + -rm -f ./$(DEPDIR)/nghttp2_queue.Plo ++ -rm -f ./$(DEPDIR)/nghttp2_ratelim.Plo + -rm -f ./$(DEPDIR)/nghttp2_rcbuf.Plo + -rm -f ./$(DEPDIR)/nghttp2_session.Plo + -rm -f ./$(DEPDIR)/nghttp2_stream.Plo + -rm -f ./$(DEPDIR)/nghttp2_submit.Plo ++ -rm -f ./$(DEPDIR)/nghttp2_time.Plo + -rm -f ./$(DEPDIR)/nghttp2_version.Plo ++ -rm -f ./$(DEPDIR)/sfparse.Plo + -rm -f Makefile + distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags +@@ -964,13 +980,13 @@ maintainer-clean: maintainer-clean-recursive + -rm -f ./$(DEPDIR)/nghttp2_buf.Plo + -rm -f ./$(DEPDIR)/nghttp2_callbacks.Plo + -rm -f ./$(DEPDIR)/nghttp2_debug.Plo ++ -rm -f ./$(DEPDIR)/nghttp2_extpri.Plo + -rm -f ./$(DEPDIR)/nghttp2_frame.Plo + -rm -f ./$(DEPDIR)/nghttp2_hd.Plo + -rm -f ./$(DEPDIR)/nghttp2_hd_huffman.Plo + -rm -f ./$(DEPDIR)/nghttp2_hd_huffman_data.Plo + -rm -f ./$(DEPDIR)/nghttp2_helper.Plo + -rm -f ./$(DEPDIR)/nghttp2_http.Plo +- -rm -f ./$(DEPDIR)/nghttp2_ksl.Plo + -rm -f ./$(DEPDIR)/nghttp2_map.Plo + -rm -f ./$(DEPDIR)/nghttp2_mem.Plo + -rm -f ./$(DEPDIR)/nghttp2_npn.Plo +@@ -979,11 +995,14 @@ maintainer-clean: maintainer-clean-recursive + -rm -f ./$(DEPDIR)/nghttp2_pq.Plo + -rm -f ./$(DEPDIR)/nghttp2_priority_spec.Plo + -rm -f ./$(DEPDIR)/nghttp2_queue.Plo ++ -rm -f ./$(DEPDIR)/nghttp2_ratelim.Plo + -rm -f ./$(DEPDIR)/nghttp2_rcbuf.Plo + -rm -f ./$(DEPDIR)/nghttp2_session.Plo + -rm -f ./$(DEPDIR)/nghttp2_stream.Plo + -rm -f ./$(DEPDIR)/nghttp2_submit.Plo ++ -rm -f ./$(DEPDIR)/nghttp2_time.Plo + -rm -f ./$(DEPDIR)/nghttp2_version.Plo ++ -rm -f ./$(DEPDIR)/sfparse.Plo + -rm -f Makefile + maintainer-clean-am: distclean-am maintainer-clean-generic + +diff --git a/deps/nghttp2/lib/Makefile.msvc b/deps/nghttp2/lib/Makefile.msvc +index f649c0bda4..611b39d0b1 100644 +--- a/deps/nghttp2/lib/Makefile.msvc ++++ b/deps/nghttp2/lib/Makefile.msvc +@@ -6,15 +6,8 @@ + # The MIT License apply. + # + +-# +-# Choose your weapons: +-# Set 'USE_CYTHON=1' to build and install the 'nghttp2.pyd' Python extension. +-# + THIS_MAKEFILE := $(lastword $(MAKEFILE_LIST)) + +-USE_CYTHON := 0 +-#USE_CYTHON := 1 +- + _VERSION := $(shell grep AC_INIT ../configure.ac | cut -d'[' -f3 | sed -e 's/-DEV//g' -e 's/], //g') + _VERSION := $(subst ., ,$(_VERSION)) + VER_MAJOR := $(word 1,$(_VERSION)) +@@ -102,7 +95,7 @@ NGHTTP2_OBJ_D := $(addprefix $(OBJ_DIR)/d_, $(notdir $(NGHTTP2_SRC:.c=.obj))) + clean_nghttp2_pyd_0 clean_nghttp2_pyd_1 + + +-all: intro includes/nghttp2/nghttp2ver.h $(OBJ_DIR) $(TARGETS) build_nghttp2_pyd_$(USE_CYTHON) ++all: intro includes/nghttp2/nghttp2ver.h $(OBJ_DIR) $(TARGETS) + @echo 'Welcome to NgHTTP2 (release + debug).' + @echo 'Do a "make -f Makefile.MSVC install" at own risk!' + +@@ -121,7 +114,7 @@ $(OBJ_DIR): + + install: includes/nghttp2/nghttp2.h includes/nghttp2/nghttp2ver.h \ + $(TARGETS) \ +- copy_headers_and_libs install_nghttp2_pyd_$(USE_CYTHON) ++ copy_headers_and_libs + + # + # This MUST be done before using the 'install_nghttp2_pyd_1' rule. +@@ -160,31 +153,6 @@ $(DLL_D): $(NGHTTP2_OBJ_D) $(OBJ_DIR)/d_nghttp2.res + WIN_OBJDIR:=$(shell cygpath -w $(abspath $(OBJ_DIR))) + WIN_OBJDIR:=$(subst \,/,$(WIN_OBJDIR)) + +-../python/setup.py: ../python/setup.py.in $(THIS_MAKEFILE) +- cd ../python ; \ +- echo '# $(GENERATED). DO NOT EDIT.' > setup.py ; \ +- sed -e 's/@top_srcdir@/../' \ +- -e 's%@top_builddir@%$(WIN_OBJDIR)%' \ +- -e 's/@PACKAGE_VERSION@/$(VERSION)/' setup.py.in >> setup.py ; +- +-build_nghttp2_pyd_0: ; +- +-build_nghttp2_pyd_1: $(addprefix ../python/, setup.py nghttp2.pyx) +- cd ../python ; \ +- python setup.py build_ext -i -f bdist_wininst +- +-install_nghttp2_pyd_0: ; +- +-install_nghttp2_pyd_1: $(addprefix ../python/, setup.py nghttp2.pyx) +- cd ../python ; \ +- pip install . +- +-clean_nghttp2_pyd_0: ; +- +-clean_nghttp2_pyd_1: +- cd ../python ; \ +- rm -fR build dist +- + $(OBJ_DIR)/r_%.obj: %.c $(THIS_MAKEFILE) + $(CC) $(CFLAGS_R) $(CFLAGS) -Fo$@ -c $< + @echo +@@ -262,7 +230,7 @@ clean: + rm -f $(OBJ_DIR)/* includes/nghttp2/nghttp2ver.h + @echo + +-vclean realclean: clean clean_nghttp2_pyd_$(USE_CYTHON) ++vclean realclean: clean + - rm -rf $(OBJ_DIR) + - rm -f .depend.MSVC + +diff --git a/deps/nghttp2/lib/includes/Makefile.in b/deps/nghttp2/lib/includes/Makefile.in +index e1948dfeaa..3de90d7bef 100644 +--- a/deps/nghttp2/lib/includes/Makefile.in ++++ b/deps/nghttp2/lib/includes/Makefile.in +@@ -1,7 +1,7 @@ +-# Makefile.in generated by automake 1.16.2 from Makefile.am. ++# Makefile.in generated by automake 1.16.5 from Makefile.am. + # @configure_input@ + +-# Copyright (C) 1994-2020 Free Software Foundation, Inc. ++# Copyright (C) 1994-2021 Free Software Foundation, Inc. + + # This Makefile.in is free software; the Free Software Foundation + # gives unlimited permission to copy and/or distribute it, +@@ -114,13 +114,8 @@ host_triplet = @host@ + target_triplet = @target@ + subdir = lib/includes + ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +-am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_asio.m4 \ +- $(top_srcdir)/m4/ax_boost_base.m4 \ +- $(top_srcdir)/m4/ax_boost_system.m4 \ +- $(top_srcdir)/m4/ax_boost_thread.m4 \ +- $(top_srcdir)/m4/ax_check_compile_flag.m4 \ ++am__aclocal_m4_deps = $(top_srcdir)/m4/ax_check_compile_flag.m4 \ + $(top_srcdir)/m4/ax_cxx_compile_stdcxx.m4 \ +- $(top_srcdir)/m4/ax_python_devel.m4 \ + $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ + $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ + $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac +@@ -197,8 +192,6 @@ am__define_uniq_tagged_files = \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | $(am__uniquify_input)` +-ETAGS = etags +-CTAGS = ctags + am__DIST_COMMON = $(srcdir)/Makefile.in + DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) + ACLOCAL = @ACLOCAL@ +@@ -210,16 +203,14 @@ AUTOCONF = @AUTOCONF@ + AUTOHEADER = @AUTOHEADER@ + AUTOMAKE = @AUTOMAKE@ + AWK = @AWK@ +-BOOST_ASIO_LIB = @BOOST_ASIO_LIB@ +-BOOST_CPPFLAGS = @BOOST_CPPFLAGS@ +-BOOST_LDFLAGS = @BOOST_LDFLAGS@ +-BOOST_SYSTEM_LIB = @BOOST_SYSTEM_LIB@ +-BOOST_THREAD_LIB = @BOOST_THREAD_LIB@ ++BPFCFLAGS = @BPFCFLAGS@ + CC = @CC@ + CCDEPMODE = @CCDEPMODE@ + CFLAGS = @CFLAGS@ + CPP = @CPP@ + CPPFLAGS = @CPPFLAGS@ ++CSCOPE = @CSCOPE@ ++CTAGS = @CTAGS@ + CUNIT_CFLAGS = @CUNIT_CFLAGS@ + CUNIT_LIBS = @CUNIT_LIBS@ + CXX = @CXX@ +@@ -228,7 +219,6 @@ CXXCPP = @CXXCPP@ + CXXDEPMODE = @CXXDEPMODE@ + CXXFLAGS = @CXXFLAGS@ + CYGPATH_W = @CYGPATH_W@ +-CYTHON = @CYTHON@ + DEFS = @DEFS@ + DEPDIR = @DEPDIR@ + DLLTOOL = @DLLTOOL@ +@@ -238,9 +228,13 @@ ECHO_C = @ECHO_C@ + ECHO_N = @ECHO_N@ + ECHO_T = @ECHO_T@ + EGREP = @EGREP@ ++ETAGS = @ETAGS@ + EXEEXT = @EXEEXT@ ++EXTRABPFCFLAGS = @EXTRABPFCFLAGS@ + EXTRACFLAG = @EXTRACFLAG@ ++EXTRA_DEFS = @EXTRA_DEFS@ + FGREP = @FGREP@ ++FILECMD = @FILECMD@ + GREP = @GREP@ + HAVE_CXX14 = @HAVE_CXX14@ + INSTALL = @INSTALL@ +@@ -250,9 +244,12 @@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ + INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ + JANSSON_CFLAGS = @JANSSON_CFLAGS@ + JANSSON_LIBS = @JANSSON_LIBS@ ++JEMALLOC_CFLAGS = @JEMALLOC_CFLAGS@ + JEMALLOC_LIBS = @JEMALLOC_LIBS@ + LD = @LD@ + LDFLAGS = @LDFLAGS@ ++LIBBPF_CFLAGS = @LIBBPF_CFLAGS@ ++LIBBPF_LIBS = @LIBBPF_LIBS@ + LIBCARES_CFLAGS = @LIBCARES_CFLAGS@ + LIBCARES_LIBS = @LIBCARES_LIBS@ + LIBEVENT_OPENSSL_CFLAGS = @LIBEVENT_OPENSSL_CFLAGS@ +@@ -261,9 +258,18 @@ LIBEV_CFLAGS = @LIBEV_CFLAGS@ + LIBEV_LIBS = @LIBEV_LIBS@ + LIBMRUBY_CFLAGS = @LIBMRUBY_CFLAGS@ + LIBMRUBY_LIBS = @LIBMRUBY_LIBS@ ++LIBNGHTTP3_CFLAGS = @LIBNGHTTP3_CFLAGS@ ++LIBNGHTTP3_LIBS = @LIBNGHTTP3_LIBS@ ++LIBNGTCP2_CFLAGS = @LIBNGTCP2_CFLAGS@ ++LIBNGTCP2_CRYPTO_BORINGSSL_CFLAGS = @LIBNGTCP2_CRYPTO_BORINGSSL_CFLAGS@ ++LIBNGTCP2_CRYPTO_BORINGSSL_LIBS = @LIBNGTCP2_CRYPTO_BORINGSSL_LIBS@ ++LIBNGTCP2_CRYPTO_QUICTLS_CFLAGS = @LIBNGTCP2_CRYPTO_QUICTLS_CFLAGS@ ++LIBNGTCP2_CRYPTO_QUICTLS_LIBS = @LIBNGTCP2_CRYPTO_QUICTLS_LIBS@ ++LIBNGTCP2_LIBS = @LIBNGTCP2_LIBS@ + LIBOBJS = @LIBOBJS@ + LIBS = @LIBS@ + LIBTOOL = @LIBTOOL@ ++LIBTOOL_LDFLAGS = @LIBTOOL_LDFLAGS@ + LIBXML2_CFLAGS = @LIBXML2_CFLAGS@ + LIBXML2_LIBS = @LIBXML2_LIBS@ + LIPO = @LIPO@ +@@ -297,14 +303,9 @@ PKG_CONFIG = @PKG_CONFIG@ + PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ + PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ + PYTHON = @PYTHON@ +-PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ + PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ +-PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@ +-PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ +-PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ + PYTHON_PLATFORM = @PYTHON_PLATFORM@ + PYTHON_PREFIX = @PYTHON_PREFIX@ +-PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ + PYTHON_VERSION = @PYTHON_VERSION@ + RANLIB = @RANLIB@ + SED = @SED@ +@@ -497,7 +498,6 @@ cscopelist-am: $(am__tagged_files) + + distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags +- + distdir: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) distdir-am + +diff --git a/deps/nghttp2/lib/includes/nghttp2/nghttp2.h b/deps/nghttp2/lib/includes/nghttp2/nghttp2.h +index d9fae5bf0c..fa22081c51 100644 +--- a/deps/nghttp2/lib/includes/nghttp2/nghttp2.h ++++ b/deps/nghttp2/lib/includes/nghttp2/nghttp2.h +@@ -411,12 +411,12 @@ typedef enum { + */ + NGHTTP2_ERR_TOO_MANY_SETTINGS = -537, + /** +- * The errors < :enum:`NGHTTP2_ERR_FATAL` mean that the library is +- * under unexpected condition and processing was terminated (e.g., +- * out of memory). If application receives this error code, it must +- * stop using that :type:`nghttp2_session` object and only allowed +- * operation for that object is deallocate it using +- * `nghttp2_session_del()`. ++ * The errors < :enum:`nghttp2_error.NGHTTP2_ERR_FATAL` mean that ++ * the library is under unexpected condition and processing was ++ * terminated (e.g., out of memory). If application receives this ++ * error code, it must stop using that :type:`nghttp2_session` ++ * object and only allowed operation for that object is deallocate ++ * it using `nghttp2_session_del()`. + */ + NGHTTP2_ERR_FATAL = -900, + /** +@@ -545,9 +545,9 @@ typedef struct { + * :type:`nghttp2_on_frame_send_callback`, and + * :type:`nghttp2_on_frame_not_send_callback`), it may not be + * NULL-terminated if header field is passed from application with +- * the flag :enum:`NGHTTP2_NV_FLAG_NO_COPY_NAME`). When application +- * is constructing this struct, |name| is not required to be +- * NULL-terminated. ++ * the flag :enum:`nghttp2_nv_flag.NGHTTP2_NV_FLAG_NO_COPY_NAME`). ++ * When application is constructing this struct, |name| is not ++ * required to be NULL-terminated. + */ + uint8_t *name; + /** +@@ -558,9 +558,9 @@ typedef struct { + * :type:`nghttp2_on_frame_send_callback`, and + * :type:`nghttp2_on_frame_not_send_callback`), it may not be + * NULL-terminated if header field is passed from application with +- * the flag :enum:`NGHTTP2_NV_FLAG_NO_COPY_VALUE`). When +- * application is constructing this struct, |value| is not required +- * to be NULL-terminated. ++ * the flag :enum:`nghttp2_nv_flag.NGHTTP2_NV_FLAG_NO_COPY_VALUE`). ++ * When application is constructing this struct, |value| is not ++ * required to be NULL-terminated. + */ + uint8_t *value; + /** +@@ -634,7 +634,11 @@ typedef enum { + * The ORIGIN frame, which is defined by `RFC 8336 + * `_. + */ +- NGHTTP2_ORIGIN = 0x0c ++ NGHTTP2_ORIGIN = 0x0c, ++ /** ++ * The PRIORITY_UPDATE frame, which is defined by :rfc:`9218`. ++ */ ++ NGHTTP2_PRIORITY_UPDATE = 0x10 + } nghttp2_frame_type; + + /** +@@ -703,7 +707,11 @@ typedef enum { + * SETTINGS_ENABLE_CONNECT_PROTOCOL + * (`RFC 8441 `_) + */ +- NGHTTP2_SETTINGS_ENABLE_CONNECT_PROTOCOL = 0x08 ++ NGHTTP2_SETTINGS_ENABLE_CONNECT_PROTOCOL = 0x08, ++ /** ++ * SETTINGS_NO_RFC7540_PRIORITIES (:rfc:`9218`) ++ */ ++ NGHTTP2_SETTINGS_NO_RFC7540_PRIORITIES = 0x09 + } nghttp2_settings_id; + /* Note: If we add SETTINGS, update the capacity of + NGHTTP2_INBOUND_NUM_IV as well */ +@@ -717,8 +725,8 @@ typedef enum { + * + * Default maximum number of incoming concurrent streams. Use + * `nghttp2_submit_settings()` with +- * :enum:`NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS` to change the +- * maximum number of incoming concurrent streams. ++ * :enum:`nghttp2_settings_id.NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS` ++ * to change the maximum number of incoming concurrent streams. + * + * .. note:: + * +@@ -872,38 +880,41 @@ typedef enum { + * The implementation of this function must read at most |length| + * bytes of data from |source| (or possibly other places) and store + * them in |buf| and return number of data stored in |buf|. If EOF is +- * reached, set :enum:`NGHTTP2_DATA_FLAG_EOF` flag in |*data_flags|. ++ * reached, set :enum:`nghttp2_data_flag.NGHTTP2_DATA_FLAG_EOF` flag ++ * in |*data_flags|. + * + * Sometime it is desirable to avoid copying data into |buf| and let + * application to send data directly. To achieve this, set +- * :enum:`NGHTTP2_DATA_FLAG_NO_COPY` to |*data_flags| (and possibly +- * other flags, just like when we do copy), and return the number of +- * bytes to send without copying data into |buf|. The library, seeing +- * :enum:`NGHTTP2_DATA_FLAG_NO_COPY`, will invoke ++ * :enum:`nghttp2_data_flag.NGHTTP2_DATA_FLAG_NO_COPY` to ++ * |*data_flags| (and possibly other flags, just like when we do ++ * copy), and return the number of bytes to send without copying data ++ * into |buf|. The library, seeing ++ * :enum:`nghttp2_data_flag.NGHTTP2_DATA_FLAG_NO_COPY`, will invoke + * :type:`nghttp2_send_data_callback`. The application must send + * complete DATA frame in that callback. + * + * If this callback is set by `nghttp2_submit_request()`, + * `nghttp2_submit_response()` or `nghttp2_submit_headers()` and + * `nghttp2_submit_data()` with flag parameter +- * :enum:`NGHTTP2_FLAG_END_STREAM` set, and +- * :enum:`NGHTTP2_DATA_FLAG_EOF` flag is set to |*data_flags|, DATA +- * frame will have END_STREAM flag set. Usually, this is expected +- * behaviour and all are fine. One exception is send trailer fields. +- * You cannot send trailer fields after sending frame with END_STREAM +- * set. To avoid this problem, one can set +- * :enum:`NGHTTP2_DATA_FLAG_NO_END_STREAM` along with +- * :enum:`NGHTTP2_DATA_FLAG_EOF` to signal the library not to set +- * END_STREAM in DATA frame. Then application can use +- * `nghttp2_submit_trailer()` to send trailer fields. ++ * :enum:`nghttp2_flag.NGHTTP2_FLAG_END_STREAM` set, and ++ * :enum:`nghttp2_data_flag.NGHTTP2_DATA_FLAG_EOF` flag is set to ++ * |*data_flags|, DATA frame will have END_STREAM flag set. Usually, ++ * this is expected behaviour and all are fine. One exception is send ++ * trailer fields. You cannot send trailer fields after sending frame ++ * with END_STREAM set. To avoid this problem, one can set ++ * :enum:`nghttp2_data_flag.NGHTTP2_DATA_FLAG_NO_END_STREAM` along ++ * with :enum:`nghttp2_data_flag.NGHTTP2_DATA_FLAG_EOF` to signal the ++ * library not to set END_STREAM in DATA frame. Then application can ++ * use `nghttp2_submit_trailer()` to send trailer fields. + * `nghttp2_submit_trailer()` can be called inside this callback. + * + * If the application wants to postpone DATA frames (e.g., + * asynchronous I/O, or reading data blocks for long time), it is +- * achieved by returning :enum:`NGHTTP2_ERR_DEFERRED` without reading +- * any data in this invocation. The library removes DATA frame from +- * the outgoing queue temporarily. To move back deferred DATA frame +- * to outgoing queue, call `nghttp2_session_resume_data()`. ++ * achieved by returning :enum:`nghttp2_error.NGHTTP2_ERR_DEFERRED` ++ * without reading any data in this invocation. The library removes ++ * DATA frame from the outgoing queue temporarily. To move back ++ * deferred DATA frame to outgoing queue, call ++ * `nghttp2_session_resume_data()`. + * + * By default, |length| is limited to 16KiB at maximum. If peer + * allows larger frames, application can enlarge transmission buffer +@@ -912,16 +923,17 @@ typedef enum { + * + * If the application just wants to return from + * `nghttp2_session_send()` or `nghttp2_session_mem_send()` without +- * sending anything, return :enum:`NGHTTP2_ERR_PAUSE`. ++ * sending anything, return :enum:`nghttp2_error.NGHTTP2_ERR_PAUSE`. + * + * In case of error, there are 2 choices. Returning +- * :enum:`NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE` will close the stream +- * by issuing RST_STREAM with :enum:`NGHTTP2_INTERNAL_ERROR`. If a +- * different error code is desirable, use +- * `nghttp2_submit_rst_stream()` with a desired error code and then +- * return :enum:`NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE`. Returning +- * :enum:`NGHTTP2_ERR_CALLBACK_FAILURE` will signal the entire session +- * failure. ++ * :enum:`nghttp2_error.NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE` will ++ * close the stream by issuing RST_STREAM with ++ * :enum:`nghttp2_error_code.NGHTTP2_INTERNAL_ERROR`. If a different ++ * error code is desirable, use `nghttp2_submit_rst_stream()` with a ++ * desired error code and then return ++ * :enum:`nghttp2_error.NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE`. ++ * Returning :enum:`nghttp2_error.NGHTTP2_ERR_CALLBACK_FAILURE` will ++ * signal the entire session failure. + */ + typedef ssize_t (*nghttp2_data_source_read_callback)( + nghttp2_session *session, int32_t stream_id, uint8_t *buf, size_t length, +@@ -1301,8 +1313,9 @@ typedef union { + * |length| bytes of data stored in |data|. The |flags| is currently + * not used and always 0. It must return the number of bytes sent if + * it succeeds. If it cannot send any single byte without blocking, +- * it must return :enum:`NGHTTP2_ERR_WOULDBLOCK`. For other errors, +- * it must return :enum:`NGHTTP2_ERR_CALLBACK_FAILURE`. The ++ * it must return :enum:`nghttp2_error.NGHTTP2_ERR_WOULDBLOCK`. For ++ * other errors, it must return ++ * :enum:`nghttp2_error.NGHTTP2_ERR_CALLBACK_FAILURE`. The + * |user_data| pointer is the third argument passed in to the call to + * `nghttp2_session_client_new()` or `nghttp2_session_server_new()`. + * +@@ -1330,9 +1343,10 @@ typedef ssize_t (*nghttp2_send_callback)(nghttp2_session *session, + /** + * @functypedef + * +- * Callback function invoked when :enum:`NGHTTP2_DATA_FLAG_NO_COPY` is +- * used in :type:`nghttp2_data_source_read_callback` to send complete +- * DATA frame. ++ * Callback function invoked when ++ * :enum:`nghttp2_data_flag.NGHTTP2_DATA_FLAG_NO_COPY` is used in ++ * :type:`nghttp2_data_source_read_callback` to send complete DATA ++ * frame. + * + * The |frame| is a DATA frame to send. The |framehd| is the + * serialized frame header (9 bytes). The |length| is the length of +@@ -1350,21 +1364,22 @@ typedef ssize_t (*nghttp2_send_callback)(nghttp2_session *session, + * If all data were written successfully, return 0. + * + * If it cannot send any data at all, just return +- * :enum:`NGHTTP2_ERR_WOULDBLOCK`; the library will call this callback +- * with the same parameters later (It is recommended to send complete +- * DATA frame at once in this function to deal with error; if partial +- * frame data has already sent, it is impossible to send another data +- * in that state, and all we can do is tear down connection). When +- * data is fully processed, but application wants to make +- * `nghttp2_session_mem_send()` or `nghttp2_session_send()` return +- * immediately without processing next frames, return +- * :enum:`NGHTTP2_ERR_PAUSE`. If application decided to reset this +- * stream, return :enum:`NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE`, then ++ * :enum:`nghttp2_error.NGHTTP2_ERR_WOULDBLOCK`; the library will call ++ * this callback with the same parameters later (It is recommended to ++ * send complete DATA frame at once in this function to deal with ++ * error; if partial frame data has already sent, it is impossible to ++ * send another data in that state, and all we can do is tear down ++ * connection). When data is fully processed, but application wants ++ * to make `nghttp2_session_mem_send()` or `nghttp2_session_send()` ++ * return immediately without processing next frames, return ++ * :enum:`nghttp2_error.NGHTTP2_ERR_PAUSE`. If application decided to ++ * reset this stream, return ++ * :enum:`nghttp2_error.NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE`, then + * the library will send RST_STREAM with INTERNAL_ERROR as error code. + * The application can also return +- * :enum:`NGHTTP2_ERR_CALLBACK_FAILURE`, which will result in +- * connection closure. Returning any other value is treated as +- * :enum:`NGHTTP2_ERR_CALLBACK_FAILURE` is returned. ++ * :enum:`nghttp2_error.NGHTTP2_ERR_CALLBACK_FAILURE`, which will ++ * result in connection closure. Returning any other value is treated ++ * as :enum:`nghttp2_error.NGHTTP2_ERR_CALLBACK_FAILURE` is returned. + */ + typedef int (*nghttp2_send_data_callback)(nghttp2_session *session, + nghttp2_frame *frame, +@@ -1381,11 +1396,13 @@ typedef int (*nghttp2_send_data_callback)(nghttp2_session *session, + * currently not used and always 0. It must return the number of + * bytes written in |buf| if it succeeds. If it cannot read any + * single byte without blocking, it must return +- * :enum:`NGHTTP2_ERR_WOULDBLOCK`. If it gets EOF before it reads any +- * single byte, it must return :enum:`NGHTTP2_ERR_EOF`. For other +- * errors, it must return :enum:`NGHTTP2_ERR_CALLBACK_FAILURE`. +- * Returning 0 is treated as :enum:`NGHTTP2_ERR_WOULDBLOCK`. The +- * |user_data| pointer is the third argument passed in to the call to ++ * :enum:`nghttp2_error.NGHTTP2_ERR_WOULDBLOCK`. If it gets EOF ++ * before it reads any single byte, it must return ++ * :enum:`nghttp2_error.NGHTTP2_ERR_EOF`. For other errors, it must ++ * return :enum:`nghttp2_error.NGHTTP2_ERR_CALLBACK_FAILURE`. ++ * Returning 0 is treated as ++ * :enum:`nghttp2_error.NGHTTP2_ERR_WOULDBLOCK`. The |user_data| ++ * pointer is the third argument passed in to the call to + * `nghttp2_session_client_new()` or `nghttp2_session_server_new()`. + * + * This callback is required if the application uses +@@ -1413,12 +1430,6 @@ typedef ssize_t (*nghttp2_recv_callback)(nghttp2_session *session, uint8_t *buf, + * respectively. The header name/value pairs are emitted via + * :type:`nghttp2_on_header_callback`. + * +- * For HEADERS, PUSH_PROMISE and DATA frames, this callback may be +- * called after stream is closed (see +- * :type:`nghttp2_on_stream_close_callback`). The application should +- * check that stream is still alive using its own stream management or +- * :func:`nghttp2_session_get_stream_user_data()`. +- * + * Only HEADERS and DATA frame can signal the end of incoming data. + * If ``frame->hd.flags & NGHTTP2_FLAG_END_STREAM`` is nonzero, the + * |frame| is the last frame from the remote peer in this stream. +@@ -1429,7 +1440,8 @@ typedef ssize_t (*nghttp2_recv_callback)(nghttp2_session *session, uint8_t *buf, + * The implementation of this function must return 0 if it succeeds. + * If nonzero value is returned, it is treated as fatal error and + * `nghttp2_session_recv()` and `nghttp2_session_mem_recv()` functions +- * immediately return :enum:`NGHTTP2_ERR_CALLBACK_FAILURE`. ++ * immediately return ++ * :enum:`nghttp2_error.NGHTTP2_ERR_CALLBACK_FAILURE`. + * + * To set this callback to :type:`nghttp2_session_callbacks`, use + * `nghttp2_session_callbacks_set_on_frame_recv_callback()`. +@@ -1457,7 +1469,8 @@ typedef int (*nghttp2_on_frame_recv_callback)(nghttp2_session *session, + * The implementation of this function must return 0 if it succeeds. + * If nonzero is returned, it is treated as fatal error and + * `nghttp2_session_recv()` and `nghttp2_session_mem_recv()` functions +- * immediately return :enum:`NGHTTP2_ERR_CALLBACK_FAILURE`. ++ * immediately return ++ * :enum:`nghttp2_error.NGHTTP2_ERR_CALLBACK_FAILURE`. + * + * To set this callback to :type:`nghttp2_session_callbacks`, use + * `nghttp2_session_callbacks_set_on_invalid_frame_recv_callback()`. +@@ -1480,9 +1493,9 @@ typedef int (*nghttp2_on_invalid_frame_recv_callback)( + * `nghttp2_session_server_new()`. + * + * If the application uses `nghttp2_session_mem_recv()`, it can return +- * :enum:`NGHTTP2_ERR_PAUSE` to make `nghttp2_session_mem_recv()` +- * return without processing further input bytes. The memory by +- * pointed by the |data| is retained until ++ * :enum:`nghttp2_error.NGHTTP2_ERR_PAUSE` to make ++ * `nghttp2_session_mem_recv()` return without processing further ++ * input bytes. The memory by pointed by the |data| is retained until + * `nghttp2_session_mem_recv()` or `nghttp2_session_recv()` is called. + * The application must retain the input bytes which was used to + * produce the |data| parameter, because it may refer to the memory +@@ -1491,7 +1504,8 @@ typedef int (*nghttp2_on_invalid_frame_recv_callback)( + * The implementation of this function must return 0 if it succeeds. + * If nonzero is returned, it is treated as fatal error, and + * `nghttp2_session_recv()` and `nghttp2_session_mem_recv()` functions +- * immediately return :enum:`NGHTTP2_ERR_CALLBACK_FAILURE`. ++ * immediately return ++ * :enum:`nghttp2_error.NGHTTP2_ERR_CALLBACK_FAILURE`. + * + * To set this callback to :type:`nghttp2_session_callbacks`, use + * `nghttp2_session_callbacks_set_on_data_chunk_recv_callback()`. +@@ -1511,19 +1525,20 @@ typedef int (*nghttp2_on_data_chunk_recv_callback)(nghttp2_session *session, + * `nghttp2_session_server_new()`. + * + * The implementation of this function must return 0 if it succeeds. +- * It can also return :enum:`NGHTTP2_ERR_CANCEL` to cancel the +- * transmission of the given frame. ++ * It can also return :enum:`nghttp2_error.NGHTTP2_ERR_CANCEL` to ++ * cancel the transmission of the given frame. + * + * If there is a fatal error while executing this callback, the +- * implementation should return :enum:`NGHTTP2_ERR_CALLBACK_FAILURE`, +- * which makes `nghttp2_session_send()` and +- * `nghttp2_session_mem_send()` functions immediately return +- * :enum:`NGHTTP2_ERR_CALLBACK_FAILURE`. ++ * implementation should return ++ * :enum:`nghttp2_error.NGHTTP2_ERR_CALLBACK_FAILURE`, which makes ++ * `nghttp2_session_send()` and `nghttp2_session_mem_send()` functions ++ * immediately return ++ * :enum:`nghttp2_error.NGHTTP2_ERR_CALLBACK_FAILURE`. + * + * If the other value is returned, it is treated as if +- * :enum:`NGHTTP2_ERR_CALLBACK_FAILURE` is returned. But the +- * implementation should not rely on this since the library may define +- * new return value to extend its capability. ++ * :enum:`nghttp2_error.NGHTTP2_ERR_CALLBACK_FAILURE` is returned. ++ * But the implementation should not rely on this since the library ++ * may define new return value to extend its capability. + * + * To set this callback to :type:`nghttp2_session_callbacks`, use + * `nghttp2_session_callbacks_set_before_frame_send_callback()`. +@@ -1542,7 +1557,8 @@ typedef int (*nghttp2_before_frame_send_callback)(nghttp2_session *session, + * The implementation of this function must return 0 if it succeeds. + * If nonzero is returned, it is treated as fatal error and + * `nghttp2_session_send()` and `nghttp2_session_mem_send()` functions +- * immediately return :enum:`NGHTTP2_ERR_CALLBACK_FAILURE`. ++ * immediately return ++ * :enum:`nghttp2_error.NGHTTP2_ERR_CALLBACK_FAILURE`. + * + * To set this callback to :type:`nghttp2_session_callbacks`, use + * `nghttp2_session_callbacks_set_on_frame_send_callback()`. +@@ -1564,7 +1580,8 @@ typedef int (*nghttp2_on_frame_send_callback)(nghttp2_session *session, + * The implementation of this function must return 0 if it succeeds. + * If nonzero is returned, it is treated as fatal error and + * `nghttp2_session_send()` and `nghttp2_session_mem_send()` functions +- * immediately return :enum:`NGHTTP2_ERR_CALLBACK_FAILURE`. ++ * immediately return ++ * :enum:`nghttp2_error.NGHTTP2_ERR_CALLBACK_FAILURE`. + * + * `nghttp2_session_get_stream_user_data()` can be used to get + * associated data. +@@ -1595,7 +1612,8 @@ typedef int (*nghttp2_on_frame_not_send_callback)(nghttp2_session *session, + * If nonzero is returned, it is treated as fatal error and + * `nghttp2_session_recv()`, `nghttp2_session_mem_recv()`, + * `nghttp2_session_send()`, and `nghttp2_session_mem_send()` +- * functions immediately return :enum:`NGHTTP2_ERR_CALLBACK_FAILURE`. ++ * functions immediately return ++ * :enum:`nghttp2_error.NGHTTP2_ERR_CALLBACK_FAILURE`. + * + * To set this callback to :type:`nghttp2_session_callbacks`, use + * `nghttp2_session_callbacks_set_on_stream_close_callback()`. +@@ -1613,10 +1631,11 @@ typedef int (*nghttp2_on_stream_close_callback)(nghttp2_session *session, + * will be emitted by :type:`nghttp2_on_header_callback`. + * + * The ``frame->hd.flags`` may not have +- * :enum:`NGHTTP2_FLAG_END_HEADERS` flag set, which indicates that one +- * or more CONTINUATION frames are involved. But the application does +- * not need to care about that because the header name/value pairs are +- * emitted transparently regardless of CONTINUATION frames. ++ * :enum:`nghttp2_flag.NGHTTP2_FLAG_END_HEADERS` flag set, which ++ * indicates that one or more CONTINUATION frames are involved. But ++ * the application does not need to care about that because the header ++ * name/value pairs are emitted transparently regardless of ++ * CONTINUATION frames. + * + * The server applications probably create an object to store + * information about new stream if ``frame->hd.type == +@@ -1639,26 +1658,31 @@ typedef int (*nghttp2_on_stream_close_callback)(nghttp2_session *session, + * trailer fields also has ``frame->headers.cat == + * NGHTTP2_HCAT_HEADERS`` which does not contain any status code. + * +- * Returning :enum:`NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE` will close +- * the stream (promised stream if frame is PUSH_PROMISE) by issuing +- * RST_STREAM with :enum:`NGHTTP2_INTERNAL_ERROR`. In this case, ++ * Returning ++ * :enum:`nghttp2_error.NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE` will ++ * close the stream (promised stream if frame is PUSH_PROMISE) by ++ * issuing RST_STREAM with ++ * :enum:`nghttp2_error_code.NGHTTP2_INTERNAL_ERROR`. In this case, + * :type:`nghttp2_on_header_callback` and + * :type:`nghttp2_on_frame_recv_callback` will not be invoked. If a + * different error code is desirable, use + * `nghttp2_submit_rst_stream()` with a desired error code and then +- * return :enum:`NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE`. Again, use +- * ``frame->push_promise.promised_stream_id`` as stream_id parameter +- * in `nghttp2_submit_rst_stream()` if frame is PUSH_PROMISE. ++ * return :enum:`nghttp2_error.NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE`. ++ * Again, use ``frame->push_promise.promised_stream_id`` as stream_id ++ * parameter in `nghttp2_submit_rst_stream()` if frame is ++ * PUSH_PROMISE. + * + * The implementation of this function must return 0 if it succeeds. +- * It can return :enum:`NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE` to ++ * It can return ++ * :enum:`nghttp2_error.NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE` to + * reset the stream (promised stream if frame is PUSH_PROMISE). For + * critical errors, it must return +- * :enum:`NGHTTP2_ERR_CALLBACK_FAILURE`. If the other value is +- * returned, it is treated as if :enum:`NGHTTP2_ERR_CALLBACK_FAILURE` +- * is returned. If :enum:`NGHTTP2_ERR_CALLBACK_FAILURE` is returned, ++ * :enum:`nghttp2_error.NGHTTP2_ERR_CALLBACK_FAILURE`. If the other ++ * value is returned, it is treated as if ++ * :enum:`nghttp2_error.NGHTTP2_ERR_CALLBACK_FAILURE` is returned. If ++ * :enum:`nghttp2_error.NGHTTP2_ERR_CALLBACK_FAILURE` is returned, + * `nghttp2_session_mem_recv()` function will immediately return +- * :enum:`NGHTTP2_ERR_CALLBACK_FAILURE`. ++ * :enum:`nghttp2_error.NGHTTP2_ERR_CALLBACK_FAILURE`. + * + * To set this callback to :type:`nghttp2_session_callbacks`, use + * `nghttp2_session_callbacks_set_on_begin_headers_callback()`. +@@ -1675,16 +1699,17 @@ typedef int (*nghttp2_on_begin_headers_callback)(nghttp2_session *session, + * The |value| of length |valuelen| is header value. The |flags| is + * bitwise OR of one or more of :type:`nghttp2_nv_flag`. + * +- * If :enum:`NGHTTP2_NV_FLAG_NO_INDEX` is set in |flags|, the receiver +- * must not index this name/value pair when forwarding it to the next +- * hop. More specifically, "Literal Header Field never Indexed" +- * representation must be used in HPACK encoding. ++ * If :enum:`nghttp2_nv_flag.NGHTTP2_NV_FLAG_NO_INDEX` is set in ++ * |flags|, the receiver must not index this name/value pair when ++ * forwarding it to the next hop. More specifically, "Literal Header ++ * Field never Indexed" representation must be used in HPACK encoding. + * + * When this callback is invoked, ``frame->hd.type`` is either +- * :enum:`NGHTTP2_HEADERS` or :enum:`NGHTTP2_PUSH_PROMISE`. After all +- * header name/value pairs are processed with this callback, and no +- * error has been detected, :type:`nghttp2_on_frame_recv_callback` +- * will be invoked. If there is an error in decompression, ++ * :enum:`nghttp2_frame_type.NGHTTP2_HEADERS` or ++ * :enum:`nghttp2_frame_type.NGHTTP2_PUSH_PROMISE`. After all header ++ * name/value pairs are processed with this callback, and no error has ++ * been detected, :type:`nghttp2_on_frame_recv_callback` will be ++ * invoked. If there is an error in decompression, + * :type:`nghttp2_on_frame_recv_callback` for the |frame| will not be + * invoked. + * +@@ -1702,34 +1727,39 @@ typedef int (*nghttp2_on_begin_headers_callback)(nghttp2_session *session, + * explained in :ref:`http-messaging` section. + * + * If the application uses `nghttp2_session_mem_recv()`, it can return +- * :enum:`NGHTTP2_ERR_PAUSE` to make `nghttp2_session_mem_recv()` +- * return without processing further input bytes. The memory pointed +- * by |frame|, |name| and |value| parameters are retained until +- * `nghttp2_session_mem_recv()` or `nghttp2_session_recv()` is called. +- * The application must retain the input bytes which was used to +- * produce these parameters, because it may refer to the memory region +- * included in the input bytes. +- * +- * Returning :enum:`NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE` will close +- * the stream (promised stream if frame is PUSH_PROMISE) by issuing +- * RST_STREAM with :enum:`NGHTTP2_INTERNAL_ERROR`. In this case, ++ * :enum:`nghttp2_error.NGHTTP2_ERR_PAUSE` to make ++ * `nghttp2_session_mem_recv()` return without processing further ++ * input bytes. The memory pointed by |frame|, |name| and |value| ++ * parameters are retained until `nghttp2_session_mem_recv()` or ++ * `nghttp2_session_recv()` is called. The application must retain ++ * the input bytes which was used to produce these parameters, because ++ * it may refer to the memory region included in the input bytes. ++ * ++ * Returning ++ * :enum:`nghttp2_error.NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE` will ++ * close the stream (promised stream if frame is PUSH_PROMISE) by ++ * issuing RST_STREAM with ++ * :enum:`nghttp2_error_code.NGHTTP2_INTERNAL_ERROR`. In this case, + * :type:`nghttp2_on_header_callback` and + * :type:`nghttp2_on_frame_recv_callback` will not be invoked. If a + * different error code is desirable, use + * `nghttp2_submit_rst_stream()` with a desired error code and then +- * return :enum:`NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE`. Again, use +- * ``frame->push_promise.promised_stream_id`` as stream_id parameter +- * in `nghttp2_submit_rst_stream()` if frame is PUSH_PROMISE. ++ * return :enum:`nghttp2_error.NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE`. ++ * Again, use ``frame->push_promise.promised_stream_id`` as stream_id ++ * parameter in `nghttp2_submit_rst_stream()` if frame is ++ * PUSH_PROMISE. + * + * The implementation of this function must return 0 if it succeeds. +- * It may return :enum:`NGHTTP2_ERR_PAUSE` or +- * :enum:`NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE`. For other critical +- * failures, it must return :enum:`NGHTTP2_ERR_CALLBACK_FAILURE`. If +- * the other nonzero value is returned, it is treated as +- * :enum:`NGHTTP2_ERR_CALLBACK_FAILURE`. If +- * :enum:`NGHTTP2_ERR_CALLBACK_FAILURE` is returned, ++ * It may return :enum:`nghttp2_error.NGHTTP2_ERR_PAUSE` or ++ * :enum:`nghttp2_error.NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE`. For ++ * other critical failures, it must return ++ * :enum:`nghttp2_error.NGHTTP2_ERR_CALLBACK_FAILURE`. If the other ++ * nonzero value is returned, it is treated as ++ * :enum:`nghttp2_error.NGHTTP2_ERR_CALLBACK_FAILURE`. If ++ * :enum:`nghttp2_error.NGHTTP2_ERR_CALLBACK_FAILURE` is returned, + * `nghttp2_session_recv()` and `nghttp2_session_mem_recv()` functions +- * immediately return :enum:`NGHTTP2_ERR_CALLBACK_FAILURE`. ++ * immediately return ++ * :enum:`nghttp2_error.NGHTTP2_ERR_CALLBACK_FAILURE`. + * + * To set this callback to :type:`nghttp2_session_callbacks`, use + * `nghttp2_session_callbacks_set_on_header_callback()`. +@@ -1796,11 +1826,12 @@ typedef int (*nghttp2_on_header_callback2)(nghttp2_session *session, + * + * With this callback, application inspects the incoming invalid + * field, and it also can reset stream from this callback by returning +- * :enum:`NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE`. By default, the +- * error code is :enum:`NGHTTP2_PROTOCOL_ERROR`. To change the error +- * code, call `nghttp2_submit_rst_stream()` with the error code of +- * choice in addition to returning +- * :enum:`NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE`. ++ * :enum:`nghttp2_error.NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE`. By ++ * default, the error code is ++ * :enum:`nghttp2_error_code.NGHTTP2_PROTOCOL_ERROR`. To change the ++ * error code, call `nghttp2_submit_rst_stream()` with the error code ++ * of choice in addition to returning ++ * :enum:`nghttp2_error.NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE`. + * + * If 0 is returned, the header field is ignored, and the stream is + * not reset. +@@ -1831,11 +1862,12 @@ typedef int (*nghttp2_on_invalid_header_callback)( + * + * With this callback, application inspects the incoming invalid + * field, and it also can reset stream from this callback by returning +- * :enum:`NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE`. By default, the +- * error code is :enum:`NGHTTP2_INTERNAL_ERROR`. To change the error +- * code, call `nghttp2_submit_rst_stream()` with the error code of +- * choice in addition to returning +- * :enum:`NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE`. ++ * :enum:`nghttp2_error.NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE`. By ++ * default, the error code is ++ * :enum:`nghttp2_error_code.NGHTTP2_INTERNAL_ERROR`. To change the ++ * error code, call `nghttp2_submit_rst_stream()` with the error code ++ * of choice in addition to returning ++ * :enum:`nghttp2_error.NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE`. + */ + typedef int (*nghttp2_on_invalid_header_callback2)( + nghttp2_session *session, const nghttp2_frame *frame, nghttp2_rcbuf *name, +@@ -1849,11 +1881,12 @@ typedef int (*nghttp2_on_invalid_header_callback2)( + * |frame|. The application must choose the total length of payload + * including padded bytes in range [frame->hd.length, max_payloadlen], + * inclusive. Choosing number not in this range will be treated as +- * :enum:`NGHTTP2_ERR_CALLBACK_FAILURE`. Returning ++ * :enum:`nghttp2_error.NGHTTP2_ERR_CALLBACK_FAILURE`. Returning + * ``frame->hd.length`` means no padding is added. Returning +- * :enum:`NGHTTP2_ERR_CALLBACK_FAILURE` will make ++ * :enum:`nghttp2_error.NGHTTP2_ERR_CALLBACK_FAILURE` will make + * `nghttp2_session_send()` and `nghttp2_session_mem_send()` functions +- * immediately return :enum:`NGHTTP2_ERR_CALLBACK_FAILURE`. ++ * immediately return ++ * :enum:`nghttp2_error.NGHTTP2_ERR_CALLBACK_FAILURE`. + * + * To set this callback to :type:`nghttp2_session_callbacks`, use + * `nghttp2_session_callbacks_set_select_padding_callback()`. +@@ -1873,16 +1906,17 @@ typedef ssize_t (*nghttp2_select_padding_callback)(nghttp2_session *session, + * |remote_max_frame_size|)]. If a value greater than this range is + * returned than the max allow value will be used. Returning a value + * smaller than this range is treated as +- * :enum:`NGHTTP2_ERR_CALLBACK_FAILURE`. The |frame_type| is provided +- * for future extensibility and identifies the type of frame (see +- * :type:`nghttp2_frame_type`) for which to get the length for. +- * Currently supported frame types are: :enum:`NGHTTP2_DATA`. ++ * :enum:`nghttp2_error.NGHTTP2_ERR_CALLBACK_FAILURE`. The ++ * |frame_type| is provided for future extensibility and identifies ++ * the type of frame (see :type:`nghttp2_frame_type`) for which to get ++ * the length for. Currently supported frame types are: ++ * :enum:`nghttp2_frame_type.NGHTTP2_DATA`. + * + * This callback can be used to control the length in bytes for which + * :type:`nghttp2_data_source_read_callback` is allowed to send to the + * remote endpoint. This callback is optional. Returning +- * :enum:`NGHTTP2_ERR_CALLBACK_FAILURE` will signal the entire session +- * failure. ++ * :enum:`nghttp2_error.NGHTTP2_ERR_CALLBACK_FAILURE` will signal the ++ * entire session failure. + * + * To set this callback to :type:`nghttp2_session_callbacks`, use + * `nghttp2_session_callbacks_set_data_source_read_length_callback()`. +@@ -1909,7 +1943,8 @@ typedef ssize_t (*nghttp2_data_source_read_length_callback)( + * The implementation of this function must return 0 if it succeeds. + * If nonzero value is returned, it is treated as fatal error and + * `nghttp2_session_recv()` and `nghttp2_session_mem_recv()` functions +- * immediately return :enum:`NGHTTP2_ERR_CALLBACK_FAILURE`. ++ * immediately return ++ * :enum:`nghttp2_error.NGHTTP2_ERR_CALLBACK_FAILURE`. + * + * To set this callback to :type:`nghttp2_session_callbacks`, use + * `nghttp2_session_callbacks_set_on_begin_frame_callback()`. +@@ -1928,14 +1963,15 @@ typedef int (*nghttp2_on_begin_frame_callback)(nghttp2_session *session, + * The implementation of this function must return 0 if it succeeds. + * + * To abort processing this extension frame, return +- * :enum:`NGHTTP2_ERR_CANCEL`. ++ * :enum:`nghttp2_error.NGHTTP2_ERR_CANCEL`. + * + * If fatal error occurred, application should return +- * :enum:`NGHTTP2_ERR_CALLBACK_FAILURE`. In this case, ++ * :enum:`nghttp2_error.NGHTTP2_ERR_CALLBACK_FAILURE`. In this case, + * `nghttp2_session_recv()` and `nghttp2_session_mem_recv()` functions +- * immediately return :enum:`NGHTTP2_ERR_CALLBACK_FAILURE`. If the +- * other values are returned, currently they are treated as +- * :enum:`NGHTTP2_ERR_CALLBACK_FAILURE`. ++ * immediately return ++ * :enum:`nghttp2_error.NGHTTP2_ERR_CALLBACK_FAILURE`. If the other ++ * values are returned, currently they are treated as ++ * :enum:`nghttp2_error.NGHTTP2_ERR_CALLBACK_FAILURE`. + */ + typedef int (*nghttp2_on_extension_chunk_recv_callback)( + nghttp2_session *session, const nghttp2_frame_hd *hd, const uint8_t *data, +@@ -1965,14 +2001,15 @@ typedef int (*nghttp2_on_extension_chunk_recv_callback)( + * |*payload|, and do its own mechanism to process extension frames. + * + * To abort processing this extension frame, return +- * :enum:`NGHTTP2_ERR_CANCEL`. ++ * :enum:`nghttp2_error.NGHTTP2_ERR_CANCEL`. + * + * If fatal error occurred, application should return +- * :enum:`NGHTTP2_ERR_CALLBACK_FAILURE`. In this case, ++ * :enum:`nghttp2_error.NGHTTP2_ERR_CALLBACK_FAILURE`. In this case, + * `nghttp2_session_recv()` and `nghttp2_session_mem_recv()` functions +- * immediately return :enum:`NGHTTP2_ERR_CALLBACK_FAILURE`. If the +- * other values are returned, currently they are treated as +- * :enum:`NGHTTP2_ERR_CALLBACK_FAILURE`. ++ * immediately return ++ * :enum:`nghttp2_error.NGHTTP2_ERR_CALLBACK_FAILURE`. If the other ++ * values are returned, currently they are treated as ++ * :enum:`nghttp2_error.NGHTTP2_ERR_CALLBACK_FAILURE`. + */ + typedef int (*nghttp2_unpack_extension_callback)(nghttp2_session *session, + void **payload, +@@ -1994,17 +2031,18 @@ typedef int (*nghttp2_unpack_extension_callback)(nghttp2_session *session, + * bytes written into |buf| when it succeeds. + * + * To abort processing this extension frame, return +- * :enum:`NGHTTP2_ERR_CANCEL`, and ++ * :enum:`nghttp2_error.NGHTTP2_ERR_CANCEL`, and + * :type:`nghttp2_on_frame_not_send_callback` will be invoked. + * + * If fatal error occurred, application should return +- * :enum:`NGHTTP2_ERR_CALLBACK_FAILURE`. In this case, ++ * :enum:`nghttp2_error.NGHTTP2_ERR_CALLBACK_FAILURE`. In this case, + * `nghttp2_session_send()` and `nghttp2_session_mem_send()` functions +- * immediately return :enum:`NGHTTP2_ERR_CALLBACK_FAILURE`. If the +- * other values are returned, currently they are treated as +- * :enum:`NGHTTP2_ERR_CALLBACK_FAILURE`. If the return value is +- * strictly larger than |len|, it is treated as +- * :enum:`NGHTTP2_ERR_CALLBACK_FAILURE`. ++ * immediately return ++ * :enum:`nghttp2_error.NGHTTP2_ERR_CALLBACK_FAILURE`. If the other ++ * values are returned, currently they are treated as ++ * :enum:`nghttp2_error.NGHTTP2_ERR_CALLBACK_FAILURE`. If the return ++ * value is strictly larger than |len|, it is treated as ++ * :enum:`nghttp2_error.NGHTTP2_ERR_CALLBACK_FAILURE`. + */ + typedef ssize_t (*nghttp2_pack_extension_callback)(nghttp2_session *session, + uint8_t *buf, size_t len, +@@ -2029,12 +2067,12 @@ typedef ssize_t (*nghttp2_pack_extension_callback)(nghttp2_session *session, + * + * Normally, application should return 0 from this callback. If fatal + * error occurred while doing something in this callback, application +- * should return :enum:`NGHTTP2_ERR_CALLBACK_FAILURE`. In this case, +- * library will return immediately with return value +- * :enum:`NGHTTP2_ERR_CALLBACK_FAILURE`. Currently, if nonzero value +- * is returned from this callback, they are treated as +- * :enum:`NGHTTP2_ERR_CALLBACK_FAILURE`, but application should not +- * rely on this details. ++ * should return :enum:`nghttp2_error.NGHTTP2_ERR_CALLBACK_FAILURE`. ++ * In this case, library will return immediately with return value ++ * :enum:`nghttp2_error.NGHTTP2_ERR_CALLBACK_FAILURE`. Currently, if ++ * nonzero value is returned from this callback, they are treated as ++ * :enum:`nghttp2_error.NGHTTP2_ERR_CALLBACK_FAILURE`, but application ++ * should not rely on this details. + */ + typedef int (*nghttp2_error_callback)(nghttp2_session *session, const char *msg, + size_t len, void *user_data); +@@ -2055,12 +2093,12 @@ typedef int (*nghttp2_error_callback)(nghttp2_session *session, const char *msg, + * + * Normally, application should return 0 from this callback. If fatal + * error occurred while doing something in this callback, application +- * should return :enum:`NGHTTP2_ERR_CALLBACK_FAILURE`. In this case, +- * library will return immediately with return value +- * :enum:`NGHTTP2_ERR_CALLBACK_FAILURE`. Currently, if nonzero value +- * is returned from this callback, they are treated as +- * :enum:`NGHTTP2_ERR_CALLBACK_FAILURE`, but application should not +- * rely on this details. ++ * should return :enum:`nghttp2_error.NGHTTP2_ERR_CALLBACK_FAILURE`. ++ * In this case, library will return immediately with return value ++ * :enum:`nghttp2_error.NGHTTP2_ERR_CALLBACK_FAILURE`. Currently, if ++ * nonzero value is returned from this callback, they are treated as ++ * :enum:`nghttp2_error.NGHTTP2_ERR_CALLBACK_FAILURE`, but application ++ * should not rely on this details. + */ + typedef int (*nghttp2_error_callback2)(nghttp2_session *session, + int lib_error_code, const char *msg, +@@ -2090,7 +2128,7 @@ typedef struct nghttp2_session_callbacks nghttp2_session_callbacks; + * This function returns 0 if it succeeds, or one of the following + * negative error codes: + * +- * :enum:`NGHTTP2_ERR_NOMEM` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_NOMEM` + * Out of memory. + */ + NGHTTP2_EXTERN int +@@ -2287,7 +2325,7 @@ NGHTTP2_EXTERN void nghttp2_session_callbacks_set_on_begin_frame_callback( + * @function + * + * Sets callback function invoked when +- * :enum:`NGHTTP2_DATA_FLAG_NO_COPY` is used in ++ * :enum:`nghttp2_data_flag.NGHTTP2_DATA_FLAG_NO_COPY` is used in + * :type:`nghttp2_data_source_read_callback` to avoid data copy. + */ + NGHTTP2_EXTERN void nghttp2_session_callbacks_set_send_data_callback( +@@ -2470,7 +2508,7 @@ typedef struct nghttp2_option nghttp2_option; + * This function returns 0 if it succeeds, or one of the following + * negative error codes: + * +- * :enum:`NGHTTP2_ERR_NOMEM` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_NOMEM` + * Out of memory. + */ + NGHTTP2_EXTERN int nghttp2_option_new(nghttp2_option **option_ptr); +@@ -2531,7 +2569,8 @@ nghttp2_option_set_peer_max_concurrent_streams(nghttp2_option *option, + * If this option is not used or used with zero value, if MAGIC does + * not match :macro:`NGHTTP2_CLIENT_MAGIC`, `nghttp2_session_recv()` + * and `nghttp2_session_mem_recv()` will return error +- * :enum:`NGHTTP2_ERR_BAD_CLIENT_MAGIC`, which is fatal error. ++ * :enum:`nghttp2_error.NGHTTP2_ERR_BAD_CLIENT_MAGIC`, which is fatal ++ * error. + */ + NGHTTP2_EXTERN void + nghttp2_option_set_no_recv_client_magic(nghttp2_option *option, int val); +@@ -2616,8 +2655,8 @@ nghttp2_option_set_builtin_recv_extension_type(nghttp2_option *option, + * received. If this option is set to nonzero, the library won't send + * PING frame with ACK flag set in the response for incoming PING + * frame. The application can send PING frame with ACK flag set using +- * `nghttp2_submit_ping()` with :enum:`NGHTTP2_FLAG_ACK` as flags +- * parameter. ++ * `nghttp2_submit_ping()` with :enum:`nghttp2_flag.NGHTTP2_FLAG_ACK` ++ * as flags parameter. + */ + NGHTTP2_EXTERN void nghttp2_option_set_no_auto_ping_ack(nghttp2_option *option, + int val); +@@ -2631,7 +2670,7 @@ NGHTTP2_EXTERN void nghttp2_option_set_no_auto_ping_ack(nghttp2_option *option, + * `nghttp2_hd_deflate_bound()`. The default value is 64KiB. If + * application attempts to send header fields larger than this limit, + * the transmission of the frame fails with error code +- * :enum:`NGHTTP2_ERR_FRAME_SIZE_ERROR`. ++ * :enum:`nghttp2_error.NGHTTP2_ERR_FRAME_SIZE_ERROR`. + */ + NGHTTP2_EXTERN void + nghttp2_option_set_max_send_header_block_length(nghttp2_option *option, +@@ -2656,6 +2695,11 @@ nghttp2_option_set_max_deflate_dynamic_table_size(nghttp2_option *option, + * This option prevents the library from retaining closed streams to + * maintain the priority tree. If this option is set to nonzero, + * applications can discard closed stream completely to save memory. ++ * ++ * If ++ * :enum:`nghttp2_settings_id.NGHTTP2_SETTINGS_NO_RFC7540_PRIORITIES` ++ * of value of 1 is submitted via `nghttp2_submit_settings()`, any ++ * closed streams are not retained regardless of this option. + */ + NGHTTP2_EXTERN void nghttp2_option_set_no_closed_streams(nghttp2_option *option, + int val); +@@ -2682,6 +2726,53 @@ NGHTTP2_EXTERN void nghttp2_option_set_max_outbound_ack(nghttp2_option *option, + NGHTTP2_EXTERN void nghttp2_option_set_max_settings(nghttp2_option *option, + size_t val); + ++/** ++ * @function ++ * ++ * This option, if set to nonzero, allows server to fallback to ++ * :rfc:`7540` priorities if SETTINGS_NO_RFC7540_PRIORITIES was not ++ * received from client, and server submitted ++ * :enum:`nghttp2_settings_id.NGHTTP2_SETTINGS_NO_RFC7540_PRIORITIES` ++ * = 1 via `nghttp2_submit_settings()`. Most of the advanced ++ * functionality for RFC 7540 priorities are still disabled. This ++ * fallback only enables the minimal feature set of RFC 7540 ++ * priorities to deal with priority signaling from client. ++ * ++ * Client session ignores this option. ++ */ ++NGHTTP2_EXTERN void ++nghttp2_option_set_server_fallback_rfc7540_priorities(nghttp2_option *option, ++ int val); ++ ++/** ++ * @function ++ * ++ * This option, if set to nonzero, turns off RFC 9113 leading and ++ * trailing white spaces validation against HTTP field value. Some ++ * important fields, such as HTTP/2 pseudo header fields, are ++ * validated more strictly and this option does not apply to them. ++ */ ++NGHTTP2_EXTERN void ++nghttp2_option_set_no_rfc9113_leading_and_trailing_ws_validation( ++ nghttp2_option *option, int val); ++ ++/** ++ * @function ++ * ++ * This function sets the rate limit for the incoming stream reset ++ * (RST_STREAM frame). It is server use only. It is a token-bucket ++ * based rate limiter. |burst| specifies the number of tokens that is ++ * initially available. The maximum number of tokens is capped to ++ * this value. |rate| specifies the number of tokens that are ++ * regenerated per second. An incoming RST_STREAM consumes one token. ++ * If there is no token available, GOAWAY is sent to tear down the ++ * connection. |burst| and |rate| default to 1000 and 33 ++ * respectively. ++ */ ++NGHTTP2_EXTERN void ++nghttp2_option_set_stream_reset_rate_limit(nghttp2_option *option, ++ uint64_t burst, uint64_t rate); ++ + /** + * @function + * +@@ -2700,7 +2791,7 @@ NGHTTP2_EXTERN void nghttp2_option_set_max_settings(nghttp2_option *option, + * This function returns 0 if it succeeds, or one of the following + * negative error codes: + * +- * :enum:`NGHTTP2_ERR_NOMEM` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_NOMEM` + * Out of memory. + */ + NGHTTP2_EXTERN int +@@ -2726,7 +2817,7 @@ nghttp2_session_client_new(nghttp2_session **session_ptr, + * This function returns 0 if it succeeds, or one of the following + * negative error codes: + * +- * :enum:`NGHTTP2_ERR_NOMEM` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_NOMEM` + * Out of memory. + */ + NGHTTP2_EXTERN int +@@ -2752,7 +2843,7 @@ nghttp2_session_server_new(nghttp2_session **session_ptr, + * This function returns 0 if it succeeds, or one of the following + * negative error codes: + * +- * :enum:`NGHTTP2_ERR_NOMEM` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_NOMEM` + * Out of memory. + */ + NGHTTP2_EXTERN int +@@ -2778,7 +2869,7 @@ nghttp2_session_client_new2(nghttp2_session **session_ptr, + * This function returns 0 if it succeeds, or one of the following + * negative error codes: + * +- * :enum:`NGHTTP2_ERR_NOMEM` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_NOMEM` + * Out of memory. + */ + NGHTTP2_EXTERN int +@@ -2804,7 +2895,7 @@ nghttp2_session_server_new2(nghttp2_session **session_ptr, + * This function returns 0 if it succeeds, or one of the following + * negative error codes: + * +- * :enum:`NGHTTP2_ERR_NOMEM` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_NOMEM` + * Out of memory. + */ + NGHTTP2_EXTERN int nghttp2_session_client_new3( +@@ -2829,7 +2920,7 @@ NGHTTP2_EXTERN int nghttp2_session_client_new3( + * This function returns 0 if it succeeds, or one of the following + * negative error codes: + * +- * :enum:`NGHTTP2_ERR_NOMEM` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_NOMEM` + * Out of memory. + */ + NGHTTP2_EXTERN int nghttp2_session_server_new3( +@@ -2853,12 +2944,12 @@ NGHTTP2_EXTERN void nghttp2_session_del(nghttp2_session *session); + * outbound queue and sends it to the remote peer. It does this as + * many times as possible until the user callback + * :type:`nghttp2_send_callback` returns +- * :enum:`NGHTTP2_ERR_WOULDBLOCK`, the outbound queue becomes empty +- * or flow control is triggered (remote window size becomes depleted +- * or maximum number of concurrent streams is reached). +- * This function calls several callback functions which are passed +- * when initializing the |session|. Here is the simple time chart +- * which tells when each callback is invoked: ++ * :enum:`nghttp2_error.NGHTTP2_ERR_WOULDBLOCK`, the outbound queue ++ * becomes empty or flow control is triggered (remote window size ++ * becomes depleted or maximum number of concurrent streams is ++ * reached). This function calls several callback functions which are ++ * passed when initializing the |session|. Here is the simple time ++ * chart which tells when each callback is invoked: + * + * 1. Get the next frame to send from outbound queue. + * +@@ -2876,7 +2967,7 @@ NGHTTP2_EXTERN void nghttp2_session_del(nghttp2_session *session); + * + * 6. :type:`nghttp2_before_frame_send_callback` is invoked. + * +- * 7. If :enum:`NGHTTP2_ERR_CANCEL` is returned from ++ * 7. If :enum:`nghttp2_error.NGHTTP2_ERR_CANCEL` is returned from + * :type:`nghttp2_before_frame_send_callback`, the current frame + * transmission is canceled, and + * :type:`nghttp2_on_frame_not_send_callback` is invoked. Abort +@@ -2894,9 +2985,9 @@ NGHTTP2_EXTERN void nghttp2_session_del(nghttp2_session *session); + * This function returns 0 if it succeeds, or one of the following + * negative error codes: + * +- * :enum:`NGHTTP2_ERR_NOMEM` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_NOMEM` + * Out of memory. +- * :enum:`NGHTTP2_ERR_CALLBACK_FAILURE` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_CALLBACK_FAILURE` + * The callback function failed. + */ + NGHTTP2_EXTERN int nghttp2_session_send(nghttp2_session *session); +@@ -2928,7 +3019,7 @@ NGHTTP2_EXTERN int nghttp2_session_send(nghttp2_session *session); + * |*data_ptr| if it succeeds, or one of the following negative error + * codes: + * +- * :enum:`NGHTTP2_ERR_NOMEM` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_NOMEM` + * Out of memory. + * + * .. note:: +@@ -2950,8 +3041,8 @@ NGHTTP2_EXTERN ssize_t nghttp2_session_mem_send(nghttp2_session *session, + * + * This function receives as many frames as possible until the user + * callback :type:`nghttp2_recv_callback` returns +- * :enum:`NGHTTP2_ERR_WOULDBLOCK`. This function calls several +- * callback functions which are passed when initializing the ++ * :enum:`nghttp2_error.NGHTTP2_ERR_WOULDBLOCK`. This function calls ++ * several callback functions which are passed when initializing the + * |session|. Here is the simple time chart which tells when each + * callback is invoked: + * +@@ -2996,18 +3087,18 @@ NGHTTP2_EXTERN ssize_t nghttp2_session_mem_send(nghttp2_session *session, + * This function returns 0 if it succeeds, or one of the following + * negative error codes: + * +- * :enum:`NGHTTP2_ERR_EOF` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_EOF` + * The remote peer did shutdown on the connection. +- * :enum:`NGHTTP2_ERR_NOMEM` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_NOMEM` + * Out of memory. +- * :enum:`NGHTTP2_ERR_CALLBACK_FAILURE` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_CALLBACK_FAILURE` + * The callback function failed. +- * :enum:`NGHTTP2_ERR_BAD_CLIENT_MAGIC` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_BAD_CLIENT_MAGIC` + * Invalid client magic was detected. This error only returns + * when |session| was configured as server and + * `nghttp2_option_set_no_recv_client_magic()` is not used with + * nonzero value. +- * :enum:`NGHTTP2_ERR_FLOODED` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_FLOODED` + * Flooding was detected in this HTTP/2 session, and it must be + * closed. This is most likely caused by misbehaviour of peer. + */ +@@ -3017,7 +3108,7 @@ NGHTTP2_EXTERN int nghttp2_session_recv(nghttp2_session *session); + * @function + * + * Processes data |in| as an input from the remote endpoint. The +- * |inlen| indicates the number of bytes in the |in|. ++ * |inlen| indicates the number of bytes to receive in the |in|. + * + * This function behaves like `nghttp2_session_recv()` except that it + * does not use :type:`nghttp2_recv_callback` to receive data; the +@@ -3026,27 +3117,27 @@ NGHTTP2_EXTERN int nghttp2_session_recv(nghttp2_session *session); + * are called in the same way as they are in `nghttp2_session_recv()`. + * + * In the current implementation, this function always tries to +- * processes all input data unless either an error occurs or +- * :enum:`NGHTTP2_ERR_PAUSE` is returned from ++ * processes |inlen| bytes of input data unless either an error occurs or ++ * :enum:`nghttp2_error.NGHTTP2_ERR_PAUSE` is returned from + * :type:`nghttp2_on_header_callback` or + * :type:`nghttp2_on_data_chunk_recv_callback`. If +- * :enum:`NGHTTP2_ERR_PAUSE` is used, the return value includes the +- * number of bytes which was used to produce the data or frame for the +- * callback. ++ * :enum:`nghttp2_error.NGHTTP2_ERR_PAUSE` is used, the return value ++ * includes the number of bytes which was used to produce the data or ++ * frame for the callback. + * + * This function returns the number of processed bytes, or one of the + * following negative error codes: + * +- * :enum:`NGHTTP2_ERR_NOMEM` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_NOMEM` + * Out of memory. +- * :enum:`NGHTTP2_ERR_CALLBACK_FAILURE` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_CALLBACK_FAILURE` + * The callback function failed. +- * :enum:`NGHTTP2_ERR_BAD_CLIENT_MAGIC` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_BAD_CLIENT_MAGIC` + * Invalid client magic was detected. This error only returns + * when |session| was configured as server and + * `nghttp2_option_set_no_recv_client_magic()` is not used with + * nonzero value. +- * :enum:`NGHTTP2_ERR_FLOODED` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_FLOODED` + * Flooding was detected in this HTTP/2 session, and it must be + * closed. This is most likely caused by misbehaviour of peer. + */ +@@ -3063,9 +3154,9 @@ NGHTTP2_EXTERN ssize_t nghttp2_session_mem_recv(nghttp2_session *session, + * This function returns 0 if it succeeds, or one of the following + * negative error codes: + * +- * :enum:`NGHTTP2_ERR_INVALID_ARGUMENT` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_INVALID_ARGUMENT` + * The stream does not exist; or no deferred data exist. +- * :enum:`NGHTTP2_ERR_NOMEM` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_NOMEM` + * Out of memory. + */ + NGHTTP2_EXTERN int nghttp2_session_resume_data(nghttp2_session *session, +@@ -3126,7 +3217,7 @@ nghttp2_session_get_stream_user_data(nghttp2_session *session, + * This function returns 0 if it succeeds, or one of following + * negative error codes: + * +- * :enum:`NGHTTP2_ERR_INVALID_ARGUMENT` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_INVALID_ARGUMENT` + * The stream does not exist + */ + NGHTTP2_EXTERN int +@@ -3343,7 +3434,7 @@ nghttp2_session_get_hd_deflate_dynamic_table_size(nghttp2_session *session); + * This function returns 0 if it succeeds, or one of the following + * negative error codes: + * +- * :enum:`NGHTTP2_ERR_NOMEM` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_NOMEM` + * Out of memory. + */ + NGHTTP2_EXTERN int nghttp2_session_terminate_session(nghttp2_session *session, +@@ -3370,9 +3461,9 @@ NGHTTP2_EXTERN int nghttp2_session_terminate_session(nghttp2_session *session, + * This function returns 0 if it succeeds, or one of the following + * negative error codes: + * +- * :enum:`NGHTTP2_ERR_NOMEM` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_NOMEM` + * Out of memory. +- * :enum:`NGHTTP2_ERR_INVALID_ARGUMENT` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_INVALID_ARGUMENT` + * The |last_stream_id| is invalid. + */ + NGHTTP2_EXTERN int nghttp2_session_terminate_session2(nghttp2_session *session, +@@ -3387,7 +3478,7 @@ NGHTTP2_EXTERN int nghttp2_session_terminate_session2(nghttp2_session *session, + * + * This function is only usable for server. If this function is + * called with client side session, this function returns +- * :enum:`NGHTTP2_ERR_INVALID_STATE`. ++ * :enum:`nghttp2_error.NGHTTP2_ERR_INVALID_STATE`. + * + * To gracefully shutdown HTTP/2 session, server should call this + * function to send GOAWAY with last_stream_id (1u << 31) - 1. And +@@ -3409,9 +3500,9 @@ NGHTTP2_EXTERN int nghttp2_session_terminate_session2(nghttp2_session *session, + * This function returns 0 if it succeeds, or one of the following + * negative error codes: + * +- * :enum:`NGHTTP2_ERR_NOMEM` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_NOMEM` + * Out of memory. +- * :enum:`NGHTTP2_ERR_INVALID_STATE` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_INVALID_STATE` + * The |session| is initialized as client. + */ + NGHTTP2_EXTERN int nghttp2_submit_shutdown_notice(nghttp2_session *session); +@@ -3446,7 +3537,7 @@ NGHTTP2_EXTERN uint32_t nghttp2_session_get_local_settings( + * This function returns 0 if it succeeds, or one of the following + * negative error codes: + * +- * :enum:`NGHTTP2_ERR_INVALID_ARGUMENT` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_INVALID_ARGUMENT` + * The |next_stream_id| is strictly less than the value + * `nghttp2_session_get_next_stream_id()` returns; or + * |next_stream_id| is invalid (e.g., even integer for client, or +@@ -3481,11 +3572,11 @@ nghttp2_session_get_next_stream_id(nghttp2_session *session); + * This function returns 0 if it succeeds, or one of the following + * negative error codes: + * +- * :enum:`NGHTTP2_ERR_NOMEM` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_NOMEM` + * Out of memory. +- * :enum:`NGHTTP2_ERR_INVALID_ARGUMENT` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_INVALID_ARGUMENT` + * The |stream_id| is 0. +- * :enum:`NGHTTP2_ERR_INVALID_STATE` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_INVALID_STATE` + * Automatic WINDOW_UPDATE is not disabled. + */ + NGHTTP2_EXTERN int nghttp2_session_consume(nghttp2_session *session, +@@ -3502,9 +3593,9 @@ NGHTTP2_EXTERN int nghttp2_session_consume(nghttp2_session *session, + * This function returns 0 if it succeeds, or one of the following + * negative error codes: + * +- * :enum:`NGHTTP2_ERR_NOMEM` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_NOMEM` + * Out of memory. +- * :enum:`NGHTTP2_ERR_INVALID_STATE` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_INVALID_STATE` + * Automatic WINDOW_UPDATE is not disabled. + */ + NGHTTP2_EXTERN int nghttp2_session_consume_connection(nghttp2_session *session, +@@ -3521,11 +3612,11 @@ NGHTTP2_EXTERN int nghttp2_session_consume_connection(nghttp2_session *session, + * This function returns 0 if it succeeds, or one of the following + * negative error codes: + * +- * :enum:`NGHTTP2_ERR_NOMEM` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_NOMEM` + * Out of memory. +- * :enum:`NGHTTP2_ERR_INVALID_ARGUMENT` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_INVALID_ARGUMENT` + * The |stream_id| is 0. +- * :enum:`NGHTTP2_ERR_INVALID_STATE` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_INVALID_STATE` + * Automatic WINDOW_UPDATE is not disabled. + */ + NGHTTP2_EXTERN int nghttp2_session_consume_stream(nghttp2_session *session, +@@ -3552,12 +3643,17 @@ NGHTTP2_EXTERN int nghttp2_session_consume_stream(nghttp2_session *session, + * found, we use default priority instead of given |pri_spec|. That + * is make stream depend on root stream with weight 16. + * ++ * If ++ * :enum:`nghttp2_settings_id.NGHTTP2_SETTINGS_NO_RFC7540_PRIORITIES` ++ * of value of 1 is submitted via `nghttp2_submit_settings()`, this ++ * function does nothing and returns 0. ++ * + * This function returns 0 if it succeeds, or one of the following + * negative error codes: + * +- * :enum:`NGHTTP2_ERR_NOMEM` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_NOMEM` + * Out of memory. +- * :enum:`NGHTTP2_ERR_INVALID_ARGUMENT` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_INVALID_ARGUMENT` + * Attempted to depend on itself; or no stream exist for the given + * |stream_id|; or |stream_id| is 0 + */ +@@ -3595,12 +3691,17 @@ nghttp2_session_change_stream_priority(nghttp2_session *session, + * found, we use default priority instead of given |pri_spec|. That + * is make stream depend on root stream with weight 16. + * ++ * If ++ * :enum:`nghttp2_settings_id.NGHTTP2_SETTINGS_NO_RFC7540_PRIORITIES` ++ * of value of 1 is submitted via `nghttp2_submit_settings()`, this ++ * function does nothing and returns 0. ++ * + * This function returns 0 if it succeeds, or one of the following + * negative error codes: + * +- * :enum:`NGHTTP2_ERR_NOMEM` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_NOMEM` + * Out of memory. +- * :enum:`NGHTTP2_ERR_INVALID_ARGUMENT` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_INVALID_ARGUMENT` + * Attempted to depend on itself; or stream denoted by |stream_id| + * already exists; or |stream_id| cannot be used to create idle + * stream (in other words, local endpoint has already opened +@@ -3651,11 +3752,11 @@ nghttp2_session_create_idle_stream(nghttp2_session *session, int32_t stream_id, + * This function returns 0 if it succeeds, or one of the following + * negative error codes: + * +- * :enum:`NGHTTP2_ERR_NOMEM` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_NOMEM` + * Out of memory. +- * :enum:`NGHTTP2_ERR_INVALID_ARGUMENT` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_INVALID_ARGUMENT` + * The |settings_payload| is badly formed. +- * :enum:`NGHTTP2_ERR_PROTO` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_PROTO` + * The stream ID 1 is already used or closed; or is not available. + */ + NGHTTP2_EXTERN int nghttp2_session_upgrade(nghttp2_session *session, +@@ -3695,11 +3796,11 @@ NGHTTP2_EXTERN int nghttp2_session_upgrade(nghttp2_session *session, + * This function returns 0 if it succeeds, or one of the following + * negative error codes: + * +- * :enum:`NGHTTP2_ERR_NOMEM` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_NOMEM` + * Out of memory. +- * :enum:`NGHTTP2_ERR_INVALID_ARGUMENT` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_INVALID_ARGUMENT` + * The |settings_payload| is badly formed. +- * :enum:`NGHTTP2_ERR_PROTO` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_PROTO` + * The stream ID 1 is already used or closed; or is not available. + */ + NGHTTP2_EXTERN int nghttp2_session_upgrade2(nghttp2_session *session, +@@ -3723,10 +3824,10 @@ NGHTTP2_EXTERN int nghttp2_session_upgrade2(nghttp2_session *session, + * This function returns the number of bytes written in |buf|, or one + * of the following negative error codes: + * +- * :enum:`NGHTTP2_ERR_INVALID_ARGUMENT` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_INVALID_ARGUMENT` + * The |iv| contains duplicate settings ID or invalid value. + * +- * :enum:`NGHTTP2_ERR_INSUFF_BUFSIZE` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_INSUFF_BUFSIZE` + * The provided |buflen| size is too small to hold the output. + */ + NGHTTP2_EXTERN ssize_t nghttp2_pack_settings_payload( +@@ -3757,8 +3858,8 @@ NGHTTP2_EXTERN const char *nghttp2_http2_strerror(uint32_t error_code); + * on with |weight| and its exclusive flag. If |exclusive| is + * nonzero, exclusive flag is set. + * +- * The |weight| must be in [:enum:`NGHTTP2_MIN_WEIGHT`, +- * :enum:`NGHTTP2_MAX_WEIGHT`], inclusive. ++ * The |weight| must be in [:macro:`NGHTTP2_MIN_WEIGHT`, ++ * :macro:`NGHTTP2_MAX_WEIGHT`], inclusive. + */ + NGHTTP2_EXTERN void nghttp2_priority_spec_init(nghttp2_priority_spec *pri_spec, + int32_t stream_id, +@@ -3793,11 +3894,17 @@ nghttp2_priority_spec_check_default(const nghttp2_priority_spec *pri_spec); + * use `nghttp2_priority_spec_init()`. If |pri_spec| is not ``NULL``, + * this function will copy its data members. + * +- * The ``pri_spec->weight`` must be in [:enum:`NGHTTP2_MIN_WEIGHT`, +- * :enum:`NGHTTP2_MAX_WEIGHT`], inclusive. If ``pri_spec->weight`` is +- * strictly less than :enum:`NGHTTP2_MIN_WEIGHT`, it becomes +- * :enum:`NGHTTP2_MIN_WEIGHT`. If it is strictly greater than +- * :enum:`NGHTTP2_MAX_WEIGHT`, it becomes :enum:`NGHTTP2_MAX_WEIGHT`. ++ * The ``pri_spec->weight`` must be in [:macro:`NGHTTP2_MIN_WEIGHT`, ++ * :macro:`NGHTTP2_MAX_WEIGHT`], inclusive. If ``pri_spec->weight`` ++ * is strictly less than :macro:`NGHTTP2_MIN_WEIGHT`, it becomes ++ * :macro:`NGHTTP2_MIN_WEIGHT`. If it is strictly greater than ++ * :macro:`NGHTTP2_MAX_WEIGHT`, it becomes ++ * :macro:`NGHTTP2_MAX_WEIGHT`. ++ * ++ * If ++ * :enum:`nghttp2_settings_id.NGHTTP2_SETTINGS_NO_RFC7540_PRIORITIES` ++ * of value of 1 is received by a remote endpoint, |pri_spec| is ++ * ignored, and treated as if ``NULL`` is specified. + * + * The |nva| is an array of name/value pair :type:`nghttp2_nv` with + * |nvlen| elements. The application is responsible to include +@@ -3808,12 +3915,12 @@ nghttp2_priority_spec_check_default(const nghttp2_priority_spec *pri_spec); + * This function creates copies of all name/value pairs in |nva|. It + * also lower-cases all names in |nva|. The order of elements in + * |nva| is preserved. For header fields with +- * :enum:`NGHTTP2_NV_FLAG_NO_COPY_NAME` and +- * :enum:`NGHTTP2_NV_FLAG_NO_COPY_VALUE` are set, header field name +- * and value are not copied respectively. With +- * :enum:`NGHTTP2_NV_FLAG_NO_COPY_NAME`, application is responsible to +- * pass header field name in lowercase. The application should +- * maintain the references to them until ++ * :enum:`nghttp2_nv_flag.NGHTTP2_NV_FLAG_NO_COPY_NAME` and ++ * :enum:`nghttp2_nv_flag.NGHTTP2_NV_FLAG_NO_COPY_VALUE` are set, ++ * header field name and value are not copied respectively. With ++ * :enum:`nghttp2_nv_flag.NGHTTP2_NV_FLAG_NO_COPY_NAME`, application ++ * is responsible to pass header field name in lowercase. The ++ * application should maintain the references to them until + * :type:`nghttp2_on_frame_send_callback` or + * :type:`nghttp2_on_frame_not_send_callback` is called. + * +@@ -3835,15 +3942,15 @@ nghttp2_priority_spec_check_default(const nghttp2_priority_spec *pri_spec); + * This function returns assigned stream ID if it succeeds, or one of + * the following negative error codes: + * +- * :enum:`NGHTTP2_ERR_NOMEM` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_NOMEM` + * Out of memory. +- * :enum:`NGHTTP2_ERR_STREAM_ID_NOT_AVAILABLE` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_STREAM_ID_NOT_AVAILABLE` + * No stream ID is available because maximum stream ID was + * reached. +- * :enum:`NGHTTP2_ERR_INVALID_ARGUMENT` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_INVALID_ARGUMENT` + * Trying to depend on itself (new stream ID equals + * ``pri_spec->stream_id``). +- * :enum:`NGHTTP2_ERR_PROTO` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_PROTO` + * The |session| is server session. + * + * .. warning:: +@@ -3878,12 +3985,12 @@ NGHTTP2_EXTERN int32_t nghttp2_submit_request( + * This function creates copies of all name/value pairs in |nva|. It + * also lower-cases all names in |nva|. The order of elements in + * |nva| is preserved. For header fields with +- * :enum:`NGHTTP2_NV_FLAG_NO_COPY_NAME` and +- * :enum:`NGHTTP2_NV_FLAG_NO_COPY_VALUE` are set, header field name +- * and value are not copied respectively. With +- * :enum:`NGHTTP2_NV_FLAG_NO_COPY_NAME`, application is responsible to +- * pass header field name in lowercase. The application should +- * maintain the references to them until ++ * :enum:`nghttp2_nv_flag.NGHTTP2_NV_FLAG_NO_COPY_NAME` and ++ * :enum:`nghttp2_nv_flag.NGHTTP2_NV_FLAG_NO_COPY_VALUE` are set, ++ * header field name and value are not copied respectively. With ++ * :enum:`nghttp2_nv_flag.NGHTTP2_NV_FLAG_NO_COPY_NAME`, application ++ * is responsible to pass header field name in lowercase. The ++ * application should maintain the references to them until + * :type:`nghttp2_on_frame_send_callback` or + * :type:`nghttp2_on_frame_not_send_callback` is called. + * +@@ -3909,16 +4016,16 @@ NGHTTP2_EXTERN int32_t nghttp2_submit_request( + * This function returns 0 if it succeeds, or one of the following + * negative error codes: + * +- * :enum:`NGHTTP2_ERR_NOMEM` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_NOMEM` + * Out of memory. +- * :enum:`NGHTTP2_ERR_INVALID_ARGUMENT` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_INVALID_ARGUMENT` + * The |stream_id| is 0. +- * :enum:`NGHTTP2_ERR_DATA_EXIST` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_DATA_EXIST` + * DATA or HEADERS has been already submitted and not fully + * processed yet. Normally, this does not happen, but when + * application wrongly calls `nghttp2_submit_response()` twice, + * this may happen. +- * :enum:`NGHTTP2_ERR_PROTO` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_PROTO` + * The |session| is client session. + * + * .. warning:: +@@ -3944,12 +4051,12 @@ nghttp2_submit_response(nghttp2_session *session, int32_t stream_id, + * This function creates copies of all name/value pairs in |nva|. It + * also lower-cases all names in |nva|. The order of elements in + * |nva| is preserved. For header fields with +- * :enum:`NGHTTP2_NV_FLAG_NO_COPY_NAME` and +- * :enum:`NGHTTP2_NV_FLAG_NO_COPY_VALUE` are set, header field name +- * and value are not copied respectively. With +- * :enum:`NGHTTP2_NV_FLAG_NO_COPY_NAME`, application is responsible to +- * pass header field name in lowercase. The application should +- * maintain the references to them until ++ * :enum:`nghttp2_nv_flag.NGHTTP2_NV_FLAG_NO_COPY_NAME` and ++ * :enum:`nghttp2_nv_flag.NGHTTP2_NV_FLAG_NO_COPY_VALUE` are set, ++ * header field name and value are not copied respectively. With ++ * :enum:`nghttp2_nv_flag.NGHTTP2_NV_FLAG_NO_COPY_NAME`, application ++ * is responsible to pass header field name in lowercase. The ++ * application should maintain the references to them until + * :type:`nghttp2_on_frame_send_callback` or + * :type:`nghttp2_on_frame_not_send_callback` is called. + * +@@ -3961,16 +4068,16 @@ nghttp2_submit_response(nghttp2_session *session, int32_t stream_id, + * |nva| will be sent as response headers, which will result in error. + * + * This function has the same effect with `nghttp2_submit_headers()`, +- * with flags = :enum:`NGHTTP2_FLAG_END_STREAM` and both pri_spec and +- * stream_user_data to NULL. ++ * with flags = :enum:`nghttp2_flag.NGHTTP2_FLAG_END_STREAM` and both ++ * pri_spec and stream_user_data to NULL. + * + * To submit trailer fields after `nghttp2_submit_response()` is + * called, the application has to specify + * :type:`nghttp2_data_provider` to `nghttp2_submit_response()`. + * Inside of :type:`nghttp2_data_source_read_callback`, when setting +- * :enum:`NGHTTP2_DATA_FLAG_EOF`, also set +- * :enum:`NGHTTP2_DATA_FLAG_NO_END_STREAM`. After that, the +- * application can send trailer fields using ++ * :enum:`nghttp2_data_flag.NGHTTP2_DATA_FLAG_EOF`, also set ++ * :enum:`nghttp2_data_flag.NGHTTP2_DATA_FLAG_NO_END_STREAM`. After ++ * that, the application can send trailer fields using + * `nghttp2_submit_trailer()`. `nghttp2_submit_trailer()` can be used + * inside :type:`nghttp2_data_source_read_callback`. + * +@@ -3978,9 +4085,9 @@ nghttp2_submit_response(nghttp2_session *session, int32_t stream_id, + * Otherwise, this function returns 0 if it succeeds, or one of the + * following negative error codes: + * +- * :enum:`NGHTTP2_ERR_NOMEM` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_NOMEM` + * Out of memory. +- * :enum:`NGHTTP2_ERR_INVALID_ARGUMENT` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_INVALID_ARGUMENT` + * The |stream_id| is 0. + */ + NGHTTP2_EXTERN int nghttp2_submit_trailer(nghttp2_session *session, +@@ -3993,10 +4100,10 @@ NGHTTP2_EXTERN int nghttp2_submit_trailer(nghttp2_session *session, + * Submits HEADERS frame. The |flags| is bitwise OR of the + * following values: + * +- * * :enum:`NGHTTP2_FLAG_END_STREAM` ++ * * :enum:`nghttp2_flag.NGHTTP2_FLAG_END_STREAM` + * +- * If |flags| includes :enum:`NGHTTP2_FLAG_END_STREAM`, this frame has +- * END_STREAM flag set. ++ * If |flags| includes :enum:`nghttp2_flag.NGHTTP2_FLAG_END_STREAM`, ++ * this frame has END_STREAM flag set. + * + * The library handles the CONTINUATION frame internally and it + * correctly sets END_HEADERS to the last sequence of the PUSH_PROMISE +@@ -4013,11 +4120,16 @@ NGHTTP2_EXTERN int nghttp2_submit_trailer(nghttp2_session *session, + * use `nghttp2_priority_spec_init()`. If |pri_spec| is not ``NULL``, + * this function will copy its data members. + * +- * The ``pri_spec->weight`` must be in [:enum:`NGHTTP2_MIN_WEIGHT`, +- * :enum:`NGHTTP2_MAX_WEIGHT`], inclusive. If ``pri_spec->weight`` is +- * strictly less than :enum:`NGHTTP2_MIN_WEIGHT`, it becomes +- * :enum:`NGHTTP2_MIN_WEIGHT`. If it is strictly greater than +- * :enum:`NGHTTP2_MAX_WEIGHT`, it becomes :enum:`NGHTTP2_MAX_WEIGHT`. ++ * The ``pri_spec->weight`` must be in [:macro:`NGHTTP2_MIN_WEIGHT`, ++ * :macro:`NGHTTP2_MAX_WEIGHT`], inclusive. If ``pri_spec->weight`` ++ * is strictly less than :macro:`NGHTTP2_MIN_WEIGHT`, it becomes ++ * :macro:`NGHTTP2_MIN_WEIGHT`. If it is strictly greater than ++ * :macro:`NGHTTP2_MAX_WEIGHT`, it becomes :macro:`NGHTTP2_MAX_WEIGHT`. ++ * ++ * If ++ * :enum:`nghttp2_settings_id.NGHTTP2_SETTINGS_NO_RFC7540_PRIORITIES` ++ * of value of 1 is received by a remote endpoint, |pri_spec| is ++ * ignored, and treated as if ``NULL`` is specified. + * + * The |nva| is an array of name/value pair :type:`nghttp2_nv` with + * |nvlen| elements. The application is responsible to include +@@ -4028,12 +4140,12 @@ NGHTTP2_EXTERN int nghttp2_submit_trailer(nghttp2_session *session, + * This function creates copies of all name/value pairs in |nva|. It + * also lower-cases all names in |nva|. The order of elements in + * |nva| is preserved. For header fields with +- * :enum:`NGHTTP2_NV_FLAG_NO_COPY_NAME` and +- * :enum:`NGHTTP2_NV_FLAG_NO_COPY_VALUE` are set, header field name +- * and value are not copied respectively. With +- * :enum:`NGHTTP2_NV_FLAG_NO_COPY_NAME`, application is responsible to +- * pass header field name in lowercase. The application should +- * maintain the references to them until ++ * :enum:`nghttp2_nv_flag.NGHTTP2_NV_FLAG_NO_COPY_NAME` and ++ * :enum:`nghttp2_nv_flag.NGHTTP2_NV_FLAG_NO_COPY_VALUE` are set, ++ * header field name and value are not copied respectively. With ++ * :enum:`nghttp2_nv_flag.NGHTTP2_NV_FLAG_NO_COPY_NAME`, application ++ * is responsible to pass header field name in lowercase. The ++ * application should maintain the references to them until + * :type:`nghttp2_on_frame_send_callback` or + * :type:`nghttp2_on_frame_not_send_callback` is called. + * +@@ -4051,19 +4163,19 @@ NGHTTP2_EXTERN int nghttp2_submit_trailer(nghttp2_session *session, + * |stream_id| is -1. Otherwise, this function returns 0 if it + * succeeds, or one of the following negative error codes: + * +- * :enum:`NGHTTP2_ERR_NOMEM` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_NOMEM` + * Out of memory. +- * :enum:`NGHTTP2_ERR_STREAM_ID_NOT_AVAILABLE` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_STREAM_ID_NOT_AVAILABLE` + * No stream ID is available because maximum stream ID was + * reached. +- * :enum:`NGHTTP2_ERR_INVALID_ARGUMENT` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_INVALID_ARGUMENT` + * The |stream_id| is 0; or trying to depend on itself (stream ID + * equals ``pri_spec->stream_id``). +- * :enum:`NGHTTP2_ERR_DATA_EXIST` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_DATA_EXIST` + * DATA or HEADERS has been already submitted and not fully + * processed yet. This happens if stream denoted by |stream_id| + * is in reserved state. +- * :enum:`NGHTTP2_ERR_PROTO` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_PROTO` + * The |stream_id| is -1, and |session| is server session. + * + * .. warning:: +@@ -4085,8 +4197,8 @@ NGHTTP2_EXTERN int32_t nghttp2_submit_headers( + * + * Submits one or more DATA frames to the stream |stream_id|. The + * data to be sent are provided by |data_prd|. If |flags| contains +- * :enum:`NGHTTP2_FLAG_END_STREAM`, the last DATA frame has END_STREAM +- * flag set. ++ * :enum:`nghttp2_flag.NGHTTP2_FLAG_END_STREAM`, the last DATA frame ++ * has END_STREAM flag set. + * + * This function does not take ownership of the |data_prd|. The + * function copies the members of the |data_prd|. +@@ -4094,27 +4206,28 @@ NGHTTP2_EXTERN int32_t nghttp2_submit_headers( + * This function returns 0 if it succeeds, or one of the following + * negative error codes: + * +- * :enum:`NGHTTP2_ERR_NOMEM` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_NOMEM` + * Out of memory. +- * :enum:`NGHTTP2_ERR_DATA_EXIST` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_DATA_EXIST` + * DATA or HEADERS has been already submitted and not fully + * processed yet. +- * :enum:`NGHTTP2_ERR_INVALID_ARGUMENT` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_INVALID_ARGUMENT` + * The |stream_id| is 0. +- * :enum:`NGHTTP2_ERR_STREAM_CLOSED` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_STREAM_CLOSED` + * The stream was already closed; or the |stream_id| is invalid. + * + * .. note:: + * + * Currently, only one DATA or HEADERS is allowed for a stream at a + * time. Submitting these frames more than once before first DATA +- * or HEADERS is finished results in :enum:`NGHTTP2_ERR_DATA_EXIST` +- * error code. The earliest callback which tells that previous +- * frame is done is :type:`nghttp2_on_frame_send_callback`. In side +- * that callback, new data can be submitted using +- * `nghttp2_submit_data()`. Of course, all data except for last one +- * must not have :enum:`NGHTTP2_FLAG_END_STREAM` flag set in +- * |flags|. This sounds a bit complicated, and we recommend to use ++ * or HEADERS is finished results in ++ * :enum:`nghttp2_error.NGHTTP2_ERR_DATA_EXIST` error code. The ++ * earliest callback which tells that previous frame is done is ++ * :type:`nghttp2_on_frame_send_callback`. In side that callback, ++ * new data can be submitted using `nghttp2_submit_data()`. Of ++ * course, all data except for last one must not have ++ * :enum:`nghttp2_flag.NGHTTP2_FLAG_END_STREAM` flag set in |flags|. ++ * This sounds a bit complicated, and we recommend to use + * `nghttp2_submit_request()` and `nghttp2_submit_response()` to + * avoid this cascading issue. The experience shows that for HTTP + * use, these two functions are enough to implement both client and +@@ -4131,25 +4244,31 @@ NGHTTP2_EXTERN int nghttp2_submit_data(nghttp2_session *session, uint8_t flags, + * to the priority specification |pri_spec|. + * + * The |flags| is currently ignored and should be +- * :enum:`NGHTTP2_FLAG_NONE`. ++ * :enum:`nghttp2_flag.NGHTTP2_FLAG_NONE`. + * + * The |pri_spec| is priority specification of this request. ``NULL`` + * is not allowed for this function. To specify the priority, use + * `nghttp2_priority_spec_init()`. This function will copy its data + * members. + * +- * The ``pri_spec->weight`` must be in [:enum:`NGHTTP2_MIN_WEIGHT`, +- * :enum:`NGHTTP2_MAX_WEIGHT`], inclusive. If ``pri_spec->weight`` is +- * strictly less than :enum:`NGHTTP2_MIN_WEIGHT`, it becomes +- * :enum:`NGHTTP2_MIN_WEIGHT`. If it is strictly greater than +- * :enum:`NGHTTP2_MAX_WEIGHT`, it becomes :enum:`NGHTTP2_MAX_WEIGHT`. ++ * The ``pri_spec->weight`` must be in [:macro:`NGHTTP2_MIN_WEIGHT`, ++ * :macro:`NGHTTP2_MAX_WEIGHT`], inclusive. If ``pri_spec->weight`` ++ * is strictly less than :macro:`NGHTTP2_MIN_WEIGHT`, it becomes ++ * :macro:`NGHTTP2_MIN_WEIGHT`. If it is strictly greater than ++ * :macro:`NGHTTP2_MAX_WEIGHT`, it becomes ++ * :macro:`NGHTTP2_MAX_WEIGHT`. ++ * ++ * If ++ * :enum:`nghttp2_settings_id.NGHTTP2_SETTINGS_NO_RFC7540_PRIORITIES` ++ * of value of 1 is received by a remote endpoint, this function does ++ * nothing and returns 0. + * + * This function returns 0 if it succeeds, or one of the following + * negative error codes: + * +- * :enum:`NGHTTP2_ERR_NOMEM` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_NOMEM` + * Out of memory. +- * :enum:`NGHTTP2_ERR_INVALID_ARGUMENT` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_INVALID_ARGUMENT` + * The |stream_id| is 0; or the |pri_spec| is NULL; or trying to + * depend on itself. + */ +@@ -4158,6 +4277,61 @@ nghttp2_submit_priority(nghttp2_session *session, uint8_t flags, + int32_t stream_id, + const nghttp2_priority_spec *pri_spec); + ++/** ++ * @macro ++ * ++ * :macro:`NGHTTP2_EXTPRI_DEFAULT_URGENCY` is the default urgency ++ * level for :rfc:`9218` extensible priorities. ++ */ ++#define NGHTTP2_EXTPRI_DEFAULT_URGENCY 3 ++ ++/** ++ * @macro ++ * ++ * :macro:`NGHTTP2_EXTPRI_URGENCY_HIGH` is the highest urgency level ++ * for :rfc:`9218` extensible priorities. ++ */ ++#define NGHTTP2_EXTPRI_URGENCY_HIGH 0 ++ ++/** ++ * @macro ++ * ++ * :macro:`NGHTTP2_EXTPRI_URGENCY_LOW` is the lowest urgency level for ++ * :rfc:`9218` extensible priorities. ++ */ ++#define NGHTTP2_EXTPRI_URGENCY_LOW 7 ++ ++/** ++ * @macro ++ * ++ * :macro:`NGHTTP2_EXTPRI_URGENCY_LEVELS` is the number of urgency ++ * levels for :rfc:`9218` extensible priorities. ++ */ ++#define NGHTTP2_EXTPRI_URGENCY_LEVELS (NGHTTP2_EXTPRI_URGENCY_LOW + 1) ++ ++/** ++ * @struct ++ * ++ * :type:`nghttp2_extpri` is :rfc:`9218` extensible priorities ++ * specification for a stream. ++ */ ++typedef struct nghttp2_extpri { ++ /** ++ * :member:`urgency` is the urgency of a stream, it must be in ++ * [:macro:`NGHTTP2_EXTPRI_URGENCY_HIGH`, ++ * :macro:`NGHTTP2_EXTPRI_URGENCY_LOW`], inclusive, and 0 is the ++ * highest urgency. ++ */ ++ uint32_t urgency; ++ /** ++ * :member:`inc` indicates that a content can be processed ++ * incrementally or not. If inc is 0, it cannot be processed ++ * incrementally. If inc is 1, it can be processed incrementally. ++ * Other value is not permitted. ++ */ ++ int inc; ++} nghttp2_extpri; ++ + /** + * @function + * +@@ -4167,14 +4341,14 @@ nghttp2_submit_priority(nghttp2_session *session, uint8_t flags, + * The pre-defined error code is one of :enum:`nghttp2_error_code`. + * + * The |flags| is currently ignored and should be +- * :enum:`NGHTTP2_FLAG_NONE`. ++ * :enum:`nghttp2_flag.NGHTTP2_FLAG_NONE`. + * + * This function returns 0 if it succeeds, or one of the following + * negative error codes: + * +- * :enum:`NGHTTP2_ERR_NOMEM` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_NOMEM` + * Out of memory. +- * :enum:`NGHTTP2_ERR_INVALID_ARGUMENT` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_INVALID_ARGUMENT` + * The |stream_id| is 0. + */ + NGHTTP2_EXTERN int nghttp2_submit_rst_stream(nghttp2_session *session, +@@ -4189,7 +4363,7 @@ NGHTTP2_EXTERN int nghttp2_submit_rst_stream(nghttp2_session *session, + * indicates the number of :type:`nghttp2_settings_entry`. + * + * The |flags| is currently ignored and should be +- * :enum:`NGHTTP2_FLAG_NONE`. ++ * :enum:`nghttp2_flag.NGHTTP2_FLAG_NONE`. + * + * This function does not take ownership of the |iv|. This function + * copies all the elements in the |iv|. +@@ -4198,16 +4372,17 @@ NGHTTP2_EXTERN int nghttp2_submit_rst_stream(nghttp2_session *session, + * size becomes strictly larger than NGHTTP2_MAX_WINDOW_SIZE, + * RST_STREAM is issued against such a stream. + * +- * SETTINGS with :enum:`NGHTTP2_FLAG_ACK` is automatically submitted +- * by the library and application could not send it at its will. ++ * SETTINGS with :enum:`nghttp2_flag.NGHTTP2_FLAG_ACK` is ++ * automatically submitted by the library and application could not ++ * send it at its will. + * + * This function returns 0 if it succeeds, or one of the following + * negative error codes: + * +- * :enum:`NGHTTP2_ERR_INVALID_ARGUMENT` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_INVALID_ARGUMENT` + * The |iv| contains invalid value (e.g., initial window size + * strictly greater than (1 << 31) - 1. +- * :enum:`NGHTTP2_ERR_NOMEM` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_NOMEM` + * Out of memory. + */ + NGHTTP2_EXTERN int nghttp2_submit_settings(nghttp2_session *session, +@@ -4235,12 +4410,12 @@ NGHTTP2_EXTERN int nghttp2_submit_settings(nghttp2_session *session, + * This function creates copies of all name/value pairs in |nva|. It + * also lower-cases all names in |nva|. The order of elements in + * |nva| is preserved. For header fields with +- * :enum:`NGHTTP2_NV_FLAG_NO_COPY_NAME` and +- * :enum:`NGHTTP2_NV_FLAG_NO_COPY_VALUE` are set, header field name +- * and value are not copied respectively. With +- * :enum:`NGHTTP2_NV_FLAG_NO_COPY_NAME`, application is responsible to +- * pass header field name in lowercase. The application should +- * maintain the references to them until ++ * :enum:`nghttp2_nv_flag.NGHTTP2_NV_FLAG_NO_COPY_NAME` and ++ * :enum:`nghttp2_nv_flag.NGHTTP2_NV_FLAG_NO_COPY_VALUE` are set, ++ * header field name and value are not copied respectively. With ++ * :enum:`nghttp2_nv_flag.NGHTTP2_NV_FLAG_NO_COPY_NAME`, application ++ * is responsible to pass header field name in lowercase. The ++ * application should maintain the references to them until + * :type:`nghttp2_on_frame_send_callback` or + * :type:`nghttp2_on_frame_not_send_callback` is called. + * +@@ -4259,18 +4434,18 @@ NGHTTP2_EXTERN int nghttp2_submit_settings(nghttp2_session *session, + * This function returns assigned promised stream ID if it succeeds, + * or one of the following negative error codes: + * +- * :enum:`NGHTTP2_ERR_NOMEM` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_NOMEM` + * Out of memory. +- * :enum:`NGHTTP2_ERR_PROTO` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_PROTO` + * This function was invoked when |session| is initialized as + * client. +- * :enum:`NGHTTP2_ERR_STREAM_ID_NOT_AVAILABLE` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_STREAM_ID_NOT_AVAILABLE` + * No stream ID is available because maximum stream ID was + * reached. +- * :enum:`NGHTTP2_ERR_INVALID_ARGUMENT` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_INVALID_ARGUMENT` + * The |stream_id| is 0; The |stream_id| does not designate stream + * that peer initiated. +- * :enum:`NGHTTP2_ERR_STREAM_CLOSED` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_STREAM_CLOSED` + * The stream was already closed; or the |stream_id| is invalid. + * + * .. warning:: +@@ -4299,10 +4474,10 @@ NGHTTP2_EXTERN int32_t nghttp2_submit_push_promise( + * + * The |flags| is bitwise OR of 0 or more of the following value. + * +- * * :enum:`NGHTTP2_FLAG_ACK` ++ * * :enum:`nghttp2_flag.NGHTTP2_FLAG_ACK` + * + * Unless `nghttp2_option_set_no_auto_ping_ack()` is used, the |flags| +- * should be :enum:`NGHTTP2_FLAG_NONE`. ++ * should be :enum:`nghttp2_flag.NGHTTP2_FLAG_NONE`. + * + * If the |opaque_data| is non ``NULL``, then it should point to the 8 + * bytes array of memory to specify opaque data to send with PING +@@ -4312,7 +4487,7 @@ NGHTTP2_EXTERN int32_t nghttp2_submit_push_promise( + * This function returns 0 if it succeeds, or one of the following + * negative error codes: + * +- * :enum:`NGHTTP2_ERR_NOMEM` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_NOMEM` + * Out of memory. + */ + NGHTTP2_EXTERN int nghttp2_submit_ping(nghttp2_session *session, uint8_t flags, +@@ -4327,7 +4502,7 @@ NGHTTP2_EXTERN int nghttp2_submit_ping(nghttp2_session *session, uint8_t flags, + * The pre-defined error code is one of :enum:`nghttp2_error_code`. + * + * The |flags| is currently ignored and should be +- * :enum:`NGHTTP2_FLAG_NONE`. ++ * :enum:`nghttp2_flag.NGHTTP2_FLAG_NONE`. + * + * The |last_stream_id| is peer's stream ID or 0. So if |session| is + * initialized as client, |last_stream_id| must be even or 0. If +@@ -4357,9 +4532,9 @@ NGHTTP2_EXTERN int nghttp2_submit_ping(nghttp2_session *session, uint8_t flags, + * This function returns 0 if it succeeds, or one of the following + * negative error codes: + * +- * :enum:`NGHTTP2_ERR_NOMEM` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_NOMEM` + * Out of memory. +- * :enum:`NGHTTP2_ERR_INVALID_ARGUMENT` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_INVALID_ARGUMENT` + * The |opaque_data_len| is too large; the |last_stream_id| is + * invalid. + */ +@@ -4415,7 +4590,7 @@ nghttp2_session_check_server_session(nghttp2_session *session); + * Submits WINDOW_UPDATE frame. + * + * The |flags| is currently ignored and should be +- * :enum:`NGHTTP2_FLAG_NONE`. ++ * :enum:`nghttp2_flag.NGHTTP2_FLAG_NONE`. + * + * The |stream_id| is the stream ID to send this WINDOW_UPDATE. To + * send connection level WINDOW_UPDATE, specify 0 to |stream_id|. +@@ -4442,9 +4617,9 @@ nghttp2_session_check_server_session(nghttp2_session *session); + * This function returns 0 if it succeeds, or one of the following + * negative error codes: + * +- * :enum:`NGHTTP2_ERR_FLOW_CONTROL` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_FLOW_CONTROL` + * The local window size overflow or gets negative. +- * :enum:`NGHTTP2_ERR_NOMEM` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_NOMEM` + * Out of memory. + */ + NGHTTP2_EXTERN int nghttp2_submit_window_update(nghttp2_session *session, +@@ -4462,7 +4637,7 @@ NGHTTP2_EXTERN int nghttp2_submit_window_update(nghttp2_session *session, + * to transmission queue. + * + * The |flags| is currently ignored and should be +- * :enum:`NGHTTP2_FLAG_NONE`. ++ * :enum:`nghttp2_flag.NGHTTP2_FLAG_NONE`. + * + * This sounds similar to `nghttp2_submit_window_update()`, but there + * are 2 differences. The first difference is that this function +@@ -4481,9 +4656,9 @@ NGHTTP2_EXTERN int nghttp2_submit_window_update(nghttp2_session *session, + * This function returns 0 if it succeeds, or one of the following + * negative error codes: + * +- * :enum:`NGHTTP2_ERR_INVALID_ARGUMENT` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_INVALID_ARGUMENT` + * The |stream_id| is negative. +- * :enum:`NGHTTP2_ERR_NOMEM` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_NOMEM` + * Out of memory. + */ + NGHTTP2_EXTERN int +@@ -4514,18 +4689,19 @@ nghttp2_session_set_local_window_size(nghttp2_session *session, uint8_t flags, + * + * The standard HTTP/2 frame cannot be sent with this function, so + * |type| must be strictly grater than 0x9. Otherwise, this function +- * will fail with error code :enum:`NGHTTP2_ERR_INVALID_ARGUMENT`. ++ * will fail with error code ++ * :enum:`nghttp2_error.NGHTTP2_ERR_INVALID_ARGUMENT`. + * + * This function returns 0 if it succeeds, or one of the following + * negative error codes: + * +- * :enum:`NGHTTP2_ERR_INVALID_STATE` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_INVALID_STATE` + * If :type:`nghttp2_pack_extension_callback` is not set. +- * :enum:`NGHTTP2_ERR_INVALID_ARGUMENT` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_INVALID_ARGUMENT` + * If |type| specifies standard HTTP/2 frame type. The frame + * types in the rage [0x0, 0x9], both inclusive, are standard + * HTTP/2 frame type, and cannot be sent using this function. +- * :enum:`NGHTTP2_ERR_NOMEM` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_NOMEM` + * Out of memory + */ + NGHTTP2_EXTERN int nghttp2_submit_extension(nghttp2_session *session, +@@ -4539,8 +4715,8 @@ NGHTTP2_EXTERN int nghttp2_submit_extension(nghttp2_session *session, + * extension to HTTP/2. If this frame is received, and + * `nghttp2_option_set_user_recv_extension_type()` is not set, and + * `nghttp2_option_set_builtin_recv_extension_type()` is set for +- * :enum:`NGHTTP2_ALTSVC`, ``nghttp2_extension.payload`` will point to +- * this struct. ++ * :enum:`nghttp2_frame_type.NGHTTP2_ALTSVC`, ++ * ``nghttp2_extension.payload`` will point to this struct. + * + * It has the following members: + */ +@@ -4574,7 +4750,7 @@ typedef struct { + * `RFC 7383 `_. + * + * The |flags| is currently ignored and should be +- * :enum:`NGHTTP2_FLAG_NONE`. ++ * :enum:`nghttp2_flag.NGHTTP2_FLAG_NONE`. + * + * The |origin| points to the origin this alternative service is + * associated with. The |origin_len| is the length of the origin. If +@@ -4584,16 +4760,16 @@ typedef struct { + * + * The ALTSVC frame is only usable from server side. If this function + * is invoked with client side session, this function returns +- * :enum:`NGHTTP2_ERR_INVALID_STATE`. ++ * :enum:`nghttp2_error.NGHTTP2_ERR_INVALID_STATE`. + * + * This function returns 0 if it succeeds, or one of the following + * negative error codes: + * +- * :enum:`NGHTTP2_ERR_NOMEM` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_NOMEM` + * Out of memory +- * :enum:`NGHTTP2_ERR_INVALID_STATE` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_INVALID_STATE` + * The function is called from client side session +- * :enum:`NGHTTP2_ERR_INVALID_ARGUMENT` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_INVALID_ARGUMENT` + * The sum of |origin_len| and |field_value_len| is larger than + * 16382; or |origin_len| is 0 while |stream_id| is 0; or + * |origin_len| is not 0 while |stream_id| is not 0. +@@ -4632,8 +4808,8 @@ typedef struct { + * If this frame is received, and + * `nghttp2_option_set_user_recv_extension_type()` is not set, and + * `nghttp2_option_set_builtin_recv_extension_type()` is set for +- * :enum:`NGHTTP2_ORIGIN`, ``nghttp2_extension.payload`` will point to +- * this struct. ++ * :enum:`nghttp2_frame_type.NGHTTP2_ORIGIN`, ++ * ``nghttp2_extension.payload`` will point to this struct. + * + * It has the following members: + */ +@@ -4657,7 +4833,7 @@ typedef struct { + * `RFC 8336 `_. + * + * The |flags| is currently ignored and should be +- * :enum:`NGHTTP2_FLAG_NONE`. ++ * :enum:`nghttp2_flag.NGHTTP2_FLAG_NONE`. + * + * The |ov| points to the array of origins. The |nov| specifies the + * number of origins included in |ov|. This function creates copies +@@ -4665,13 +4841,13 @@ typedef struct { + * + * The ORIGIN frame is only usable by a server. If this function is + * invoked with client side session, this function returns +- * :enum:`NGHTTP2_ERR_INVALID_STATE`. ++ * :enum:`nghttp2_error.NGHTTP2_ERR_INVALID_STATE`. + * +- * :enum:`NGHTTP2_ERR_NOMEM` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_NOMEM` + * Out of memory +- * :enum:`NGHTTP2_ERR_INVALID_STATE` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_INVALID_STATE` + * The function is called from client side session. +- * :enum:`NGHTTP2_ERR_INVALID_ARGUMENT` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_INVALID_ARGUMENT` + * There are too many origins, or an origin is too large to fit + * into a default frame payload. + */ +@@ -4680,6 +4856,108 @@ NGHTTP2_EXTERN int nghttp2_submit_origin(nghttp2_session *session, + const nghttp2_origin_entry *ov, + size_t nov); + ++/** ++ * @struct ++ * ++ * The payload of PRIORITY_UPDATE frame. PRIORITY_UPDATE frame is a ++ * non-critical extension to HTTP/2. If this frame is received, and ++ * `nghttp2_option_set_user_recv_extension_type()` is not set, and ++ * `nghttp2_option_set_builtin_recv_extension_type()` is set for ++ * :enum:`nghttp2_frame_type.NGHTTP2_PRIORITY_UPDATE`, ++ * ``nghttp2_extension.payload`` will point to this struct. ++ * ++ * It has the following members: ++ */ ++typedef struct { ++ /** ++ * The stream ID of the stream whose priority is updated. ++ */ ++ int32_t stream_id; ++ /** ++ * The pointer to Priority field value. It is not necessarily ++ * NULL-terminated. ++ */ ++ uint8_t *field_value; ++ /** ++ * The length of the :member:`field_value`. ++ */ ++ size_t field_value_len; ++} nghttp2_ext_priority_update; ++ ++/** ++ * @function ++ * ++ * Submits PRIORITY_UPDATE frame. ++ * ++ * PRIORITY_UPDATE frame is a non-critical extension to HTTP/2, and ++ * defined in :rfc:`9218#section-7.1`. ++ * ++ * The |flags| is currently ignored and should be ++ * :enum:`nghttp2_flag.NGHTTP2_FLAG_NONE`. ++ * ++ * The |stream_id| is the ID of stream which is prioritized. The ++ * |field_value| points to the Priority field value. The ++ * |field_value_len| is the length of the Priority field value. ++ * ++ * If this function is called by server, ++ * :enum:`nghttp2_error.NGHTTP2_ERR_INVALID_STATE` is returned. ++ * ++ * If ++ * :enum:`nghttp2_settings_id.NGHTTP2_SETTINGS_NO_RFC7540_PRIORITIES` ++ * of value of 0 is received by a remote endpoint (or it is omitted), ++ * this function does nothing and returns 0. ++ * ++ * This function returns 0 if it succeeds, or one of the following ++ * negative error codes: ++ * ++ * :enum:`nghttp2_error.NGHTTP2_ERR_NOMEM` ++ * Out of memory ++ * :enum:`nghttp2_error.NGHTTP2_ERR_INVALID_STATE` ++ * The function is called from server side session ++ * :enum:`nghttp2_error.NGHTTP2_ERR_INVALID_ARGUMENT` ++ * The |field_value_len| is larger than 16380; or |stream_id| is ++ * 0. ++ */ ++NGHTTP2_EXTERN int nghttp2_submit_priority_update(nghttp2_session *session, ++ uint8_t flags, ++ int32_t stream_id, ++ const uint8_t *field_value, ++ size_t field_value_len); ++ ++/** ++ * @function ++ * ++ * Changes the priority of the existing stream denoted by |stream_id|. ++ * The new priority is |extpri|. This function is meant to be used by ++ * server for :rfc:`9218` extensible prioritization scheme. ++ * ++ * If |session| is initialized as client, this function returns ++ * :enum:`nghttp2_error.NGHTTP2_ERR_INVALID_STATE`. For client, use ++ * `nghttp2_submit_priority_update()` instead. ++ * ++ * If :member:`extpri->urgency ` is out of ++ * bound, it is set to :macro:`NGHTTP2_EXTPRI_URGENCY_LOW`. ++ * ++ * If |ignore_client_signal| is nonzero, server starts to ignore ++ * client priority signals for this stream. ++ * ++ * If ++ * :enum:`nghttp2_settings_id.NGHTTP2_SETTINGS_NO_RFC7540_PRIORITIES` ++ * of value of 1 is not submitted via `nghttp2_submit_settings()`, ++ * this function does nothing and returns 0. ++ * ++ * :enum:`nghttp2_error.NGHTTP2_ERR_NOMEM` ++ * Out of memory. ++ * :enum:`nghttp2_error.NGHTTP2_ERR_INVALID_STATE` ++ * The |session| is initialized as client. ++ * :enum:`nghttp2_error.NGHTTP2_ERR_INVALID_ARGUMENT` ++ * |stream_id| is zero; or a stream denoted by |stream_id| is not ++ * found. ++ */ ++NGHTTP2_EXTERN int nghttp2_session_change_extpri_stream_priority( ++ nghttp2_session *session, int32_t stream_id, const nghttp2_extpri *extpri, ++ int ignore_client_signal); ++ + /** + * @function + * +@@ -4791,13 +5069,51 @@ NGHTTP2_EXTERN int nghttp2_check_header_name(const uint8_t *name, size_t len); + * Returns nonzero if HTTP header field value |value| of length |len| + * is valid according to + * http://tools.ietf.org/html/rfc7230#section-3.2 ++ * ++ * This function is considered obsolete, and application should ++ * consider to use `nghttp2_check_header_value_rfc9113()` instead. + */ + NGHTTP2_EXTERN int nghttp2_check_header_value(const uint8_t *value, size_t len); + + /** + * @function + * +- * Returns nonzero if the |value| which is supposed to the value of ++ * Returns nonzero if HTTP header field value |value| of length |len| ++ * is valid according to ++ * http://tools.ietf.org/html/rfc7230#section-3.2, plus ++ * https://datatracker.ietf.org/doc/html/rfc9113#section-8.2.1 ++ */ ++NGHTTP2_EXTERN int nghttp2_check_header_value_rfc9113(const uint8_t *value, ++ size_t len); ++ ++/** ++ * @function ++ * ++ * Returns nonzero if the |value| which is supposed to be the value of ++ * the :method header field is valid according to ++ * https://datatracker.ietf.org/doc/html/rfc7231#section-4 and ++ * https://datatracker.ietf.org/doc/html/rfc7230#section-3.2.6 ++ */ ++NGHTTP2_EXTERN int nghttp2_check_method(const uint8_t *value, size_t len); ++ ++/** ++ * @function ++ * ++ * Returns nonzero if the |value| which is supposed to be the value of ++ * the :path header field is valid according to ++ * https://datatracker.ietf.org/doc/html/rfc7540#section-8.1.2.3 ++ * ++ * |value| is valid if it merely consists of the allowed characters. ++ * In particular, it does not check whether |value| follows the syntax ++ * of path. The allowed characters are all characters valid by ++ * `nghttp2_check_header_value` minus SPC and HT. ++ */ ++NGHTTP2_EXTERN int nghttp2_check_path(const uint8_t *value, size_t len); ++ ++/** ++ * @function ++ * ++ * Returns nonzero if the |value| which is supposed to be the value of the + * :authority or host header field is valid according to + * https://tools.ietf.org/html/rfc3986#section-3.2 + * +@@ -4831,7 +5147,7 @@ typedef struct nghttp2_hd_deflater nghttp2_hd_deflater; + * This function returns 0 if it succeeds, or one of the following + * negative error codes: + * +- * :enum:`NGHTTP2_ERR_NOMEM` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_NOMEM` + * Out of memory. + */ + NGHTTP2_EXTERN int +@@ -4885,7 +5201,7 @@ NGHTTP2_EXTERN void nghttp2_hd_deflate_del(nghttp2_hd_deflater *deflater); + * This function returns 0 if it succeeds, or one of the following + * negative error codes: + * +- * :enum:`NGHTTP2_ERR_NOMEM` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_NOMEM` + * Out of memory. + */ + NGHTTP2_EXTERN int +@@ -4899,24 +5215,24 @@ nghttp2_hd_deflate_change_table_size(nghttp2_hd_deflater *deflater, + * the |buf| of length |buflen|. + * + * If |buf| is not large enough to store the deflated header block, +- * this function fails with :enum:`NGHTTP2_ERR_INSUFF_BUFSIZE`. The +- * caller should use `nghttp2_hd_deflate_bound()` to know the upper +- * bound of buffer size required to deflate given header name/value +- * pairs. ++ * this function fails with ++ * :enum:`nghttp2_error.NGHTTP2_ERR_INSUFF_BUFSIZE`. The caller ++ * should use `nghttp2_hd_deflate_bound()` to know the upper bound of ++ * buffer size required to deflate given header name/value pairs. + * + * Once this function fails, subsequent call of this function always +- * returns :enum:`NGHTTP2_ERR_HEADER_COMP`. ++ * returns :enum:`nghttp2_error.NGHTTP2_ERR_HEADER_COMP`. + * + * After this function returns, it is safe to delete the |nva|. + * + * This function returns the number of bytes written to |buf| if it + * succeeds, or one of the following negative error codes: + * +- * :enum:`NGHTTP2_ERR_NOMEM` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_NOMEM` + * Out of memory. +- * :enum:`NGHTTP2_ERR_HEADER_COMP` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_HEADER_COMP` + * Deflation process has failed. +- * :enum:`NGHTTP2_ERR_INSUFF_BUFSIZE` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_INSUFF_BUFSIZE` + * The provided |buflen| size is too small to hold the output. + */ + NGHTTP2_EXTERN ssize_t nghttp2_hd_deflate_hd(nghttp2_hd_deflater *deflater, +@@ -4932,23 +5248,24 @@ NGHTTP2_EXTERN ssize_t nghttp2_hd_deflate_hd(nghttp2_hd_deflater *deflater, + * must be set in len field of :type:`nghttp2_vec`. If and only if + * one chunk is filled up completely, next chunk will be used. If + * |vec| is not large enough to store the deflated header block, this +- * function fails with :enum:`NGHTTP2_ERR_INSUFF_BUFSIZE`. The caller ++ * function fails with ++ * :enum:`nghttp2_error.NGHTTP2_ERR_INSUFF_BUFSIZE`. The caller + * should use `nghttp2_hd_deflate_bound()` to know the upper bound of + * buffer size required to deflate given header name/value pairs. + * + * Once this function fails, subsequent call of this function always +- * returns :enum:`NGHTTP2_ERR_HEADER_COMP`. ++ * returns :enum:`nghttp2_error.NGHTTP2_ERR_HEADER_COMP`. + * + * After this function returns, it is safe to delete the |nva|. + * + * This function returns the number of bytes written to |vec| if it + * succeeds, or one of the following negative error codes: + * +- * :enum:`NGHTTP2_ERR_NOMEM` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_NOMEM` + * Out of memory. +- * :enum:`NGHTTP2_ERR_HEADER_COMP` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_HEADER_COMP` + * Deflation process has failed. +- * :enum:`NGHTTP2_ERR_INSUFF_BUFSIZE` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_INSUFF_BUFSIZE` + * The provided |buflen| size is too small to hold the output. + */ + NGHTTP2_EXTERN ssize_t nghttp2_hd_deflate_hd_vec(nghttp2_hd_deflater *deflater, +@@ -5028,7 +5345,7 @@ typedef struct nghttp2_hd_inflater nghttp2_hd_inflater; + * This function returns 0 if it succeeds, or one of the following + * negative error codes: + * +- * :enum:`NGHTTP2_ERR_NOMEM` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_NOMEM` + * Out of memory. + */ + NGHTTP2_EXTERN int nghttp2_hd_inflate_new(nghttp2_hd_inflater **inflater_ptr); +@@ -5077,9 +5394,9 @@ NGHTTP2_EXTERN void nghttp2_hd_inflate_del(nghttp2_hd_inflater *inflater); + * This function returns 0 if it succeeds, or one of the following + * negative error codes: + * +- * :enum:`NGHTTP2_ERR_NOMEM` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_NOMEM` + * Out of memory. +- * :enum:`NGHTTP2_ERR_INVALID_STATE` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_INVALID_STATE` + * The function is called while header block is being inflated. + * Probably, application missed to call + * `nghttp2_hd_inflate_end_headers()`. +@@ -5117,7 +5434,8 @@ typedef enum { + * + * Inflates name/value block stored in |in| with length |inlen|. This + * function performs decompression. For each successful emission of +- * header name/value pair, :enum:`NGHTTP2_HD_INFLATE_EMIT` is set in ++ * header name/value pair, ++ * :enum:`nghttp2_hd_inflate_flag.NGHTTP2_HD_INFLATE_EMIT` is set in + * |*inflate_flags| and name/value pair is assigned to the |nv_out| + * and the function returns. The caller must not free the members of + * |nv_out|. +@@ -5140,11 +5458,11 @@ typedef enum { + * This function returns the number of bytes processed if it succeeds, + * or one of the following negative error codes: + * +- * :enum:`NGHTTP2_ERR_NOMEM` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_NOMEM` + * Out of memory. +- * :enum:`NGHTTP2_ERR_HEADER_COMP` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_HEADER_COMP` + * Inflation process has failed. +- * :enum:`NGHTTP2_ERR_BUFFER_ERROR` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_BUFFER_ERROR` + * The header field name or value is too large. + * + * Example follows:: +@@ -5199,7 +5517,8 @@ NGHTTP2_EXTERN ssize_t nghttp2_hd_inflate_hd(nghttp2_hd_inflater *inflater, + * + * Inflates name/value block stored in |in| with length |inlen|. This + * function performs decompression. For each successful emission of +- * header name/value pair, :enum:`NGHTTP2_HD_INFLATE_EMIT` is set in ++ * header name/value pair, ++ * :enum:`nghttp2_hd_inflate_flag.NGHTTP2_HD_INFLATE_EMIT` is set in + * |*inflate_flags| and name/value pair is assigned to the |nv_out| + * and the function returns. The caller must not free the members of + * |nv_out|. +@@ -5215,8 +5534,9 @@ NGHTTP2_EXTERN ssize_t nghttp2_hd_inflate_hd(nghttp2_hd_inflater *inflater, + * for the next header block input. + * + * In other words, if |in_final| is nonzero, and this function returns +- * |inlen|, you can assert that :enum:`NGHTTP2_HD_INFLATE_FINAL` is +- * set in |*inflate_flags|. ++ * |inlen|, you can assert that ++ * :enum:`nghttp2_hd_inflate_final.NGHTTP2_HD_INFLATE_FINAL` is set in ++ * |*inflate_flags|. + * + * The caller can feed complete compressed header block. It also can + * feed it in several chunks. The caller must set |in_final| to +@@ -5226,11 +5546,11 @@ NGHTTP2_EXTERN ssize_t nghttp2_hd_inflate_hd(nghttp2_hd_inflater *inflater, + * This function returns the number of bytes processed if it succeeds, + * or one of the following negative error codes: + * +- * :enum:`NGHTTP2_ERR_NOMEM` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_NOMEM` + * Out of memory. +- * :enum:`NGHTTP2_ERR_HEADER_COMP` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_HEADER_COMP` + * Inflation process has failed. +- * :enum:`NGHTTP2_ERR_BUFFER_ERROR` ++ * :enum:`nghttp2_error.NGHTTP2_ERR_BUFFER_ERROR` + * The header field name or value is too large. + * + * Example follows:: +@@ -5401,7 +5721,7 @@ typedef enum { + * + * Returns state of |stream|. The root stream retrieved by + * `nghttp2_session_get_root_stream()` will have stream state +- * :enum:`NGHTTP2_STREAM_STATE_IDLE`. ++ * :enum:`nghttp2_stream_proto_state.NGHTTP2_STREAM_STATE_IDLE`. + */ + NGHTTP2_EXTERN nghttp2_stream_proto_state + nghttp2_stream_get_state(nghttp2_stream *stream); +diff --git a/deps/nghttp2/lib/includes/nghttp2/nghttp2ver.h b/deps/nghttp2/lib/includes/nghttp2/nghttp2ver.h +index ff6bf3d3b2..f56954e7fd 100644 +--- a/deps/nghttp2/lib/includes/nghttp2/nghttp2ver.h ++++ b/deps/nghttp2/lib/includes/nghttp2/nghttp2ver.h +@@ -29,7 +29,7 @@ + * @macro + * Version number of the nghttp2 library release + */ +-#define NGHTTP2_VERSION "1.42.0" ++#define NGHTTP2_VERSION "1.57.0" + + /** + * @macro +@@ -37,6 +37,6 @@ + * release. This is a 24 bit number with 8 bits for major number, 8 bits + * for minor and 8 bits for patch. Version 1.2.3 becomes 0x010203. + */ +-#define NGHTTP2_VERSION_NUM 0x012a00 ++#define NGHTTP2_VERSION_NUM 0x013900 + + #endif /* NGHTTP2VER_H */ +diff --git a/deps/nghttp2/lib/nghttp2_buf.h b/deps/nghttp2/lib/nghttp2_buf.h +index 06cce67a11..45f62f16e2 100644 +--- a/deps/nghttp2/lib/nghttp2_buf.h ++++ b/deps/nghttp2/lib/nghttp2_buf.h +@@ -99,7 +99,7 @@ void nghttp2_buf_free(nghttp2_buf *buf, nghttp2_mem *mem); + * |new_cap|. If extensions took place, buffer pointers in |buf| will + * change. + * +- * This function returns 0 if it succeeds, or one of the followings ++ * This function returns 0 if it succeeds, or one of the following + * negative error codes: + * + * NGHTTP2_ERR_NOMEM +diff --git a/deps/nghttp2/lib/nghttp2_extpri.c b/deps/nghttp2/lib/nghttp2_extpri.c +new file mode 100644 +index 0000000000..3fd9b78163 +--- /dev/null ++++ b/deps/nghttp2/lib/nghttp2_extpri.c +@@ -0,0 +1,35 @@ ++/* ++ * nghttp2 - HTTP/2 C Library ++ * ++ * Copyright (c) 2022 nghttp3 contributors ++ * Copyright (c) 2022 nghttp2 contributors ++ * ++ * Permission is hereby granted, free of charge, to any person obtaining ++ * a copy of this software and associated documentation files (the ++ * "Software"), to deal in the Software without restriction, including ++ * without limitation the rights to use, copy, modify, merge, publish, ++ * distribute, sublicense, and/or sell copies of the Software, and to ++ * permit persons to whom the Software is furnished to do so, subject to ++ * the following conditions: ++ * ++ * The above copyright notice and this permission notice shall be ++ * included in all copies or substantial portions of the Software. ++ * ++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, ++ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF ++ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND ++ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE ++ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION ++ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION ++ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ++ */ ++#include "nghttp2_extpri.h" ++ ++uint8_t nghttp2_extpri_to_uint8(const nghttp2_extpri *extpri) { ++ return (uint8_t)((uint32_t)extpri->inc << 7 | extpri->urgency); ++} ++ ++void nghttp2_extpri_from_uint8(nghttp2_extpri *extpri, uint8_t u8extpri) { ++ extpri->urgency = nghttp2_extpri_uint8_urgency(u8extpri); ++ extpri->inc = nghttp2_extpri_uint8_inc(u8extpri); ++} +diff --git a/deps/nghttp2/lib/nghttp2_extpri.h b/deps/nghttp2/lib/nghttp2_extpri.h +new file mode 100644 +index 0000000000..23c6ddc0c0 +--- /dev/null ++++ b/deps/nghttp2/lib/nghttp2_extpri.h +@@ -0,0 +1,65 @@ ++/* ++ * nghttp2 - HTTP/2 C Library ++ * ++ * Copyright (c) 2022 nghttp3 contributors ++ * Copyright (c) 2022 nghttp2 contributors ++ * ++ * Permission is hereby granted, free of charge, to any person obtaining ++ * a copy of this software and associated documentation files (the ++ * "Software"), to deal in the Software without restriction, including ++ * without limitation the rights to use, copy, modify, merge, publish, ++ * distribute, sublicense, and/or sell copies of the Software, and to ++ * permit persons to whom the Software is furnished to do so, subject to ++ * the following conditions: ++ * ++ * The above copyright notice and this permission notice shall be ++ * included in all copies or substantial portions of the Software. ++ * ++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, ++ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF ++ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND ++ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE ++ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION ++ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION ++ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ++ */ ++#ifndef NGHTTP2_EXTPRI_H ++#define NGHTTP2_EXTPRI_H ++ ++#ifdef HAVE_CONFIG_H ++# include ++#endif /* HAVE_CONFIG_H */ ++ ++#include ++ ++/* ++ * NGHTTP2_EXTPRI_INC_MASK is a bit mask to retrieve incremental bit ++ * from a value produced by nghttp2_extpri_to_uint8. ++ */ ++#define NGHTTP2_EXTPRI_INC_MASK (1 << 7) ++ ++/* ++ * nghttp2_extpri_to_uint8 encodes |pri| into uint8_t variable. ++ */ ++uint8_t nghttp2_extpri_to_uint8(const nghttp2_extpri *extpri); ++ ++/* ++ * nghttp2_extpri_from_uint8 decodes |u8extpri|, which is produced by ++ * nghttp2_extpri_to_uint8, intto |extpri|. ++ */ ++void nghttp2_extpri_from_uint8(nghttp2_extpri *extpri, uint8_t u8extpri); ++ ++/* ++ * nghttp2_extpri_uint8_urgency extracts urgency from |PRI| which is ++ * supposed to be constructed by nghttp2_extpri_to_uint8. ++ */ ++#define nghttp2_extpri_uint8_urgency(PRI) \ ++ ((uint32_t)((PRI) & ~NGHTTP2_EXTPRI_INC_MASK)) ++ ++/* ++ * nghttp2_extpri_uint8_inc extracts inc from |PRI| which is supposed to ++ * be constructed by nghttp2_extpri_to_uint8. ++ */ ++#define nghttp2_extpri_uint8_inc(PRI) (((PRI)&NGHTTP2_EXTPRI_INC_MASK) != 0) ++ ++#endif /* NGHTTP2_EXTPRI_H */ +diff --git a/deps/nghttp2/lib/nghttp2_frame.c b/deps/nghttp2/lib/nghttp2_frame.c +index 382a26c818..77cb463df5 100644 +--- a/deps/nghttp2/lib/nghttp2_frame.c ++++ b/deps/nghttp2/lib/nghttp2_frame.c +@@ -253,6 +253,31 @@ void nghttp2_frame_origin_free(nghttp2_extension *frame, nghttp2_mem *mem) { + nghttp2_mem_free(mem, origin->ov); + } + ++void nghttp2_frame_priority_update_init(nghttp2_extension *frame, ++ int32_t stream_id, uint8_t *field_value, ++ size_t field_value_len) { ++ nghttp2_ext_priority_update *priority_update; ++ ++ nghttp2_frame_hd_init(&frame->hd, 4 + field_value_len, ++ NGHTTP2_PRIORITY_UPDATE, NGHTTP2_FLAG_NONE, 0); ++ ++ priority_update = frame->payload; ++ priority_update->stream_id = stream_id; ++ priority_update->field_value = field_value; ++ priority_update->field_value_len = field_value_len; ++} ++ ++void nghttp2_frame_priority_update_free(nghttp2_extension *frame, ++ nghttp2_mem *mem) { ++ nghttp2_ext_priority_update *priority_update; ++ ++ priority_update = frame->payload; ++ if (priority_update == NULL) { ++ return; ++ } ++ nghttp2_mem_free(mem, priority_update->field_value); ++} ++ + size_t nghttp2_frame_priority_len(uint8_t flags) { + if (flags & NGHTTP2_FLAG_PRIORITY) { + return NGHTTP2_PRIORITY_SPECLEN; +@@ -393,8 +418,8 @@ void nghttp2_frame_unpack_priority_spec(nghttp2_priority_spec *pri_spec, + nghttp2_priority_spec_init(pri_spec, dep_stream_id, weight, exclusive); + } + +-int nghttp2_frame_unpack_headers_payload(nghttp2_headers *frame, +- const uint8_t *payload) { ++void nghttp2_frame_unpack_headers_payload(nghttp2_headers *frame, ++ const uint8_t *payload) { + if (frame->hd.flags & NGHTTP2_FLAG_PRIORITY) { + nghttp2_frame_unpack_priority_spec(&frame->pri_spec, payload); + } else { +@@ -403,11 +428,9 @@ int nghttp2_frame_unpack_headers_payload(nghttp2_headers *frame, + + frame->nva = NULL; + frame->nvlen = 0; +- +- return 0; + } + +-int nghttp2_frame_pack_priority(nghttp2_bufs *bufs, nghttp2_priority *frame) { ++void nghttp2_frame_pack_priority(nghttp2_bufs *bufs, nghttp2_priority *frame) { + nghttp2_buf *buf; + + assert(bufs->head == bufs->cur); +@@ -423,8 +446,6 @@ int nghttp2_frame_pack_priority(nghttp2_bufs *bufs, nghttp2_priority *frame) { + nghttp2_frame_pack_priority_spec(buf->last, &frame->pri_spec); + + buf->last += NGHTTP2_PRIORITY_SPECLEN; +- +- return 0; + } + + void nghttp2_frame_unpack_priority_payload(nghttp2_priority *frame, +@@ -432,8 +453,8 @@ void nghttp2_frame_unpack_priority_payload(nghttp2_priority *frame, + nghttp2_frame_unpack_priority_spec(&frame->pri_spec, payload); + } + +-int nghttp2_frame_pack_rst_stream(nghttp2_bufs *bufs, +- nghttp2_rst_stream *frame) { ++void nghttp2_frame_pack_rst_stream(nghttp2_bufs *bufs, ++ nghttp2_rst_stream *frame) { + nghttp2_buf *buf; + + assert(bufs->head == bufs->cur); +@@ -448,8 +469,6 @@ int nghttp2_frame_pack_rst_stream(nghttp2_bufs *bufs, + + nghttp2_put_uint32be(buf->last, frame->error_code); + buf->last += 4; +- +- return 0; + } + + void nghttp2_frame_unpack_rst_stream_payload(nghttp2_rst_stream *frame, +@@ -567,16 +586,15 @@ int nghttp2_frame_pack_push_promise(nghttp2_bufs *bufs, + return frame_pack_headers_shared(bufs, &frame->hd); + } + +-int nghttp2_frame_unpack_push_promise_payload(nghttp2_push_promise *frame, +- const uint8_t *payload) { ++void nghttp2_frame_unpack_push_promise_payload(nghttp2_push_promise *frame, ++ const uint8_t *payload) { + frame->promised_stream_id = + nghttp2_get_uint32(payload) & NGHTTP2_STREAM_ID_MASK; + frame->nva = NULL; + frame->nvlen = 0; +- return 0; + } + +-int nghttp2_frame_pack_ping(nghttp2_bufs *bufs, nghttp2_ping *frame) { ++void nghttp2_frame_pack_ping(nghttp2_bufs *bufs, nghttp2_ping *frame) { + nghttp2_buf *buf; + + assert(bufs->head == bufs->cur); +@@ -591,8 +609,6 @@ int nghttp2_frame_pack_ping(nghttp2_bufs *bufs, nghttp2_ping *frame) { + + buf->last = + nghttp2_cpymem(buf->last, frame->opaque_data, sizeof(frame->opaque_data)); +- +- return 0; + } + + void nghttp2_frame_unpack_ping_payload(nghttp2_ping *frame, +@@ -654,8 +670,6 @@ int nghttp2_frame_unpack_goaway_payload2(nghttp2_goaway *frame, + var_gift_payloadlen = 0; + } + +- payloadlen -= var_gift_payloadlen; +- + if (!var_gift_payloadlen) { + var_gift_payload = NULL; + } else { +@@ -674,8 +688,8 @@ int nghttp2_frame_unpack_goaway_payload2(nghttp2_goaway *frame, + return 0; + } + +-int nghttp2_frame_pack_window_update(nghttp2_bufs *bufs, +- nghttp2_window_update *frame) { ++void nghttp2_frame_pack_window_update(nghttp2_bufs *bufs, ++ nghttp2_window_update *frame) { + nghttp2_buf *buf; + + assert(bufs->head == bufs->cur); +@@ -690,8 +704,6 @@ int nghttp2_frame_pack_window_update(nghttp2_bufs *bufs, + + nghttp2_put_uint32be(buf->last, (uint32_t)frame->window_size_increment); + buf->last += 4; +- +- return 0; + } + + void nghttp2_frame_unpack_window_update_payload(nghttp2_window_update *frame, +@@ -700,7 +712,7 @@ void nghttp2_frame_unpack_window_update_payload(nghttp2_window_update *frame, + nghttp2_get_uint32(payload) & NGHTTP2_WINDOW_SIZE_INCREMENT_MASK; + } + +-int nghttp2_frame_pack_altsvc(nghttp2_bufs *bufs, nghttp2_extension *frame) { ++void nghttp2_frame_pack_altsvc(nghttp2_bufs *bufs, nghttp2_extension *frame) { + int rv; + nghttp2_buf *buf; + nghttp2_ext_altsvc *altsvc; +@@ -729,8 +741,6 @@ int nghttp2_frame_pack_altsvc(nghttp2_bufs *bufs, nghttp2_extension *frame) { + rv = nghttp2_bufs_add(bufs, altsvc->field_value, altsvc->field_value_len); + + assert(rv == 0); +- +- return 0; + } + + void nghttp2_frame_unpack_altsvc_payload(nghttp2_extension *frame, +@@ -878,6 +888,55 @@ int nghttp2_frame_unpack_origin_payload(nghttp2_extension *frame, + return 0; + } + ++void nghttp2_frame_pack_priority_update(nghttp2_bufs *bufs, ++ nghttp2_extension *frame) { ++ int rv; ++ nghttp2_buf *buf; ++ nghttp2_ext_priority_update *priority_update; ++ ++ /* This is required with --disable-assert. */ ++ (void)rv; ++ ++ priority_update = frame->payload; ++ ++ buf = &bufs->head->buf; ++ ++ assert(nghttp2_buf_avail(buf) >= 4 + priority_update->field_value_len); ++ ++ buf->pos -= NGHTTP2_FRAME_HDLEN; ++ ++ nghttp2_frame_pack_frame_hd(buf->pos, &frame->hd); ++ ++ nghttp2_put_uint32be(buf->last, (uint32_t)priority_update->stream_id); ++ buf->last += 4; ++ ++ rv = nghttp2_bufs_add(bufs, priority_update->field_value, ++ priority_update->field_value_len); ++ ++ assert(rv == 0); ++} ++ ++void nghttp2_frame_unpack_priority_update_payload(nghttp2_extension *frame, ++ uint8_t *payload, ++ size_t payloadlen) { ++ nghttp2_ext_priority_update *priority_update; ++ ++ assert(payloadlen >= 4); ++ ++ priority_update = frame->payload; ++ ++ priority_update->stream_id = ++ nghttp2_get_uint32(payload) & NGHTTP2_STREAM_ID_MASK; ++ ++ if (payloadlen > 4) { ++ priority_update->field_value = payload + 4; ++ priority_update->field_value_len = payloadlen - 4; ++ } else { ++ priority_update->field_value = NULL; ++ priority_update->field_value_len = 0; ++ } ++} ++ + nghttp2_settings_entry *nghttp2_frame_iv_copy(const nghttp2_settings_entry *iv, + size_t niv, nghttp2_mem *mem) { + nghttp2_settings_entry *iv_copy; +@@ -1073,6 +1132,11 @@ int nghttp2_iv_check(const nghttp2_settings_entry *iv, size_t niv) { + return 0; + } + break; ++ case NGHTTP2_SETTINGS_NO_RFC7540_PRIORITIES: ++ if (iv[i].value != 0 && iv[i].value != 1) { ++ return 0; ++ } ++ break; + } + } + return 1; +@@ -1107,14 +1171,14 @@ static void frame_set_pad(nghttp2_buf *buf, size_t padlen, int framehd_only) { + buf->last += trail_padlen; + } + +-int nghttp2_frame_add_pad(nghttp2_bufs *bufs, nghttp2_frame_hd *hd, +- size_t padlen, int framehd_only) { ++void nghttp2_frame_add_pad(nghttp2_bufs *bufs, nghttp2_frame_hd *hd, ++ size_t padlen, int framehd_only) { + nghttp2_buf *buf; + + if (padlen == 0) { + DEBUGF("send: padlen = 0, nothing to do\n"); + +- return 0; ++ return; + } + + /* +@@ -1147,6 +1211,4 @@ int nghttp2_frame_add_pad(nghttp2_bufs *bufs, nghttp2_frame_hd *hd, + hd->flags |= NGHTTP2_FLAG_PADDED; + + DEBUGF("send: final payloadlen=%zu, padlen=%zu\n", hd->length, padlen); +- +- return 0; + } +diff --git a/deps/nghttp2/lib/nghttp2_frame.h b/deps/nghttp2/lib/nghttp2_frame.h +index 615bbf31f5..d58668806c 100644 +--- a/deps/nghttp2/lib/nghttp2_frame.h ++++ b/deps/nghttp2/lib/nghttp2_frame.h +@@ -46,7 +46,7 @@ + #define NGHTTP2_MAX_FRAME_SIZE_MIN (1 << 14) + + #define NGHTTP2_MAX_PAYLOADLEN 16384 +-/* The one frame buffer length for tranmission. We may use several of ++/* The one frame buffer length for transmission. We may use several of + them to support CONTINUATION. To account for Pad Length field, we + allocate extra 1 byte, which saves extra large memcopying. */ + #define NGHTTP2_FRAMEBUF_CHUNKLEN \ +@@ -57,7 +57,7 @@ + + /* Maximum headers block size to send, calculated using + nghttp2_hd_deflate_bound(). This is the default value, and can be +- overridden by nghttp2_option_set_max_send_header_block_size(). */ ++ overridden by nghttp2_option_set_max_send_header_block_length(). */ + #define NGHTTP2_MAX_HEADERSLEN 65536 + + /* The number of bytes for each SETTINGS entry */ +@@ -73,6 +73,7 @@ + typedef union { + nghttp2_ext_altsvc altsvc; + nghttp2_ext_origin origin; ++ nghttp2_ext_priority_update priority_update; + } nghttp2_ext_frame_payload; + + void nghttp2_frame_pack_frame_hd(uint8_t *buf, const nghttp2_frame_hd *hd); +@@ -142,11 +143,9 @@ int nghttp2_frame_pack_headers(nghttp2_bufs *bufs, nghttp2_headers *frame, + * Unpacks HEADERS frame byte sequence into |frame|. This function + * only unapcks bytes that come before name/value header block and + * after possible Pad Length field. +- * +- * This function always succeeds and returns 0. + */ +-int nghttp2_frame_unpack_headers_payload(nghttp2_headers *frame, +- const uint8_t *payload); ++void nghttp2_frame_unpack_headers_payload(nghttp2_headers *frame, ++ const uint8_t *payload); + + /* + * Packs PRIORITY frame |frame| in wire format and store it in +@@ -154,10 +153,8 @@ int nghttp2_frame_unpack_headers_payload(nghttp2_headers *frame, + * + * The caller must make sure that nghttp2_bufs_reset(bufs) is called + * before calling this function. +- * +- * This function always succeeds and returns 0. + */ +-int nghttp2_frame_pack_priority(nghttp2_bufs *bufs, nghttp2_priority *frame); ++void nghttp2_frame_pack_priority(nghttp2_bufs *bufs, nghttp2_priority *frame); + + /* + * Unpacks PRIORITY wire format into |frame|. +@@ -171,11 +168,9 @@ void nghttp2_frame_unpack_priority_payload(nghttp2_priority *frame, + * + * The caller must make sure that nghttp2_bufs_reset(bufs) is called + * before calling this function. +- * +- * This function always succeeds and returns 0. + */ +-int nghttp2_frame_pack_rst_stream(nghttp2_bufs *bufs, +- nghttp2_rst_stream *frame); ++void nghttp2_frame_pack_rst_stream(nghttp2_bufs *bufs, ++ nghttp2_rst_stream *frame); + + /* + * Unpacks RST_STREAM frame byte sequence into |frame|. +@@ -264,15 +259,9 @@ int nghttp2_frame_pack_push_promise(nghttp2_bufs *bufs, + * Unpacks PUSH_PROMISE frame byte sequence into |frame|. This + * function only unapcks bytes that come before name/value header + * block and after possible Pad Length field. +- * +- * This function returns 0 if it succeeds or one of the following +- * negative error codes: +- * +- * NGHTTP2_ERR_PROTO +- * TODO END_HEADERS flag is not set + */ +-int nghttp2_frame_unpack_push_promise_payload(nghttp2_push_promise *frame, +- const uint8_t *payload); ++void nghttp2_frame_unpack_push_promise_payload(nghttp2_push_promise *frame, ++ const uint8_t *payload); + + /* + * Packs PING frame |frame| in wire format and store it in +@@ -280,10 +269,8 @@ int nghttp2_frame_unpack_push_promise_payload(nghttp2_push_promise *frame, + * + * The caller must make sure that nghttp2_bufs_reset(bufs) is called + * before calling this function. +- * +- * This function always succeeds and returns 0. + */ +-int nghttp2_frame_pack_ping(nghttp2_bufs *bufs, nghttp2_ping *frame); ++void nghttp2_frame_pack_ping(nghttp2_bufs *bufs, nghttp2_ping *frame); + + /* + * Unpacks PING wire format into |frame|. +@@ -342,11 +329,9 @@ int nghttp2_frame_unpack_goaway_payload2(nghttp2_goaway *frame, + * + * The caller must make sure that nghttp2_bufs_reset(bufs) is called + * before calling this function. +- * +- * This function always succeeds and returns 0. + */ +-int nghttp2_frame_pack_window_update(nghttp2_bufs *bufs, +- nghttp2_window_update *frame); ++void nghttp2_frame_pack_window_update(nghttp2_bufs *bufs, ++ nghttp2_window_update *frame); + + /* + * Unpacks WINDOW_UPDATE frame byte sequence into |frame|. +@@ -360,17 +345,13 @@ void nghttp2_frame_unpack_window_update_payload(nghttp2_window_update *frame, + * + * The caller must make sure that nghttp2_bufs_reset(bufs) is called + * before calling this function. +- * +- * This function always succeeds and returns 0. + */ +-int nghttp2_frame_pack_altsvc(nghttp2_bufs *bufs, nghttp2_extension *ext); ++void nghttp2_frame_pack_altsvc(nghttp2_bufs *bufs, nghttp2_extension *ext); + + /* + * Unpacks ALTSVC wire format into |frame|. The |payload| of + * |payloadlen| bytes contains frame payload. This function assumes + * that frame->payload points to the nghttp2_ext_altsvc object. +- * +- * This function always succeeds and returns 0. + */ + void nghttp2_frame_unpack_altsvc_payload(nghttp2_extension *frame, + size_t origin_len, uint8_t *payload, +@@ -423,6 +404,27 @@ int nghttp2_frame_pack_origin(nghttp2_bufs *bufs, nghttp2_extension *ext); + int nghttp2_frame_unpack_origin_payload(nghttp2_extension *frame, + const uint8_t *payload, + size_t payloadlen, nghttp2_mem *mem); ++ ++/* ++ * Packs PRIORITY_UPDATE frame |frame| in wire frame format and store ++ * it in |bufs|. ++ * ++ * The caller must make sure that nghttp2_bufs_reset(bufs) is called ++ * before calling this function. ++ */ ++void nghttp2_frame_pack_priority_update(nghttp2_bufs *bufs, ++ nghttp2_extension *ext); ++ ++/* ++ * Unpacks PRIORITY_UPDATE wire format into |frame|. The |payload| of ++ * |payloadlen| bytes contains frame payload. This function assumes ++ * that frame->payload points to the nghttp2_ext_priority_update ++ * object. ++ */ ++void nghttp2_frame_unpack_priority_update_payload(nghttp2_extension *frame, ++ uint8_t *payload, ++ size_t payloadlen); ++ + /* + * Initializes HEADERS frame |frame| with given values. |frame| takes + * ownership of |nva|, so caller must not free it. If |stream_id| is +@@ -538,6 +540,25 @@ void nghttp2_frame_origin_init(nghttp2_extension *frame, + */ + void nghttp2_frame_origin_free(nghttp2_extension *frame, nghttp2_mem *mem); + ++/* ++ * Initializes PRIORITY_UPDATE frame |frame| with given values. This ++ * function assumes that frame->payload points to ++ * nghttp2_ext_priority_update object. On success, this function ++ * takes ownership of |field_value|, so caller must not free it. ++ */ ++void nghttp2_frame_priority_update_init(nghttp2_extension *frame, ++ int32_t stream_id, uint8_t *field_value, ++ size_t field_value_len); ++ ++/* ++ * Frees up resources under |frame|. This function does not free ++ * nghttp2_ext_priority_update object pointed by frame->payload. This ++ * function only frees field_value pointed by ++ * nghttp2_ext_priority_update.field_value. ++ */ ++void nghttp2_frame_priority_update_free(nghttp2_extension *frame, ++ nghttp2_mem *mem); ++ + /* + * Returns the number of padding bytes after payload. The total + * padding length is given in the |padlen|. The returned value does +@@ -609,16 +630,8 @@ int nghttp2_iv_check(const nghttp2_settings_entry *iv, size_t niv); + * |padlen| including Pad Length field. The |hd| is the frame header + * for the serialized data. This function fills zeros padding region + * unless framehd_only is nonzero. +- * +- * This function returns 0 if it succeeds, or one of the following +- * negative error codes: +- * +- * NGHTTP2_ERR_NOMEM +- * Out of memory. +- * NGHTTP2_ERR_FRAME_SIZE_ERROR +- * The length of the resulting frame is too large. + */ +-int nghttp2_frame_add_pad(nghttp2_bufs *bufs, nghttp2_frame_hd *hd, +- size_t padlen, int framehd_only); ++void nghttp2_frame_add_pad(nghttp2_bufs *bufs, nghttp2_frame_hd *hd, ++ size_t padlen, int framehd_only); + + #endif /* NGHTTP2_FRAME_H */ +diff --git a/deps/nghttp2/lib/nghttp2_hd.c b/deps/nghttp2/lib/nghttp2_hd.c +index 5e86931525..8a2bda64c1 100644 +--- a/deps/nghttp2/lib/nghttp2_hd.c ++++ b/deps/nghttp2/lib/nghttp2_hd.c +@@ -269,6 +269,11 @@ static int32_t lookup_token(const uint8_t *name, size_t namelen) { + return NGHTTP2_TOKEN_LOCATION; + } + break; ++ case 'y': ++ if (memeq("priorit", name, 7)) { ++ return NGHTTP2_TOKEN_PRIORITY; ++ } ++ break; + } + break; + case 9: +@@ -1263,6 +1268,8 @@ int nghttp2_hd_inflate_change_table_size( + return NGHTTP2_ERR_INVALID_STATE; + } + ++ inflater->settings_hd_table_bufsize_max = settings_max_dynamic_table_size; ++ + /* It seems that encoder is not required to send dynamic table size + update if the table size is not changed after applying + SETTINGS_HEADER_TABLE_SIZE. RFC 7541 is ambiguous here, but this +@@ -1275,13 +1282,12 @@ int nghttp2_hd_inflate_change_table_size( + /* Remember minimum value, and validate that encoder sends the + value less than or equal to this. */ + inflater->min_hd_table_bufsize_max = settings_max_dynamic_table_size; +- } + +- inflater->settings_hd_table_bufsize_max = settings_max_dynamic_table_size; ++ inflater->ctx.hd_table_bufsize_max = settings_max_dynamic_table_size; + +- inflater->ctx.hd_table_bufsize_max = settings_max_dynamic_table_size; ++ hd_context_shrink_table_size(&inflater->ctx, NULL); ++ } + +- hd_context_shrink_table_size(&inflater->ctx, NULL); + return 0; + } + +diff --git a/deps/nghttp2/lib/nghttp2_hd.h b/deps/nghttp2/lib/nghttp2_hd.h +index 267402881f..6de0052aae 100644 +--- a/deps/nghttp2/lib/nghttp2_hd.h ++++ b/deps/nghttp2/lib/nghttp2_hd.h +@@ -112,6 +112,7 @@ typedef enum { + NGHTTP2_TOKEN_PROXY_CONNECTION, + NGHTTP2_TOKEN_UPGRADE, + NGHTTP2_TOKEN__PROTOCOL, ++ NGHTTP2_TOKEN_PRIORITY, + } nghttp2_token; + + struct nghttp2_hd_entry; +diff --git a/deps/nghttp2/lib/nghttp2_helper.c b/deps/nghttp2/lib/nghttp2_helper.c +index 0bd5414723..93dd4754b7 100644 +--- a/deps/nghttp2/lib/nghttp2_helper.c ++++ b/deps/nghttp2/lib/nghttp2_helper.c +@@ -507,7 +507,179 @@ int nghttp2_check_header_value(const uint8_t *value, size_t len) { + return 1; + } + +-/* Generated by genauthroitychartbl.py */ ++int nghttp2_check_header_value_rfc9113(const uint8_t *value, size_t len) { ++ if (len == 0) { ++ return 1; ++ } ++ ++ if (*value == ' ' || *value == '\t' || *(value + len - 1) == ' ' || ++ *(value + len - 1) == '\t') { ++ return 0; ++ } ++ ++ return nghttp2_check_header_value(value, len); ++} ++ ++/* Generated by genmethodchartbl.py */ ++static char VALID_METHOD_CHARS[] = { ++ 0 /* NUL */, 0 /* SOH */, 0 /* STX */, 0 /* ETX */, ++ 0 /* EOT */, 0 /* ENQ */, 0 /* ACK */, 0 /* BEL */, ++ 0 /* BS */, 0 /* HT */, 0 /* LF */, 0 /* VT */, ++ 0 /* FF */, 0 /* CR */, 0 /* SO */, 0 /* SI */, ++ 0 /* DLE */, 0 /* DC1 */, 0 /* DC2 */, 0 /* DC3 */, ++ 0 /* DC4 */, 0 /* NAK */, 0 /* SYN */, 0 /* ETB */, ++ 0 /* CAN */, 0 /* EM */, 0 /* SUB */, 0 /* ESC */, ++ 0 /* FS */, 0 /* GS */, 0 /* RS */, 0 /* US */, ++ 0 /* SPC */, 1 /* ! */, 0 /* " */, 1 /* # */, ++ 1 /* $ */, 1 /* % */, 1 /* & */, 1 /* ' */, ++ 0 /* ( */, 0 /* ) */, 1 /* * */, 1 /* + */, ++ 0 /* , */, 1 /* - */, 1 /* . */, 0 /* / */, ++ 1 /* 0 */, 1 /* 1 */, 1 /* 2 */, 1 /* 3 */, ++ 1 /* 4 */, 1 /* 5 */, 1 /* 6 */, 1 /* 7 */, ++ 1 /* 8 */, 1 /* 9 */, 0 /* : */, 0 /* ; */, ++ 0 /* < */, 0 /* = */, 0 /* > */, 0 /* ? */, ++ 0 /* @ */, 1 /* A */, 1 /* B */, 1 /* C */, ++ 1 /* D */, 1 /* E */, 1 /* F */, 1 /* G */, ++ 1 /* H */, 1 /* I */, 1 /* J */, 1 /* K */, ++ 1 /* L */, 1 /* M */, 1 /* N */, 1 /* O */, ++ 1 /* P */, 1 /* Q */, 1 /* R */, 1 /* S */, ++ 1 /* T */, 1 /* U */, 1 /* V */, 1 /* W */, ++ 1 /* X */, 1 /* Y */, 1 /* Z */, 0 /* [ */, ++ 0 /* \ */, 0 /* ] */, 1 /* ^ */, 1 /* _ */, ++ 1 /* ` */, 1 /* a */, 1 /* b */, 1 /* c */, ++ 1 /* d */, 1 /* e */, 1 /* f */, 1 /* g */, ++ 1 /* h */, 1 /* i */, 1 /* j */, 1 /* k */, ++ 1 /* l */, 1 /* m */, 1 /* n */, 1 /* o */, ++ 1 /* p */, 1 /* q */, 1 /* r */, 1 /* s */, ++ 1 /* t */, 1 /* u */, 1 /* v */, 1 /* w */, ++ 1 /* x */, 1 /* y */, 1 /* z */, 0 /* { */, ++ 1 /* | */, 0 /* } */, 1 /* ~ */, 0 /* DEL */, ++ 0 /* 0x80 */, 0 /* 0x81 */, 0 /* 0x82 */, 0 /* 0x83 */, ++ 0 /* 0x84 */, 0 /* 0x85 */, 0 /* 0x86 */, 0 /* 0x87 */, ++ 0 /* 0x88 */, 0 /* 0x89 */, 0 /* 0x8a */, 0 /* 0x8b */, ++ 0 /* 0x8c */, 0 /* 0x8d */, 0 /* 0x8e */, 0 /* 0x8f */, ++ 0 /* 0x90 */, 0 /* 0x91 */, 0 /* 0x92 */, 0 /* 0x93 */, ++ 0 /* 0x94 */, 0 /* 0x95 */, 0 /* 0x96 */, 0 /* 0x97 */, ++ 0 /* 0x98 */, 0 /* 0x99 */, 0 /* 0x9a */, 0 /* 0x9b */, ++ 0 /* 0x9c */, 0 /* 0x9d */, 0 /* 0x9e */, 0 /* 0x9f */, ++ 0 /* 0xa0 */, 0 /* 0xa1 */, 0 /* 0xa2 */, 0 /* 0xa3 */, ++ 0 /* 0xa4 */, 0 /* 0xa5 */, 0 /* 0xa6 */, 0 /* 0xa7 */, ++ 0 /* 0xa8 */, 0 /* 0xa9 */, 0 /* 0xaa */, 0 /* 0xab */, ++ 0 /* 0xac */, 0 /* 0xad */, 0 /* 0xae */, 0 /* 0xaf */, ++ 0 /* 0xb0 */, 0 /* 0xb1 */, 0 /* 0xb2 */, 0 /* 0xb3 */, ++ 0 /* 0xb4 */, 0 /* 0xb5 */, 0 /* 0xb6 */, 0 /* 0xb7 */, ++ 0 /* 0xb8 */, 0 /* 0xb9 */, 0 /* 0xba */, 0 /* 0xbb */, ++ 0 /* 0xbc */, 0 /* 0xbd */, 0 /* 0xbe */, 0 /* 0xbf */, ++ 0 /* 0xc0 */, 0 /* 0xc1 */, 0 /* 0xc2 */, 0 /* 0xc3 */, ++ 0 /* 0xc4 */, 0 /* 0xc5 */, 0 /* 0xc6 */, 0 /* 0xc7 */, ++ 0 /* 0xc8 */, 0 /* 0xc9 */, 0 /* 0xca */, 0 /* 0xcb */, ++ 0 /* 0xcc */, 0 /* 0xcd */, 0 /* 0xce */, 0 /* 0xcf */, ++ 0 /* 0xd0 */, 0 /* 0xd1 */, 0 /* 0xd2 */, 0 /* 0xd3 */, ++ 0 /* 0xd4 */, 0 /* 0xd5 */, 0 /* 0xd6 */, 0 /* 0xd7 */, ++ 0 /* 0xd8 */, 0 /* 0xd9 */, 0 /* 0xda */, 0 /* 0xdb */, ++ 0 /* 0xdc */, 0 /* 0xdd */, 0 /* 0xde */, 0 /* 0xdf */, ++ 0 /* 0xe0 */, 0 /* 0xe1 */, 0 /* 0xe2 */, 0 /* 0xe3 */, ++ 0 /* 0xe4 */, 0 /* 0xe5 */, 0 /* 0xe6 */, 0 /* 0xe7 */, ++ 0 /* 0xe8 */, 0 /* 0xe9 */, 0 /* 0xea */, 0 /* 0xeb */, ++ 0 /* 0xec */, 0 /* 0xed */, 0 /* 0xee */, 0 /* 0xef */, ++ 0 /* 0xf0 */, 0 /* 0xf1 */, 0 /* 0xf2 */, 0 /* 0xf3 */, ++ 0 /* 0xf4 */, 0 /* 0xf5 */, 0 /* 0xf6 */, 0 /* 0xf7 */, ++ 0 /* 0xf8 */, 0 /* 0xf9 */, 0 /* 0xfa */, 0 /* 0xfb */, ++ 0 /* 0xfc */, 0 /* 0xfd */, 0 /* 0xfe */, 0 /* 0xff */ ++}; ++ ++int nghttp2_check_method(const uint8_t *value, size_t len) { ++ const uint8_t *last; ++ if (len == 0) { ++ return 0; ++ } ++ for (last = value + len; value != last; ++value) { ++ if (!VALID_METHOD_CHARS[*value]) { ++ return 0; ++ } ++ } ++ return 1; ++} ++ ++/* Generated by genpathchartbl.py */ ++static char VALID_PATH_CHARS[] = { ++ 0 /* NUL */, 0 /* SOH */, 0 /* STX */, 0 /* ETX */, ++ 0 /* EOT */, 0 /* ENQ */, 0 /* ACK */, 0 /* BEL */, ++ 0 /* BS */, 0 /* HT */, 0 /* LF */, 0 /* VT */, ++ 0 /* FF */, 0 /* CR */, 0 /* SO */, 0 /* SI */, ++ 0 /* DLE */, 0 /* DC1 */, 0 /* DC2 */, 0 /* DC3 */, ++ 0 /* DC4 */, 0 /* NAK */, 0 /* SYN */, 0 /* ETB */, ++ 0 /* CAN */, 0 /* EM */, 0 /* SUB */, 0 /* ESC */, ++ 0 /* FS */, 0 /* GS */, 0 /* RS */, 0 /* US */, ++ 0 /* SPC */, 1 /* ! */, 1 /* " */, 1 /* # */, ++ 1 /* $ */, 1 /* % */, 1 /* & */, 1 /* ' */, ++ 1 /* ( */, 1 /* ) */, 1 /* * */, 1 /* + */, ++ 1 /* , */, 1 /* - */, 1 /* . */, 1 /* / */, ++ 1 /* 0 */, 1 /* 1 */, 1 /* 2 */, 1 /* 3 */, ++ 1 /* 4 */, 1 /* 5 */, 1 /* 6 */, 1 /* 7 */, ++ 1 /* 8 */, 1 /* 9 */, 1 /* : */, 1 /* ; */, ++ 1 /* < */, 1 /* = */, 1 /* > */, 1 /* ? */, ++ 1 /* @ */, 1 /* A */, 1 /* B */, 1 /* C */, ++ 1 /* D */, 1 /* E */, 1 /* F */, 1 /* G */, ++ 1 /* H */, 1 /* I */, 1 /* J */, 1 /* K */, ++ 1 /* L */, 1 /* M */, 1 /* N */, 1 /* O */, ++ 1 /* P */, 1 /* Q */, 1 /* R */, 1 /* S */, ++ 1 /* T */, 1 /* U */, 1 /* V */, 1 /* W */, ++ 1 /* X */, 1 /* Y */, 1 /* Z */, 1 /* [ */, ++ 1 /* \ */, 1 /* ] */, 1 /* ^ */, 1 /* _ */, ++ 1 /* ` */, 1 /* a */, 1 /* b */, 1 /* c */, ++ 1 /* d */, 1 /* e */, 1 /* f */, 1 /* g */, ++ 1 /* h */, 1 /* i */, 1 /* j */, 1 /* k */, ++ 1 /* l */, 1 /* m */, 1 /* n */, 1 /* o */, ++ 1 /* p */, 1 /* q */, 1 /* r */, 1 /* s */, ++ 1 /* t */, 1 /* u */, 1 /* v */, 1 /* w */, ++ 1 /* x */, 1 /* y */, 1 /* z */, 1 /* { */, ++ 1 /* | */, 1 /* } */, 1 /* ~ */, 0 /* DEL */, ++ 1 /* 0x80 */, 1 /* 0x81 */, 1 /* 0x82 */, 1 /* 0x83 */, ++ 1 /* 0x84 */, 1 /* 0x85 */, 1 /* 0x86 */, 1 /* 0x87 */, ++ 1 /* 0x88 */, 1 /* 0x89 */, 1 /* 0x8a */, 1 /* 0x8b */, ++ 1 /* 0x8c */, 1 /* 0x8d */, 1 /* 0x8e */, 1 /* 0x8f */, ++ 1 /* 0x90 */, 1 /* 0x91 */, 1 /* 0x92 */, 1 /* 0x93 */, ++ 1 /* 0x94 */, 1 /* 0x95 */, 1 /* 0x96 */, 1 /* 0x97 */, ++ 1 /* 0x98 */, 1 /* 0x99 */, 1 /* 0x9a */, 1 /* 0x9b */, ++ 1 /* 0x9c */, 1 /* 0x9d */, 1 /* 0x9e */, 1 /* 0x9f */, ++ 1 /* 0xa0 */, 1 /* 0xa1 */, 1 /* 0xa2 */, 1 /* 0xa3 */, ++ 1 /* 0xa4 */, 1 /* 0xa5 */, 1 /* 0xa6 */, 1 /* 0xa7 */, ++ 1 /* 0xa8 */, 1 /* 0xa9 */, 1 /* 0xaa */, 1 /* 0xab */, ++ 1 /* 0xac */, 1 /* 0xad */, 1 /* 0xae */, 1 /* 0xaf */, ++ 1 /* 0xb0 */, 1 /* 0xb1 */, 1 /* 0xb2 */, 1 /* 0xb3 */, ++ 1 /* 0xb4 */, 1 /* 0xb5 */, 1 /* 0xb6 */, 1 /* 0xb7 */, ++ 1 /* 0xb8 */, 1 /* 0xb9 */, 1 /* 0xba */, 1 /* 0xbb */, ++ 1 /* 0xbc */, 1 /* 0xbd */, 1 /* 0xbe */, 1 /* 0xbf */, ++ 1 /* 0xc0 */, 1 /* 0xc1 */, 1 /* 0xc2 */, 1 /* 0xc3 */, ++ 1 /* 0xc4 */, 1 /* 0xc5 */, 1 /* 0xc6 */, 1 /* 0xc7 */, ++ 1 /* 0xc8 */, 1 /* 0xc9 */, 1 /* 0xca */, 1 /* 0xcb */, ++ 1 /* 0xcc */, 1 /* 0xcd */, 1 /* 0xce */, 1 /* 0xcf */, ++ 1 /* 0xd0 */, 1 /* 0xd1 */, 1 /* 0xd2 */, 1 /* 0xd3 */, ++ 1 /* 0xd4 */, 1 /* 0xd5 */, 1 /* 0xd6 */, 1 /* 0xd7 */, ++ 1 /* 0xd8 */, 1 /* 0xd9 */, 1 /* 0xda */, 1 /* 0xdb */, ++ 1 /* 0xdc */, 1 /* 0xdd */, 1 /* 0xde */, 1 /* 0xdf */, ++ 1 /* 0xe0 */, 1 /* 0xe1 */, 1 /* 0xe2 */, 1 /* 0xe3 */, ++ 1 /* 0xe4 */, 1 /* 0xe5 */, 1 /* 0xe6 */, 1 /* 0xe7 */, ++ 1 /* 0xe8 */, 1 /* 0xe9 */, 1 /* 0xea */, 1 /* 0xeb */, ++ 1 /* 0xec */, 1 /* 0xed */, 1 /* 0xee */, 1 /* 0xef */, ++ 1 /* 0xf0 */, 1 /* 0xf1 */, 1 /* 0xf2 */, 1 /* 0xf3 */, ++ 1 /* 0xf4 */, 1 /* 0xf5 */, 1 /* 0xf6 */, 1 /* 0xf7 */, ++ 1 /* 0xf8 */, 1 /* 0xf9 */, 1 /* 0xfa */, 1 /* 0xfb */, ++ 1 /* 0xfc */, 1 /* 0xfd */, 1 /* 0xfe */, 1 /* 0xff */ ++}; ++ ++int nghttp2_check_path(const uint8_t *value, size_t len) { ++ const uint8_t *last; ++ for (last = value + len; value != last; ++value) { ++ if (!VALID_PATH_CHARS[*value]) { ++ return 0; ++ } ++ } ++ return 1; ++} ++ ++/* Generated by genauthoritychartbl.py */ + static char VALID_AUTHORITY_CHARS[] = { + 0 /* NUL */, 0 /* SOH */, 0 /* STX */, 0 /* ETX */, + 0 /* EOT */, 0 /* ENQ */, 0 /* ACK */, 0 /* BEL */, +diff --git a/deps/nghttp2/lib/nghttp2_http.c b/deps/nghttp2/lib/nghttp2_http.c +index 62f57b6aec..ecdeb21ddb 100644 +--- a/deps/nghttp2/lib/nghttp2_http.c ++++ b/deps/nghttp2/lib/nghttp2_http.c +@@ -30,6 +30,8 @@ + + #include "nghttp2_hd.h" + #include "nghttp2_helper.h" ++#include "nghttp2_extpri.h" ++#include "sfparse.h" + + static uint8_t downcase(uint8_t c) { + return 'A' <= c && c <= 'Z' ? (uint8_t)(c - 'A' + 'a') : c; +@@ -72,25 +74,12 @@ static int64_t parse_uint(const uint8_t *s, size_t len) { + return n; + } + +-static int lws(const uint8_t *s, size_t n) { +- size_t i; +- for (i = 0; i < n; ++i) { +- if (s[i] != ' ' && s[i] != '\t') { +- return 0; +- } +- } +- return 1; +-} +- + static int check_pseudo_header(nghttp2_stream *stream, const nghttp2_hd_nv *nv, +- int flag) { +- if (stream->http_flags & flag) { +- return 0; +- } +- if (lws(nv->value->base, nv->value->len)) { ++ uint32_t flag) { ++ if ((stream->http_flags & flag) || nv->value->len == 0) { + return 0; + } +- stream->http_flags = (uint16_t)(stream->http_flags | flag); ++ stream->http_flags = stream->http_flags | flag; + return 1; + } + +@@ -114,6 +103,8 @@ static int check_path(nghttp2_stream *stream) { + + static int http_request_on_header(nghttp2_stream *stream, nghttp2_hd_nv *nv, + int trailer, int connect_protocol) { ++ nghttp2_extpri extpri; ++ + if (nv->name->base[0] == ':') { + if (trailer || + (stream->http_flags & NGHTTP2_HTTP_FLAG_PSEUDO_HEADER_DISALLOWED)) { +@@ -212,6 +203,23 @@ static int http_request_on_header(nghttp2_stream *stream, nghttp2_hd_nv *nv, + return NGHTTP2_ERR_HTTP_HEADER; + } + break; ++ case NGHTTP2_TOKEN_PRIORITY: ++ if (!trailer && ++ /* Do not parse the header field in PUSH_PROMISE. */ ++ (stream->stream_id & 1) && ++ (stream->flags & NGHTTP2_STREAM_FLAG_NO_RFC7540_PRIORITIES) && ++ !(stream->http_flags & NGHTTP2_HTTP_FLAG_BAD_PRIORITY)) { ++ nghttp2_extpri_from_uint8(&extpri, stream->http_extpri); ++ if (nghttp2_http_parse_priority(&extpri, nv->value->base, ++ nv->value->len) == 0) { ++ stream->http_extpri = nghttp2_extpri_to_uint8(&extpri); ++ stream->http_flags |= NGHTTP2_HTTP_FLAG_PRIORITY; ++ } else { ++ stream->http_flags &= (uint32_t)~NGHTTP2_HTTP_FLAG_PRIORITY; ++ stream->http_flags |= NGHTTP2_HTTP_FLAG_BAD_PRIORITY; ++ } ++ } ++ break; + default: + if (nv->name->base[0] == ':') { + return NGHTTP2_ERR_HTTP_HEADER; +@@ -329,6 +337,16 @@ static int check_scheme(const uint8_t *value, size_t len) { + return 1; + } + ++static int lws(const uint8_t *s, size_t n) { ++ size_t i; ++ for (i = 0; i < n; ++i) { ++ if (s[i] != ' ' && s[i] != '\t') { ++ return 0; ++ } ++ } ++ return 1; ++} ++ + int nghttp2_http_on_header(nghttp2_session *session, nghttp2_stream *stream, + nghttp2_frame *frame, nghttp2_hd_nv *nv, + int trailer) { +@@ -360,13 +378,46 @@ int nghttp2_http_on_header(nghttp2_session *session, nghttp2_stream *stream, + return NGHTTP2_ERR_IGN_HTTP_HEADER; + } + +- if (nv->token == NGHTTP2_TOKEN__AUTHORITY || +- nv->token == NGHTTP2_TOKEN_HOST) { +- rv = nghttp2_check_authority(nv->value->base, nv->value->len); +- } else if (nv->token == NGHTTP2_TOKEN__SCHEME) { ++ switch (nv->token) { ++ case NGHTTP2_TOKEN__METHOD: ++ rv = nghttp2_check_method(nv->value->base, nv->value->len); ++ break; ++ case NGHTTP2_TOKEN__PATH: ++ rv = nghttp2_check_path(nv->value->base, nv->value->len); ++ break; ++ case NGHTTP2_TOKEN__AUTHORITY: ++ case NGHTTP2_TOKEN_HOST: ++ if (session->server || frame->hd.type == NGHTTP2_PUSH_PROMISE) { ++ rv = nghttp2_check_authority(nv->value->base, nv->value->len); ++ } else if ( ++ stream->flags & ++ NGHTTP2_STREAM_FLAG_NO_RFC9113_LEADING_AND_TRAILING_WS_VALIDATION) { ++ rv = nghttp2_check_header_value(nv->value->base, nv->value->len); ++ } else { ++ rv = nghttp2_check_header_value_rfc9113(nv->value->base, nv->value->len); ++ } ++ break; ++ case NGHTTP2_TOKEN__SCHEME: + rv = check_scheme(nv->value->base, nv->value->len); +- } else { +- rv = nghttp2_check_header_value(nv->value->base, nv->value->len); ++ break; ++ case NGHTTP2_TOKEN__PROTOCOL: ++ /* Check the value consists of just white spaces, which was done ++ in check_pseudo_header before ++ nghttp2_check_header_value_rfc9113 has been introduced. */ ++ if ((stream->flags & ++ NGHTTP2_STREAM_FLAG_NO_RFC9113_LEADING_AND_TRAILING_WS_VALIDATION) && ++ lws(nv->value->base, nv->value->len)) { ++ rv = 0; ++ break; ++ } ++ /* fall through */ ++ default: ++ if (stream->flags & ++ NGHTTP2_STREAM_FLAG_NO_RFC9113_LEADING_AND_TRAILING_WS_VALIDATION) { ++ rv = nghttp2_check_header_value(nv->value->base, nv->value->len); ++ } else { ++ rv = nghttp2_check_header_value_rfc9113(nv->value->base, nv->value->len); ++ } + } + + if (rv == 0) { +@@ -434,16 +485,15 @@ int nghttp2_http_on_response_headers(nghttp2_stream *stream) { + + if (stream->status_code / 100 == 1) { + /* non-final response */ +- stream->http_flags = +- (uint16_t)((stream->http_flags & NGHTTP2_HTTP_FLAG_METH_ALL) | +- NGHTTP2_HTTP_FLAG_EXPECT_FINAL_RESPONSE); ++ stream->http_flags = (stream->http_flags & NGHTTP2_HTTP_FLAG_METH_ALL) | ++ NGHTTP2_HTTP_FLAG_EXPECT_FINAL_RESPONSE; + stream->content_length = -1; + stream->status_code = -1; + return 0; + } + + stream->http_flags = +- (uint16_t)(stream->http_flags & ~NGHTTP2_HTTP_FLAG_EXPECT_FINAL_RESPONSE); ++ stream->http_flags & (uint32_t)~NGHTTP2_HTTP_FLAG_EXPECT_FINAL_RESPONSE; + + if (!expect_response_body(stream)) { + stream->content_length = 0; +@@ -528,3 +578,54 @@ void nghttp2_http_record_request_method(nghttp2_stream *stream, + return; + } + } ++ ++int nghttp2_http_parse_priority(nghttp2_extpri *dest, const uint8_t *value, ++ size_t valuelen) { ++ nghttp2_extpri pri = *dest; ++ sf_parser sfp; ++ sf_vec key; ++ sf_value val; ++ int rv; ++ ++ sf_parser_init(&sfp, value, valuelen); ++ ++ for (;;) { ++ rv = sf_parser_dict(&sfp, &key, &val); ++ if (rv != 0) { ++ if (rv == SF_ERR_EOF) { ++ break; ++ } ++ ++ return NGHTTP2_ERR_INVALID_ARGUMENT; ++ } ++ ++ if (key.len != 1) { ++ continue; ++ } ++ ++ switch (key.base[0]) { ++ case 'i': ++ if (val.type != SF_TYPE_BOOLEAN) { ++ return NGHTTP2_ERR_INVALID_ARGUMENT; ++ } ++ ++ pri.inc = val.boolean; ++ ++ break; ++ case 'u': ++ if (val.type != SF_TYPE_INTEGER || ++ val.integer < NGHTTP2_EXTPRI_URGENCY_HIGH || ++ NGHTTP2_EXTPRI_URGENCY_LOW < val.integer) { ++ return NGHTTP2_ERR_INVALID_ARGUMENT; ++ } ++ ++ pri.urgency = (uint32_t)val.integer; ++ ++ break; ++ } ++ } ++ ++ *dest = pri; ++ ++ return 0; ++} +diff --git a/deps/nghttp2/lib/nghttp2_http.h b/deps/nghttp2/lib/nghttp2_http.h +index dd057cdb60..d9992fe690 100644 +--- a/deps/nghttp2/lib/nghttp2_http.h ++++ b/deps/nghttp2/lib/nghttp2_http.h +@@ -94,4 +94,7 @@ int nghttp2_http_on_data_chunk(nghttp2_stream *stream, size_t n); + void nghttp2_http_record_request_method(nghttp2_stream *stream, + nghttp2_frame *frame); + ++int nghttp2_http_parse_priority(nghttp2_extpri *dest, const uint8_t *value, ++ size_t valuelen); ++ + #endif /* NGHTTP2_HTTP_H */ +diff --git a/deps/nghttp2/lib/nghttp2_ksl.c b/deps/nghttp2/lib/nghttp2_ksl.c +deleted file mode 100644 +index dffd1cbcff..0000000000 +--- a/deps/nghttp2/lib/nghttp2_ksl.c ++++ /dev/null +@@ -1,707 +0,0 @@ +-/* +- * nghttp2 - HTTP/2 C Library +- * +- * Copyright (c) 2020 nghttp2 contributors +- * Copyright (c) 2018 ngtcp2 contributors +- * +- * Permission is hereby granted, free of charge, to any person obtaining +- * a copy of this software and associated documentation files (the +- * "Software"), to deal in the Software without restriction, including +- * without limitation the rights to use, copy, modify, merge, publish, +- * distribute, sublicense, and/or sell copies of the Software, and to +- * permit persons to whom the Software is furnished to do so, subject to +- * the following conditions: +- * +- * The above copyright notice and this permission notice shall be +- * included in all copies or substantial portions of the Software. +- * +- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +- * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +- * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +- */ +-#include "nghttp2_ksl.h" +- +-#include +-#include +-#include +-#include +- +-#include "nghttp2_mem.h" +- +-static size_t ksl_nodelen(size_t keylen) { +- return (sizeof(nghttp2_ksl_node) + keylen - sizeof(uint64_t) + 0xf) & +- (size_t)~0xf; +-} +- +-static size_t ksl_blklen(size_t nodelen) { +- return sizeof(nghttp2_ksl_blk) + nodelen * NGHTTP2_KSL_MAX_NBLK - +- sizeof(uint64_t); +-} +- +-/* +- * ksl_node_set_key sets |key| to |node|. +- */ +-static void ksl_node_set_key(nghttp2_ksl *ksl, nghttp2_ksl_node *node, +- const void *key) { +- memcpy(node->key, key, ksl->keylen); +-} +- +-int nghttp2_ksl_init(nghttp2_ksl *ksl, nghttp2_ksl_compar compar, size_t keylen, +- nghttp2_mem *mem) { +- size_t nodelen = ksl_nodelen(keylen); +- size_t blklen = ksl_blklen(nodelen); +- nghttp2_ksl_blk *head; +- +- ksl->head = nghttp2_mem_malloc(mem, blklen); +- if (!ksl->head) { +- return NGHTTP2_ERR_NOMEM; +- } +- ksl->front = ksl->back = ksl->head; +- ksl->compar = compar; +- ksl->keylen = keylen; +- ksl->nodelen = nodelen; +- ksl->n = 0; +- ksl->mem = mem; +- +- head = ksl->head; +- head->next = head->prev = NULL; +- head->n = 0; +- head->leaf = 1; +- +- return 0; +-} +- +-/* +- * ksl_free_blk frees |blk| recursively. +- */ +-static void ksl_free_blk(nghttp2_ksl *ksl, nghttp2_ksl_blk *blk) { +- size_t i; +- +- if (!blk->leaf) { +- for (i = 0; i < blk->n; ++i) { +- ksl_free_blk(ksl, nghttp2_ksl_nth_node(ksl, blk, i)->blk); +- } +- } +- +- nghttp2_mem_free(ksl->mem, blk); +-} +- +-void nghttp2_ksl_free(nghttp2_ksl *ksl) { +- if (!ksl) { +- return; +- } +- +- ksl_free_blk(ksl, ksl->head); +-} +- +-/* +- * ksl_split_blk splits |blk| into 2 nghttp2_ksl_blk objects. The new +- * nghttp2_ksl_blk is always the "right" block. +- * +- * It returns the pointer to the nghttp2_ksl_blk created which is the +- * located at the right of |blk|, or NULL which indicates out of +- * memory error. +- */ +-static nghttp2_ksl_blk *ksl_split_blk(nghttp2_ksl *ksl, nghttp2_ksl_blk *blk) { +- nghttp2_ksl_blk *rblk; +- +- rblk = nghttp2_mem_malloc(ksl->mem, ksl_blklen(ksl->nodelen)); +- if (rblk == NULL) { +- return NULL; +- } +- +- rblk->next = blk->next; +- blk->next = rblk; +- if (rblk->next) { +- rblk->next->prev = rblk; +- } else if (ksl->back == blk) { +- ksl->back = rblk; +- } +- rblk->prev = blk; +- rblk->leaf = blk->leaf; +- +- rblk->n = blk->n / 2; +- +- memcpy(rblk->nodes, blk->nodes + ksl->nodelen * (blk->n - rblk->n), +- ksl->nodelen * rblk->n); +- +- blk->n -= rblk->n; +- +- assert(blk->n >= NGHTTP2_KSL_MIN_NBLK); +- assert(rblk->n >= NGHTTP2_KSL_MIN_NBLK); +- +- return rblk; +-} +- +-/* +- * ksl_split_node splits a node included in |blk| at the position |i| +- * into 2 adjacent nodes. The new node is always inserted at the +- * position |i+1|. +- * +- * It returns 0 if it succeeds, or one of the following negative error +- * codes: +- * +- * NGHTTP2_ERR_NOMEM +- * Out of memory. +- */ +-static int ksl_split_node(nghttp2_ksl *ksl, nghttp2_ksl_blk *blk, size_t i) { +- nghttp2_ksl_node *node; +- nghttp2_ksl_blk *lblk = nghttp2_ksl_nth_node(ksl, blk, i)->blk, *rblk; +- +- rblk = ksl_split_blk(ksl, lblk); +- if (rblk == NULL) { +- return NGHTTP2_ERR_NOMEM; +- } +- +- memmove(blk->nodes + (i + 2) * ksl->nodelen, +- blk->nodes + (i + 1) * ksl->nodelen, +- ksl->nodelen * (blk->n - (i + 1))); +- +- node = nghttp2_ksl_nth_node(ksl, blk, i + 1); +- node->blk = rblk; +- ++blk->n; +- ksl_node_set_key(ksl, node, +- nghttp2_ksl_nth_node(ksl, rblk, rblk->n - 1)->key); +- +- node = nghttp2_ksl_nth_node(ksl, blk, i); +- ksl_node_set_key(ksl, node, +- nghttp2_ksl_nth_node(ksl, lblk, lblk->n - 1)->key); +- +- return 0; +-} +- +-/* +- * ksl_split_head splits a head (root) block. It increases the height +- * of skip list by 1. +- * +- * It returns 0 if it succeeds, or one of the following negative error +- * codes: +- * +- * NGHTTP2_ERR_NOMEM +- * Out of memory. +- */ +-static int ksl_split_head(nghttp2_ksl *ksl) { +- nghttp2_ksl_blk *rblk = NULL, *lblk, *nhead = NULL; +- nghttp2_ksl_node *node; +- +- rblk = ksl_split_blk(ksl, ksl->head); +- if (rblk == NULL) { +- return NGHTTP2_ERR_NOMEM; +- } +- +- lblk = ksl->head; +- +- nhead = nghttp2_mem_malloc(ksl->mem, ksl_blklen(ksl->nodelen)); +- if (nhead == NULL) { +- nghttp2_mem_free(ksl->mem, rblk); +- return NGHTTP2_ERR_NOMEM; +- } +- nhead->next = nhead->prev = NULL; +- nhead->n = 2; +- nhead->leaf = 0; +- +- node = nghttp2_ksl_nth_node(ksl, nhead, 0); +- ksl_node_set_key(ksl, node, +- nghttp2_ksl_nth_node(ksl, lblk, lblk->n - 1)->key); +- node->blk = lblk; +- +- node = nghttp2_ksl_nth_node(ksl, nhead, 1); +- ksl_node_set_key(ksl, node, +- nghttp2_ksl_nth_node(ksl, rblk, rblk->n - 1)->key); +- node->blk = rblk; +- +- ksl->head = nhead; +- +- return 0; +-} +- +-/* +- * insert_node inserts a node whose key is |key| with the associated +- * |data| at the index of |i|. This function assumes that the number +- * of nodes contained by |blk| is strictly less than +- * NGHTTP2_KSL_MAX_NBLK. +- */ +-static void ksl_insert_node(nghttp2_ksl *ksl, nghttp2_ksl_blk *blk, size_t i, +- const nghttp2_ksl_key *key, void *data) { +- nghttp2_ksl_node *node; +- +- assert(blk->n < NGHTTP2_KSL_MAX_NBLK); +- +- memmove(blk->nodes + (i + 1) * ksl->nodelen, blk->nodes + i * ksl->nodelen, +- ksl->nodelen * (blk->n - i)); +- +- node = nghttp2_ksl_nth_node(ksl, blk, i); +- ksl_node_set_key(ksl, node, key); +- node->data = data; +- +- ++blk->n; +-} +- +-static size_t ksl_bsearch(nghttp2_ksl *ksl, nghttp2_ksl_blk *blk, +- const nghttp2_ksl_key *key, +- nghttp2_ksl_compar compar) { +- ssize_t left = -1, right = (ssize_t)blk->n, mid; +- nghttp2_ksl_node *node; +- +- while (right - left > 1) { +- mid = (left + right) / 2; +- node = nghttp2_ksl_nth_node(ksl, blk, (size_t)mid); +- if (compar((nghttp2_ksl_key *)node->key, key)) { +- left = mid; +- } else { +- right = mid; +- } +- } +- +- return (size_t)right; +-} +- +-int nghttp2_ksl_insert(nghttp2_ksl *ksl, nghttp2_ksl_it *it, +- const nghttp2_ksl_key *key, void *data) { +- nghttp2_ksl_blk *blk = ksl->head; +- nghttp2_ksl_node *node; +- size_t i; +- int rv; +- +- if (blk->n == NGHTTP2_KSL_MAX_NBLK) { +- rv = ksl_split_head(ksl); +- if (rv != 0) { +- return rv; +- } +- blk = ksl->head; +- } +- +- for (;;) { +- i = ksl_bsearch(ksl, blk, key, ksl->compar); +- +- if (blk->leaf) { +- if (i < blk->n && +- !ksl->compar(key, nghttp2_ksl_nth_node(ksl, blk, i)->key)) { +- if (it) { +- *it = nghttp2_ksl_end(ksl); +- } +- return NGHTTP2_ERR_INVALID_ARGUMENT; +- } +- ksl_insert_node(ksl, blk, i, key, data); +- ++ksl->n; +- if (it) { +- nghttp2_ksl_it_init(it, ksl, blk, i); +- } +- return 0; +- } +- +- if (i == blk->n) { +- /* This insertion extends the largest key in this subtree. */ +- for (; !blk->leaf;) { +- node = nghttp2_ksl_nth_node(ksl, blk, blk->n - 1); +- if (node->blk->n == NGHTTP2_KSL_MAX_NBLK) { +- rv = ksl_split_node(ksl, blk, blk->n - 1); +- if (rv != 0) { +- return rv; +- } +- node = nghttp2_ksl_nth_node(ksl, blk, blk->n - 1); +- } +- ksl_node_set_key(ksl, node, key); +- blk = node->blk; +- } +- ksl_insert_node(ksl, blk, blk->n, key, data); +- ++ksl->n; +- if (it) { +- nghttp2_ksl_it_init(it, ksl, blk, blk->n - 1); +- } +- return 0; +- } +- +- node = nghttp2_ksl_nth_node(ksl, blk, i); +- +- if (node->blk->n == NGHTTP2_KSL_MAX_NBLK) { +- rv = ksl_split_node(ksl, blk, i); +- if (rv != 0) { +- return rv; +- } +- if (ksl->compar((nghttp2_ksl_key *)node->key, key)) { +- node = nghttp2_ksl_nth_node(ksl, blk, i + 1); +- if (ksl->compar((nghttp2_ksl_key *)node->key, key)) { +- ksl_node_set_key(ksl, node, key); +- } +- } +- } +- +- blk = node->blk; +- } +-} +- +-/* +- * ksl_remove_node removes the node included in |blk| at the index of +- * |i|. +- */ +-static void ksl_remove_node(nghttp2_ksl *ksl, nghttp2_ksl_blk *blk, size_t i) { +- memmove(blk->nodes + i * ksl->nodelen, blk->nodes + (i + 1) * ksl->nodelen, +- ksl->nodelen * (blk->n - (i + 1))); +- +- --blk->n; +-} +- +-/* +- * ksl_merge_node merges 2 nodes which are the nodes at the index of +- * |i| and |i + 1|. +- * +- * If |blk| is the direct descendant of head (root) block and the head +- * block contains just 2 nodes, the merged block becomes head block, +- * which decreases the height of |ksl| by 1. +- * +- * This function returns the pointer to the merged block. +- */ +-static nghttp2_ksl_blk *ksl_merge_node(nghttp2_ksl *ksl, nghttp2_ksl_blk *blk, +- size_t i) { +- nghttp2_ksl_blk *lblk, *rblk; +- +- assert(i + 1 < blk->n); +- +- lblk = nghttp2_ksl_nth_node(ksl, blk, i)->blk; +- rblk = nghttp2_ksl_nth_node(ksl, blk, i + 1)->blk; +- +- assert(lblk->n + rblk->n < NGHTTP2_KSL_MAX_NBLK); +- +- memcpy(lblk->nodes + ksl->nodelen * lblk->n, rblk->nodes, +- ksl->nodelen * rblk->n); +- +- lblk->n += rblk->n; +- lblk->next = rblk->next; +- if (lblk->next) { +- lblk->next->prev = lblk; +- } else if (ksl->back == rblk) { +- ksl->back = lblk; +- } +- +- nghttp2_mem_free(ksl->mem, rblk); +- +- if (ksl->head == blk && blk->n == 2) { +- nghttp2_mem_free(ksl->mem, ksl->head); +- ksl->head = lblk; +- } else { +- ksl_remove_node(ksl, blk, i + 1); +- ksl_node_set_key(ksl, nghttp2_ksl_nth_node(ksl, blk, i), +- nghttp2_ksl_nth_node(ksl, lblk, lblk->n - 1)->key); +- } +- +- return lblk; +-} +- +-/* +- * ksl_shift_left moves the first node in blk->nodes[i]->blk->nodes to +- * blk->nodes[i - 1]->blk->nodes. +- */ +-static void ksl_shift_left(nghttp2_ksl *ksl, nghttp2_ksl_blk *blk, size_t i) { +- nghttp2_ksl_node *lnode, *rnode, *dest, *src; +- +- assert(i > 0); +- +- lnode = nghttp2_ksl_nth_node(ksl, blk, i - 1); +- rnode = nghttp2_ksl_nth_node(ksl, blk, i); +- +- assert(lnode->blk->n < NGHTTP2_KSL_MAX_NBLK); +- assert(rnode->blk->n > NGHTTP2_KSL_MIN_NBLK); +- +- dest = nghttp2_ksl_nth_node(ksl, lnode->blk, lnode->blk->n); +- src = nghttp2_ksl_nth_node(ksl, rnode->blk, 0); +- +- memcpy(dest, src, ksl->nodelen); +- ksl_node_set_key(ksl, lnode, dest->key); +- ++lnode->blk->n; +- +- --rnode->blk->n; +- memmove(rnode->blk->nodes, rnode->blk->nodes + ksl->nodelen, +- ksl->nodelen * rnode->blk->n); +-} +- +-/* +- * ksl_shift_right moves the last node in blk->nodes[i]->blk->nodes to +- * blk->nodes[i + 1]->blk->nodes. +- */ +-static void ksl_shift_right(nghttp2_ksl *ksl, nghttp2_ksl_blk *blk, size_t i) { +- nghttp2_ksl_node *lnode, *rnode, *dest, *src; +- +- assert(i < blk->n - 1); +- +- lnode = nghttp2_ksl_nth_node(ksl, blk, i); +- rnode = nghttp2_ksl_nth_node(ksl, blk, i + 1); +- +- assert(lnode->blk->n > NGHTTP2_KSL_MIN_NBLK); +- assert(rnode->blk->n < NGHTTP2_KSL_MAX_NBLK); +- +- memmove(rnode->blk->nodes + ksl->nodelen, rnode->blk->nodes, +- ksl->nodelen * rnode->blk->n); +- ++rnode->blk->n; +- +- dest = nghttp2_ksl_nth_node(ksl, rnode->blk, 0); +- src = nghttp2_ksl_nth_node(ksl, lnode->blk, lnode->blk->n - 1); +- +- memcpy(dest, src, ksl->nodelen); +- +- --lnode->blk->n; +- ksl_node_set_key( +- ksl, lnode, +- nghttp2_ksl_nth_node(ksl, lnode->blk, lnode->blk->n - 1)->key); +-} +- +-/* +- * key_equal returns nonzero if |lhs| and |rhs| are equal using the +- * function |compar|. +- */ +-static int key_equal(nghttp2_ksl_compar compar, const nghttp2_ksl_key *lhs, +- const nghttp2_ksl_key *rhs) { +- return !compar(lhs, rhs) && !compar(rhs, lhs); +-} +- +-int nghttp2_ksl_remove(nghttp2_ksl *ksl, nghttp2_ksl_it *it, +- const nghttp2_ksl_key *key) { +- nghttp2_ksl_blk *blk = ksl->head; +- nghttp2_ksl_node *node; +- size_t i; +- +- if (!blk->leaf && blk->n == 2 && +- nghttp2_ksl_nth_node(ksl, blk, 0)->blk->n == NGHTTP2_KSL_MIN_NBLK && +- nghttp2_ksl_nth_node(ksl, blk, 1)->blk->n == NGHTTP2_KSL_MIN_NBLK) { +- blk = ksl_merge_node(ksl, ksl->head, 0); +- } +- +- for (;;) { +- i = ksl_bsearch(ksl, blk, key, ksl->compar); +- +- if (i == blk->n) { +- if (it) { +- *it = nghttp2_ksl_end(ksl); +- } +- return NGHTTP2_ERR_INVALID_ARGUMENT; +- } +- +- if (blk->leaf) { +- if (ksl->compar(key, nghttp2_ksl_nth_node(ksl, blk, i)->key)) { +- if (it) { +- *it = nghttp2_ksl_end(ksl); +- } +- return NGHTTP2_ERR_INVALID_ARGUMENT; +- } +- ksl_remove_node(ksl, blk, i); +- --ksl->n; +- if (it) { +- if (blk->n == i && blk->next) { +- nghttp2_ksl_it_init(it, ksl, blk->next, 0); +- } else { +- nghttp2_ksl_it_init(it, ksl, blk, i); +- } +- } +- return 0; +- } +- +- node = nghttp2_ksl_nth_node(ksl, blk, i); +- +- if (node->blk->n == NGHTTP2_KSL_MIN_NBLK) { +- if (i > 0 && nghttp2_ksl_nth_node(ksl, blk, i - 1)->blk->n > +- NGHTTP2_KSL_MIN_NBLK) { +- ksl_shift_right(ksl, blk, i - 1); +- blk = node->blk; +- } else if (i + 1 < blk->n && +- nghttp2_ksl_nth_node(ksl, blk, i + 1)->blk->n > +- NGHTTP2_KSL_MIN_NBLK) { +- ksl_shift_left(ksl, blk, i + 1); +- blk = node->blk; +- } else if (i > 0) { +- blk = ksl_merge_node(ksl, blk, i - 1); +- } else { +- assert(i + 1 < blk->n); +- blk = ksl_merge_node(ksl, blk, i); +- } +- } else { +- blk = node->blk; +- } +- } +-} +- +-nghttp2_ksl_it nghttp2_ksl_lower_bound(nghttp2_ksl *ksl, +- const nghttp2_ksl_key *key) { +- nghttp2_ksl_blk *blk = ksl->head; +- nghttp2_ksl_it it; +- size_t i; +- +- for (;;) { +- i = ksl_bsearch(ksl, blk, key, ksl->compar); +- +- if (blk->leaf) { +- if (i == blk->n && blk->next) { +- blk = blk->next; +- i = 0; +- } +- nghttp2_ksl_it_init(&it, ksl, blk, i); +- return it; +- } +- +- if (i == blk->n) { +- /* This happens if descendant has smaller key. Fast forward to +- find last node in this subtree. */ +- for (; !blk->leaf; blk = nghttp2_ksl_nth_node(ksl, blk, blk->n - 1)->blk) +- ; +- if (blk->next) { +- blk = blk->next; +- i = 0; +- } else { +- i = blk->n; +- } +- nghttp2_ksl_it_init(&it, ksl, blk, i); +- return it; +- } +- blk = nghttp2_ksl_nth_node(ksl, blk, i)->blk; +- } +-} +- +-nghttp2_ksl_it nghttp2_ksl_lower_bound_compar(nghttp2_ksl *ksl, +- const nghttp2_ksl_key *key, +- nghttp2_ksl_compar compar) { +- nghttp2_ksl_blk *blk = ksl->head; +- nghttp2_ksl_it it; +- size_t i; +- +- for (;;) { +- i = ksl_bsearch(ksl, blk, key, compar); +- +- if (blk->leaf) { +- if (i == blk->n && blk->next) { +- blk = blk->next; +- i = 0; +- } +- nghttp2_ksl_it_init(&it, ksl, blk, i); +- return it; +- } +- +- if (i == blk->n) { +- /* This happens if descendant has smaller key. Fast forward to +- find last node in this subtree. */ +- for (; !blk->leaf; blk = nghttp2_ksl_nth_node(ksl, blk, blk->n - 1)->blk) +- ; +- if (blk->next) { +- blk = blk->next; +- i = 0; +- } else { +- i = blk->n; +- } +- nghttp2_ksl_it_init(&it, ksl, blk, i); +- return it; +- } +- blk = nghttp2_ksl_nth_node(ksl, blk, i)->blk; +- } +-} +- +-void nghttp2_ksl_update_key(nghttp2_ksl *ksl, const nghttp2_ksl_key *old_key, +- const nghttp2_ksl_key *new_key) { +- nghttp2_ksl_blk *blk = ksl->head; +- nghttp2_ksl_node *node; +- size_t i; +- +- for (;;) { +- i = ksl_bsearch(ksl, blk, old_key, ksl->compar); +- +- assert(i < blk->n); +- node = nghttp2_ksl_nth_node(ksl, blk, i); +- +- if (blk->leaf) { +- assert(key_equal(ksl->compar, (nghttp2_ksl_key *)node->key, old_key)); +- ksl_node_set_key(ksl, node, new_key); +- return; +- } +- +- if (key_equal(ksl->compar, (nghttp2_ksl_key *)node->key, old_key) || +- ksl->compar((nghttp2_ksl_key *)node->key, new_key)) { +- ksl_node_set_key(ksl, node, new_key); +- } +- +- blk = node->blk; +- } +-} +- +-static void ksl_print(nghttp2_ksl *ksl, nghttp2_ksl_blk *blk, size_t level) { +- size_t i; +- nghttp2_ksl_node *node; +- +- fprintf(stderr, "LV=%zu n=%zu\n", level, blk->n); +- +- if (blk->leaf) { +- for (i = 0; i < blk->n; ++i) { +- node = nghttp2_ksl_nth_node(ksl, blk, i); +- fprintf(stderr, " %" PRId64, *(int64_t *)(void *)node->key); +- } +- fprintf(stderr, "\n"); +- return; +- } +- +- for (i = 0; i < blk->n; ++i) { +- ksl_print(ksl, nghttp2_ksl_nth_node(ksl, blk, i)->blk, level + 1); +- } +-} +- +-size_t nghttp2_ksl_len(nghttp2_ksl *ksl) { return ksl->n; } +- +-void nghttp2_ksl_clear(nghttp2_ksl *ksl) { +- size_t i; +- nghttp2_ksl_blk *head; +- +- if (!ksl->head->leaf) { +- for (i = 0; i < ksl->head->n; ++i) { +- ksl_free_blk(ksl, nghttp2_ksl_nth_node(ksl, ksl->head, i)->blk); +- } +- } +- +- ksl->front = ksl->back = ksl->head; +- ksl->n = 0; +- +- head = ksl->head; +- +- head->next = head->prev = NULL; +- head->n = 0; +- head->leaf = 1; +-} +- +-void nghttp2_ksl_print(nghttp2_ksl *ksl) { ksl_print(ksl, ksl->head, 0); } +- +-nghttp2_ksl_it nghttp2_ksl_begin(const nghttp2_ksl *ksl) { +- nghttp2_ksl_it it; +- nghttp2_ksl_it_init(&it, ksl, ksl->front, 0); +- return it; +-} +- +-nghttp2_ksl_it nghttp2_ksl_end(const nghttp2_ksl *ksl) { +- nghttp2_ksl_it it; +- nghttp2_ksl_it_init(&it, ksl, ksl->back, ksl->back->n); +- return it; +-} +- +-void nghttp2_ksl_it_init(nghttp2_ksl_it *it, const nghttp2_ksl *ksl, +- nghttp2_ksl_blk *blk, size_t i) { +- it->ksl = ksl; +- it->blk = blk; +- it->i = i; +-} +- +-void *nghttp2_ksl_it_get(const nghttp2_ksl_it *it) { +- assert(it->i < it->blk->n); +- return nghttp2_ksl_nth_node(it->ksl, it->blk, it->i)->data; +-} +- +-void nghttp2_ksl_it_prev(nghttp2_ksl_it *it) { +- assert(!nghttp2_ksl_it_begin(it)); +- +- if (it->i == 0) { +- it->blk = it->blk->prev; +- it->i = it->blk->n - 1; +- } else { +- --it->i; +- } +-} +- +-int nghttp2_ksl_it_begin(const nghttp2_ksl_it *it) { +- return it->i == 0 && it->blk->prev == NULL; +-} +diff --git a/deps/nghttp2/lib/nghttp2_ksl.h b/deps/nghttp2/lib/nghttp2_ksl.h +deleted file mode 100644 +index 39d900ffbf..0000000000 +--- a/deps/nghttp2/lib/nghttp2_ksl.h ++++ /dev/null +@@ -1,315 +0,0 @@ +-/* +- * nghttp2 - HTTP/2 C Library +- * +- * Copyright (c) 2020 nghttp2 contributors +- * Copyright (c) 2018 ngtcp2 contributors +- * +- * Permission is hereby granted, free of charge, to any person obtaining +- * a copy of this software and associated documentation files (the +- * "Software"), to deal in the Software without restriction, including +- * without limitation the rights to use, copy, modify, merge, publish, +- * distribute, sublicense, and/or sell copies of the Software, and to +- * permit persons to whom the Software is furnished to do so, subject to +- * the following conditions: +- * +- * The above copyright notice and this permission notice shall be +- * included in all copies or substantial portions of the Software. +- * +- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +- * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +- * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +- */ +-#ifndef NGHTTP2_KSL_H +-#define NGHTTP2_KSL_H +- +-#ifdef HAVE_CONFIG_H +-# include +-#endif /* HAVE_CONFIG_H */ +- +-#include +- +-#include +- +-/* +- * Skip List using single key instead of range. +- */ +- +-#define NGHTTP2_KSL_DEGR 16 +-/* NGHTTP2_KSL_MAX_NBLK is the maximum number of nodes which a single +- block can contain. */ +-#define NGHTTP2_KSL_MAX_NBLK (2 * NGHTTP2_KSL_DEGR - 1) +-/* NGHTTP2_KSL_MIN_NBLK is the minimum number of nodes which a single +- block other than root must contains. */ +-#define NGHTTP2_KSL_MIN_NBLK (NGHTTP2_KSL_DEGR - 1) +- +-/* +- * nghttp2_ksl_key represents key in nghttp2_ksl. +- */ +-typedef void nghttp2_ksl_key; +- +-struct nghttp2_ksl_node; +-typedef struct nghttp2_ksl_node nghttp2_ksl_node; +- +-struct nghttp2_ksl_blk; +-typedef struct nghttp2_ksl_blk nghttp2_ksl_blk; +- +-/* +- * nghttp2_ksl_node is a node which contains either nghttp2_ksl_blk or +- * opaque data. If a node is an internal node, it contains +- * nghttp2_ksl_blk. Otherwise, it has data. The key is stored at the +- * location starting at key. +- */ +-struct nghttp2_ksl_node { +- union { +- nghttp2_ksl_blk *blk; +- void *data; +- }; +- union { +- uint64_t align; +- /* key is a buffer to include key associated to this node. +- Because the length of key is unknown until nghttp2_ksl_init is +- called, the actual buffer will be allocated after this +- field. */ +- uint8_t key[1]; +- }; +-}; +- +-/* +- * nghttp2_ksl_blk contains nghttp2_ksl_node objects. +- */ +-struct nghttp2_ksl_blk { +- /* next points to the next block if leaf field is nonzero. */ +- nghttp2_ksl_blk *next; +- /* prev points to the previous block if leaf field is nonzero. */ +- nghttp2_ksl_blk *prev; +- /* n is the number of nodes this object contains in nodes. */ +- size_t n; +- /* leaf is nonzero if this block contains leaf nodes. */ +- int leaf; +- union { +- uint64_t align; +- /* nodes is a buffer to contain NGHTTP2_KSL_MAX_NBLK +- nghttp2_ksl_node objects. Because nghttp2_ksl_node object is +- allocated along with the additional variable length key +- storage, the size of buffer is unknown until nghttp2_ksl_init is +- called. */ +- uint8_t nodes[1]; +- }; +-}; +- +-/* +- * nghttp2_ksl_compar is a function type which returns nonzero if key +- * |lhs| should be placed before |rhs|. It returns 0 otherwise. +- */ +-typedef int (*nghttp2_ksl_compar)(const nghttp2_ksl_key *lhs, +- const nghttp2_ksl_key *rhs); +- +-struct nghttp2_ksl; +-typedef struct nghttp2_ksl nghttp2_ksl; +- +-struct nghttp2_ksl_it; +-typedef struct nghttp2_ksl_it nghttp2_ksl_it; +- +-/* +- * nghttp2_ksl_it is a forward iterator to iterate nodes. +- */ +-struct nghttp2_ksl_it { +- const nghttp2_ksl *ksl; +- nghttp2_ksl_blk *blk; +- size_t i; +-}; +- +-/* +- * nghttp2_ksl is a deterministic paged skip list. +- */ +-struct nghttp2_ksl { +- /* head points to the root block. */ +- nghttp2_ksl_blk *head; +- /* front points to the first leaf block. */ +- nghttp2_ksl_blk *front; +- /* back points to the last leaf block. */ +- nghttp2_ksl_blk *back; +- nghttp2_ksl_compar compar; +- size_t n; +- /* keylen is the size of key */ +- size_t keylen; +- /* nodelen is the actual size of nghttp2_ksl_node including key +- storage. */ +- size_t nodelen; +- nghttp2_mem *mem; +-}; +- +-/* +- * nghttp2_ksl_init initializes |ksl|. |compar| specifies compare +- * function. |keylen| is the length of key. +- * +- * It returns 0 if it succeeds, or one of the following negative error +- * codes: +- * +- * NGHTTP2_ERR_NOMEM +- * Out of memory. +- */ +-int nghttp2_ksl_init(nghttp2_ksl *ksl, nghttp2_ksl_compar compar, size_t keylen, +- nghttp2_mem *mem); +- +-/* +- * nghttp2_ksl_free frees resources allocated for |ksl|. If |ksl| is +- * NULL, this function does nothing. It does not free the memory +- * region pointed by |ksl| itself. +- */ +-void nghttp2_ksl_free(nghttp2_ksl *ksl); +- +-/* +- * nghttp2_ksl_insert inserts |key| with its associated |data|. On +- * successful insertion, the iterator points to the inserted node is +- * stored in |*it|. +- * +- * This function returns 0 if it succeeds, or one of the following +- * negative error codes: +- * +- * NGHTTP2_ERR_NOMEM +- * Out of memory. +- * NGHTTP2_ERR_INVALID_ARGUMENT +- * |key| already exists. +- */ +-int nghttp2_ksl_insert(nghttp2_ksl *ksl, nghttp2_ksl_it *it, +- const nghttp2_ksl_key *key, void *data); +- +-/* +- * nghttp2_ksl_remove removes the |key| from |ksl|. +- * +- * This function assigns the iterator to |*it|, which points to the +- * node which is located at the right next of the removed node if |it| +- * is not NULL. If |key| is not found, no deletion takes place and +- * the return value of nghttp2_ksl_end(ksl) is assigned to |*it|. +- * +- * This function returns 0 if it succeeds, or one of the following +- * negative error codes: +- * +- * NGHTTP2_ERR_INVALID_ARGUMENT +- * |key| does not exist. +- */ +-int nghttp2_ksl_remove(nghttp2_ksl *ksl, nghttp2_ksl_it *it, +- const nghttp2_ksl_key *key); +- +-/* +- * nghttp2_ksl_lower_bound returns the iterator which points to the +- * first node which has the key which is equal to |key| or the last +- * node which satisfies !compar(&node->key, key). If there is no such +- * node, it returns the iterator which satisfies nghttp2_ksl_it_end(it) +- * != 0. +- */ +-nghttp2_ksl_it nghttp2_ksl_lower_bound(nghttp2_ksl *ksl, +- const nghttp2_ksl_key *key); +- +-/* +- * nghttp2_ksl_lower_bound_compar works like nghttp2_ksl_lower_bound, +- * but it takes custom function |compar| to do lower bound search. +- */ +-nghttp2_ksl_it nghttp2_ksl_lower_bound_compar(nghttp2_ksl *ksl, +- const nghttp2_ksl_key *key, +- nghttp2_ksl_compar compar); +- +-/* +- * nghttp2_ksl_update_key replaces the key of nodes which has |old_key| +- * with |new_key|. |new_key| must be strictly greater than the +- * previous node and strictly smaller than the next node. +- */ +-void nghttp2_ksl_update_key(nghttp2_ksl *ksl, const nghttp2_ksl_key *old_key, +- const nghttp2_ksl_key *new_key); +- +-/* +- * nghttp2_ksl_begin returns the iterator which points to the first +- * node. If there is no node in |ksl|, it returns the iterator which +- * satisfies nghttp2_ksl_it_end(it) != 0. +- */ +-nghttp2_ksl_it nghttp2_ksl_begin(const nghttp2_ksl *ksl); +- +-/* +- * nghttp2_ksl_end returns the iterator which points to the node +- * following the last node. The returned object satisfies +- * nghttp2_ksl_it_end(). If there is no node in |ksl|, it returns the +- * iterator which satisfies nghttp2_ksl_it_begin(it) != 0. +- */ +-nghttp2_ksl_it nghttp2_ksl_end(const nghttp2_ksl *ksl); +- +-/* +- * nghttp2_ksl_len returns the number of elements stored in |ksl|. +- */ +-size_t nghttp2_ksl_len(nghttp2_ksl *ksl); +- +-/* +- * nghttp2_ksl_clear removes all elements stored in |ksl|. +- */ +-void nghttp2_ksl_clear(nghttp2_ksl *ksl); +- +-/* +- * nghttp2_ksl_nth_node returns the |n|th node under |blk|. +- */ +-#define nghttp2_ksl_nth_node(KSL, BLK, N) \ +- ((nghttp2_ksl_node *)(void *)((BLK)->nodes + (KSL)->nodelen * (N))) +- +-/* +- * nghttp2_ksl_print prints its internal state in stderr. It assumes +- * that the key is of type int64_t. This function should be used for +- * the debugging purpose only. +- */ +-void nghttp2_ksl_print(nghttp2_ksl *ksl); +- +-/* +- * nghttp2_ksl_it_init initializes |it|. +- */ +-void nghttp2_ksl_it_init(nghttp2_ksl_it *it, const nghttp2_ksl *ksl, +- nghttp2_ksl_blk *blk, size_t i); +- +-/* +- * nghttp2_ksl_it_get returns the data associated to the node which +- * |it| points to. It is undefined to call this function when +- * nghttp2_ksl_it_end(it) returns nonzero. +- */ +-void *nghttp2_ksl_it_get(const nghttp2_ksl_it *it); +- +-/* +- * nghttp2_ksl_it_next advances the iterator by one. It is undefined +- * if this function is called when nghttp2_ksl_it_end(it) returns +- * nonzero. +- */ +-#define nghttp2_ksl_it_next(IT) \ +- (++(IT)->i == (IT)->blk->n && (IT)->blk->next \ +- ? ((IT)->blk = (IT)->blk->next, (IT)->i = 0) \ +- : 0) +- +-/* +- * nghttp2_ksl_it_prev moves backward the iterator by one. It is +- * undefined if this function is called when nghttp2_ksl_it_begin(it) +- * returns nonzero. +- */ +-void nghttp2_ksl_it_prev(nghttp2_ksl_it *it); +- +-/* +- * nghttp2_ksl_it_end returns nonzero if |it| points to the beyond the +- * last node. +- */ +-#define nghttp2_ksl_it_end(IT) \ +- ((IT)->blk->n == (IT)->i && (IT)->blk->next == NULL) +- +-/* +- * nghttp2_ksl_it_begin returns nonzero if |it| points to the first +- * node. |it| might satisfy both nghttp2_ksl_it_begin(&it) and +- * nghttp2_ksl_it_end(&it) if the skip list has no node. +- */ +-int nghttp2_ksl_it_begin(const nghttp2_ksl_it *it); +- +-/* +- * nghttp2_ksl_key returns the key of the node which |it| points to. +- * It is undefined to call this function when nghttp2_ksl_it_end(it) +- * returns nonzero. +- */ +-#define nghttp2_ksl_it_key(IT) \ +- ((nghttp2_ksl_key *)nghttp2_ksl_nth_node((IT)->ksl, (IT)->blk, (IT)->i)->key) +- +-#endif /* NGHTTP2_KSL_H */ +diff --git a/deps/nghttp2/lib/nghttp2_map.c b/deps/nghttp2/lib/nghttp2_map.c +index d12a1f4757..5f63fc2bb8 100644 +--- a/deps/nghttp2/lib/nghttp2_map.c ++++ b/deps/nghttp2/lib/nghttp2_map.c +@@ -27,172 +27,166 @@ + + #include + #include ++#include + + #include "nghttp2_helper.h" + +-#define INITIAL_TABLE_LENGTH 256 ++#define NGHTTP2_INITIAL_TABLE_LENBITS 4 + +-int nghttp2_map_init(nghttp2_map *map, nghttp2_mem *mem) { ++void nghttp2_map_init(nghttp2_map *map, nghttp2_mem *mem) { + map->mem = mem; +- map->tablelen = INITIAL_TABLE_LENGTH; +- map->table = +- nghttp2_mem_calloc(mem, map->tablelen, sizeof(nghttp2_map_bucket)); +- if (map->table == NULL) { +- return NGHTTP2_ERR_NOMEM; +- } +- ++ map->tablelen = 0; ++ map->tablelenbits = 0; ++ map->table = NULL; + map->size = 0; +- +- return 0; + } + + void nghttp2_map_free(nghttp2_map *map) { +- size_t i; +- nghttp2_map_bucket *bkt; +- + if (!map) { + return; + } + +- for (i = 0; i < map->tablelen; ++i) { +- bkt = &map->table[i]; +- if (bkt->ksl) { +- nghttp2_ksl_free(bkt->ksl); +- nghttp2_mem_free(map->mem, bkt->ksl); +- } +- } +- + nghttp2_mem_free(map->mem, map->table); + } + +-void nghttp2_map_each_free(nghttp2_map *map, +- int (*func)(nghttp2_map_entry *entry, void *ptr), ++void nghttp2_map_each_free(nghttp2_map *map, int (*func)(void *data, void *ptr), + void *ptr) { + uint32_t i; + nghttp2_map_bucket *bkt; +- nghttp2_ksl_it it; + + for (i = 0; i < map->tablelen; ++i) { + bkt = &map->table[i]; + +- if (bkt->ptr) { +- func(bkt->ptr, ptr); +- bkt->ptr = NULL; +- assert(bkt->ksl == NULL || nghttp2_ksl_len(bkt->ksl) == 0); ++ if (bkt->data == NULL) { + continue; + } + +- if (bkt->ksl) { +- for (it = nghttp2_ksl_begin(bkt->ksl); !nghttp2_ksl_it_end(&it); +- nghttp2_ksl_it_next(&it)) { +- func(nghttp2_ksl_it_get(&it), ptr); +- } +- +- nghttp2_ksl_free(bkt->ksl); +- nghttp2_mem_free(map->mem, bkt->ksl); +- bkt->ksl = NULL; +- } ++ func(bkt->data, ptr); + } + } + +-int nghttp2_map_each(nghttp2_map *map, +- int (*func)(nghttp2_map_entry *entry, void *ptr), ++int nghttp2_map_each(nghttp2_map *map, int (*func)(void *data, void *ptr), + void *ptr) { + int rv; + uint32_t i; + nghttp2_map_bucket *bkt; +- nghttp2_ksl_it it; ++ ++ if (map->size == 0) { ++ return 0; ++ } + + for (i = 0; i < map->tablelen; ++i) { + bkt = &map->table[i]; + +- if (bkt->ptr) { +- rv = func(bkt->ptr, ptr); +- if (rv != 0) { +- return rv; +- } +- assert(bkt->ksl == NULL || nghttp2_ksl_len(bkt->ksl) == 0); ++ if (bkt->data == NULL) { + continue; + } + +- if (bkt->ksl) { +- for (it = nghttp2_ksl_begin(bkt->ksl); !nghttp2_ksl_it_end(&it); +- nghttp2_ksl_it_next(&it)) { +- rv = func(nghttp2_ksl_it_get(&it), ptr); +- if (rv != 0) { +- return rv; +- } +- } ++ rv = func(bkt->data, ptr); ++ if (rv != 0) { ++ return rv; + } + } ++ + return 0; + } + +-void nghttp2_map_entry_init(nghttp2_map_entry *entry, key_type key) { +- entry->key = key; +- entry->next = NULL; ++static uint32_t hash(nghttp2_map_key_type key) { ++ return (uint32_t)key * 2654435769u; + } + +-/* FNV1a hash */ +-static uint32_t hash(key_type key, uint32_t mod) { +- uint8_t *p, *end; +- uint32_t h = 0x811C9DC5u; ++static size_t h2idx(uint32_t hash, uint32_t bits) { ++ return hash >> (32 - bits); ++} + +- p = (uint8_t *)&key; +- end = p + sizeof(key_type); ++static size_t distance(uint32_t tablelen, uint32_t tablelenbits, ++ nghttp2_map_bucket *bkt, size_t idx) { ++ return (idx - h2idx(bkt->hash, tablelenbits)) & (tablelen - 1); ++} + +- for (; p != end;) { +- h ^= *p++; +- h += (h << 1) + (h << 4) + (h << 7) + (h << 8) + (h << 24); +- } ++static void map_bucket_swap(nghttp2_map_bucket *bkt, uint32_t *phash, ++ nghttp2_map_key_type *pkey, void **pdata) { ++ uint32_t h = bkt->hash; ++ nghttp2_map_key_type key = bkt->key; ++ void *data = bkt->data; + +- return h & (mod - 1); ++ bkt->hash = *phash; ++ bkt->key = *pkey; ++ bkt->data = *pdata; ++ ++ *phash = h; ++ *pkey = key; ++ *pdata = data; + } + +-static int less(const nghttp2_ksl_key *lhs, const nghttp2_ksl_key *rhs) { +- return *(key_type *)lhs < *(key_type *)rhs; ++static void map_bucket_set_data(nghttp2_map_bucket *bkt, uint32_t hash, ++ nghttp2_map_key_type key, void *data) { ++ bkt->hash = hash; ++ bkt->key = key; ++ bkt->data = data; + } + +-static int map_insert(nghttp2_map *map, nghttp2_map_bucket *table, +- uint32_t tablelen, nghttp2_map_entry *entry) { +- uint32_t h = hash(entry->key, tablelen); +- nghttp2_map_bucket *bkt = &table[h]; +- nghttp2_mem *mem = map->mem; +- int rv; ++void nghttp2_map_print_distance(nghttp2_map *map) { ++ uint32_t i; ++ size_t idx; ++ nghttp2_map_bucket *bkt; + +- if (bkt->ptr == NULL && +- (bkt->ksl == NULL || nghttp2_ksl_len(bkt->ksl) == 0)) { +- bkt->ptr = entry; +- return 0; +- } ++ for (i = 0; i < map->tablelen; ++i) { ++ bkt = &map->table[i]; + +- if (!bkt->ksl) { +- bkt->ksl = nghttp2_mem_malloc(mem, sizeof(*bkt->ksl)); +- if (bkt->ksl == NULL) { +- return NGHTTP2_ERR_NOMEM; ++ if (bkt->data == NULL) { ++ fprintf(stderr, "@%u \n", i); ++ continue; + } +- nghttp2_ksl_init(bkt->ksl, less, sizeof(key_type), mem); ++ ++ idx = h2idx(bkt->hash, map->tablelenbits); ++ fprintf(stderr, "@%u hash=%08x key=%d base=%zu distance=%zu\n", i, ++ bkt->hash, bkt->key, idx, ++ distance(map->tablelen, map->tablelenbits, bkt, idx)); + } ++} + +- if (bkt->ptr) { +- rv = nghttp2_ksl_insert(bkt->ksl, NULL, &bkt->ptr->key, bkt->ptr); +- if (rv != 0) { +- return rv; ++static int insert(nghttp2_map_bucket *table, uint32_t tablelen, ++ uint32_t tablelenbits, uint32_t hash, ++ nghttp2_map_key_type key, void *data) { ++ size_t idx = h2idx(hash, tablelenbits); ++ size_t d = 0, dd; ++ nghttp2_map_bucket *bkt; ++ ++ for (;;) { ++ bkt = &table[idx]; ++ ++ if (bkt->data == NULL) { ++ map_bucket_set_data(bkt, hash, key, data); ++ return 0; + } + +- bkt->ptr = NULL; +- } ++ dd = distance(tablelen, tablelenbits, bkt, idx); ++ if (d > dd) { ++ map_bucket_swap(bkt, &hash, &key, &data); ++ d = dd; ++ } else if (bkt->key == key) { ++ /* TODO This check is just a waste after first swap or if this ++ function is called from map_resize. That said, there is no ++ difference with or without this conditional in performance ++ wise. */ ++ return NGHTTP2_ERR_INVALID_ARGUMENT; ++ } + +- return nghttp2_ksl_insert(bkt->ksl, NULL, &entry->key, entry); ++ ++d; ++ idx = (idx + 1) & (tablelen - 1); ++ } + } + +-/* new_tablelen must be power of 2 */ +-static int map_resize(nghttp2_map *map, uint32_t new_tablelen) { ++/* new_tablelen must be power of 2 and new_tablelen == (1 << ++ new_tablelenbits) must hold. */ ++static int map_resize(nghttp2_map *map, uint32_t new_tablelen, ++ uint32_t new_tablelenbits) { + uint32_t i; + nghttp2_map_bucket *new_table; + nghttp2_map_bucket *bkt; +- nghttp2_ksl_it it; + int rv; ++ (void)rv; + + new_table = + nghttp2_mem_calloc(map->mem, new_tablelen, sizeof(nghttp2_map_bucket)); +@@ -202,64 +196,46 @@ static int map_resize(nghttp2_map *map, uint32_t new_tablelen) { + + for (i = 0; i < map->tablelen; ++i) { + bkt = &map->table[i]; +- +- if (bkt->ptr) { +- rv = map_insert(map, new_table, new_tablelen, bkt->ptr); +- if (rv != 0) { +- goto fail; +- } +- assert(bkt->ksl == NULL || nghttp2_ksl_len(bkt->ksl) == 0); ++ if (bkt->data == NULL) { + continue; + } ++ rv = insert(new_table, new_tablelen, new_tablelenbits, bkt->hash, bkt->key, ++ bkt->data); + +- if (bkt->ksl) { +- for (it = nghttp2_ksl_begin(bkt->ksl); !nghttp2_ksl_it_end(&it); +- nghttp2_ksl_it_next(&it)) { +- rv = map_insert(map, new_table, new_tablelen, nghttp2_ksl_it_get(&it)); +- if (rv != 0) { +- goto fail; +- } +- } +- } +- } +- +- for (i = 0; i < map->tablelen; ++i) { +- bkt = &map->table[i]; +- if (bkt->ksl) { +- nghttp2_ksl_free(bkt->ksl); +- nghttp2_mem_free(map->mem, bkt->ksl); +- } ++ assert(0 == rv); + } + + nghttp2_mem_free(map->mem, map->table); + map->tablelen = new_tablelen; ++ map->tablelenbits = new_tablelenbits; + map->table = new_table; + + return 0; +- +-fail: +- for (i = 0; i < new_tablelen; ++i) { +- bkt = &new_table[i]; +- if (bkt->ksl) { +- nghttp2_ksl_free(bkt->ksl); +- nghttp2_mem_free(map->mem, bkt->ksl); +- } +- } +- +- return rv; + } + +-int nghttp2_map_insert(nghttp2_map *map, nghttp2_map_entry *new_entry) { ++int nghttp2_map_insert(nghttp2_map *map, nghttp2_map_key_type key, void *data) { + int rv; + ++ assert(data); ++ + /* Load factor is 0.75 */ + if ((map->size + 1) * 4 > map->tablelen * 3) { +- rv = map_resize(map, map->tablelen * 2); +- if (rv != 0) { +- return rv; ++ if (map->tablelen) { ++ rv = map_resize(map, map->tablelen * 2, map->tablelenbits + 1); ++ if (rv != 0) { ++ return rv; ++ } ++ } else { ++ rv = map_resize(map, 1 << NGHTTP2_INITIAL_TABLE_LENBITS, ++ NGHTTP2_INITIAL_TABLE_LENBITS); ++ if (rv != 0) { ++ return rv; ++ } + } + } +- rv = map_insert(map, map->table, map->tablelen, new_entry); ++ ++ rv = insert(map->table, map->tablelen, map->tablelenbits, hash(key), key, ++ data); + if (rv != 0) { + return rv; + } +@@ -267,68 +243,93 @@ int nghttp2_map_insert(nghttp2_map *map, nghttp2_map_entry *new_entry) { + return 0; + } + +-nghttp2_map_entry *nghttp2_map_find(nghttp2_map *map, key_type key) { +- nghttp2_map_bucket *bkt = &map->table[hash(key, map->tablelen)]; +- nghttp2_ksl_it it; ++void *nghttp2_map_find(nghttp2_map *map, nghttp2_map_key_type key) { ++ uint32_t h; ++ size_t idx; ++ nghttp2_map_bucket *bkt; ++ size_t d = 0; + +- if (bkt->ptr) { +- if (bkt->ptr->key == key) { +- return bkt->ptr; +- } ++ if (map->size == 0) { + return NULL; + } + +- if (bkt->ksl) { +- it = nghttp2_ksl_lower_bound(bkt->ksl, &key); +- if (nghttp2_ksl_it_end(&it) || +- *(key_type *)nghttp2_ksl_it_key(&it) != key) { ++ h = hash(key); ++ idx = h2idx(h, map->tablelenbits); ++ ++ for (;;) { ++ bkt = &map->table[idx]; ++ ++ if (bkt->data == NULL || ++ d > distance(map->tablelen, map->tablelenbits, bkt, idx)) { + return NULL; + } +- return nghttp2_ksl_it_get(&it); +- } + +- return NULL; ++ if (bkt->key == key) { ++ return bkt->data; ++ } ++ ++ ++d; ++ idx = (idx + 1) & (map->tablelen - 1); ++ } + } + +-int nghttp2_map_remove(nghttp2_map *map, key_type key) { +- nghttp2_map_bucket *bkt = &map->table[hash(key, map->tablelen)]; +- int rv; ++int nghttp2_map_remove(nghttp2_map *map, nghttp2_map_key_type key) { ++ uint32_t h; ++ size_t idx, didx; ++ nghttp2_map_bucket *bkt; ++ size_t d = 0; + +- if (bkt->ptr) { +- if (bkt->ptr->key == key) { +- bkt->ptr = NULL; +- --map->size; +- return 0; +- } ++ if (map->size == 0) { + return NGHTTP2_ERR_INVALID_ARGUMENT; + } + +- if (bkt->ksl) { +- rv = nghttp2_ksl_remove(bkt->ksl, NULL, &key); +- if (rv != 0) { +- return rv; ++ h = hash(key); ++ idx = h2idx(h, map->tablelenbits); ++ ++ for (;;) { ++ bkt = &map->table[idx]; ++ ++ if (bkt->data == NULL || ++ d > distance(map->tablelen, map->tablelenbits, bkt, idx)) { ++ return NGHTTP2_ERR_INVALID_ARGUMENT; + } +- --map->size; +- return 0; +- } + +- return NGHTTP2_ERR_INVALID_ARGUMENT; +-} ++ if (bkt->key == key) { ++ map_bucket_set_data(bkt, 0, 0, NULL); + +-void nghttp2_map_clear(nghttp2_map *map) { +- uint32_t i; +- nghttp2_map_bucket *bkt; ++ didx = idx; ++ idx = (idx + 1) & (map->tablelen - 1); + +- for (i = 0; i < map->tablelen; ++i) { +- bkt = &map->table[i]; +- bkt->ptr = NULL; +- if (bkt->ksl) { +- nghttp2_ksl_free(bkt->ksl); +- nghttp2_mem_free(map->mem, bkt->ksl); +- bkt->ksl = NULL; ++ for (;;) { ++ bkt = &map->table[idx]; ++ if (bkt->data == NULL || ++ distance(map->tablelen, map->tablelenbits, bkt, idx) == 0) { ++ break; ++ } ++ ++ map->table[didx] = *bkt; ++ map_bucket_set_data(bkt, 0, 0, NULL); ++ didx = idx; ++ ++ idx = (idx + 1) & (map->tablelen - 1); ++ } ++ ++ --map->size; ++ ++ return 0; + } ++ ++ ++d; ++ idx = (idx + 1) & (map->tablelen - 1); ++ } ++} ++ ++void nghttp2_map_clear(nghttp2_map *map) { ++ if (map->tablelen == 0) { ++ return; + } + ++ memset(map->table, 0, sizeof(*map->table) * map->tablelen); + map->size = 0; + } + +diff --git a/deps/nghttp2/lib/nghttp2_map.h b/deps/nghttp2/lib/nghttp2_map.h +index 2cf59f698e..d90245aab7 100644 +--- a/deps/nghttp2/lib/nghttp2_map.h ++++ b/deps/nghttp2/lib/nghttp2_map.h +@@ -33,43 +33,29 @@ + #include + + #include "nghttp2_mem.h" +-#include "nghttp2_ksl.h" + + /* Implementation of unordered map */ + +-typedef int32_t key_type; +- +-typedef struct nghttp2_map_entry { +- struct nghttp2_map_entry *next; +- key_type key; +-#if SIZEOF_INT_P == 4 +- /* we requires 8 bytes aligment */ +- int64_t pad; +-#endif +-} nghttp2_map_entry; ++typedef int32_t nghttp2_map_key_type; + + typedef struct nghttp2_map_bucket { +- nghttp2_map_entry *ptr; +- nghttp2_ksl *ksl; ++ uint32_t hash; ++ nghttp2_map_key_type key; ++ void *data; + } nghttp2_map_bucket; + +-typedef struct { ++typedef struct nghttp2_map { + nghttp2_map_bucket *table; + nghttp2_mem *mem; + size_t size; + uint32_t tablelen; ++ uint32_t tablelenbits; + } nghttp2_map; + + /* + * Initializes the map |map|. +- * +- * This function returns 0 if it succeeds, or one of the following +- * negative error codes: +- * +- * NGHTTP2_ERR_NOMEM +- * Out of memory + */ +-int nghttp2_map_init(nghttp2_map *map, nghttp2_mem *mem); ++void nghttp2_map_init(nghttp2_map *map, nghttp2_mem *mem); + + /* + * Deallocates any resources allocated for |map|. The stored entries +@@ -81,21 +67,14 @@ void nghttp2_map_free(nghttp2_map *map); + /* + * Deallocates each entries using |func| function and any resources + * allocated for |map|. The |func| function is responsible for freeing +- * given the |entry| object. The |ptr| will be passed to the |func| as ++ * given the |data| object. The |ptr| will be passed to the |func| as + * send argument. The return value of the |func| will be ignored. + */ +-void nghttp2_map_each_free(nghttp2_map *map, +- int (*func)(nghttp2_map_entry *entry, void *ptr), ++void nghttp2_map_each_free(nghttp2_map *map, int (*func)(void *data, void *ptr), + void *ptr); + + /* +- * Initializes the |entry| with the |key|. All entries to be inserted +- * to the map must be initialized with this function. +- */ +-void nghttp2_map_entry_init(nghttp2_map_entry *entry, key_type key); +- +-/* +- * Inserts the new |entry| with the key |entry->key| to the map |map|. ++ * Inserts the new |data| with the |key| to the map |map|. + * + * This function returns 0 if it succeeds, or one of the following + * negative error codes: +@@ -105,25 +84,25 @@ void nghttp2_map_entry_init(nghttp2_map_entry *entry, key_type key); + * NGHTTP2_ERR_NOMEM + * Out of memory + */ +-int nghttp2_map_insert(nghttp2_map *map, nghttp2_map_entry *entry); ++int nghttp2_map_insert(nghttp2_map *map, nghttp2_map_key_type key, void *data); + + /* +- * Returns the entry associated by the key |key|. If there is no such +- * entry, this function returns NULL. ++ * Returns the data associated by the key |key|. If there is no such ++ * data, this function returns NULL. + */ +-nghttp2_map_entry *nghttp2_map_find(nghttp2_map *map, key_type key); ++void *nghttp2_map_find(nghttp2_map *map, nghttp2_map_key_type key); + + /* +- * Removes the entry associated by the key |key| from the |map|. The +- * removed entry is not freed by this function. ++ * Removes the data associated by the key |key| from the |map|. The ++ * removed data is not freed by this function. + * + * This function returns 0 if it succeeds, or one of the following + * negative error codes: + * + * NGHTTP2_ERR_INVALID_ARGUMENT +- * The entry associated by |key| does not exist. ++ * The data associated by |key| does not exist. + */ +-int nghttp2_map_remove(nghttp2_map *map, key_type key); ++int nghttp2_map_remove(nghttp2_map *map, nghttp2_map_key_type key); + + /* + * Removes all entries from |map|. +@@ -136,21 +115,22 @@ void nghttp2_map_clear(nghttp2_map *map); + size_t nghttp2_map_size(nghttp2_map *map); + + /* +- * Applies the function |func| to each entry in the |map| with the ++ * Applies the function |func| to each data in the |map| with the + * optional user supplied pointer |ptr|. + * + * If the |func| returns 0, this function calls the |func| with the +- * next entry. If the |func| returns nonzero, it will not call the ++ * next data. If the |func| returns nonzero, it will not call the + * |func| for further entries and return the return value of the + * |func| immediately. Thus, this function returns 0 if all the + * invocations of the |func| return 0, or nonzero value which the last + * invocation of |func| returns. + * +- * Don't use this function to free each entry. Use ++ * Don't use this function to free each data. Use + * nghttp2_map_each_free() instead. + */ +-int nghttp2_map_each(nghttp2_map *map, +- int (*func)(nghttp2_map_entry *entry, void *ptr), ++int nghttp2_map_each(nghttp2_map *map, int (*func)(void *data, void *ptr), + void *ptr); + ++void nghttp2_map_print_distance(nghttp2_map *map); ++ + #endif /* NGHTTP2_MAP_H */ +diff --git a/deps/nghttp2/lib/nghttp2_net.h b/deps/nghttp2/lib/nghttp2_net.h +index 95ffee74a1..521f98143e 100644 +--- a/deps/nghttp2/lib/nghttp2_net.h ++++ b/deps/nghttp2/lib/nghttp2_net.h +@@ -42,7 +42,7 @@ + #if defined(WIN32) + /* Windows requires ws2_32 library for ntonl family functions. We + define inline functions for those function so that we don't have +- dependeny on that lib. */ ++ dependency on that lib. */ + + # ifdef _MSC_VER + # define STIN static __inline +@@ -53,7 +53,7 @@ + STIN uint32_t htonl(uint32_t hostlong) { + uint32_t res; + unsigned char *p = (unsigned char *)&res; +- *p++ = hostlong >> 24; ++ *p++ = (unsigned char)(hostlong >> 24); + *p++ = (hostlong >> 16) & 0xffu; + *p++ = (hostlong >> 8) & 0xffu; + *p = hostlong & 0xffu; +@@ -63,7 +63,7 @@ STIN uint32_t htonl(uint32_t hostlong) { + STIN uint16_t htons(uint16_t hostshort) { + uint16_t res; + unsigned char *p = (unsigned char *)&res; +- *p++ = hostshort >> 8; ++ *p++ = (unsigned char)(hostshort >> 8); + *p = hostshort & 0xffu; + return res; + } +@@ -71,9 +71,9 @@ STIN uint16_t htons(uint16_t hostshort) { + STIN uint32_t ntohl(uint32_t netlong) { + uint32_t res; + unsigned char *p = (unsigned char *)&netlong; +- res = *p++ << 24; +- res += *p++ << 16; +- res += *p++ << 8; ++ res = (uint32_t)(*p++ << 24); ++ res += (uint32_t)(*p++ << 16); ++ res += (uint32_t)(*p++ << 8); + res += *p; + return res; + } +@@ -81,7 +81,7 @@ STIN uint32_t ntohl(uint32_t netlong) { + STIN uint16_t ntohs(uint16_t netshort) { + uint16_t res; + unsigned char *p = (unsigned char *)&netshort; +- res = *p++ << 8; ++ res = (uint16_t)(*p++ << 8); + res += *p; + return res; + } +diff --git a/deps/nghttp2/lib/nghttp2_option.c b/deps/nghttp2/lib/nghttp2_option.c +index 34348e6606..43d4e95229 100644 +--- a/deps/nghttp2/lib/nghttp2_option.c ++++ b/deps/nghttp2/lib/nghttp2_option.c +@@ -90,6 +90,10 @@ void nghttp2_option_set_builtin_recv_extension_type(nghttp2_option *option, + option->opt_set_mask |= NGHTTP2_OPT_BUILTIN_RECV_EXT_TYPES; + option->builtin_recv_ext_types |= NGHTTP2_TYPEMASK_ORIGIN; + return; ++ case NGHTTP2_PRIORITY_UPDATE: ++ option->opt_set_mask |= NGHTTP2_OPT_BUILTIN_RECV_EXT_TYPES; ++ option->builtin_recv_ext_types |= NGHTTP2_TYPEMASK_PRIORITY_UPDATE; ++ return; + default: + return; + } +@@ -126,3 +130,23 @@ void nghttp2_option_set_max_settings(nghttp2_option *option, size_t val) { + option->opt_set_mask |= NGHTTP2_OPT_MAX_SETTINGS; + option->max_settings = val; + } ++ ++void nghttp2_option_set_server_fallback_rfc7540_priorities( ++ nghttp2_option *option, int val) { ++ option->opt_set_mask |= NGHTTP2_OPT_SERVER_FALLBACK_RFC7540_PRIORITIES; ++ option->server_fallback_rfc7540_priorities = val; ++} ++ ++void nghttp2_option_set_no_rfc9113_leading_and_trailing_ws_validation( ++ nghttp2_option *option, int val) { ++ option->opt_set_mask |= ++ NGHTTP2_OPT_NO_RFC9113_LEADING_AND_TRAILING_WS_VALIDATION; ++ option->no_rfc9113_leading_and_trailing_ws_validation = val; ++} ++ ++void nghttp2_option_set_stream_reset_rate_limit(nghttp2_option *option, ++ uint64_t burst, uint64_t rate) { ++ option->opt_set_mask |= NGHTTP2_OPT_STREAM_RESET_RATE_LIMIT; ++ option->stream_reset_burst = burst; ++ option->stream_reset_rate = rate; ++} +diff --git a/deps/nghttp2/lib/nghttp2_option.h b/deps/nghttp2/lib/nghttp2_option.h +index 939729fdcd..2259e1849d 100644 +--- a/deps/nghttp2/lib/nghttp2_option.h ++++ b/deps/nghttp2/lib/nghttp2_option.h +@@ -68,12 +68,20 @@ typedef enum { + NGHTTP2_OPT_NO_CLOSED_STREAMS = 1 << 10, + NGHTTP2_OPT_MAX_OUTBOUND_ACK = 1 << 11, + NGHTTP2_OPT_MAX_SETTINGS = 1 << 12, ++ NGHTTP2_OPT_SERVER_FALLBACK_RFC7540_PRIORITIES = 1 << 13, ++ NGHTTP2_OPT_NO_RFC9113_LEADING_AND_TRAILING_WS_VALIDATION = 1 << 14, ++ NGHTTP2_OPT_STREAM_RESET_RATE_LIMIT = 1 << 15, + } nghttp2_option_flag; + + /** + * Struct to store option values for nghttp2_session. + */ + struct nghttp2_option { ++ /** ++ * NGHTTP2_OPT_STREAM_RESET_RATE_LIMIT ++ */ ++ uint64_t stream_reset_burst; ++ uint64_t stream_reset_rate; + /** + * NGHTTP2_OPT_MAX_SEND_HEADER_BLOCK_LENGTH + */ +@@ -127,6 +135,14 @@ struct nghttp2_option { + * NGHTTP2_OPT_NO_CLOSED_STREAMS + */ + int no_closed_streams; ++ /** ++ * NGHTTP2_OPT_SERVER_FALLBACK_RFC7540_PRIORITIES ++ */ ++ int server_fallback_rfc7540_priorities; ++ /** ++ * NGHTTP2_OPT_NO_RFC9113_LEADING_AND_TRAILING_WS_VALIDATION ++ */ ++ int no_rfc9113_leading_and_trailing_ws_validation; + /** + * NGHTTP2_OPT_USER_RECV_EXT_TYPES + */ +diff --git a/deps/nghttp2/lib/nghttp2_outbound_item.c b/deps/nghttp2/lib/nghttp2_outbound_item.c +index f651c8029a..2a3041db19 100644 +--- a/deps/nghttp2/lib/nghttp2_outbound_item.c ++++ b/deps/nghttp2/lib/nghttp2_outbound_item.c +@@ -89,6 +89,9 @@ void nghttp2_outbound_item_free(nghttp2_outbound_item *item, nghttp2_mem *mem) { + case NGHTTP2_ORIGIN: + nghttp2_frame_origin_free(&frame->ext, mem); + break; ++ case NGHTTP2_PRIORITY_UPDATE: ++ nghttp2_frame_priority_update_free(&frame->ext, mem); ++ break; + default: + assert(0); + break; +diff --git a/deps/nghttp2/lib/nghttp2_outbound_item.h b/deps/nghttp2/lib/nghttp2_outbound_item.h +index b5f503a312..bd4611b551 100644 +--- a/deps/nghttp2/lib/nghttp2_outbound_item.h ++++ b/deps/nghttp2/lib/nghttp2_outbound_item.h +@@ -111,7 +111,7 @@ struct nghttp2_outbound_item { + to this structure to avoid frequent memory allocation. */ + nghttp2_ext_frame_payload ext_frame_payload; + nghttp2_aux_data aux_data; +- /* The priority used in priority comparion. Smaller is served ++ /* The priority used in priority comparison. Smaller is served + earlier. For PING, SETTINGS and non-DATA frames (excluding + response HEADERS frame) have dedicated cycle value defined above. + For DATA frame, cycle is computed by taking into account of +diff --git a/deps/nghttp2/lib/nghttp2_pq.c b/deps/nghttp2/lib/nghttp2_pq.c +index bebccc7606..64353acc96 100644 +--- a/deps/nghttp2/lib/nghttp2_pq.c ++++ b/deps/nghttp2/lib/nghttp2_pq.c +@@ -29,13 +29,12 @@ + + #include "nghttp2_helper.h" + +-int nghttp2_pq_init(nghttp2_pq *pq, nghttp2_less less, nghttp2_mem *mem) { ++void nghttp2_pq_init(nghttp2_pq *pq, nghttp2_less less, nghttp2_mem *mem) { + pq->mem = mem; + pq->capacity = 0; + pq->q = NULL; + pq->length = 0; + pq->less = less; +- return 0; + } + + void nghttp2_pq_free(nghttp2_pq *pq) { +diff --git a/deps/nghttp2/lib/nghttp2_pq.h b/deps/nghttp2/lib/nghttp2_pq.h +index 2d7b702ac1..c8d90ef2cc 100644 +--- a/deps/nghttp2/lib/nghttp2_pq.h ++++ b/deps/nghttp2/lib/nghttp2_pq.h +@@ -55,14 +55,8 @@ typedef struct { + + /* + * Initializes priority queue |pq| with compare function |cmp|. +- * +- * This function returns 0 if it succeeds, or one of the following +- * negative error codes: +- * +- * NGHTTP2_ERR_NOMEM +- * Out of memory. + */ +-int nghttp2_pq_init(nghttp2_pq *pq, nghttp2_less less, nghttp2_mem *mem); ++void nghttp2_pq_init(nghttp2_pq *pq, nghttp2_less less, nghttp2_mem *mem); + + /* + * Deallocates any resources allocated for |pq|. The stored items are +@@ -114,7 +108,7 @@ typedef int (*nghttp2_pq_item_cb)(nghttp2_pq_entry *item, void *arg); + void nghttp2_pq_update(nghttp2_pq *pq, nghttp2_pq_item_cb fun, void *arg); + + /* +- * Applys |fun| to each item in |pq|. The |arg| is passed as arg ++ * Applies |fun| to each item in |pq|. The |arg| is passed as arg + * parameter to callback function. This function must not change the + * ordering key. If the return value from callback is nonzero, this + * function returns 1 immediately without iterating remaining items. +diff --git a/deps/nghttp2/lib/nghttp2_ratelim.c b/deps/nghttp2/lib/nghttp2_ratelim.c +new file mode 100644 +index 0000000000..7011655b00 +--- /dev/null ++++ b/deps/nghttp2/lib/nghttp2_ratelim.c +@@ -0,0 +1,75 @@ ++/* ++ * nghttp2 - HTTP/2 C Library ++ * ++ * Copyright (c) 2023 nghttp2 contributors ++ * ++ * Permission is hereby granted, free of charge, to any person obtaining ++ * a copy of this software and associated documentation files (the ++ * "Software"), to deal in the Software without restriction, including ++ * without limitation the rights to use, copy, modify, merge, publish, ++ * distribute, sublicense, and/or sell copies of the Software, and to ++ * permit persons to whom the Software is furnished to do so, subject to ++ * the following conditions: ++ * ++ * The above copyright notice and this permission notice shall be ++ * included in all copies or substantial portions of the Software. ++ * ++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, ++ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF ++ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND ++ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE ++ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION ++ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION ++ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ++ */ ++#include "nghttp2_ratelim.h" ++#include "nghttp2_helper.h" ++ ++void nghttp2_ratelim_init(nghttp2_ratelim *rl, uint64_t burst, uint64_t rate) { ++ rl->val = rl->burst = burst; ++ rl->rate = rate; ++ rl->tstamp = 0; ++} ++ ++void nghttp2_ratelim_update(nghttp2_ratelim *rl, uint64_t tstamp) { ++ uint64_t d, gain; ++ ++ if (tstamp == rl->tstamp) { ++ return; ++ } ++ ++ if (tstamp > rl->tstamp) { ++ d = tstamp - rl->tstamp; ++ } else { ++ d = 1; ++ } ++ ++ rl->tstamp = tstamp; ++ ++ if (UINT64_MAX / d < rl->rate) { ++ rl->val = rl->burst; ++ ++ return; ++ } ++ ++ gain = rl->rate * d; ++ ++ if (UINT64_MAX - gain < rl->val) { ++ rl->val = rl->burst; ++ ++ return; ++ } ++ ++ rl->val += gain; ++ rl->val = nghttp2_min(rl->val, rl->burst); ++} ++ ++int nghttp2_ratelim_drain(nghttp2_ratelim *rl, uint64_t n) { ++ if (rl->val < n) { ++ return -1; ++ } ++ ++ rl->val -= n; ++ ++ return 0; ++} +diff --git a/deps/nghttp2/lib/nghttp2_ratelim.h b/deps/nghttp2/lib/nghttp2_ratelim.h +new file mode 100644 +index 0000000000..866ed3f00a +--- /dev/null ++++ b/deps/nghttp2/lib/nghttp2_ratelim.h +@@ -0,0 +1,57 @@ ++/* ++ * nghttp2 - HTTP/2 C Library ++ * ++ * Copyright (c) 2023 nghttp2 contributors ++ * ++ * Permission is hereby granted, free of charge, to any person obtaining ++ * a copy of this software and associated documentation files (the ++ * "Software"), to deal in the Software without restriction, including ++ * without limitation the rights to use, copy, modify, merge, publish, ++ * distribute, sublicense, and/or sell copies of the Software, and to ++ * permit persons to whom the Software is furnished to do so, subject to ++ * the following conditions: ++ * ++ * The above copyright notice and this permission notice shall be ++ * included in all copies or substantial portions of the Software. ++ * ++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, ++ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF ++ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND ++ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE ++ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION ++ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION ++ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ++ */ ++#ifndef NGHTTP2_RATELIM_H ++#define NGHTTP2_RATELIM_H ++ ++#ifdef HAVE_CONFIG_H ++# include ++#endif /* HAVE_CONFIG_H */ ++ ++#include ++ ++typedef struct nghttp2_ratelim { ++ /* burst is the maximum value of val. */ ++ uint64_t burst; ++ /* rate is the amount of value that is regenerated per 1 tstamp. */ ++ uint64_t rate; ++ /* val is the amount of value available to drain. */ ++ uint64_t val; ++ /* tstamp is the last timestamp in second resolution that is known ++ to this object. */ ++ uint64_t tstamp; ++} nghttp2_ratelim; ++ ++/* nghttp2_ratelim_init initializes |rl| with the given parameters. */ ++void nghttp2_ratelim_init(nghttp2_ratelim *rl, uint64_t burst, uint64_t rate); ++ ++/* nghttp2_ratelim_update updates rl->val with the current |tstamp| ++ given in second resolution. */ ++void nghttp2_ratelim_update(nghttp2_ratelim *rl, uint64_t tstamp); ++ ++/* nghttp2_ratelim_drain drains |n| from rl->val. It returns 0 if it ++ succeeds, or -1. */ ++int nghttp2_ratelim_drain(nghttp2_ratelim *rl, uint64_t n); ++ ++#endif /* NGHTTP2_RATELIM_H */ +diff --git a/deps/nghttp2/lib/nghttp2_session.c b/deps/nghttp2/lib/nghttp2_session.c +index 2e7e907f25..ec5024d0f2 100644 +--- a/deps/nghttp2/lib/nghttp2_session.c ++++ b/deps/nghttp2/lib/nghttp2_session.c +@@ -36,6 +36,8 @@ + #include "nghttp2_option.h" + #include "nghttp2_http.h" + #include "nghttp2_pq.h" ++#include "nghttp2_extpri.h" ++#include "nghttp2_time.h" + #include "nghttp2_debug.h" + + /* +@@ -143,6 +145,11 @@ static int session_detect_idle_stream(nghttp2_session *session, + return 0; + } + ++static int session_no_rfc7540_pri_no_fallback(nghttp2_session *session) { ++ return session->pending_no_rfc7540_priorities == 1 && ++ !session->fallback_rfc7540_priorities; ++} ++ + static int check_ext_type_set(const uint8_t *ext_types, uint8_t type) { + return (ext_types[type / 8] & (1 << (type & 0x7))) > 0; + } +@@ -354,6 +361,14 @@ static void session_inbound_frame_reset(nghttp2_session *session) { + } + nghttp2_frame_origin_free(&iframe->frame.ext, mem); + break; ++ case NGHTTP2_PRIORITY_UPDATE: ++ if ((session->builtin_recv_ext_types & ++ NGHTTP2_TYPEMASK_PRIORITY_UPDATE) == 0) { ++ break; ++ } ++ /* Do not call nghttp2_frame_priority_update_free, because all ++ fields point to sbuf. */ ++ break; + } + } + +@@ -385,6 +400,7 @@ static void init_settings(nghttp2_settings_storage *settings) { + settings->initial_window_size = NGHTTP2_INITIAL_WINDOW_SIZE; + settings->max_frame_size = NGHTTP2_MAX_FRAME_SIZE_MIN; + settings->max_header_list_size = UINT32_MAX; ++ settings->no_rfc7540_priorities = UINT32_MAX; + } + + static void active_outbound_item_reset(nghttp2_active_outbound_item *aob, +@@ -398,6 +414,21 @@ static void active_outbound_item_reset(nghttp2_active_outbound_item *aob, + aob->state = NGHTTP2_OB_POP_ITEM; + } + ++#define NGHTTP2_STREAM_MAX_CYCLE_GAP ((uint64_t)NGHTTP2_MAX_FRAME_SIZE_MAX) ++ ++static int stream_less(const void *lhsx, const void *rhsx) { ++ const nghttp2_stream *lhs, *rhs; ++ ++ lhs = nghttp2_struct_of(lhsx, nghttp2_stream, pq_entry); ++ rhs = nghttp2_struct_of(rhsx, nghttp2_stream, pq_entry); ++ ++ if (lhs->cycle == rhs->cycle) { ++ return lhs->seq < rhs->seq; ++ } ++ ++ return rhs->cycle - lhs->cycle <= NGHTTP2_STREAM_MAX_CYCLE_GAP; ++} ++ + int nghttp2_enable_strict_preface = 1; + + static int session_new(nghttp2_session **session_ptr, +@@ -408,6 +439,7 @@ static int session_new(nghttp2_session **session_ptr, + size_t nbuffer; + size_t max_deflate_dynamic_table_size = + NGHTTP2_HD_DEFAULT_MAX_DEFLATE_BUFFER_SIZE; ++ size_t i; + + if (mem == NULL) { + mem = nghttp2_mem_default(); +@@ -442,6 +474,11 @@ static int session_new(nghttp2_session **session_ptr, + (*session_ptr)->pending_local_max_concurrent_stream = + NGHTTP2_DEFAULT_MAX_CONCURRENT_STREAMS; + (*session_ptr)->pending_enable_push = 1; ++ (*session_ptr)->pending_no_rfc7540_priorities = UINT8_MAX; ++ ++ nghttp2_ratelim_init(&(*session_ptr)->stream_reset_ratelim, ++ NGHTTP2_DEFAULT_STREAM_RESET_BURST, ++ NGHTTP2_DEFAULT_STREAM_RESET_RATE); + + if (server) { + (*session_ptr)->server = 1; +@@ -527,6 +564,26 @@ static int session_new(nghttp2_session **session_ptr, + option->max_settings) { + (*session_ptr)->max_settings = option->max_settings; + } ++ ++ if ((option->opt_set_mask & ++ NGHTTP2_OPT_SERVER_FALLBACK_RFC7540_PRIORITIES) && ++ option->server_fallback_rfc7540_priorities) { ++ (*session_ptr)->opt_flags |= ++ NGHTTP2_OPTMASK_SERVER_FALLBACK_RFC7540_PRIORITIES; ++ } ++ ++ if ((option->opt_set_mask & ++ NGHTTP2_OPT_NO_RFC9113_LEADING_AND_TRAILING_WS_VALIDATION) && ++ option->no_rfc9113_leading_and_trailing_ws_validation) { ++ (*session_ptr)->opt_flags |= ++ NGHTTP2_OPTMASK_NO_RFC9113_LEADING_AND_TRAILING_WS_VALIDATION; ++ } ++ ++ if (option->opt_set_mask & NGHTTP2_OPT_STREAM_RESET_RATE_LIMIT) { ++ nghttp2_ratelim_init(&(*session_ptr)->stream_reset_ratelim, ++ option->stream_reset_burst, ++ option->stream_reset_rate); ++ } + } + + rv = nghttp2_hd_deflate_init2(&(*session_ptr)->hd_deflater, +@@ -538,10 +595,6 @@ static int session_new(nghttp2_session **session_ptr, + if (rv != 0) { + goto fail_hd_inflater; + } +- rv = nghttp2_map_init(&(*session_ptr)->streams, mem); +- if (rv != 0) { +- goto fail_map; +- } + + nbuffer = ((*session_ptr)->max_send_header_block_length + + NGHTTP2_FRAMEBUF_CHUNKLEN - 1) / +@@ -559,6 +612,8 @@ static int session_new(nghttp2_session **session_ptr, + goto fail_aob_framebuf; + } + ++ nghttp2_map_init(&(*session_ptr)->streams, mem); ++ + active_outbound_item_reset(&(*session_ptr)->aob, mem); + + (*session_ptr)->callbacks = *callbacks; +@@ -584,11 +639,13 @@ static int session_new(nghttp2_session **session_ptr, + } + } + ++ for (i = 0; i < NGHTTP2_EXTPRI_URGENCY_LEVELS; ++i) { ++ nghttp2_pq_init(&(*session_ptr)->sched[i].ob_data, stream_less, mem); ++ } ++ + return 0; + + fail_aob_framebuf: +- nghttp2_map_free(&(*session_ptr)->streams); +-fail_map: + nghttp2_hd_inflate_free(&(*session_ptr)->hd_inflater); + fail_hd_inflater: + nghttp2_hd_deflate_free(&(*session_ptr)->hd_deflater); +@@ -666,7 +723,7 @@ int nghttp2_session_server_new3(nghttp2_session **session_ptr, + return 0; + } + +-static int free_streams(nghttp2_map_entry *entry, void *ptr) { ++static int free_streams(void *entry, void *ptr) { + nghttp2_session *session; + nghttp2_stream *stream; + nghttp2_outbound_item *item; +@@ -735,6 +792,7 @@ static void inflight_settings_del(nghttp2_inflight_settings *settings, + void nghttp2_session_del(nghttp2_session *session) { + nghttp2_mem *mem; + nghttp2_inflight_settings *settings; ++ size_t i; + + if (session == NULL) { + return; +@@ -748,6 +806,9 @@ void nghttp2_session_del(nghttp2_session *session) { + settings = next; + } + ++ for (i = 0; i < NGHTTP2_EXTPRI_URGENCY_LEVELS; ++i) { ++ nghttp2_pq_free(&session->sched[i].ob_data); ++ } + nghttp2_stream_free(&session->root); + + /* Have to free streams first, so that we can check +@@ -775,6 +836,8 @@ int nghttp2_session_reprioritize_stream( + nghttp2_priority_spec pri_spec_default; + const nghttp2_priority_spec *pri_spec = pri_spec_in; + ++ assert((!session->server && session->pending_no_rfc7540_priorities != 1) || ++ (session->server && !session_no_rfc7540_pri_no_fallback(session))); + assert(pri_spec->stream_id != stream->stream_id); + + if (!nghttp2_stream_in_dep_tree(stream)) { +@@ -842,6 +905,202 @@ int nghttp2_session_reprioritize_stream( + return 0; + } + ++static uint64_t pq_get_first_cycle(nghttp2_pq *pq) { ++ nghttp2_stream *stream; ++ ++ if (nghttp2_pq_empty(pq)) { ++ return 0; ++ } ++ ++ stream = nghttp2_struct_of(nghttp2_pq_top(pq), nghttp2_stream, pq_entry); ++ return stream->cycle; ++} ++ ++static int session_ob_data_push(nghttp2_session *session, ++ nghttp2_stream *stream) { ++ int rv; ++ uint32_t urgency; ++ int inc; ++ nghttp2_pq *pq; ++ ++ assert(stream->flags & NGHTTP2_STREAM_FLAG_NO_RFC7540_PRIORITIES); ++ assert(stream->queued == 0); ++ ++ urgency = nghttp2_extpri_uint8_urgency(stream->extpri); ++ inc = nghttp2_extpri_uint8_inc(stream->extpri); ++ ++ assert(urgency < NGHTTP2_EXTPRI_URGENCY_LEVELS); ++ ++ pq = &session->sched[urgency].ob_data; ++ ++ stream->cycle = pq_get_first_cycle(pq); ++ if (inc) { ++ stream->cycle += stream->last_writelen; ++ } ++ ++ rv = nghttp2_pq_push(pq, &stream->pq_entry); ++ if (rv != 0) { ++ return rv; ++ } ++ ++ stream->queued = 1; ++ ++ return 0; ++} ++ ++static void session_ob_data_remove(nghttp2_session *session, ++ nghttp2_stream *stream) { ++ uint32_t urgency; ++ ++ assert(stream->flags & NGHTTP2_STREAM_FLAG_NO_RFC7540_PRIORITIES); ++ assert(stream->queued == 1); ++ ++ urgency = nghttp2_extpri_uint8_urgency(stream->extpri); ++ ++ assert(urgency < NGHTTP2_EXTPRI_URGENCY_LEVELS); ++ ++ nghttp2_pq_remove(&session->sched[urgency].ob_data, &stream->pq_entry); ++ ++ stream->queued = 0; ++} ++ ++static int session_attach_stream_item(nghttp2_session *session, ++ nghttp2_stream *stream, ++ nghttp2_outbound_item *item) { ++ int rv; ++ ++ rv = nghttp2_stream_attach_item(stream, item); ++ if (rv != 0) { ++ return rv; ++ } ++ ++ if (!(stream->flags & NGHTTP2_STREAM_FLAG_NO_RFC7540_PRIORITIES)) { ++ return 0; ++ } ++ ++ return session_ob_data_push(session, stream); ++} ++ ++static void session_detach_stream_item(nghttp2_session *session, ++ nghttp2_stream *stream) { ++ nghttp2_stream_detach_item(stream); ++ ++ if (!(stream->flags & NGHTTP2_STREAM_FLAG_NO_RFC7540_PRIORITIES) || ++ !stream->queued) { ++ return; ++ } ++ ++ session_ob_data_remove(session, stream); ++} ++ ++static void session_defer_stream_item(nghttp2_session *session, ++ nghttp2_stream *stream, uint8_t flags) { ++ nghttp2_stream_defer_item(stream, flags); ++ ++ if (!(stream->flags & NGHTTP2_STREAM_FLAG_NO_RFC7540_PRIORITIES) || ++ !stream->queued) { ++ return; ++ } ++ ++ session_ob_data_remove(session, stream); ++} ++ ++static int session_resume_deferred_stream_item(nghttp2_session *session, ++ nghttp2_stream *stream, ++ uint8_t flags) { ++ int rv; ++ ++ rv = nghttp2_stream_resume_deferred_item(stream, flags); ++ if (rv != 0) { ++ return rv; ++ } ++ ++ if (!(stream->flags & NGHTTP2_STREAM_FLAG_NO_RFC7540_PRIORITIES) || ++ (stream->flags & NGHTTP2_STREAM_FLAG_DEFERRED_ALL)) { ++ return 0; ++ } ++ ++ return session_ob_data_push(session, stream); ++} ++ ++static nghttp2_outbound_item * ++session_sched_get_next_outbound_item(nghttp2_session *session) { ++ size_t i; ++ nghttp2_pq_entry *ent; ++ nghttp2_stream *stream; ++ ++ for (i = 0; i < NGHTTP2_EXTPRI_URGENCY_LEVELS; ++i) { ++ ent = nghttp2_pq_top(&session->sched[i].ob_data); ++ if (!ent) { ++ continue; ++ } ++ ++ stream = nghttp2_struct_of(ent, nghttp2_stream, pq_entry); ++ return stream->item; ++ } ++ ++ return NULL; ++} ++ ++static int session_sched_empty(nghttp2_session *session) { ++ size_t i; ++ ++ for (i = 0; i < NGHTTP2_EXTPRI_URGENCY_LEVELS; ++i) { ++ if (!nghttp2_pq_empty(&session->sched[i].ob_data)) { ++ return 0; ++ } ++ } ++ ++ return 1; ++} ++ ++static void session_sched_reschedule_stream(nghttp2_session *session, ++ nghttp2_stream *stream) { ++ nghttp2_pq *pq; ++ uint32_t urgency = nghttp2_extpri_uint8_urgency(stream->extpri); ++ int inc = nghttp2_extpri_uint8_inc(stream->extpri); ++ uint64_t penalty = (uint64_t)stream->last_writelen; ++ int rv; ++ ++ (void)rv; ++ ++ assert(urgency < NGHTTP2_EXTPRI_URGENCY_LEVELS); ++ ++ pq = &session->sched[urgency].ob_data; ++ ++ if (!inc || nghttp2_pq_size(pq) == 1) { ++ return; ++ } ++ ++ nghttp2_pq_remove(pq, &stream->pq_entry); ++ ++ stream->cycle += penalty; ++ ++ rv = nghttp2_pq_push(pq, &stream->pq_entry); ++ ++ assert(0 == rv); ++} ++ ++static int session_update_stream_priority(nghttp2_session *session, ++ nghttp2_stream *stream, ++ uint8_t u8extpri) { ++ if (stream->extpri == u8extpri) { ++ return 0; ++ } ++ ++ if (stream->queued) { ++ session_ob_data_remove(session, stream); ++ ++ stream->extpri = u8extpri; ++ ++ return session_ob_data_push(session, stream); ++ } ++ ++ stream->extpri = u8extpri; ++ ++ return 0; ++} ++ + int nghttp2_session_add_item(nghttp2_session *session, + nghttp2_outbound_item *item) { + /* TODO Return error if stream is not found for the frame requiring +@@ -863,7 +1122,7 @@ int nghttp2_session_add_item(nghttp2_session *session, + return NGHTTP2_ERR_DATA_EXIST; + } + +- rv = nghttp2_stream_attach_item(stream, item); ++ rv = session_attach_stream_item(session, stream, item); + + if (rv != 0) { + return rv; +@@ -1039,13 +1298,27 @@ nghttp2_stream *nghttp2_session_open_stream(nghttp2_session *session, + mem = &session->mem; + stream = nghttp2_session_get_stream_raw(session, stream_id); + ++ if (session->opt_flags & ++ NGHTTP2_OPTMASK_NO_RFC9113_LEADING_AND_TRAILING_WS_VALIDATION) { ++ flags |= NGHTTP2_STREAM_FLAG_NO_RFC9113_LEADING_AND_TRAILING_WS_VALIDATION; ++ } ++ + if (stream) { + assert(stream->state == NGHTTP2_STREAM_IDLE); +- assert(nghttp2_stream_in_dep_tree(stream)); +- nghttp2_session_detach_idle_stream(session, stream); +- rv = nghttp2_stream_dep_remove(stream); +- if (rv != 0) { +- return NULL; ++ assert((stream->flags & NGHTTP2_STREAM_FLAG_NO_RFC7540_PRIORITIES) || ++ nghttp2_stream_in_dep_tree(stream)); ++ ++ if (nghttp2_stream_in_dep_tree(stream)) { ++ assert(!(stream->flags & NGHTTP2_STREAM_FLAG_NO_RFC7540_PRIORITIES)); ++ nghttp2_session_detach_idle_stream(session, stream); ++ rv = nghttp2_stream_dep_remove(stream); ++ if (rv != 0) { ++ return NULL; ++ } ++ ++ if (session_no_rfc7540_pri_no_fallback(session)) { ++ stream->flags |= NGHTTP2_STREAM_FLAG_NO_RFC7540_PRIORITIES; ++ } + } + } else { + stream = nghttp2_mem_malloc(mem, sizeof(nghttp2_stream)); +@@ -1056,7 +1329,21 @@ nghttp2_stream *nghttp2_session_open_stream(nghttp2_session *session, + stream_alloc = 1; + } + +- if (pri_spec->stream_id != 0) { ++ if (session_no_rfc7540_pri_no_fallback(session) || ++ session->remote_settings.no_rfc7540_priorities == 1) { ++ /* For client which has not received server ++ SETTINGS_NO_RFC7540_PRIORITIES = 1, send a priority signal ++ opportunistically. */ ++ if (session->server || ++ session->remote_settings.no_rfc7540_priorities == 1) { ++ nghttp2_priority_spec_default_init(&pri_spec_default); ++ pri_spec = &pri_spec_default; ++ } ++ ++ if (session->pending_no_rfc7540_priorities == 1) { ++ flags |= NGHTTP2_STREAM_FLAG_NO_RFC7540_PRIORITIES; ++ } ++ } else if (pri_spec->stream_id != 0) { + dep_stream = nghttp2_session_get_stream_raw(session, pri_spec->stream_id); + + if (!dep_stream && +@@ -1102,7 +1389,11 @@ nghttp2_stream *nghttp2_session_open_stream(nghttp2_session *session, + (int32_t)session->local_settings.initial_window_size, + stream_user_data, mem); + +- rv = nghttp2_map_insert(&session->streams, &stream->map_entry); ++ if (session_no_rfc7540_pri_no_fallback(session)) { ++ stream->seq = session->stream_seq++; ++ } ++ ++ rv = nghttp2_map_insert(&session->streams, stream_id, stream); + if (rv != 0) { + nghttp2_stream_free(stream); + nghttp2_mem_free(mem, stream); +@@ -1141,6 +1432,10 @@ nghttp2_stream *nghttp2_session_open_stream(nghttp2_session *session, + } + } + ++ if (stream->flags & NGHTTP2_STREAM_FLAG_NO_RFC7540_PRIORITIES) { ++ return stream; ++ } ++ + if (pri_spec->stream_id == 0) { + dep_stream = &session->root; + } +@@ -1180,11 +1475,7 @@ int nghttp2_session_close_stream(nghttp2_session *session, int32_t stream_id, + + item = stream->item; + +- rv = nghttp2_stream_detach_item(stream); +- +- if (rv != 0) { +- return rv; +- } ++ session_detach_stream_item(session, stream); + + /* If item is queued, it will be deleted when it is popped + (nghttp2_session_prep_frame() will fail). If session->aob.item +@@ -1230,6 +1521,10 @@ int nghttp2_session_close_stream(nghttp2_session *session, int32_t stream_id, + /* Closes both directions just in case they are not closed yet */ + stream->flags |= NGHTTP2_STREAM_FLAG_CLOSED; + ++ if (session->pending_no_rfc7540_priorities == 1) { ++ return nghttp2_session_destroy_stream(session, stream); ++ } ++ + if ((session->opt_flags & NGHTTP2_OPTMASK_NO_CLOSED_STREAMS) == 0 && + session->server && !is_my_stream_id && + nghttp2_stream_in_dep_tree(stream)) { +@@ -1784,6 +2079,28 @@ static int session_predicate_origin_send(nghttp2_session *session) { + return 0; + } + ++static int session_predicate_priority_update_send(nghttp2_session *session, ++ int32_t stream_id) { ++ nghttp2_stream *stream; ++ ++ if (session_is_closing(session)) { ++ return NGHTTP2_ERR_SESSION_CLOSING; ++ } ++ ++ stream = nghttp2_session_get_stream(session, stream_id); ++ if (stream == NULL) { ++ return 0; ++ } ++ if (stream->state == NGHTTP2_STREAM_CLOSING) { ++ return NGHTTP2_ERR_STREAM_CLOSING; ++ } ++ if (stream->shut_flags & NGHTTP2_SHUT_RD) { ++ return NGHTTP2_ERR_INVALID_STREAM_STATE; ++ } ++ ++ return 0; ++} ++ + /* Take into account settings max frame size and both connection-level + flow control here */ + static ssize_t +@@ -1899,7 +2216,6 @@ static ssize_t session_call_select_padding(nghttp2_session *session, + frame->push_promise has also padlen in the same position. */ + static int session_headers_add_pad(nghttp2_session *session, + nghttp2_frame *frame) { +- int rv; + ssize_t padded_payloadlen; + nghttp2_active_outbound_item *aob; + nghttp2_bufs *framebufs; +@@ -1924,11 +2240,7 @@ static int session_headers_add_pad(nghttp2_session *session, + DEBUGF("send: padding selected: payloadlen=%zd, padlen=%zu\n", + padded_payloadlen, padlen); + +- rv = nghttp2_frame_add_pad(framebufs, &frame->hd, padlen, 0); +- +- if (rv != 0) { +- return rv; +- } ++ nghttp2_frame_add_pad(framebufs, &frame->hd, padlen, 0); + + frame->headers.padlen = padlen; + +@@ -2011,13 +2323,7 @@ static int session_prep_frame(nghttp2_session *session, + // Search stream including closed again. + stream = nghttp2_session_get_stream_raw(session, frame->hd.stream_id); + if (stream) { +- int rv2; +- +- rv2 = nghttp2_stream_detach_item(stream); +- +- if (nghttp2_is_fatal(rv2)) { +- return rv2; +- } ++ session_detach_stream_item(session, stream); + } + + return rv; +@@ -2032,12 +2338,8 @@ static int session_prep_frame(nghttp2_session *session, + queue when session->remote_window_size > 0 */ + assert(session->remote_window_size > 0); + +- rv = nghttp2_stream_defer_item(stream, +- NGHTTP2_STREAM_FLAG_DEFERRED_FLOW_CONTROL); +- +- if (nghttp2_is_fatal(rv)) { +- return rv; +- } ++ session_defer_stream_item(session, stream, ++ NGHTTP2_STREAM_FLAG_DEFERRED_FLOW_CONTROL); + + session->aob.item = NULL; + active_outbound_item_reset(&session->aob, mem); +@@ -2051,22 +2353,15 @@ static int session_prep_frame(nghttp2_session *session, + return rv; + } + if (rv == NGHTTP2_ERR_DEFERRED) { +- rv = nghttp2_stream_defer_item(stream, NGHTTP2_STREAM_FLAG_DEFERRED_USER); +- +- if (nghttp2_is_fatal(rv)) { +- return rv; +- } ++ session_defer_stream_item(session, stream, ++ NGHTTP2_STREAM_FLAG_DEFERRED_USER); + + session->aob.item = NULL; + active_outbound_item_reset(&session->aob, mem); + return NGHTTP2_ERR_DEFERRED; + } + if (rv == NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE) { +- rv = nghttp2_stream_detach_item(stream); +- +- if (nghttp2_is_fatal(rv)) { +- return rv; +- } ++ session_detach_stream_item(session, stream); + + rv = nghttp2_session_add_rst_stream(session, frame->hd.stream_id, + NGHTTP2_INTERNAL_ERROR); +@@ -2076,13 +2371,7 @@ static int session_prep_frame(nghttp2_session *session, + return NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE; + } + if (rv != 0) { +- int rv2; +- +- rv2 = nghttp2_stream_detach_item(stream); +- +- if (nghttp2_is_fatal(rv2)) { +- return rv2; +- } ++ session_detach_stream_item(session, stream); + + return rv; + } +@@ -2328,6 +2617,18 @@ static int session_prep_frame(nghttp2_session *session, + } + + return 0; ++ case NGHTTP2_PRIORITY_UPDATE: { ++ nghttp2_ext_priority_update *priority_update = frame->ext.payload; ++ rv = session_predicate_priority_update_send(session, ++ priority_update->stream_id); ++ if (rv != 0) { ++ return rv; ++ } ++ ++ nghttp2_frame_pack_priority_update(&session->aob.framebufs, &frame->ext); ++ ++ return 0; ++ } + default: + /* Unreachable here */ + assert(0); +@@ -2339,6 +2640,8 @@ static int session_prep_frame(nghttp2_session *session, + + nghttp2_outbound_item * + nghttp2_session_get_next_ob_item(nghttp2_session *session) { ++ nghttp2_outbound_item *item; ++ + if (nghttp2_outbound_queue_top(&session->ob_urgent)) { + return nghttp2_outbound_queue_top(&session->ob_urgent); + } +@@ -2354,7 +2657,12 @@ nghttp2_session_get_next_ob_item(nghttp2_session *session) { + } + + if (session->remote_window_size > 0) { +- return nghttp2_stream_next_outbound_item(&session->root); ++ item = nghttp2_stream_next_outbound_item(&session->root); ++ if (item) { ++ return item; ++ } ++ ++ return session_sched_get_next_outbound_item(session); + } + + return NULL; +@@ -2388,7 +2696,12 @@ nghttp2_session_pop_next_ob_item(nghttp2_session *session) { + } + + if (session->remote_window_size > 0) { +- return nghttp2_stream_next_outbound_item(&session->root); ++ item = nghttp2_stream_next_outbound_item(&session->root); ++ if (item) { ++ return item; ++ } ++ ++ return session_sched_get_next_outbound_item(session); + } + + return NULL; +@@ -2424,7 +2737,7 @@ static int session_call_on_frame_send(nghttp2_session *session, + return 0; + } + +-static int find_stream_on_goaway_func(nghttp2_map_entry *entry, void *ptr) { ++static int find_stream_on_goaway_func(void *entry, void *ptr) { + nghttp2_close_stream_on_goaway_arg *arg; + nghttp2_stream *stream; + +@@ -2498,10 +2811,20 @@ static int session_close_stream_on_goaway(nghttp2_session *session, + return 0; + } + +-static void reschedule_stream(nghttp2_stream *stream) { ++static void session_reschedule_stream(nghttp2_session *session, ++ nghttp2_stream *stream) { + stream->last_writelen = stream->item->frame.hd.length; + +- nghttp2_stream_reschedule(stream); ++ if (!(stream->flags & NGHTTP2_STREAM_FLAG_NO_RFC7540_PRIORITIES)) { ++ nghttp2_stream_reschedule(stream); ++ return; ++ } ++ ++ if (!session->server) { ++ return; ++ } ++ ++ session_sched_reschedule_stream(session, stream); + } + + static int session_update_stream_consumed_size(nghttp2_session *session, +@@ -2550,10 +2873,7 @@ static int session_after_frame_sent1(nghttp2_session *session) { + } + + if (stream && aux_data->eof) { +- rv = nghttp2_stream_detach_item(stream); +- if (nghttp2_is_fatal(rv)) { +- return rv; +- } ++ session_detach_stream_item(session, stream); + + /* Call on_frame_send_callback after + nghttp2_stream_detach_item(), so that application can issue +@@ -2675,9 +2995,8 @@ static int session_after_frame_sent1(nghttp2_session *session) { + } + } + case NGHTTP2_PRIORITY: +- if (session->server) { ++ if (session->server || session->pending_no_rfc7540_priorities == 1) { + return 0; +- ; + } + + stream = nghttp2_session_get_stream_raw(session, frame->hd.stream_id); +@@ -2787,17 +3106,8 @@ static int session_after_frame_sent1(nghttp2_session *session) { + /* + * Called after a frame is sent and session_after_frame_sent1. This + * function is responsible to reset session->aob. +- * +- * This function returns 0 if it succeeds, or one of the following +- * negative error codes: +- * +- * NGHTTP2_ERR_NOMEM +- * Out of memory. +- * NGHTTP2_ERR_CALLBACK_FAILURE +- * The callback function failed. + */ +-static int session_after_frame_sent2(nghttp2_session *session) { +- int rv; ++static void session_after_frame_sent2(nghttp2_session *session) { + nghttp2_active_outbound_item *aob = &session->aob; + nghttp2_outbound_item *item = aob->item; + nghttp2_bufs *framebufs = &aob->framebufs; +@@ -2820,13 +3130,13 @@ static int session_after_frame_sent2(nghttp2_session *session) { + DEBUGF("send: next CONTINUATION frame, %zu bytes\n", + nghttp2_buf_len(&framebufs->cur->buf)); + +- return 0; ++ return; + } + } + + active_outbound_item_reset(&session->aob, mem); + +- return 0; ++ return; + } + + /* DATA frame */ +@@ -2840,7 +3150,7 @@ static int session_after_frame_sent2(nghttp2_session *session) { + if (aux_data->eof) { + active_outbound_item_reset(aob, mem); + +- return 0; ++ return; + } + + /* Reset no_copy here because next write may not use this. */ +@@ -2852,22 +3162,18 @@ static int session_after_frame_sent2(nghttp2_session *session) { + further data. */ + if (nghttp2_session_predicate_data_send(session, stream) != 0) { + if (stream) { +- rv = nghttp2_stream_detach_item(stream); +- +- if (nghttp2_is_fatal(rv)) { +- return rv; +- } ++ session_detach_stream_item(session, stream); + } + + active_outbound_item_reset(aob, mem); + +- return 0; ++ return; + } + + aob->item = NULL; + active_outbound_item_reset(&session->aob, mem); + +- return 0; ++ return; + } + + static int session_call_send_data(nghttp2_session *session, +@@ -2940,6 +3246,7 @@ static ssize_t nghttp2_session_mem_send_internal(nghttp2_session *session, + if (rv < 0) { + int32_t opened_stream_id = 0; + uint32_t error_code = NGHTTP2_INTERNAL_ERROR; ++ int rv2 = 0; + + DEBUGF("send: frame preparation failed with %s\n", + nghttp2_strerror(rv)); +@@ -2982,19 +3289,18 @@ static ssize_t nghttp2_session_mem_send_internal(nghttp2_session *session, + } + if (opened_stream_id) { + /* careful not to override rv */ +- int rv2; + rv2 = nghttp2_session_close_stream(session, opened_stream_id, + error_code); +- +- if (nghttp2_is_fatal(rv2)) { +- return rv2; +- } + } + + nghttp2_outbound_item_free(item, mem); + nghttp2_mem_free(mem, item); + active_outbound_item_reset(aob, mem); + ++ if (nghttp2_is_fatal(rv2)) { ++ return rv2; ++ } ++ + if (rv == NGHTTP2_ERR_HEADER_COMP) { + /* If header compression error occurred, should terminiate + connection. */ +@@ -3098,7 +3404,7 @@ static ssize_t nghttp2_session_mem_send_internal(nghttp2_session *session, + + /* Frame has completely sent */ + if (fast_cb) { +- rv = session_after_frame_sent2(session); ++ session_after_frame_sent2(session); + } else { + rv = session_after_frame_sent1(session); + if (rv < 0) { +@@ -3106,12 +3412,7 @@ static ssize_t nghttp2_session_mem_send_internal(nghttp2_session *session, + assert(nghttp2_is_fatal(rv)); + return rv; + } +- rv = session_after_frame_sent2(session); +- } +- if (rv < 0) { +- /* FATAL */ +- assert(nghttp2_is_fatal(rv)); +- return rv; ++ session_after_frame_sent2(session); + } + /* We have already adjusted the next state */ + break; +@@ -3150,11 +3451,7 @@ static ssize_t nghttp2_session_mem_send_internal(nghttp2_session *session, + } + + if (rv == NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE) { +- rv = nghttp2_stream_detach_item(stream); +- +- if (nghttp2_is_fatal(rv)) { +- return rv; +- } ++ session_detach_stream_item(session, stream); + + rv = nghttp2_session_add_rst_stream(session, frame->hd.stream_id, + NGHTTP2_INTERNAL_ERROR); +@@ -3178,11 +3475,7 @@ static ssize_t nghttp2_session_mem_send_internal(nghttp2_session *session, + assert(nghttp2_is_fatal(rv)); + return rv; + } +- rv = session_after_frame_sent2(session); +- if (rv < 0) { +- assert(nghttp2_is_fatal(rv)); +- return rv; +- } ++ session_after_frame_sent2(session); + + /* We have already adjusted the next state */ + +@@ -3730,6 +4023,21 @@ static int session_end_stream_headers_received(nghttp2_session *session, + nghttp2_frame *frame, + nghttp2_stream *stream) { + int rv; ++ ++ assert(frame->hd.type == NGHTTP2_HEADERS); ++ ++ if (session->server && session_enforce_http_messaging(session) && ++ frame->headers.cat == NGHTTP2_HCAT_REQUEST && ++ (stream->flags & NGHTTP2_STREAM_FLAG_NO_RFC7540_PRIORITIES) && ++ !(stream->flags & NGHTTP2_STREAM_FLAG_IGNORE_CLIENT_PRIORITIES) && ++ (stream->http_flags & NGHTTP2_HTTP_FLAG_PRIORITY)) { ++ rv = session_update_stream_priority(session, stream, stream->http_extpri); ++ if (rv != 0) { ++ assert(nghttp2_is_fatal(rv)); ++ return rv; ++ } ++ } ++ + if ((frame->hd.flags & NGHTTP2_FLAG_END_STREAM) == 0) { + return 0; + } +@@ -4053,17 +4361,12 @@ int nghttp2_session_on_headers_received(nghttp2_session *session, + } + + static int session_process_headers_frame(nghttp2_session *session) { +- int rv; + nghttp2_inbound_frame *iframe = &session->iframe; + nghttp2_frame *frame = &iframe->frame; + nghttp2_stream *stream; + +- rv = nghttp2_frame_unpack_headers_payload(&frame->headers, iframe->sbuf.pos); ++ nghttp2_frame_unpack_headers_payload(&frame->headers, iframe->sbuf.pos); + +- if (rv != 0) { +- return nghttp2_session_terminate_session_with_reason( +- session, NGHTTP2_PROTOCOL_ERROR, "HEADERS: could not unpack"); +- } + stream = nghttp2_session_get_stream(session, frame->hd.stream_id); + if (!stream) { + frame->headers.cat = NGHTTP2_HCAT_REQUEST; +@@ -4091,6 +4394,8 @@ int nghttp2_session_on_priority_received(nghttp2_session *session, + int rv; + nghttp2_stream *stream; + ++ assert(!session_no_rfc7540_pri_no_fallback(session)); ++ + if (frame->hd.stream_id == 0) { + return session_handle_invalid_connection(session, frame, NGHTTP2_ERR_PROTO, + "PRIORITY: stream_id == 0"); +@@ -4148,11 +4453,30 @@ static int session_process_priority_frame(nghttp2_session *session) { + nghttp2_inbound_frame *iframe = &session->iframe; + nghttp2_frame *frame = &iframe->frame; + ++ assert(!session_no_rfc7540_pri_no_fallback(session)); ++ + nghttp2_frame_unpack_priority_payload(&frame->priority, iframe->sbuf.pos); + + return nghttp2_session_on_priority_received(session, frame); + } + ++static int session_update_stream_reset_ratelim(nghttp2_session *session) { ++ if (!session->server || (session->goaway_flags & NGHTTP2_GOAWAY_SUBMITTED)) { ++ return 0; ++ } ++ ++ nghttp2_ratelim_update(&session->stream_reset_ratelim, ++ nghttp2_time_now_sec()); ++ ++ if (nghttp2_ratelim_drain(&session->stream_reset_ratelim, 1) == 0) { ++ return 0; ++ } ++ ++ return nghttp2_session_add_goaway(session, session->last_recv_stream_id, ++ NGHTTP2_INTERNAL_ERROR, NULL, 0, ++ NGHTTP2_GOAWAY_AUX_NONE); ++} ++ + int nghttp2_session_on_rst_stream_received(nghttp2_session *session, + nghttp2_frame *frame) { + int rv; +@@ -4182,7 +4506,8 @@ int nghttp2_session_on_rst_stream_received(nghttp2_session *session, + if (nghttp2_is_fatal(rv)) { + return rv; + } +- return 0; ++ ++ return session_update_stream_reset_ratelim(session); + } + + static int session_process_rst_stream_frame(nghttp2_session *session) { +@@ -4194,8 +4519,7 @@ static int session_process_rst_stream_frame(nghttp2_session *session) { + return nghttp2_session_on_rst_stream_received(session, frame); + } + +-static int update_remote_initial_window_size_func(nghttp2_map_entry *entry, +- void *ptr) { ++static int update_remote_initial_window_size_func(void *entry, void *ptr) { + int rv; + nghttp2_update_window_size_arg *arg; + nghttp2_stream *stream; +@@ -4215,8 +4539,8 @@ static int update_remote_initial_window_size_func(nghttp2_map_entry *entry, + if (stream->remote_window_size > 0 && + nghttp2_stream_check_deferred_by_flow_control(stream)) { + +- rv = nghttp2_stream_resume_deferred_item( +- stream, NGHTTP2_STREAM_FLAG_DEFERRED_FLOW_CONTROL); ++ rv = session_resume_deferred_stream_item( ++ arg->session, stream, NGHTTP2_STREAM_FLAG_DEFERRED_FLOW_CONTROL); + + if (nghttp2_is_fatal(rv)) { + return rv; +@@ -4248,8 +4572,7 @@ session_update_remote_initial_window_size(nghttp2_session *session, + update_remote_initial_window_size_func, &arg); + } + +-static int update_local_initial_window_size_func(nghttp2_map_entry *entry, +- void *ptr) { ++static int update_local_initial_window_size_func(void *entry, void *ptr) { + int rv; + nghttp2_update_window_size_arg *arg; + nghttp2_stream *stream; +@@ -4261,9 +4584,16 @@ static int update_local_initial_window_size_func(nghttp2_map_entry *entry, + return nghttp2_session_add_rst_stream(arg->session, stream->stream_id, + NGHTTP2_FLOW_CONTROL_ERROR); + } +- if (!(arg->session->opt_flags & NGHTTP2_OPTMASK_NO_AUTO_WINDOW_UPDATE) && +- stream->window_update_queued == 0 && +- nghttp2_should_send_window_update(stream->local_window_size, ++ ++ if (stream->window_update_queued) { ++ return 0; ++ } ++ ++ if (arg->session->opt_flags & NGHTTP2_OPTMASK_NO_AUTO_WINDOW_UPDATE) { ++ return session_update_stream_consumed_size(arg->session, stream, 0); ++ } ++ ++ if (nghttp2_should_send_window_update(stream->local_window_size, + stream->recv_window_size)) { + + rv = nghttp2_session_add_window_update(arg->session, NGHTTP2_FLAG_NONE, +@@ -4384,6 +4714,9 @@ int nghttp2_session_update_local_settings(nghttp2_session *session, + case NGHTTP2_SETTINGS_ENABLE_CONNECT_PROTOCOL: + session->local_settings.enable_connect_protocol = iv[i].value; + break; ++ case NGHTTP2_SETTINGS_NO_RFC7540_PRIORITIES: ++ session->local_settings.no_rfc7540_priorities = iv[i].value; ++ break; + } + } + +@@ -4542,10 +4875,38 @@ int nghttp2_session_on_settings_received(nghttp2_session *session, + + session->remote_settings.enable_connect_protocol = entry->value; + ++ break; ++ case NGHTTP2_SETTINGS_NO_RFC7540_PRIORITIES: ++ ++ if (entry->value != 0 && entry->value != 1) { ++ return session_handle_invalid_connection( ++ session, frame, NGHTTP2_ERR_PROTO, ++ "SETTINGS: invalid SETTINGS_NO_RFC7540_PRIORITIES"); ++ } ++ ++ if (session->remote_settings.no_rfc7540_priorities != UINT32_MAX && ++ session->remote_settings.no_rfc7540_priorities != entry->value) { ++ return session_handle_invalid_connection( ++ session, frame, NGHTTP2_ERR_PROTO, ++ "SETTINGS: SETTINGS_NO_RFC7540_PRIORITIES cannot be changed"); ++ } ++ ++ session->remote_settings.no_rfc7540_priorities = entry->value; ++ + break; + } + } + ++ if (session->remote_settings.no_rfc7540_priorities == UINT32_MAX) { ++ session->remote_settings.no_rfc7540_priorities = 0; ++ ++ if (session->server && session->pending_no_rfc7540_priorities && ++ (session->opt_flags & ++ NGHTTP2_OPTMASK_SERVER_FALLBACK_RFC7540_PRIORITIES)) { ++ session->fallback_rfc7540_priorities = 1; ++ } ++ } ++ + if (!noack && !session_is_closing(session)) { + rv = nghttp2_session_add_settings(session, NGHTTP2_FLAG_ACK, NULL, 0); + +@@ -4686,17 +5047,11 @@ int nghttp2_session_on_push_promise_received(nghttp2_session *session, + } + + static int session_process_push_promise_frame(nghttp2_session *session) { +- int rv; + nghttp2_inbound_frame *iframe = &session->iframe; + nghttp2_frame *frame = &iframe->frame; + +- rv = nghttp2_frame_unpack_push_promise_payload(&frame->push_promise, +- iframe->sbuf.pos); +- +- if (rv != 0) { +- return nghttp2_session_terminate_session_with_reason( +- session, NGHTTP2_PROTOCOL_ERROR, "PUSH_PROMISE: could not unpack"); +- } ++ nghttp2_frame_unpack_push_promise_payload(&frame->push_promise, ++ iframe->sbuf.pos); + + return nghttp2_session_on_push_promise_received(session, frame); + } +@@ -4828,8 +5183,8 @@ static int session_on_stream_window_update_received(nghttp2_session *session, + if (stream->remote_window_size > 0 && + nghttp2_stream_check_deferred_by_flow_control(stream)) { + +- rv = nghttp2_stream_resume_deferred_item( +- stream, NGHTTP2_STREAM_FLAG_DEFERRED_FLOW_CONTROL); ++ rv = session_resume_deferred_stream_item( ++ session, stream, NGHTTP2_STREAM_FLAG_DEFERRED_FLOW_CONTROL); + + if (nghttp2_is_fatal(rv)) { + return rv; +@@ -4900,6 +5255,80 @@ int nghttp2_session_on_origin_received(nghttp2_session *session, + return session_call_on_frame_received(session, frame); + } + ++int nghttp2_session_on_priority_update_received(nghttp2_session *session, ++ nghttp2_frame *frame) { ++ nghttp2_ext_priority_update *priority_update; ++ nghttp2_stream *stream; ++ nghttp2_priority_spec pri_spec; ++ nghttp2_extpri extpri; ++ int rv; ++ ++ assert(session->server); ++ ++ priority_update = frame->ext.payload; ++ ++ if (frame->hd.stream_id != 0) { ++ return session_handle_invalid_connection(session, frame, NGHTTP2_ERR_PROTO, ++ "PRIORITY_UPDATE: stream_id == 0"); ++ } ++ ++ if (nghttp2_session_is_my_stream_id(session, priority_update->stream_id)) { ++ if (session_detect_idle_stream(session, priority_update->stream_id)) { ++ return session_handle_invalid_connection( ++ session, frame, NGHTTP2_ERR_PROTO, ++ "PRIORITY_UPDATE: prioritizing idle push is not allowed"); ++ } ++ ++ /* TODO Ignore priority signal to a push stream for now */ ++ return session_call_on_frame_received(session, frame); ++ } ++ ++ stream = nghttp2_session_get_stream_raw(session, priority_update->stream_id); ++ if (stream) { ++ /* Stream already exists. */ ++ if (stream->flags & NGHTTP2_STREAM_FLAG_IGNORE_CLIENT_PRIORITIES) { ++ return session_call_on_frame_received(session, frame); ++ } ++ } else if (session_detect_idle_stream(session, priority_update->stream_id)) { ++ if (session->num_idle_streams + session->num_incoming_streams >= ++ session->local_settings.max_concurrent_streams) { ++ return session_handle_invalid_connection( ++ session, frame, NGHTTP2_ERR_PROTO, ++ "PRIORITY_UPDATE: max concurrent streams exceeded"); ++ } ++ ++ nghttp2_priority_spec_default_init(&pri_spec); ++ stream = nghttp2_session_open_stream(session, priority_update->stream_id, ++ NGHTTP2_FLAG_NONE, &pri_spec, ++ NGHTTP2_STREAM_IDLE, NULL); ++ if (!stream) { ++ return NGHTTP2_ERR_NOMEM; ++ } ++ } else { ++ return session_call_on_frame_received(session, frame); ++ } ++ ++ extpri.urgency = NGHTTP2_EXTPRI_DEFAULT_URGENCY; ++ extpri.inc = 0; ++ ++ rv = nghttp2_http_parse_priority(&extpri, priority_update->field_value, ++ priority_update->field_value_len); ++ if (rv != 0) { ++ /* Just ignore field_value if it cannot be parsed. */ ++ return session_call_on_frame_received(session, frame); ++ } ++ ++ rv = session_update_stream_priority(session, stream, ++ nghttp2_extpri_to_uint8(&extpri)); ++ if (rv != 0) { ++ if (nghttp2_is_fatal(rv)) { ++ return rv; ++ } ++ } ++ ++ return session_call_on_frame_received(session, frame); ++} ++ + static int session_process_altsvc_frame(nghttp2_session *session) { + nghttp2_inbound_frame *iframe = &session->iframe; + nghttp2_frame *frame = &iframe->frame; +@@ -4934,6 +5363,16 @@ static int session_process_origin_frame(nghttp2_session *session) { + return nghttp2_session_on_origin_received(session, frame); + } + ++static int session_process_priority_update_frame(nghttp2_session *session) { ++ nghttp2_inbound_frame *iframe = &session->iframe; ++ nghttp2_frame *frame = &iframe->frame; ++ ++ nghttp2_frame_unpack_priority_update_payload(&frame->ext, iframe->sbuf.pos, ++ nghttp2_buf_len(&iframe->sbuf)); ++ ++ return nghttp2_session_on_priority_update_received(session, frame); ++} ++ + static int session_process_extension_frame(nghttp2_session *session) { + int rv; + nghttp2_inbound_frame *iframe = &session->iframe; +@@ -5271,6 +5710,7 @@ static void inbound_frame_set_settings_entry(nghttp2_inbound_frame *iframe) { + case NGHTTP2_SETTINGS_MAX_FRAME_SIZE: + case NGHTTP2_SETTINGS_MAX_HEADER_LIST_SIZE: + case NGHTTP2_SETTINGS_ENABLE_CONNECT_PROTOCOL: ++ case NGHTTP2_SETTINGS_NO_RFC7540_PRIORITIES: + break; + default: + DEBUGF("recv: unknown settings id=0x%02x\n", iv.settings_id); +@@ -5343,7 +5783,7 @@ static ssize_t inbound_frame_compute_pad(nghttp2_inbound_frame *iframe) { + + /* + * This function returns the effective payload length in the data of +- * length |readlen| when the remaning payload is |payloadleft|. The ++ * length |readlen| when the remaining payload is |payloadleft|. The + * |payloadleft| does not include |readlen|. If padding was started + * strictly before this data chunk, this function returns -1. + */ +@@ -5431,7 +5871,7 @@ ssize_t nghttp2_session_mem_recv(nghttp2_session *session, const uint8_t *in, + in += readlen; + + if (nghttp2_buf_mark_avail(&iframe->sbuf)) { +- return in - first; ++ return (ssize_t)(in - first); + } + + if (iframe->sbuf.pos[3] != NGHTTP2_SETTINGS || +@@ -5468,7 +5908,7 @@ ssize_t nghttp2_session_mem_recv(nghttp2_session *session, const uint8_t *in, + in += readlen; + + if (nghttp2_buf_mark_avail(&iframe->sbuf)) { +- return in - first; ++ return (ssize_t)(in - first); + } + + nghttp2_frame_unpack_frame_hd(&iframe->frame.hd, iframe->sbuf.pos); +@@ -5884,6 +6324,49 @@ ssize_t nghttp2_session_mem_recv(nghttp2_session *session, const uint8_t *in, + + iframe->state = NGHTTP2_IB_READ_ORIGIN_PAYLOAD; + ++ break; ++ case NGHTTP2_PRIORITY_UPDATE: ++ if ((session->builtin_recv_ext_types & ++ NGHTTP2_TYPEMASK_PRIORITY_UPDATE) == 0) { ++ busy = 1; ++ iframe->state = NGHTTP2_IB_IGN_PAYLOAD; ++ break; ++ } ++ ++ DEBUGF("recv: PRIORITY_UPDATE\n"); ++ ++ iframe->frame.hd.flags = NGHTTP2_FLAG_NONE; ++ iframe->frame.ext.payload = ++ &iframe->ext_frame_payload.priority_update; ++ ++ if (!session->server) { ++ rv = nghttp2_session_terminate_session_with_reason( ++ session, NGHTTP2_PROTOCOL_ERROR, ++ "PRIORITY_UPDATE is received from server"); ++ if (nghttp2_is_fatal(rv)) { ++ return rv; ++ } ++ return (ssize_t)inlen; ++ } ++ ++ if (iframe->payloadleft < 4) { ++ busy = 1; ++ iframe->state = NGHTTP2_IB_FRAME_SIZE_ERROR; ++ break; ++ } ++ ++ if (!session_no_rfc7540_pri_no_fallback(session) || ++ iframe->payloadleft > sizeof(iframe->raw_sbuf)) { ++ busy = 1; ++ iframe->state = NGHTTP2_IB_IGN_PAYLOAD; ++ break; ++ } ++ ++ busy = 1; ++ ++ iframe->state = NGHTTP2_IB_READ_NBYTE; ++ inbound_frame_set_mark(iframe, iframe->payloadleft); ++ + break; + default: + busy = 1; +@@ -5925,7 +6408,7 @@ ssize_t nghttp2_session_mem_recv(nghttp2_session *session, const uint8_t *in, + iframe->payloadleft, nghttp2_buf_mark_avail(&iframe->sbuf)); + + if (nghttp2_buf_mark_avail(&iframe->sbuf)) { +- return in - first; ++ return (ssize_t)(in - first); + } + + switch (iframe->frame.hd.type) { +@@ -5990,13 +6473,16 @@ ssize_t nghttp2_session_mem_recv(nghttp2_session *session, const uint8_t *in, + + break; + case NGHTTP2_PRIORITY: +- rv = session_process_priority_frame(session); +- if (nghttp2_is_fatal(rv)) { +- return rv; +- } ++ if (!session_no_rfc7540_pri_no_fallback(session) && ++ session->remote_settings.no_rfc7540_priorities != 1) { ++ rv = session_process_priority_frame(session); ++ if (nghttp2_is_fatal(rv)) { ++ return rv; ++ } + +- if (iframe->state == NGHTTP2_IB_IGN_ALL) { +- return (ssize_t)inlen; ++ if (iframe->state == NGHTTP2_IB_IGN_ALL) { ++ return (ssize_t)inlen; ++ } + } + + session_inbound_frame_reset(session); +@@ -6152,6 +6638,18 @@ ssize_t nghttp2_session_mem_recv(nghttp2_session *session, const uint8_t *in, + + iframe->state = NGHTTP2_IB_READ_ALTSVC_PAYLOAD; + ++ break; ++ case NGHTTP2_PRIORITY_UPDATE: ++ DEBUGF("recv: prioritized_stream_id=%d\n", ++ nghttp2_get_uint32(iframe->sbuf.pos) & NGHTTP2_STREAM_ID_MASK); ++ ++ rv = session_process_priority_update_frame(session); ++ if (nghttp2_is_fatal(rv)) { ++ return rv; ++ } ++ ++ session_inbound_frame_reset(session); ++ + break; + } + default: +@@ -6214,7 +6712,7 @@ ssize_t nghttp2_session_mem_recv(nghttp2_session *session, const uint8_t *in, + in += hd_proclen; + iframe->payloadleft -= hd_proclen; + +- return in - first; ++ return (ssize_t)(in - first); + } + + if (rv == NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE) { +@@ -6405,7 +6903,7 @@ ssize_t nghttp2_session_mem_recv(nghttp2_session *session, const uint8_t *in, + in += readlen; + + if (nghttp2_buf_mark_avail(&iframe->sbuf)) { +- return in - first; ++ return (ssize_t)(in - first); + } + + nghttp2_frame_unpack_frame_hd(&cont_hd, iframe->sbuf.pos); +@@ -6432,8 +6930,9 @@ ssize_t nghttp2_session_mem_recv(nghttp2_session *session, const uint8_t *in, + + /* CONTINUATION won't bear NGHTTP2_PADDED flag */ + +- iframe->frame.hd.flags = (uint8_t)( +- iframe->frame.hd.flags | (cont_hd.flags & NGHTTP2_FLAG_END_HEADERS)); ++ iframe->frame.hd.flags = ++ (uint8_t)(iframe->frame.hd.flags | ++ (cont_hd.flags & NGHTTP2_FLAG_END_HEADERS)); + iframe->frame.hd.length += cont_hd.length; + + busy = 1; +@@ -6462,7 +6961,7 @@ ssize_t nghttp2_session_mem_recv(nghttp2_session *session, const uint8_t *in, + iframe->payloadleft, nghttp2_buf_mark_avail(&iframe->sbuf)); + + if (nghttp2_buf_mark_avail(&iframe->sbuf)) { +- return in - first; ++ return (ssize_t)(in - first); + } + + /* Pad Length field is subject to flow control */ +@@ -6612,7 +7111,7 @@ ssize_t nghttp2_session_mem_recv(nghttp2_session *session, const uint8_t *in, + session, iframe->frame.hd.flags, iframe->frame.hd.stream_id, + in - readlen, (size_t)data_readlen, session->user_data); + if (rv == NGHTTP2_ERR_PAUSE) { +- return in - first; ++ return (ssize_t)(in - first); + } + + if (nghttp2_is_fatal(rv)) { +@@ -6792,7 +7291,7 @@ ssize_t nghttp2_session_mem_recv(nghttp2_session *session, const uint8_t *in, + + assert(in == last); + +- return in - first; ++ return (ssize_t)(in - first); + } + + int nghttp2_session_recv(nghttp2_session *session) { +@@ -6864,7 +7363,8 @@ int nghttp2_session_want_write(nghttp2_session *session) { + */ + return session->aob.item || nghttp2_outbound_queue_top(&session->ob_urgent) || + nghttp2_outbound_queue_top(&session->ob_reg) || +- (!nghttp2_pq_empty(&session->root.obq) && ++ ((!nghttp2_pq_empty(&session->root.obq) || ++ !session_sched_empty(session)) && + session->remote_window_size > 0) || + (nghttp2_outbound_queue_top(&session->ob_syn) && + !session_is_outgoing_concurrent_streams_max(session)); +@@ -6963,6 +7463,9 @@ int nghttp2_session_add_goaway(nghttp2_session *session, int32_t last_stream_id, + nghttp2_mem_free(mem, item); + return rv; + } ++ ++ session->goaway_flags |= NGHTTP2_GOAWAY_SUBMITTED; ++ + return 0; + } + +@@ -7017,6 +7520,7 @@ int nghttp2_session_add_settings(nghttp2_session *session, uint8_t flags, + int rv; + nghttp2_mem *mem; + nghttp2_inflight_settings *inflight_settings = NULL; ++ uint8_t no_rfc7540_pri = session->pending_no_rfc7540_priorities; + + mem = &session->mem; + +@@ -7034,6 +7538,21 @@ int nghttp2_session_add_settings(nghttp2_session *session, uint8_t flags, + return NGHTTP2_ERR_INVALID_ARGUMENT; + } + ++ for (i = 0; i < niv; ++i) { ++ if (iv[i].settings_id != NGHTTP2_SETTINGS_NO_RFC7540_PRIORITIES) { ++ continue; ++ } ++ ++ if (no_rfc7540_pri == UINT8_MAX) { ++ no_rfc7540_pri = (uint8_t)iv[i].value; ++ continue; ++ } ++ ++ if (iv[i].value != (uint32_t)no_rfc7540_pri) { ++ return NGHTTP2_ERR_INVALID_ARGUMENT; ++ } ++ } ++ + item = nghttp2_mem_malloc(mem, sizeof(nghttp2_outbound_item)); + if (item == NULL) { + return NGHTTP2_ERR_NOMEM; +@@ -7108,6 +7627,12 @@ int nghttp2_session_add_settings(nghttp2_session *session, uint8_t flags, + } + } + ++ if (no_rfc7540_pri == UINT8_MAX) { ++ session->pending_no_rfc7540_priorities = 0; ++ } else { ++ session->pending_no_rfc7540_priorities = no_rfc7540_pri; ++ } ++ + return 0; + } + +@@ -7230,13 +7755,10 @@ int nghttp2_session_pack_data(nghttp2_session *session, nghttp2_bufs *bufs, + + nghttp2_frame_pack_frame_hd(buf->pos, &frame->hd); + +- rv = nghttp2_frame_add_pad(bufs, &frame->hd, frame->data.padlen, +- aux_data->no_copy); +- if (rv != 0) { +- return rv; +- } ++ nghttp2_frame_add_pad(bufs, &frame->hd, frame->data.padlen, ++ aux_data->no_copy); + +- reschedule_stream(stream); ++ session_reschedule_stream(session, stream); + + if (frame->hd.length == 0 && (data_flags & NGHTTP2_DATA_FLAG_EOF) && + (data_flags & NGHTTP2_DATA_FLAG_NO_END_STREAM)) { +@@ -7310,7 +7832,7 @@ int nghttp2_session_resume_data(nghttp2_session *session, int32_t stream_id) { + return NGHTTP2_ERR_INVALID_ARGUMENT; + } + +- rv = nghttp2_stream_resume_deferred_item(stream, ++ rv = session_resume_deferred_stream_item(session, stream, + NGHTTP2_STREAM_FLAG_DEFERRED_USER); + + if (nghttp2_is_fatal(rv)) { +@@ -7418,6 +7940,8 @@ uint32_t nghttp2_session_get_remote_settings(nghttp2_session *session, + return session->remote_settings.max_header_list_size; + case NGHTTP2_SETTINGS_ENABLE_CONNECT_PROTOCOL: + return session->remote_settings.enable_connect_protocol; ++ case NGHTTP2_SETTINGS_NO_RFC7540_PRIORITIES: ++ return session->remote_settings.no_rfc7540_priorities; + } + + assert(0); +@@ -7441,6 +7965,8 @@ uint32_t nghttp2_session_get_local_settings(nghttp2_session *session, + return session->local_settings.max_header_list_size; + case NGHTTP2_SETTINGS_ENABLE_CONNECT_PROTOCOL: + return session->local_settings.enable_connect_protocol; ++ case NGHTTP2_SETTINGS_NO_RFC7540_PRIORITIES: ++ return session->local_settings.no_rfc7540_priorities; + } + + assert(0); +@@ -7724,6 +8250,10 @@ int nghttp2_session_change_stream_priority( + nghttp2_stream *stream; + nghttp2_priority_spec pri_spec_copy; + ++ if (session->pending_no_rfc7540_priorities == 1) { ++ return 0; ++ } ++ + if (stream_id == 0 || stream_id == pri_spec->stream_id) { + return NGHTTP2_ERR_INVALID_ARGUMENT; + } +@@ -7756,6 +8286,10 @@ int nghttp2_session_create_idle_stream(nghttp2_session *session, + nghttp2_stream *stream; + nghttp2_priority_spec pri_spec_copy; + ++ if (session->pending_no_rfc7540_priorities == 1) { ++ return 0; ++ } ++ + if (stream_id == 0 || stream_id == pri_spec->stream_id || + !session_detect_idle_stream(session, stream_id)) { + return NGHTTP2_ERR_INVALID_ARGUMENT; +@@ -7797,3 +8331,38 @@ nghttp2_session_get_hd_deflate_dynamic_table_size(nghttp2_session *session) { + void nghttp2_session_set_user_data(nghttp2_session *session, void *user_data) { + session->user_data = user_data; + } ++ ++int nghttp2_session_change_extpri_stream_priority( ++ nghttp2_session *session, int32_t stream_id, ++ const nghttp2_extpri *extpri_in, int ignore_client_signal) { ++ nghttp2_stream *stream; ++ nghttp2_extpri extpri = *extpri_in; ++ ++ if (!session->server) { ++ return NGHTTP2_ERR_INVALID_STATE; ++ } ++ ++ if (session->pending_no_rfc7540_priorities != 1) { ++ return 0; ++ } ++ ++ if (stream_id == 0) { ++ return NGHTTP2_ERR_INVALID_ARGUMENT; ++ } ++ ++ stream = nghttp2_session_get_stream_raw(session, stream_id); ++ if (!stream) { ++ return NGHTTP2_ERR_INVALID_ARGUMENT; ++ } ++ ++ if (extpri.urgency > NGHTTP2_EXTPRI_URGENCY_LOW) { ++ extpri.urgency = NGHTTP2_EXTPRI_URGENCY_LOW; ++ } ++ ++ if (ignore_client_signal) { ++ stream->flags |= NGHTTP2_STREAM_FLAG_IGNORE_CLIENT_PRIORITIES; ++ } ++ ++ return session_update_stream_priority(session, stream, ++ nghttp2_extpri_to_uint8(&extpri)); ++} +diff --git a/deps/nghttp2/lib/nghttp2_session.h b/deps/nghttp2/lib/nghttp2_session.h +index 07bfbb6c90..b119329a04 100644 +--- a/deps/nghttp2/lib/nghttp2_session.h ++++ b/deps/nghttp2/lib/nghttp2_session.h +@@ -39,6 +39,7 @@ + #include "nghttp2_buf.h" + #include "nghttp2_callbacks.h" + #include "nghttp2_mem.h" ++#include "nghttp2_ratelim.h" + + /* The global variable for tests where we want to disable strict + preface handling. */ +@@ -52,7 +53,9 @@ typedef enum { + NGHTTP2_OPTMASK_NO_RECV_CLIENT_MAGIC = 1 << 1, + NGHTTP2_OPTMASK_NO_HTTP_MESSAGING = 1 << 2, + NGHTTP2_OPTMASK_NO_AUTO_PING_ACK = 1 << 3, +- NGHTTP2_OPTMASK_NO_CLOSED_STREAMS = 1 << 4 ++ NGHTTP2_OPTMASK_NO_CLOSED_STREAMS = 1 << 4, ++ NGHTTP2_OPTMASK_SERVER_FALLBACK_RFC7540_PRIORITIES = 1 << 5, ++ NGHTTP2_OPTMASK_NO_RFC9113_LEADING_AND_TRAILING_WS_VALIDATION = 1 << 6, + } nghttp2_optmask; + + /* +@@ -62,7 +65,8 @@ typedef enum { + typedef enum { + NGHTTP2_TYPEMASK_NONE = 0, + NGHTTP2_TYPEMASK_ALTSVC = 1 << 0, +- NGHTTP2_TYPEMASK_ORIGIN = 1 << 1 ++ NGHTTP2_TYPEMASK_ORIGIN = 1 << 1, ++ NGHTTP2_TYPEMASK_PRIORITY_UPDATE = 1 << 2 + } nghttp2_typemask; + + typedef enum { +@@ -102,6 +106,10 @@ typedef struct { + /* The default value of maximum number of concurrent streams. */ + #define NGHTTP2_DEFAULT_MAX_CONCURRENT_STREAMS 0xffffffffu + ++/* The default values for stream reset rate limiter. */ ++#define NGHTTP2_DEFAULT_STREAM_RESET_BURST 1000 ++#define NGHTTP2_DEFAULT_STREAM_RESET_RATE 33 ++ + /* Internal state when receiving incoming frame */ + typedef enum { + /* Receiving frame header */ +@@ -151,10 +159,8 @@ typedef struct { + /* padding length for the current frame */ + size_t padlen; + nghttp2_inbound_state state; +- /* Small buffer. Currently the largest contiguous chunk to buffer +- is frame header. We buffer part of payload, but they are smaller +- than frame header. */ +- uint8_t raw_sbuf[NGHTTP2_FRAME_HDLEN]; ++ /* Small fixed sized buffer. */ ++ uint8_t raw_sbuf[32]; + } nghttp2_inbound_frame; + + typedef struct { +@@ -165,6 +171,7 @@ typedef struct { + uint32_t max_frame_size; + uint32_t max_header_list_size; + uint32_t enable_connect_protocol; ++ uint32_t no_rfc7540_priorities; + } nghttp2_settings_storage; + + typedef enum { +@@ -176,7 +183,9 @@ typedef enum { + /* Flag means GOAWAY was sent */ + NGHTTP2_GOAWAY_SENT = 0x4, + /* Flag means GOAWAY was received */ +- NGHTTP2_GOAWAY_RECV = 0x8 ++ NGHTTP2_GOAWAY_RECV = 0x8, ++ /* Flag means GOAWAY has been submitted at least once */ ++ NGHTTP2_GOAWAY_SUBMITTED = 0x10 + } nghttp2_goaway_flag; + + /* nghttp2_inflight_settings stores the SETTINGS entries which local +@@ -202,6 +211,12 @@ struct nghttp2_session { + response) frame, which are subject to + SETTINGS_MAX_CONCURRENT_STREAMS limit. */ + nghttp2_outbound_queue ob_syn; ++ /* Queues for DATA frames which is used when ++ SETTINGS_NO_RFC7540_PRIORITIES is enabled. This implements RFC ++ 9218 extensible prioritization scheme. */ ++ struct { ++ nghttp2_pq ob_data; ++ } sched[NGHTTP2_EXTPRI_URGENCY_LEVELS]; + nghttp2_active_outbound_item aob; + nghttp2_inbound_frame iframe; + nghttp2_hd_deflater hd_deflater; +@@ -227,6 +242,12 @@ struct nghttp2_session { + /* Queue of In-flight SETTINGS values. SETTINGS bearing ACK is not + considered as in-flight. */ + nghttp2_inflight_settings *inflight_settings_head; ++ /* Stream reset rate limiter. If receiving excessive amount of ++ stream resets, GOAWAY will be sent. */ ++ nghttp2_ratelim stream_reset_ratelim; ++ /* Sequential number across all streams to process streams in ++ FIFO. */ ++ uint64_t stream_seq; + /* The number of outgoing streams. This will be capped by + remote_settings.max_concurrent_streams. */ + size_t num_outgoing_streams; +@@ -328,6 +349,11 @@ struct nghttp2_session { + /* Unacked local ENABLE_CONNECT_PROTOCOL value. We use this to + accept :protocol header field before SETTINGS_ACK is received. */ + uint8_t pending_enable_connect_protocol; ++ /* Unacked local SETTINGS_NO_RFC7540_PRIORITIES value, which is ++ effective before it is acknowledged. */ ++ uint8_t pending_no_rfc7540_priorities; ++ /* Turn on fallback to RFC 7540 priorities; for server use only. */ ++ uint8_t fallback_rfc7540_priorities; + /* Nonzero if the session is server side. */ + uint8_t server; + /* Flags indicating GOAWAY is sent and/or received. The flags are +@@ -408,7 +434,7 @@ int nghttp2_session_add_rst_stream(nghttp2_session *session, int32_t stream_id, + uint32_t error_code); + + /* +- * Adds PING frame. This is a convenient functin built on top of ++ * Adds PING frame. This is a convenient function built on top of + * nghttp2_session_add_frame() to add PING easily. + * + * If the |opaque_data| is not NULL, it must point to 8 bytes memory +@@ -773,6 +799,19 @@ int nghttp2_session_on_altsvc_received(nghttp2_session *session, + int nghttp2_session_on_origin_received(nghttp2_session *session, + nghttp2_frame *frame); + ++/* ++ * Called when PRIORITY_UPDATE is received, assuming |frame| is ++ * properly initialized. ++ * ++ * This function returns 0 if it succeeds, or one of the following ++ * negative error codes: ++ * ++ * NGHTTP2_ERR_CALLBACK_FAILURE ++ * The callback function failed. ++ */ ++int nghttp2_session_on_priority_update_received(nghttp2_session *session, ++ nghttp2_frame *frame); ++ + /* + * Called when DATA is received, assuming |frame| is properly + * initialized. +diff --git a/deps/nghttp2/lib/nghttp2_stream.c b/deps/nghttp2/lib/nghttp2_stream.c +index dc3a6b11cc..f1951f879d 100644 +--- a/deps/nghttp2/lib/nghttp2_stream.c ++++ b/deps/nghttp2/lib/nghttp2_stream.c +@@ -33,7 +33,7 @@ + #include "nghttp2_frame.h" + + /* Maximum distance between any two stream's cycle in the same +- prirority queue. Imagine stream A's cycle is A, and stream B's ++ priority queue. Imagine stream A's cycle is A, and stream B's + cycle is B, and A < B. The cycle is unsigned 32 bit integer, it + may get overflow. Because of how we calculate the next cycle + value, if B - A is less than or equals to +@@ -62,7 +62,6 @@ void nghttp2_stream_init(nghttp2_stream *stream, int32_t stream_id, + int32_t weight, int32_t remote_initial_window_size, + int32_t local_initial_window_size, + void *stream_user_data, nghttp2_mem *mem) { +- nghttp2_map_entry_init(&stream->map_entry, (key_type)stream_id); + nghttp2_pq_init(&stream->obq, stream_less, mem); + + stream->stream_id = stream_id; +@@ -101,6 +100,8 @@ void nghttp2_stream_init(nghttp2_stream *stream, int32_t stream_id, + stream->descendant_next_seq = 0; + stream->seq = 0; + stream->last_writelen = 0; ++ ++ stream->extpri = stream->http_extpri = NGHTTP2_EXTPRI_DEFAULT_URGENCY; + } + + void nghttp2_stream_free(nghttp2_stream *stream) { +@@ -464,14 +465,12 @@ static int stream_update_dep_on_attach_item(nghttp2_stream *stream) { + return 0; + } + +-static int stream_update_dep_on_detach_item(nghttp2_stream *stream) { ++static void stream_update_dep_on_detach_item(nghttp2_stream *stream) { + if (nghttp2_pq_empty(&stream->obq)) { + stream_obq_remove(stream); + } + + validate_tree(stream); +- +- return 0; + } + + int nghttp2_stream_attach_item(nghttp2_stream *stream, +@@ -485,6 +484,10 @@ int nghttp2_stream_attach_item(nghttp2_stream *stream, + + stream->item = item; + ++ if (stream->flags & NGHTTP2_STREAM_FLAG_NO_RFC7540_PRIORITIES) { ++ return 0; ++ } ++ + rv = stream_update_dep_on_attach_item(stream); + if (rv != 0) { + /* This may relave stream->queued == 1, but stream->item == NULL. +@@ -498,16 +501,20 @@ int nghttp2_stream_attach_item(nghttp2_stream *stream, + return 0; + } + +-int nghttp2_stream_detach_item(nghttp2_stream *stream) { ++void nghttp2_stream_detach_item(nghttp2_stream *stream) { + DEBUGF("stream: stream=%d detach item=%p\n", stream->stream_id, stream->item); + + stream->item = NULL; + stream->flags = (uint8_t)(stream->flags & ~NGHTTP2_STREAM_FLAG_DEFERRED_ALL); + +- return stream_update_dep_on_detach_item(stream); ++ if (stream->flags & NGHTTP2_STREAM_FLAG_NO_RFC7540_PRIORITIES) { ++ return; ++ } ++ ++ stream_update_dep_on_detach_item(stream); + } + +-int nghttp2_stream_defer_item(nghttp2_stream *stream, uint8_t flags) { ++void nghttp2_stream_defer_item(nghttp2_stream *stream, uint8_t flags) { + assert(stream->item); + + DEBUGF("stream: stream=%d defer item=%p cause=%02x\n", stream->stream_id, +@@ -515,7 +522,11 @@ int nghttp2_stream_defer_item(nghttp2_stream *stream, uint8_t flags) { + + stream->flags |= flags; + +- return stream_update_dep_on_detach_item(stream); ++ if (stream->flags & NGHTTP2_STREAM_FLAG_NO_RFC7540_PRIORITIES) { ++ return; ++ } ++ ++ stream_update_dep_on_detach_item(stream); + } + + int nghttp2_stream_resume_deferred_item(nghttp2_stream *stream, uint8_t flags) { +@@ -530,6 +541,10 @@ int nghttp2_stream_resume_deferred_item(nghttp2_stream *stream, uint8_t flags) { + return 0; + } + ++ if (stream->flags & NGHTTP2_STREAM_FLAG_NO_RFC7540_PRIORITIES) { ++ return 0; ++ } ++ + return stream_update_dep_on_attach_item(stream); + } + +diff --git a/deps/nghttp2/lib/nghttp2_stream.h b/deps/nghttp2/lib/nghttp2_stream.h +index a1b807d295..71b9fb1140 100644 +--- a/deps/nghttp2/lib/nghttp2_stream.h ++++ b/deps/nghttp2/lib/nghttp2_stream.h +@@ -90,8 +90,15 @@ typedef enum { + NGHTTP2_STREAM_FLAG_DEFERRED_USER = 0x08, + /* bitwise OR of NGHTTP2_STREAM_FLAG_DEFERRED_FLOW_CONTROL and + NGHTTP2_STREAM_FLAG_DEFERRED_USER. */ +- NGHTTP2_STREAM_FLAG_DEFERRED_ALL = 0x0c +- ++ NGHTTP2_STREAM_FLAG_DEFERRED_ALL = 0x0c, ++ /* Indicates that this stream is not subject to RFC7540 ++ priorities scheme. */ ++ NGHTTP2_STREAM_FLAG_NO_RFC7540_PRIORITIES = 0x10, ++ /* Ignore client RFC 9218 priority signal. */ ++ NGHTTP2_STREAM_FLAG_IGNORE_CLIENT_PRIORITIES = 0x20, ++ /* Indicates that RFC 9113 leading and trailing white spaces ++ validation against a field value is not performed. */ ++ NGHTTP2_STREAM_FLAG_NO_RFC9113_LEADING_AND_TRAILING_WS_VALIDATION = 0x40, + } nghttp2_stream_flag; + + /* HTTP related flags to enforce HTTP semantics */ +@@ -132,11 +139,14 @@ typedef enum { + /* set if final response is expected */ + NGHTTP2_HTTP_FLAG_EXPECT_FINAL_RESPONSE = 1 << 14, + NGHTTP2_HTTP_FLAG__PROTOCOL = 1 << 15, ++ /* set if priority header field is received */ ++ NGHTTP2_HTTP_FLAG_PRIORITY = 1 << 16, ++ /* set if an error is encountered while parsing priority header ++ field */ ++ NGHTTP2_HTTP_FLAG_BAD_PRIORITY = 1 << 17, + } nghttp2_http_flag; + + struct nghttp2_stream { +- /* Intrusive Map */ +- nghttp2_map_entry map_entry; + /* Entry for dep_prev->obq */ + nghttp2_pq_entry pq_entry; + /* Priority Queue storing direct descendant (nghttp2_stream). Only +@@ -206,7 +216,7 @@ struct nghttp2_stream { + /* status code from remote server */ + int16_t status_code; + /* Bitwise OR of zero or more nghttp2_http_flag values */ +- uint16_t http_flags; ++ uint32_t http_flags; + /* This is bitwise-OR of 0 or more of nghttp2_stream_flag. */ + uint8_t flags; + /* Bitwise OR of zero or more nghttp2_shut_flag values */ +@@ -220,6 +230,12 @@ struct nghttp2_stream { + this stream. The nonzero does not necessarily mean WINDOW_UPDATE + is not queued. */ + uint8_t window_update_queued; ++ /* extpri is a stream priority produced by nghttp2_extpri_to_uint8 ++ used by RFC 9218 extensible priorities. */ ++ uint8_t extpri; ++ /* http_extpri is a stream priority received in HTTP request header ++ fields and produced by nghttp2_extpri_to_uint8. */ ++ uint8_t http_extpri; + }; + + void nghttp2_stream_init(nghttp2_stream *stream, int32_t stream_id, +@@ -242,14 +258,8 @@ void nghttp2_stream_shutdown(nghttp2_stream *stream, nghttp2_shut_flag flag); + * more of NGHTTP2_STREAM_FLAG_DEFERRED_USER and + * NGHTTP2_STREAM_FLAG_DEFERRED_FLOW_CONTROL. The |flags| indicates + * the reason of this action. +- * +- * This function returns 0 if it succeeds, or one of the following +- * negative error codes: +- * +- * NGHTTP2_ERR_NOMEM +- * Out of memory + */ +-int nghttp2_stream_defer_item(nghttp2_stream *stream, uint8_t flags); ++void nghttp2_stream_defer_item(nghttp2_stream *stream, uint8_t flags); + + /* + * Put back deferred data in this stream to active state. The |flags| +@@ -363,14 +373,8 @@ int nghttp2_stream_attach_item(nghttp2_stream *stream, + /* + * Detaches |stream->item|. This function does not free + * |stream->item|. The caller must free it. +- * +- * This function returns 0 if it succeeds, or one of the following +- * negative error codes: +- * +- * NGHTTP2_ERR_NOMEM +- * Out of memory + */ +-int nghttp2_stream_detach_item(nghttp2_stream *stream); ++void nghttp2_stream_detach_item(nghttp2_stream *stream); + + /* + * Makes the |stream| depend on the |dep_stream|. This dependency is +diff --git a/deps/nghttp2/lib/nghttp2_submit.c b/deps/nghttp2/lib/nghttp2_submit.c +index 744a49cf60..f5554eb564 100644 +--- a/deps/nghttp2/lib/nghttp2_submit.c ++++ b/deps/nghttp2/lib/nghttp2_submit.c +@@ -196,7 +196,8 @@ int32_t nghttp2_submit_headers(nghttp2_session *session, uint8_t flags, + + flags &= NGHTTP2_FLAG_END_STREAM; + +- if (pri_spec && !nghttp2_priority_spec_check_default(pri_spec)) { ++ if (pri_spec && !nghttp2_priority_spec_check_default(pri_spec) && ++ session->remote_settings.no_rfc7540_priorities != 1) { + rv = detect_self_dependency(session, stream_id, pri_spec); + if (rv != 0) { + return rv; +@@ -229,6 +230,10 @@ int nghttp2_submit_priority(nghttp2_session *session, uint8_t flags, + + mem = &session->mem; + ++ if (session->remote_settings.no_rfc7540_priorities == 1) { ++ return 0; ++ } ++ + if (stream_id == 0 || pri_spec == NULL) { + return NGHTTP2_ERR_INVALID_ARGUMENT; + } +@@ -492,8 +497,6 @@ int nghttp2_session_set_local_window_size(nghttp2_session *session, + return nghttp2_session_update_recv_stream_window_size(session, stream, 0, + 1); + } +- +- return 0; + } + + int nghttp2_submit_altsvc(nghttp2_session *session, uint8_t flags, +@@ -664,6 +667,78 @@ fail_item_malloc: + return rv; + } + ++int nghttp2_submit_priority_update(nghttp2_session *session, uint8_t flags, ++ int32_t stream_id, ++ const uint8_t *field_value, ++ size_t field_value_len) { ++ nghttp2_mem *mem; ++ uint8_t *buf, *p; ++ nghttp2_outbound_item *item; ++ nghttp2_frame *frame; ++ nghttp2_ext_priority_update *priority_update; ++ int rv; ++ (void)flags; ++ ++ mem = &session->mem; ++ ++ if (session->server) { ++ return NGHTTP2_ERR_INVALID_STATE; ++ } ++ ++ if (session->remote_settings.no_rfc7540_priorities == 0) { ++ return 0; ++ } ++ ++ if (stream_id == 0 || 4 + field_value_len > NGHTTP2_MAX_PAYLOADLEN) { ++ return NGHTTP2_ERR_INVALID_ARGUMENT; ++ } ++ ++ if (field_value_len) { ++ buf = nghttp2_mem_malloc(mem, field_value_len + 1); ++ if (buf == NULL) { ++ return NGHTTP2_ERR_NOMEM; ++ } ++ ++ p = nghttp2_cpymem(buf, field_value, field_value_len); ++ *p = '\0'; ++ } else { ++ buf = NULL; ++ } ++ ++ item = nghttp2_mem_malloc(mem, sizeof(nghttp2_outbound_item)); ++ if (item == NULL) { ++ rv = NGHTTP2_ERR_NOMEM; ++ goto fail_item_malloc; ++ } ++ ++ nghttp2_outbound_item_init(item); ++ ++ item->aux_data.ext.builtin = 1; ++ ++ priority_update = &item->ext_frame_payload.priority_update; ++ ++ frame = &item->frame; ++ frame->ext.payload = priority_update; ++ ++ nghttp2_frame_priority_update_init(&frame->ext, stream_id, buf, ++ field_value_len); ++ ++ rv = nghttp2_session_add_item(session, item); ++ if (rv != 0) { ++ nghttp2_frame_priority_update_free(&frame->ext, mem); ++ nghttp2_mem_free(mem, item); ++ ++ return rv; ++ } ++ ++ return 0; ++ ++fail_item_malloc: ++ free(buf); ++ ++ return rv; ++} ++ + static uint8_t set_request_flags(const nghttp2_priority_spec *pri_spec, + const nghttp2_data_provider *data_prd) { + uint8_t flags = NGHTTP2_FLAG_NONE; +@@ -690,7 +765,8 @@ int32_t nghttp2_submit_request(nghttp2_session *session, + return NGHTTP2_ERR_PROTO; + } + +- if (pri_spec && !nghttp2_priority_spec_check_default(pri_spec)) { ++ if (pri_spec && !nghttp2_priority_spec_check_default(pri_spec) && ++ session->remote_settings.no_rfc7540_priorities != 1) { + rv = detect_self_dependency(session, -1, pri_spec); + if (rv != 0) { + return rv; +diff --git a/deps/nghttp2/lib/nghttp2_time.c b/deps/nghttp2/lib/nghttp2_time.c +new file mode 100644 +index 0000000000..2a5f1a6ff5 +--- /dev/null ++++ b/deps/nghttp2/lib/nghttp2_time.c +@@ -0,0 +1,62 @@ ++/* ++ * nghttp2 - HTTP/2 C Library ++ * ++ * Copyright (c) 2023 nghttp2 contributors ++ * ++ * Permission is hereby granted, free of charge, to any person obtaining ++ * a copy of this software and associated documentation files (the ++ * "Software"), to deal in the Software without restriction, including ++ * without limitation the rights to use, copy, modify, merge, publish, ++ * distribute, sublicense, and/or sell copies of the Software, and to ++ * permit persons to whom the Software is furnished to do so, subject to ++ * the following conditions: ++ * ++ * The above copyright notice and this permission notice shall be ++ * included in all copies or substantial portions of the Software. ++ * ++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, ++ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF ++ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND ++ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE ++ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION ++ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION ++ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ++ */ ++#include "nghttp2_time.h" ++ ++#ifdef HAVE_TIME_H ++# include ++#endif /* HAVE_TIME_H */ ++ ++#ifdef HAVE_SYSINFOAPI_H ++# include ++#endif /* HAVE_SYSINFOAPI_H */ ++ ++#ifndef HAVE_GETTICKCOUNT64 ++static uint64_t time_now_sec(void) { ++ time_t t = time(NULL); ++ ++ if (t == -1) { ++ return 0; ++ } ++ ++ return (uint64_t)t; ++} ++#endif /* HAVE_GETTICKCOUNT64 */ ++ ++#ifdef HAVE_CLOCK_GETTIME ++uint64_t nghttp2_time_now_sec(void) { ++ struct timespec tp; ++ int rv = clock_gettime(CLOCK_MONOTONIC, &tp); ++ ++ if (rv == -1) { ++ return time_now_sec(); ++ } ++ ++ return (uint64_t)tp.tv_sec; ++} ++#elif defined(HAVE_GETTICKCOUNT64) ++uint64_t nghttp2_time_now_sec(void) { return GetTickCount64() / 1000; } ++#else /* !HAVE_CLOCK_GETTIME && !HAVE_GETTICKCOUNT64 */ ++uint64_t nghttp2_time_now_sec(void) { return time_now_sec(); } ++#endif /* !HAVE_CLOCK_GETTIME && !HAVE_GETTICKCOUNT64 */ +diff --git a/deps/nghttp2/lib/nghttp2_time.h b/deps/nghttp2/lib/nghttp2_time.h +new file mode 100644 +index 0000000000..03c0bbe944 +--- /dev/null ++++ b/deps/nghttp2/lib/nghttp2_time.h +@@ -0,0 +1,38 @@ ++/* ++ * nghttp2 - HTTP/2 C Library ++ * ++ * Copyright (c) 2023 nghttp2 contributors ++ * ++ * Permission is hereby granted, free of charge, to any person obtaining ++ * a copy of this software and associated documentation files (the ++ * "Software"), to deal in the Software without restriction, including ++ * without limitation the rights to use, copy, modify, merge, publish, ++ * distribute, sublicense, and/or sell copies of the Software, and to ++ * permit persons to whom the Software is furnished to do so, subject to ++ * the following conditions: ++ * ++ * The above copyright notice and this permission notice shall be ++ * included in all copies or substantial portions of the Software. ++ * ++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, ++ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF ++ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND ++ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE ++ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION ++ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION ++ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ++ */ ++#ifndef NGHTTP2_TIME_H ++#define NGHTTP2_TIME_H ++ ++#ifdef HAVE_CONFIG_H ++# include ++#endif /* HAVE_CONFIG_H */ ++ ++#include ++ ++/* nghttp2_time_now_sec returns seconds from implementation-specific ++ timepoint. If it is unable to get seconds, it returns 0. */ ++uint64_t nghttp2_time_now_sec(void); ++ ++#endif /* NGHTTP2_TIME_H */ +diff --git a/deps/nghttp2/lib/sfparse.c b/deps/nghttp2/lib/sfparse.c +new file mode 100644 +index 0000000000..efa2850c9d +--- /dev/null ++++ b/deps/nghttp2/lib/sfparse.c +@@ -0,0 +1,1146 @@ ++/* ++ * sfparse ++ * ++ * Copyright (c) 2023 sfparse contributors ++ * Copyright (c) 2019 nghttp3 contributors ++ * Copyright (c) 2015 nghttp2 contributors ++ * ++ * Permission is hereby granted, free of charge, to any person obtaining ++ * a copy of this software and associated documentation files (the ++ * "Software"), to deal in the Software without restriction, including ++ * without limitation the rights to use, copy, modify, merge, publish, ++ * distribute, sublicense, and/or sell copies of the Software, and to ++ * permit persons to whom the Software is furnished to do so, subject to ++ * the following conditions: ++ * ++ * The above copyright notice and this permission notice shall be ++ * included in all copies or substantial portions of the Software. ++ * ++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, ++ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF ++ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND ++ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE ++ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION ++ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION ++ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ++ */ ++#include "sfparse.h" ++ ++#include ++#include ++#include ++ ++#define SF_STATE_DICT 0x08u ++#define SF_STATE_LIST 0x10u ++#define SF_STATE_ITEM 0x18u ++ ++#define SF_STATE_INNER_LIST 0x04u ++ ++#define SF_STATE_BEFORE 0x00u ++#define SF_STATE_BEFORE_PARAMS 0x01u ++#define SF_STATE_PARAMS 0x02u ++#define SF_STATE_AFTER 0x03u ++ ++#define SF_STATE_OP_MASK 0x03u ++ ++#define SF_SET_STATE_AFTER(NAME) (SF_STATE_##NAME | SF_STATE_AFTER) ++#define SF_SET_STATE_BEFORE_PARAMS(NAME) \ ++ (SF_STATE_##NAME | SF_STATE_BEFORE_PARAMS) ++#define SF_SET_STATE_INNER_LIST_BEFORE(NAME) \ ++ (SF_STATE_##NAME | SF_STATE_INNER_LIST | SF_STATE_BEFORE) ++ ++#define SF_STATE_DICT_AFTER SF_SET_STATE_AFTER(DICT) ++#define SF_STATE_DICT_BEFORE_PARAMS SF_SET_STATE_BEFORE_PARAMS(DICT) ++#define SF_STATE_DICT_INNER_LIST_BEFORE SF_SET_STATE_INNER_LIST_BEFORE(DICT) ++ ++#define SF_STATE_LIST_AFTER SF_SET_STATE_AFTER(LIST) ++#define SF_STATE_LIST_BEFORE_PARAMS SF_SET_STATE_BEFORE_PARAMS(LIST) ++#define SF_STATE_LIST_INNER_LIST_BEFORE SF_SET_STATE_INNER_LIST_BEFORE(LIST) ++ ++#define SF_STATE_ITEM_AFTER SF_SET_STATE_AFTER(ITEM) ++#define SF_STATE_ITEM_BEFORE_PARAMS SF_SET_STATE_BEFORE_PARAMS(ITEM) ++#define SF_STATE_ITEM_INNER_LIST_BEFORE SF_SET_STATE_INNER_LIST_BEFORE(ITEM) ++ ++#define SF_STATE_INITIAL 0x00u ++ ++#define DIGIT_CASES \ ++ case '0': \ ++ case '1': \ ++ case '2': \ ++ case '3': \ ++ case '4': \ ++ case '5': \ ++ case '6': \ ++ case '7': \ ++ case '8': \ ++ case '9' ++ ++#define LCALPHA_CASES \ ++ case 'a': \ ++ case 'b': \ ++ case 'c': \ ++ case 'd': \ ++ case 'e': \ ++ case 'f': \ ++ case 'g': \ ++ case 'h': \ ++ case 'i': \ ++ case 'j': \ ++ case 'k': \ ++ case 'l': \ ++ case 'm': \ ++ case 'n': \ ++ case 'o': \ ++ case 'p': \ ++ case 'q': \ ++ case 'r': \ ++ case 's': \ ++ case 't': \ ++ case 'u': \ ++ case 'v': \ ++ case 'w': \ ++ case 'x': \ ++ case 'y': \ ++ case 'z' ++ ++#define UCALPHA_CASES \ ++ case 'A': \ ++ case 'B': \ ++ case 'C': \ ++ case 'D': \ ++ case 'E': \ ++ case 'F': \ ++ case 'G': \ ++ case 'H': \ ++ case 'I': \ ++ case 'J': \ ++ case 'K': \ ++ case 'L': \ ++ case 'M': \ ++ case 'N': \ ++ case 'O': \ ++ case 'P': \ ++ case 'Q': \ ++ case 'R': \ ++ case 'S': \ ++ case 'T': \ ++ case 'U': \ ++ case 'V': \ ++ case 'W': \ ++ case 'X': \ ++ case 'Y': \ ++ case 'Z' ++ ++#define ALPHA_CASES \ ++ UCALPHA_CASES: \ ++ LCALPHA_CASES ++ ++#define X20_21_CASES \ ++ case ' ': \ ++ case '!' ++ ++#define X23_5B_CASES \ ++ case '#': \ ++ case '$': \ ++ case '%': \ ++ case '&': \ ++ case '\'': \ ++ case '(': \ ++ case ')': \ ++ case '*': \ ++ case '+': \ ++ case ',': \ ++ case '-': \ ++ case '.': \ ++ case '/': \ ++ DIGIT_CASES: \ ++ case ':': \ ++ case ';': \ ++ case '<': \ ++ case '=': \ ++ case '>': \ ++ case '?': \ ++ case '@': \ ++ UCALPHA_CASES: \ ++ case '[' ++ ++#define X5D_7E_CASES \ ++ case ']': \ ++ case '^': \ ++ case '_': \ ++ case '`': \ ++ LCALPHA_CASES: \ ++ case '{': \ ++ case '|': \ ++ case '}': \ ++ case '~' ++ ++static int is_ws(uint8_t c) { ++ switch (c) { ++ case ' ': ++ case '\t': ++ return 1; ++ default: ++ return 0; ++ } ++} ++ ++static int parser_eof(sf_parser *sfp) { return sfp->pos == sfp->end; } ++ ++static void parser_discard_ows(sf_parser *sfp) { ++ for (; !parser_eof(sfp) && is_ws(*sfp->pos); ++sfp->pos) ++ ; ++} ++ ++static void parser_discard_sp(sf_parser *sfp) { ++ for (; !parser_eof(sfp) && *sfp->pos == ' '; ++sfp->pos) ++ ; ++} ++ ++static void parser_set_op_state(sf_parser *sfp, uint32_t op) { ++ sfp->state &= ~SF_STATE_OP_MASK; ++ sfp->state |= op; ++} ++ ++static void parser_unset_inner_list_state(sf_parser *sfp) { ++ sfp->state &= ~SF_STATE_INNER_LIST; ++} ++ ++static int parser_key(sf_parser *sfp, sf_vec *dest) { ++ const uint8_t *base; ++ ++ switch (*sfp->pos) { ++ case '*': ++ LCALPHA_CASES: ++ break; ++ default: ++ return SF_ERR_PARSE_ERROR; ++ } ++ ++ base = sfp->pos++; ++ ++ for (; !parser_eof(sfp); ++sfp->pos) { ++ switch (*sfp->pos) { ++ case '_': ++ case '-': ++ case '.': ++ case '*': ++ DIGIT_CASES: ++ LCALPHA_CASES: ++ continue; ++ } ++ ++ break; ++ } ++ ++ if (dest) { ++ dest->base = (uint8_t *)base; ++ dest->len = (size_t)(sfp->pos - dest->base); ++ } ++ ++ return 0; ++} ++ ++static int parser_number(sf_parser *sfp, sf_value *dest) { ++ int sign = 1; ++ int64_t value = 0; ++ size_t len = 0; ++ size_t fpos = 0; ++ ++ if (*sfp->pos == '-') { ++ ++sfp->pos; ++ if (parser_eof(sfp)) { ++ return SF_ERR_PARSE_ERROR; ++ } ++ ++ sign = -1; ++ } ++ ++ assert(!parser_eof(sfp)); ++ ++ for (; !parser_eof(sfp); ++sfp->pos) { ++ switch (*sfp->pos) { ++ DIGIT_CASES: ++ if (++len > 15) { ++ return SF_ERR_PARSE_ERROR; ++ } ++ ++ value *= 10; ++ value += *sfp->pos - '0'; ++ ++ continue; ++ } ++ ++ break; ++ } ++ ++ if (len == 0) { ++ return SF_ERR_PARSE_ERROR; ++ } ++ ++ if (parser_eof(sfp) || *sfp->pos != '.') { ++ if (dest) { ++ dest->type = SF_TYPE_INTEGER; ++ dest->flags = SF_VALUE_FLAG_NONE; ++ dest->integer = value * sign; ++ } ++ ++ return 0; ++ } ++ ++ /* decimal */ ++ ++ if (len > 12) { ++ return SF_ERR_PARSE_ERROR; ++ } ++ ++ fpos = len; ++ ++ ++sfp->pos; ++ ++ for (; !parser_eof(sfp); ++sfp->pos) { ++ switch (*sfp->pos) { ++ DIGIT_CASES: ++ if (++len > 15) { ++ return SF_ERR_PARSE_ERROR; ++ } ++ ++ value *= 10; ++ value += *sfp->pos - '0'; ++ ++ continue; ++ } ++ ++ break; ++ } ++ ++ if (fpos == len || len - fpos > 3) { ++ return SF_ERR_PARSE_ERROR; ++ } ++ ++ if (dest) { ++ dest->type = SF_TYPE_DECIMAL; ++ dest->flags = SF_VALUE_FLAG_NONE; ++ dest->decimal.numer = value * sign; ++ ++ switch (len - fpos) { ++ case 1: ++ dest->decimal.denom = 10; ++ ++ break; ++ case 2: ++ dest->decimal.denom = 100; ++ ++ break; ++ case 3: ++ dest->decimal.denom = 1000; ++ ++ break; ++ } ++ } ++ ++ return 0; ++} ++ ++static int parser_date(sf_parser *sfp, sf_value *dest) { ++ int rv; ++ sf_value val; ++ ++ /* The first byte has already been validated by the caller. */ ++ assert('@' == *sfp->pos); ++ ++ ++sfp->pos; ++ ++ if (parser_eof(sfp)) { ++ return SF_ERR_PARSE_ERROR; ++ } ++ ++ rv = parser_number(sfp, &val); ++ if (rv != 0) { ++ return rv; ++ } ++ ++ if (val.type != SF_TYPE_INTEGER) { ++ return SF_ERR_PARSE_ERROR; ++ } ++ ++ if (dest) { ++ *dest = val; ++ dest->type = SF_TYPE_DATE; ++ } ++ ++ return 0; ++} ++ ++static int parser_string(sf_parser *sfp, sf_value *dest) { ++ const uint8_t *base; ++ uint32_t flags = SF_VALUE_FLAG_NONE; ++ ++ /* The first byte has already been validated by the caller. */ ++ assert('"' == *sfp->pos); ++ ++ base = ++sfp->pos; ++ ++ for (; !parser_eof(sfp); ++sfp->pos) { ++ switch (*sfp->pos) { ++ X20_21_CASES: ++ X23_5B_CASES: ++ X5D_7E_CASES: ++ break; ++ case '\\': ++ ++sfp->pos; ++ if (parser_eof(sfp)) { ++ return SF_ERR_PARSE_ERROR; ++ } ++ ++ switch (*sfp->pos) { ++ case '"': ++ case '\\': ++ flags = SF_VALUE_FLAG_ESCAPED_STRING; ++ ++ break; ++ default: ++ return SF_ERR_PARSE_ERROR; ++ } ++ ++ break; ++ case '"': ++ if (dest) { ++ dest->type = SF_TYPE_STRING; ++ dest->flags = flags; ++ dest->vec.len = (size_t)(sfp->pos - base); ++ dest->vec.base = dest->vec.len == 0 ? NULL : (uint8_t *)base; ++ } ++ ++ ++sfp->pos; ++ ++ return 0; ++ default: ++ return SF_ERR_PARSE_ERROR; ++ } ++ } ++ ++ return SF_ERR_PARSE_ERROR; ++} ++ ++static int parser_token(sf_parser *sfp, sf_value *dest) { ++ const uint8_t *base; ++ ++ /* The first byte has already been validated by the caller. */ ++ base = sfp->pos++; ++ ++ for (; !parser_eof(sfp); ++sfp->pos) { ++ switch (*sfp->pos) { ++ case '!': ++ case '#': ++ case '$': ++ case '%': ++ case '&': ++ case '\'': ++ case '*': ++ case '+': ++ case '-': ++ case '.': ++ case '^': ++ case '_': ++ case '`': ++ case '|': ++ case '~': ++ case ':': ++ case '/': ++ DIGIT_CASES: ++ ALPHA_CASES: ++ continue; ++ } ++ ++ break; ++ } ++ ++ if (dest) { ++ dest->type = SF_TYPE_TOKEN; ++ dest->flags = SF_VALUE_FLAG_NONE; ++ dest->vec.base = (uint8_t *)base; ++ dest->vec.len = (size_t)(sfp->pos - base); ++ } ++ ++ return 0; ++} ++ ++static int parser_byteseq(sf_parser *sfp, sf_value *dest) { ++ const uint8_t *base; ++ ++ /* The first byte has already been validated by the caller. */ ++ assert(':' == *sfp->pos); ++ ++ base = ++sfp->pos; ++ ++ for (; !parser_eof(sfp); ++sfp->pos) { ++ switch (*sfp->pos) { ++ case '+': ++ case '/': ++ DIGIT_CASES: ++ ALPHA_CASES: ++ continue; ++ case '=': ++ switch ((sfp->pos - base) & 0x3) { ++ case 0: ++ case 1: ++ return SF_ERR_PARSE_ERROR; ++ case 2: ++ switch (*(sfp->pos - 1)) { ++ case 'A': ++ case 'Q': ++ case 'g': ++ case 'w': ++ break; ++ default: ++ return SF_ERR_PARSE_ERROR; ++ } ++ ++ ++sfp->pos; ++ ++ if (parser_eof(sfp) || *sfp->pos != '=') { ++ return SF_ERR_PARSE_ERROR; ++ } ++ ++ break; ++ case 3: ++ switch (*(sfp->pos - 1)) { ++ case 'A': ++ case 'E': ++ case 'I': ++ case 'M': ++ case 'Q': ++ case 'U': ++ case 'Y': ++ case 'c': ++ case 'g': ++ case 'k': ++ case 'o': ++ case 's': ++ case 'w': ++ case '0': ++ case '4': ++ case '8': ++ break; ++ default: ++ return SF_ERR_PARSE_ERROR; ++ } ++ ++ break; ++ } ++ ++ ++sfp->pos; ++ ++ if (parser_eof(sfp) || *sfp->pos != ':') { ++ return SF_ERR_PARSE_ERROR; ++ } ++ ++ goto fin; ++ case ':': ++ if ((sfp->pos - base) & 0x3) { ++ return SF_ERR_PARSE_ERROR; ++ } ++ ++ goto fin; ++ default: ++ return SF_ERR_PARSE_ERROR; ++ } ++ } ++ ++ return SF_ERR_PARSE_ERROR; ++ ++fin: ++ if (dest) { ++ dest->type = SF_TYPE_BYTESEQ; ++ dest->flags = SF_VALUE_FLAG_NONE; ++ dest->vec.len = (size_t)(sfp->pos - base); ++ dest->vec.base = dest->vec.len == 0 ? NULL : (uint8_t *)base; ++ } ++ ++ ++sfp->pos; ++ ++ return 0; ++} ++ ++static int parser_boolean(sf_parser *sfp, sf_value *dest) { ++ int b; ++ ++ /* The first byte has already been validated by the caller. */ ++ assert('?' == *sfp->pos); ++ ++ ++sfp->pos; ++ ++ if (parser_eof(sfp)) { ++ return SF_ERR_PARSE_ERROR; ++ } ++ ++ switch (*sfp->pos) { ++ case '0': ++ b = 0; ++ ++ break; ++ case '1': ++ b = 1; ++ ++ break; ++ default: ++ return SF_ERR_PARSE_ERROR; ++ } ++ ++ ++sfp->pos; ++ ++ if (dest) { ++ dest->type = SF_TYPE_BOOLEAN; ++ dest->flags = SF_VALUE_FLAG_NONE; ++ dest->boolean = b; ++ } ++ ++ return 0; ++} ++ ++static int parser_bare_item(sf_parser *sfp, sf_value *dest) { ++ switch (*sfp->pos) { ++ case '"': ++ return parser_string(sfp, dest); ++ case '-': ++ DIGIT_CASES: ++ return parser_number(sfp, dest); ++ case '@': ++ return parser_date(sfp, dest); ++ case ':': ++ return parser_byteseq(sfp, dest); ++ case '?': ++ return parser_boolean(sfp, dest); ++ case '*': ++ ALPHA_CASES: ++ return parser_token(sfp, dest); ++ default: ++ return SF_ERR_PARSE_ERROR; ++ } ++} ++ ++static int parser_skip_inner_list(sf_parser *sfp); ++ ++int sf_parser_param(sf_parser *sfp, sf_vec *dest_key, sf_value *dest_value) { ++ int rv; ++ ++ switch (sfp->state & SF_STATE_OP_MASK) { ++ case SF_STATE_BEFORE: ++ rv = parser_skip_inner_list(sfp); ++ if (rv != 0) { ++ return rv; ++ } ++ ++ /* fall through */ ++ case SF_STATE_BEFORE_PARAMS: ++ parser_set_op_state(sfp, SF_STATE_PARAMS); ++ ++ break; ++ case SF_STATE_PARAMS: ++ break; ++ default: ++ assert(0); ++ abort(); ++ } ++ ++ if (parser_eof(sfp) || *sfp->pos != ';') { ++ parser_set_op_state(sfp, SF_STATE_AFTER); ++ ++ return SF_ERR_EOF; ++ } ++ ++ ++sfp->pos; ++ ++ parser_discard_sp(sfp); ++ if (parser_eof(sfp)) { ++ return SF_ERR_PARSE_ERROR; ++ } ++ ++ rv = parser_key(sfp, dest_key); ++ if (rv != 0) { ++ return rv; ++ } ++ ++ if (parser_eof(sfp) || *sfp->pos != '=') { ++ if (dest_value) { ++ dest_value->type = SF_TYPE_BOOLEAN; ++ dest_value->flags = SF_VALUE_FLAG_NONE; ++ dest_value->boolean = 1; ++ } ++ ++ return 0; ++ } ++ ++ ++sfp->pos; ++ ++ if (parser_eof(sfp)) { ++ return SF_ERR_PARSE_ERROR; ++ } ++ ++ return parser_bare_item(sfp, dest_value); ++} ++ ++static int parser_skip_params(sf_parser *sfp) { ++ int rv; ++ ++ for (;;) { ++ rv = sf_parser_param(sfp, NULL, NULL); ++ switch (rv) { ++ case 0: ++ break; ++ case SF_ERR_EOF: ++ return 0; ++ case SF_ERR_PARSE_ERROR: ++ return rv; ++ default: ++ assert(0); ++ abort(); ++ } ++ } ++} ++ ++int sf_parser_inner_list(sf_parser *sfp, sf_value *dest) { ++ int rv; ++ ++ switch (sfp->state & SF_STATE_OP_MASK) { ++ case SF_STATE_BEFORE: ++ parser_discard_sp(sfp); ++ if (parser_eof(sfp)) { ++ return SF_ERR_PARSE_ERROR; ++ } ++ ++ break; ++ case SF_STATE_BEFORE_PARAMS: ++ rv = parser_skip_params(sfp); ++ if (rv != 0) { ++ return rv; ++ } ++ ++ /* Technically, we are entering SF_STATE_AFTER, but we will set ++ another state without reading the state. */ ++ /* parser_set_op_state(sfp, SF_STATE_AFTER); */ ++ ++ /* fall through */ ++ case SF_STATE_AFTER: ++ if (parser_eof(sfp)) { ++ return SF_ERR_PARSE_ERROR; ++ } ++ ++ switch (*sfp->pos) { ++ case ' ': ++ parser_discard_sp(sfp); ++ if (parser_eof(sfp)) { ++ return SF_ERR_PARSE_ERROR; ++ } ++ ++ break; ++ case ')': ++ break; ++ default: ++ return SF_ERR_PARSE_ERROR; ++ } ++ ++ break; ++ default: ++ assert(0); ++ abort(); ++ } ++ ++ if (*sfp->pos == ')') { ++ ++sfp->pos; ++ ++ parser_unset_inner_list_state(sfp); ++ parser_set_op_state(sfp, SF_STATE_BEFORE_PARAMS); ++ ++ return SF_ERR_EOF; ++ } ++ ++ rv = parser_bare_item(sfp, dest); ++ if (rv != 0) { ++ return rv; ++ } ++ ++ parser_set_op_state(sfp, SF_STATE_BEFORE_PARAMS); ++ ++ return 0; ++} ++ ++static int parser_skip_inner_list(sf_parser *sfp) { ++ int rv; ++ ++ for (;;) { ++ rv = sf_parser_inner_list(sfp, NULL); ++ switch (rv) { ++ case 0: ++ break; ++ case SF_ERR_EOF: ++ return 0; ++ case SF_ERR_PARSE_ERROR: ++ return rv; ++ default: ++ assert(0); ++ abort(); ++ } ++ } ++} ++ ++static int parser_next_key_or_item(sf_parser *sfp) { ++ parser_discard_ows(sfp); ++ ++ if (parser_eof(sfp)) { ++ return SF_ERR_EOF; ++ } ++ ++ if (*sfp->pos != ',') { ++ return SF_ERR_PARSE_ERROR; ++ } ++ ++ ++sfp->pos; ++ ++ parser_discard_ows(sfp); ++ if (parser_eof(sfp)) { ++ return SF_ERR_PARSE_ERROR; ++ } ++ ++ return 0; ++} ++ ++static int parser_dict_value(sf_parser *sfp, sf_value *dest) { ++ int rv; ++ ++ if (parser_eof(sfp) || *(sfp->pos) != '=') { ++ /* Boolean true */ ++ if (dest) { ++ dest->type = SF_TYPE_BOOLEAN; ++ dest->flags = SF_VALUE_FLAG_NONE; ++ dest->boolean = 1; ++ } ++ ++ sfp->state = SF_STATE_DICT_BEFORE_PARAMS; ++ ++ return 0; ++ } ++ ++ ++sfp->pos; ++ ++ if (parser_eof(sfp)) { ++ return SF_ERR_PARSE_ERROR; ++ } ++ ++ if (*sfp->pos == '(') { ++ if (dest) { ++ dest->type = SF_TYPE_INNER_LIST; ++ dest->flags = SF_VALUE_FLAG_NONE; ++ } ++ ++ ++sfp->pos; ++ ++ sfp->state = SF_STATE_DICT_INNER_LIST_BEFORE; ++ ++ return 0; ++ } ++ ++ rv = parser_bare_item(sfp, dest); ++ if (rv != 0) { ++ return rv; ++ } ++ ++ sfp->state = SF_STATE_DICT_BEFORE_PARAMS; ++ ++ return 0; ++} ++ ++int sf_parser_dict(sf_parser *sfp, sf_vec *dest_key, sf_value *dest_value) { ++ int rv; ++ ++ switch (sfp->state) { ++ case SF_STATE_DICT_INNER_LIST_BEFORE: ++ rv = parser_skip_inner_list(sfp); ++ if (rv != 0) { ++ return rv; ++ } ++ ++ /* fall through */ ++ case SF_STATE_DICT_BEFORE_PARAMS: ++ rv = parser_skip_params(sfp); ++ if (rv != 0) { ++ return rv; ++ } ++ ++ /* fall through */ ++ case SF_STATE_DICT_AFTER: ++ rv = parser_next_key_or_item(sfp); ++ if (rv != 0) { ++ return rv; ++ } ++ ++ break; ++ case SF_STATE_INITIAL: ++ parser_discard_sp(sfp); ++ ++ if (parser_eof(sfp)) { ++ return SF_ERR_EOF; ++ } ++ ++ break; ++ default: ++ assert(0); ++ abort(); ++ } ++ ++ rv = parser_key(sfp, dest_key); ++ if (rv != 0) { ++ return rv; ++ } ++ ++ return parser_dict_value(sfp, dest_value); ++} ++ ++int sf_parser_list(sf_parser *sfp, sf_value *dest) { ++ int rv; ++ ++ switch (sfp->state) { ++ case SF_STATE_LIST_INNER_LIST_BEFORE: ++ rv = parser_skip_inner_list(sfp); ++ if (rv != 0) { ++ return rv; ++ } ++ ++ /* fall through */ ++ case SF_STATE_LIST_BEFORE_PARAMS: ++ rv = parser_skip_params(sfp); ++ if (rv != 0) { ++ return rv; ++ } ++ ++ /* fall through */ ++ case SF_STATE_LIST_AFTER: ++ rv = parser_next_key_or_item(sfp); ++ if (rv != 0) { ++ return rv; ++ } ++ ++ break; ++ case SF_STATE_INITIAL: ++ parser_discard_sp(sfp); ++ ++ if (parser_eof(sfp)) { ++ return SF_ERR_EOF; ++ } ++ ++ break; ++ default: ++ assert(0); ++ abort(); ++ } ++ ++ if (*sfp->pos == '(') { ++ if (dest) { ++ dest->type = SF_TYPE_INNER_LIST; ++ dest->flags = SF_VALUE_FLAG_NONE; ++ } ++ ++ ++sfp->pos; ++ ++ sfp->state = SF_STATE_LIST_INNER_LIST_BEFORE; ++ ++ return 0; ++ } ++ ++ rv = parser_bare_item(sfp, dest); ++ if (rv != 0) { ++ return rv; ++ } ++ ++ sfp->state = SF_STATE_LIST_BEFORE_PARAMS; ++ ++ return 0; ++} ++ ++int sf_parser_item(sf_parser *sfp, sf_value *dest) { ++ int rv; ++ ++ switch (sfp->state) { ++ case SF_STATE_INITIAL: ++ parser_discard_sp(sfp); ++ ++ if (parser_eof(sfp)) { ++ return SF_ERR_PARSE_ERROR; ++ } ++ ++ break; ++ case SF_STATE_ITEM_INNER_LIST_BEFORE: ++ rv = parser_skip_inner_list(sfp); ++ if (rv != 0) { ++ return rv; ++ } ++ ++ /* fall through */ ++ case SF_STATE_ITEM_BEFORE_PARAMS: ++ rv = parser_skip_params(sfp); ++ if (rv != 0) { ++ return rv; ++ } ++ ++ /* fall through */ ++ case SF_STATE_ITEM_AFTER: ++ parser_discard_sp(sfp); ++ ++ if (!parser_eof(sfp)) { ++ return SF_ERR_PARSE_ERROR; ++ } ++ ++ return SF_ERR_EOF; ++ default: ++ assert(0); ++ abort(); ++ } ++ ++ if (*sfp->pos == '(') { ++ if (dest) { ++ dest->type = SF_TYPE_INNER_LIST; ++ dest->flags = SF_VALUE_FLAG_NONE; ++ } ++ ++ ++sfp->pos; ++ ++ sfp->state = SF_STATE_ITEM_INNER_LIST_BEFORE; ++ ++ return 0; ++ } ++ ++ rv = parser_bare_item(sfp, dest); ++ if (rv != 0) { ++ return rv; ++ } ++ ++ sfp->state = SF_STATE_ITEM_BEFORE_PARAMS; ++ ++ return 0; ++} ++ ++void sf_parser_init(sf_parser *sfp, const uint8_t *data, size_t datalen) { ++ if (datalen == 0) { ++ sfp->pos = sfp->end = NULL; ++ } else { ++ sfp->pos = data; ++ sfp->end = data + datalen; ++ } ++ ++ sfp->state = SF_STATE_INITIAL; ++} ++ ++void sf_unescape(sf_vec *dest, const sf_vec *src) { ++ const uint8_t *p, *q; ++ uint8_t *o; ++ size_t len, slen; ++ ++ if (src->len == 0) { ++ *dest = *src; ++ ++ return; ++ } ++ ++ o = dest->base; ++ p = src->base; ++ len = src->len; ++ ++ for (;;) { ++ q = memchr(p, '\\', len); ++ if (q == NULL) { ++ if (len == src->len) { ++ *dest = *src; ++ ++ return; ++ } ++ ++ memcpy(o, p, len); ++ o += len; ++ ++ break; ++ } ++ ++ slen = (size_t)(q - p); ++ memcpy(o, p, slen); ++ o += slen; ++ ++ p = q + 1; ++ *o++ = *p++; ++ len -= slen + 2; ++ } ++ ++ dest->len = (size_t)(o - dest->base); ++} ++ ++void sf_base64decode(sf_vec *dest, const sf_vec *src) { ++ static const int index_tbl[] = { ++ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, ++ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, ++ -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63, 52, 53, 54, 55, 56, 57, ++ 58, 59, 60, 61, -1, -1, -1, -1, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6, ++ 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, ++ 25, -1, -1, -1, -1, -1, -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, ++ 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, ++ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, ++ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, ++ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, ++ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, ++ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, ++ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, ++ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, ++ -1, -1, -1, -1}; ++ uint8_t *o; ++ const uint8_t *p, *end; ++ uint32_t n; ++ size_t i; ++ int idx; ++ ++ assert((src->len & 0x3) == 0); ++ ++ if (src->len == 0) { ++ *dest = *src; ++ ++ return; ++ } ++ ++ o = dest->base; ++ p = src->base; ++ end = src->base + src->len; ++ ++ for (; p != end;) { ++ n = 0; ++ ++ for (i = 1; i <= 4; ++i, ++p) { ++ idx = index_tbl[*p]; ++ ++ if (idx == -1) { ++ assert(i > 2); ++ ++ if (i == 3) { ++ assert(*p == '=' && *(p + 1) == '=' && p + 2 == end); ++ ++ *o++ = (uint8_t)(n >> 16); ++ ++ goto fin; ++ } ++ ++ assert(*p == '=' && p + 1 == end); ++ ++ *o++ = (uint8_t)(n >> 16); ++ *o++ = (n >> 8) & 0xffu; ++ ++ goto fin; ++ } ++ ++ n += (uint32_t)(idx << (24 - i * 6)); ++ } ++ ++ *o++ = (uint8_t)(n >> 16); ++ *o++ = (n >> 8) & 0xffu; ++ *o++ = n & 0xffu; ++ } ++ ++fin: ++ dest->len = (size_t)(o - dest->base); ++} +diff --git a/deps/nghttp2/lib/sfparse.h b/deps/nghttp2/lib/sfparse.h +new file mode 100644 +index 0000000000..1474db1429 +--- /dev/null ++++ b/deps/nghttp2/lib/sfparse.h +@@ -0,0 +1,409 @@ ++/* ++ * sfparse ++ * ++ * Copyright (c) 2023 sfparse contributors ++ * Copyright (c) 2019 nghttp3 contributors ++ * Copyright (c) 2015 nghttp2 contributors ++ * ++ * Permission is hereby granted, free of charge, to any person obtaining ++ * a copy of this software and associated documentation files (the ++ * "Software"), to deal in the Software without restriction, including ++ * without limitation the rights to use, copy, modify, merge, publish, ++ * distribute, sublicense, and/or sell copies of the Software, and to ++ * permit persons to whom the Software is furnished to do so, subject to ++ * the following conditions: ++ * ++ * The above copyright notice and this permission notice shall be ++ * included in all copies or substantial portions of the Software. ++ * ++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, ++ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF ++ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND ++ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE ++ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION ++ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION ++ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ++ */ ++#ifndef SFPARSE_H ++#define SFPARSE_H ++ ++/* Define WIN32 when build target is Win32 API (borrowed from ++ libcurl) */ ++#if (defined(_WIN32) || defined(__WIN32__)) && !defined(WIN32) ++# define WIN32 ++#endif ++ ++#ifdef __cplusplus ++extern "C" { ++#endif ++ ++#if defined(_MSC_VER) && (_MSC_VER < 1800) ++/* MSVC < 2013 does not have inttypes.h because it is not C99 ++ compliant. See compiler macros and version number in ++ https://sourceforge.net/p/predef/wiki/Compilers/ */ ++# include ++#else /* !defined(_MSC_VER) || (_MSC_VER >= 1800) */ ++# include ++#endif /* !defined(_MSC_VER) || (_MSC_VER >= 1800) */ ++#include ++#include ++ ++/** ++ * @enum ++ * ++ * :type:`sf_type` defines value type. ++ */ ++typedef enum sf_type { ++ /** ++ * :enum:`SF_TYPE_BOOLEAN` indicates boolean type. ++ */ ++ SF_TYPE_BOOLEAN, ++ /** ++ * :enum:`SF_TYPE_INTEGER` indicates integer type. ++ */ ++ SF_TYPE_INTEGER, ++ /** ++ * :enum:`SF_TYPE_DECIMAL` indicates decimal type. ++ */ ++ SF_TYPE_DECIMAL, ++ /** ++ * :enum:`SF_TYPE_STRING` indicates string type. ++ */ ++ SF_TYPE_STRING, ++ /** ++ * :enum:`SF_TYPE_TOKEN` indicates token type. ++ */ ++ SF_TYPE_TOKEN, ++ /** ++ * :enum:`SF_TYPE_BYTESEQ` indicates byte sequence type. ++ */ ++ SF_TYPE_BYTESEQ, ++ /** ++ * :enum:`SF_TYPE_INNER_LIST` indicates inner list type. ++ */ ++ SF_TYPE_INNER_LIST, ++ /** ++ * :enum:`SF_TYPE_DATE` indicates date type. ++ */ ++ SF_TYPE_DATE ++} sf_type; ++ ++/** ++ * @macro ++ * ++ * :macro:`SF_ERR_PARSE_ERROR` indicates fatal parse error has ++ * occurred, and it is not possible to continue the processing. ++ */ ++#define SF_ERR_PARSE_ERROR -1 ++ ++/** ++ * @macro ++ * ++ * :macro:`SF_ERR_EOF` indicates that there is nothing left to read. ++ * The context of this error varies depending on the function that ++ * returns this error code. ++ */ ++#define SF_ERR_EOF -2 ++ ++/** ++ * @struct ++ * ++ * :type:`sf_vec` stores sequence of bytes. ++ */ ++typedef struct sf_vec { ++ /** ++ * :member:`base` points to the beginning of the sequence of bytes. ++ */ ++ uint8_t *base; ++ /** ++ * :member:`len` is the number of bytes contained in this sequence. ++ */ ++ size_t len; ++} sf_vec; ++ ++/** ++ * @macro ++ * ++ * :macro:`SF_VALUE_FLAG_NONE` indicates no flag set. ++ */ ++#define SF_VALUE_FLAG_NONE 0x0u ++ ++/** ++ * @macro ++ * ++ * :macro:`SF_VALUE_FLAG_ESCAPED_STRING` indicates that a string ++ * contains escaped character(s). ++ */ ++#define SF_VALUE_FLAG_ESCAPED_STRING 0x1u ++ ++/** ++ * @struct ++ * ++ * :type:`sf_decimal` contains decimal value. ++ */ ++typedef struct sf_decimal { ++ /** ++ * :member:`numer` contains numerator of the decimal value. ++ */ ++ int64_t numer; ++ /** ++ * :member:`denom` contains denominator of the decimal value. ++ */ ++ int64_t denom; ++} sf_decimal; ++ ++/** ++ * @struct ++ * ++ * :type:`sf_value` stores a Structured Field item. For Inner List, ++ * only type is set to :enum:`sf_type.SF_TYPE_INNER_LIST`. In order ++ * to read the items contained in an inner list, call ++ * `sf_parser_inner_list`. ++ */ ++typedef struct sf_value { ++ /** ++ * :member:`type` is the type of the value contained in this ++ * particular object. ++ */ ++ sf_type type; ++ /** ++ * :member:`flags` is bitwise OR of one or more of ++ * :macro:`SF_VALUE_FLAG_* `. ++ */ ++ uint32_t flags; ++ /** ++ * @anonunion_start ++ * ++ * @sf_value_value ++ */ ++ union { ++ /** ++ * :member:`boolean` contains boolean value if :member:`type` == ++ * :enum:`sf_type.SF_TYPE_BOOLEAN`. 1 indicates true, and 0 ++ * indicates false. ++ */ ++ int boolean; ++ /** ++ * :member:`integer` contains integer value if :member:`type` is ++ * either :enum:`sf_type.SF_TYPE_INTEGER` or ++ * :enum:`sf_type.SF_TYPE_DATE`. ++ */ ++ int64_t integer; ++ /** ++ * :member:`decimal` contains decimal value if :member:`type` == ++ * :enum:`sf_type.SF_TYPE_DECIMAL`. ++ */ ++ sf_decimal decimal; ++ /** ++ * :member:`vec` contains sequence of bytes if :member:`type` is ++ * either :enum:`sf_type.SF_TYPE_STRING`, ++ * :enum:`sf_type.SF_TYPE_TOKEN`, or ++ * :enum:`sf_type.SF_TYPE_BYTESEQ`. ++ * ++ * For :enum:`sf_type.SF_TYPE_STRING`, this field contains one or ++ * more escaped characters if :member:`flags` has ++ * :macro:`SF_VALUE_FLAG_ESCAPED_STRING` set. To unescape the ++ * string, use `sf_unescape`. ++ * ++ * For :enum:`sf_type.SF_TYPE_BYTESEQ`, this field contains base64 ++ * encoded string. To decode this byte string, use ++ * `sf_base64decode`. ++ * ++ * If :member:`vec.len ` == 0, :member:`vec.base ++ * ` is guaranteed to be NULL. ++ */ ++ sf_vec vec; ++ /** ++ * @anonunion_end ++ */ ++ }; ++} sf_value; ++ ++/** ++ * @struct ++ * ++ * :type:`sf_parser` is the Structured Field Values parser. Use ++ * `sf_parser_init` to initialize it. ++ */ ++typedef struct sf_parser { ++ /* all fields are private */ ++ const uint8_t *pos; ++ const uint8_t *end; ++ uint32_t state; ++} sf_parser; ++ ++/** ++ * @function ++ * ++ * `sf_parser_init` initializes |sfp| with the given buffer pointed by ++ * |data| of length |datalen|. ++ */ ++void sf_parser_init(sf_parser *sfp, const uint8_t *data, size_t datalen); ++ ++/** ++ * @function ++ * ++ * `sf_parser_param` reads a parameter. If this function returns 0, ++ * it stores parameter key and value in |dest_key| and |dest_value| ++ * respectively, if they are not NULL. ++ * ++ * This function does no effort to find duplicated keys. Same key may ++ * be reported more than once. ++ * ++ * Caller should keep calling this function until it returns negative ++ * error code. If it returns :macro:`SF_ERR_EOF`, all parameters have ++ * read, and caller can continue to read rest of the values. If it ++ * returns :macro:`SF_ERR_PARSE_ERROR`, it encountered fatal error ++ * while parsing field value. ++ */ ++int sf_parser_param(sf_parser *sfp, sf_vec *dest_key, sf_value *dest_value); ++ ++/** ++ * @function ++ * ++ * `sf_parser_dict` reads the next dictionary key and value pair. If ++ * this function returns 0, it stores the key and value in |dest_key| ++ * and |dest_value| respectively, if they are not NULL. ++ * ++ * Caller can optionally read parameters attached to the pair by ++ * calling `sf_parser_param`. ++ * ++ * This function does no effort to find duplicated keys. Same key may ++ * be reported more than once. ++ * ++ * Caller should keep calling this function until it returns negative ++ * error code. If it returns :macro:`SF_ERR_EOF`, all key and value ++ * pairs have been read, and there is nothing left to read. ++ * ++ * This function returns 0 if it succeeds, or one of the following ++ * negative error codes: ++ * ++ * :macro:`SF_ERR_EOF` ++ * All values in the dictionary have read. ++ * :macro:`SF_ERR_PARSE_ERROR` ++ * It encountered fatal error while parsing field value. ++ */ ++int sf_parser_dict(sf_parser *sfp, sf_vec *dest_key, sf_value *dest_value); ++ ++/** ++ * @function ++ * ++ * `sf_parser_list` reads the next list item. If this function ++ * returns 0, it stores the item in |dest| if it is not NULL. ++ * ++ * Caller can optionally read parameters attached to the item by ++ * calling `sf_parser_param`. ++ * ++ * Caller should keep calling this function until it returns negative ++ * error code. If it returns :macro:`SF_ERR_EOF`, all values in the ++ * list have been read, and there is nothing left to read. ++ * ++ * This function returns 0 if it succeeds, or one of the following ++ * negative error codes: ++ * ++ * :macro:`SF_ERR_EOF` ++ * All values in the list have read. ++ * :macro:`SF_ERR_PARSE_ERROR` ++ * It encountered fatal error while parsing field value. ++ */ ++int sf_parser_list(sf_parser *sfp, sf_value *dest); ++ ++/** ++ * @function ++ * ++ * `sf_parser_item` reads a single item. If this function returns 0, ++ * it stores the item in |dest| if it is not NULL. ++ * ++ * This function is only used for the field value that consists of a ++ * single item. ++ * ++ * Caller can optionally read parameters attached to the item by ++ * calling `sf_parser_param`. ++ * ++ * Caller should call this function again to make sure that there is ++ * nothing left to read. If this 2nd function call returns ++ * :macro:`SF_ERR_EOF`, all data have been processed successfully. ++ * ++ * This function returns 0 if it succeeds, or one of the following ++ * negative error codes: ++ * ++ * :macro:`SF_ERR_EOF` ++ * There is nothing left to read. ++ * :macro:`SF_ERR_PARSE_ERROR` ++ * It encountered fatal error while parsing field value. ++ */ ++int sf_parser_item(sf_parser *sfp, sf_value *dest); ++ ++/** ++ * @function ++ * ++ * `sf_parser_inner_list` reads the next inner list item. If this ++ * function returns 0, it stores the item in |dest| if it is not NULL. ++ * ++ * Caller can optionally read parameters attached to the item by ++ * calling `sf_parser_param`. ++ * ++ * Caller should keep calling this function until it returns negative ++ * error code. If it returns :macro:`SF_ERR_EOF`, all values in this ++ * inner list have been read, and caller can optionally read ++ * parameters attached to this inner list by calling ++ * `sf_parser_param`. Then caller can continue to read rest of the ++ * values. ++ * ++ * This function returns 0 if it succeeds, or one of the following ++ * negative error codes: ++ * ++ * :macro:`SF_ERR_EOF` ++ * All values in the inner list have read. ++ * :macro:`SF_ERR_PARSE_ERROR` ++ * It encountered fatal error while parsing field value. ++ */ ++int sf_parser_inner_list(sf_parser *sfp, sf_value *dest); ++ ++/** ++ * @function ++ * ++ * `sf_unescape` copies |src| to |dest| by removing escapes (``\``). ++ * |src| should be the pointer to :member:`sf_value.vec` of type ++ * :enum:`sf_type.SF_TYPE_STRING` produced by either `sf_parser_dict`, ++ * `sf_parser_list`, `sf_parser_inner_list`, `sf_parser_item`, or ++ * `sf_parser_param`, otherwise the behavior is undefined. ++ * ++ * :member:`dest->base ` must point to the buffer that ++ * has sufficient space to store the unescaped string. ++ * ++ * If there is no escape character in |src|, |*src| is assigned to ++ * |*dest|. This includes the case that :member:`src->len ++ * ` == 0. ++ * ++ * This function sets the length of unescaped string to ++ * :member:`dest->len `. ++ */ ++void sf_unescape(sf_vec *dest, const sf_vec *src); ++ ++/** ++ * @function ++ * ++ * `sf_base64decode` decodes Base64 encoded string |src| and writes ++ * the result into |dest|. |src| should be the pointer to ++ * :member:`sf_value.vec` of type :enum:`sf_type.SF_TYPE_BYTESEQ` ++ * produced by either `sf_parser_dict`, `sf_parser_list`, ++ * `sf_parser_inner_list`, `sf_parser_item`, or `sf_parser_param`, ++ * otherwise the behavior is undefined. ++ * ++ * :member:`dest->base ` must point to the buffer that ++ * has sufficient space to store the decoded byte string. ++ * ++ * If :member:`src->len ` == 0, |*src| is assigned to ++ * |*dest|. ++ * ++ * This function sets the length of decoded byte string to ++ * :member:`dest->len `. ++ */ ++void sf_base64decode(sf_vec *dest, const sf_vec *src); ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif /* SFPARSE_H */ +diff --git a/deps/nghttp2/nghttp2.gyp b/deps/nghttp2/nghttp2.gyp +index 21fd6ba5ec..87909c5f29 100644 +--- a/deps/nghttp2/nghttp2.gyp ++++ b/deps/nghttp2/nghttp2.gyp +@@ -1,4 +1,34 @@ + { ++ 'variables': { ++ 'nghttp2_sources': [ ++ 'lib/nghttp2_buf.c', ++ 'lib/nghttp2_callbacks.c', ++ 'lib/nghttp2_debug.c', ++ 'lib/nghttp2_extpri.c', ++ 'lib/nghttp2_frame.c', ++ 'lib/nghttp2_hd.c', ++ 'lib/nghttp2_hd_huffman.c', ++ 'lib/nghttp2_hd_huffman_data.c', ++ 'lib/nghttp2_helper.c', ++ 'lib/nghttp2_http.c', ++ 'lib/nghttp2_map.c', ++ 'lib/nghttp2_mem.c', ++ 'lib/nghttp2_npn.c', ++ 'lib/nghttp2_option.c', ++ 'lib/nghttp2_outbound_item.c', ++ 'lib/nghttp2_pq.c', ++ 'lib/nghttp2_priority_spec.c', ++ 'lib/nghttp2_queue.c', ++ 'lib/nghttp2_ratelim.c', ++ 'lib/nghttp2_rcbuf.c', ++ 'lib/nghttp2_session.c', ++ 'lib/nghttp2_stream.c', ++ 'lib/nghttp2_submit.c', ++ 'lib/nghttp2_time.c', ++ 'lib/nghttp2_version.c', ++ 'lib/sfparse.c', ++ ] ++ }, + 'target_defaults': { + 'defines': [ + '_U_=' +@@ -35,29 +65,7 @@ + 'include_dirs': [ 'lib/includes' ] + }, + 'sources': [ +- 'lib/nghttp2_buf.c', +- 'lib/nghttp2_callbacks.c', +- 'lib/nghttp2_debug.c', +- 'lib/nghttp2_frame.c', +- 'lib/nghttp2_hd.c', +- 'lib/nghttp2_hd_huffman.c', +- 'lib/nghttp2_hd_huffman_data.c', +- 'lib/nghttp2_helper.c', +- 'lib/nghttp2_http.c', +- 'lib/nghttp2_ksl.c', +- 'lib/nghttp2_map.c', +- 'lib/nghttp2_mem.c', +- 'lib/nghttp2_npn.c', +- 'lib/nghttp2_option.c', +- 'lib/nghttp2_outbound_item.c', +- 'lib/nghttp2_pq.c', +- 'lib/nghttp2_priority_spec.c', +- 'lib/nghttp2_queue.c', +- 'lib/nghttp2_rcbuf.c', +- 'lib/nghttp2_session.c', +- 'lib/nghttp2_stream.c', +- 'lib/nghttp2_submit.c', +- 'lib/nghttp2_version.c' ++ '<@(nghttp2_sources)', + ] + } + ] +diff --git a/test/parallel/test-http2-methods.js b/test/parallel/test-http2-methods.js +index 143b50b66b..936a264e99 100644 +--- a/test/parallel/test-http2-methods.js ++++ b/test/parallel/test-http2-methods.js +@@ -8,7 +8,7 @@ const h2 = require('http2'); + + const server = h2.createServer(); + +-const methods = [undefined, 'GET', 'POST', 'PATCH', 'FOO', 'A B C']; ++const methods = ['GET', 'POST', 'PATCH', 'FOO', 'A_B_C']; + let expected = methods.length; + + // We use the lower-level API here +diff --git a/test/parallel/test-http2-multiplex.js b/test/parallel/test-http2-multiplex.js +index 1778bced5f..4c157d0ede 100644 +--- a/test/parallel/test-http2-multiplex.js ++++ b/test/parallel/test-http2-multiplex.js +@@ -29,7 +29,7 @@ server.listen(0, common.mustCall(() => { + }); + + function doRequest() { +- const req = client.request({ ':method': 'POST ' }); ++ const req = client.request({ ':method': 'POST' }); + + let data = ''; + req.setEncoding('utf8'); +diff --git a/tools/update-nghttp2.sh b/tools/update-nghttp2.sh +new file mode 100755 +index 0000000000..d7e176d3e1 +--- /dev/null ++++ b/tools/update-nghttp2.sh +@@ -0,0 +1,59 @@ ++#!/bin/sh ++set -e ++# Shell script to update nghttp2 in the source treee to specific version ++ ++BASE_DIR="$( pwd )"/ ++DEPS_DIR="$BASE_DIR"deps/ ++NGHTTP2_VERSION=$1 ++ ++if [ "$#" -le 0 ]; then ++ echo "Error: please provide an nghttp2 version to update to" ++ exit 1 ++fi ++ ++echo "Making temporary workspace" ++ ++WORKSPACE=$(mktemp -d 2> /dev/null || mktemp -d -t 'tmp') ++ ++cleanup () { ++ EXIT_CODE=$? ++ [ -d "$WORKSPACE" ] && rm -rf "$WORKSPACE" ++ exit $EXIT_CODE ++} ++ ++trap cleanup INT TERM EXIT ++ ++NGHTTP2_REF="v$NGHTTP2_VERSION" ++NGHTTP2_TARBALL="nghttp2-$NGHTTP2_VERSION.tar.gz" ++ ++cd "$WORKSPACE" ++ ++echo "Fetching nghttp2 source archive" ++curl -sL -o "$NGHTTP2_TARBALL" "https://github.com/nghttp2/nghttp2/releases/download/$NGHTTP2_REF/$NGHTTP2_TARBALL" ++gzip -dc "$NGHTTP2_TARBALL" | tar xf - ++rm "$NGHTTP2_TARBALL" ++mv "nghttp2-$NGHTTP2_VERSION" nghttp2 ++ ++echo "Removing everything, except lib/ and COPYING" ++cd nghttp2 ++for dir in *; do ++ if [ "$dir" = "lib" ] || [ "$dir" = "COPYING" ]; then ++ continue ++ fi ++ rm -rf "$dir" ++done ++ ++echo "Copying existing gyp files" ++cp "$DEPS_DIR/nghttp2/nghttp2.gyp" "$WORKSPACE/nghttp2" ++ ++echo "Replacing existing nghttp2" ++rm -rf "$DEPS_DIR/nghttp2" ++mv "$WORKSPACE/nghttp2" "$DEPS_DIR/" ++ ++echo "All done!" ++echo "" ++echo "Please git add nghttp2, commit the new version:" ++echo "" ++echo "$ git add -A deps/nghttp2" ++echo "$ git commit -m \"deps: update nghttp2 to $NGHTTP2_VERSION\"" ++echo "" +-- +2.41.0 + diff --git a/SOURCES/nodejs-CVE-2024-22019-v14.patch b/SOURCES/nodejs-CVE-2024-22019-v14.patch new file mode 100644 index 0000000..e808766 --- /dev/null +++ b/SOURCES/nodejs-CVE-2024-22019-v14.patch @@ -0,0 +1,560 @@ +Fix CVE-2024-22019 + +BZ#2265709 + +Instead of updating llhttp to version 6.1.0 (which would be too big jump +from the currect version), Richard bacported the missing feature into +llhttp, so we can use pretty much the same fix in the nodejs itsef, as +was originally used for upstream (v18): + +https://github.com/nodejs/node/commit/03a5c34a829742f1c47b68f831b2940af44addf6 + +From 59a3461c075ac2d6d44bd90a291db0b8ed688af8 Mon Sep 17 00:00:00 2001 +From: Richard Lau +Date: Fri, 1 Mar 2024 17:51:39 +0000 +Subject: [PATCH 1/2] deps: port llhttp + ef539d7293fc28577d45f4d7eb6ff5aabb59b372 + +Port https://github.com/nodejs/llhttp/pull/264 to llhttp 2.1.x. +--- + deps/llhttp/include/llhttp.h | 3 + + deps/llhttp/src/api.c | 22 +++++++ + deps/llhttp/src/llhttp.c | 122 +++++++++++++++++++++++++++++++---- + 3 files changed, 133 insertions(+), 14 deletions(-) + +diff --git a/deps/llhttp/include/llhttp.h b/deps/llhttp/include/llhttp.h +index fe3a927fc6..d56e5b3d20 100644 +--- a/deps/llhttp/include/llhttp.h ++++ b/deps/llhttp/include/llhttp.h +@@ -255,6 +255,9 @@ struct llhttp_settings_s { + */ + llhttp_cb on_headers_complete; + ++ /* Possible return values 0, -1, HPE_USER */ ++ llhttp_data_cb on_chunk_parameters; ++ + llhttp_data_cb on_body; + + /* Possible return values 0, -1, `HPE_PAUSED` */ +diff --git a/deps/llhttp/src/api.c b/deps/llhttp/src/api.c +index 6f7246546d..1b7ad0e65b 100644 +--- a/deps/llhttp/src/api.c ++++ b/deps/llhttp/src/api.c +@@ -15,6 +15,21 @@ + err = settings->NAME(__VA_ARGS__); \ + } while (0) + ++#define SPAN_CALLBACK_MAYBE(PARSER, NAME, START, LEN) \ ++ do { \ ++ const llhttp_settings_t* settings; \ ++ settings = (const llhttp_settings_t*) (PARSER)->settings; \ ++ if (settings == NULL || settings->NAME == NULL) { \ ++ err = 0; \ ++ break; \ ++ } \ ++ err = settings->NAME((PARSER), (START), (LEN)); \ ++ if (err == -1) { \ ++ err = HPE_USER; \ ++ llhttp_set_error_reason((PARSER), "Span callback error in " #NAME); \ ++ } \ ++ } while (0) ++ + void llhttp_init(llhttp_t* parser, llhttp_type_t type, + const llhttp_settings_t* settings) { + llhttp__internal_init(parser); +@@ -202,6 +217,13 @@ int llhttp__on_chunk_header(llhttp_t* s, const char* p, const char* endp) { + } + + ++int llhttp__on_chunk_parameters(llhttp_t* s, const char* p, const char* endp) { ++ int err; ++ SPAN_CALLBACK_MAYBE(s, on_chunk_parameters, p, endp - p); ++ return err; ++} ++ ++ + int llhttp__on_chunk_complete(llhttp_t* s, const char* p, const char* endp) { + int err; + CALLBACK_MAYBE(s, on_chunk_complete, s); +diff --git a/deps/llhttp/src/llhttp.c b/deps/llhttp/src/llhttp.c +index f5439cbf3e..6281913d10 100644 +--- a/deps/llhttp/src/llhttp.c ++++ b/deps/llhttp/src/llhttp.c +@@ -307,6 +307,8 @@ enum llparse_state_e { + s_n_llhttp__internal__n_invoke_is_equal_content_length, + s_n_llhttp__internal__n_chunk_size_almost_done, + s_n_llhttp__internal__n_chunk_parameters, ++ s_n_llhttp__internal__n_span_start_llhttp__on_chunk_parameters, ++ s_n_llhttp__internal__n_chunk_parameters_ows, + s_n_llhttp__internal__n_chunk_size_otherwise, + s_n_llhttp__internal__n_chunk_size, + s_n_llhttp__internal__n_chunk_size_digit, +@@ -482,6 +484,10 @@ int llhttp__on_body( + llhttp__internal_t* s, const unsigned char* p, + const unsigned char* endp); + ++int llhttp__on_chunk_parameters( ++ llhttp__internal_t* s, const unsigned char* p, ++ const unsigned char* endp); ++ + int llhttp__on_status( + llhttp__internal_t* s, const unsigned char* p, + const unsigned char* endp); +@@ -1118,8 +1124,7 @@ static llparse_state_t llhttp__internal__run( + goto s_n_llhttp__internal__n_chunk_parameters; + } + case 2: { +- p++; +- goto s_n_llhttp__internal__n_chunk_size_almost_done; ++ goto s_n_llhttp__internal__n_span_end_llhttp__on_chunk_parameters; + } + default: { + goto s_n_llhttp__internal__n_error_10; +@@ -1128,6 +1133,34 @@ static llparse_state_t llhttp__internal__run( + /* UNREACHABLE */; + abort(); + } ++ case s_n_llhttp__internal__n_span_start_llhttp__on_chunk_parameters: ++ s_n_llhttp__internal__n_span_start_llhttp__on_chunk_parameters: { ++ if (p == endp) { ++ return s_n_llhttp__internal__n_span_start_llhttp__on_chunk_parameters; ++ } ++ state->_span_pos0 = (void*) p; ++ state->_span_cb0 = llhttp__on_chunk_parameters; ++ goto s_n_llhttp__internal__n_chunk_parameters; ++ /* UNREACHABLE */; ++ abort(); ++ } ++ case s_n_llhttp__internal__n_chunk_parameters_ows: ++ s_n_llhttp__internal__n_chunk_parameters_ows: { ++ if (p == endp) { ++ return s_n_llhttp__internal__n_chunk_parameters_ows; ++ } ++ switch (*p) { ++ case ' ': { ++ p++; ++ goto s_n_llhttp__internal__n_chunk_parameters_ows; ++ } ++ default: { ++ goto s_n_llhttp__internal__n_span_start_llhttp__on_chunk_parameters; ++ } ++ } ++ /* UNREACHABLE */; ++ abort(); ++ } + case s_n_llhttp__internal__n_chunk_size_otherwise: + s_n_llhttp__internal__n_chunk_size_otherwise: { + if (p == endp) { +@@ -1138,13 +1171,9 @@ static llparse_state_t llhttp__internal__run( + p++; + goto s_n_llhttp__internal__n_chunk_size_almost_done; + } +- case ' ': { +- p++; +- goto s_n_llhttp__internal__n_chunk_parameters; +- } + case ';': { + p++; +- goto s_n_llhttp__internal__n_chunk_parameters; ++ goto s_n_llhttp__internal__n_chunk_parameters_ows; + } + default: { + goto s_n_llhttp__internal__n_error_11; +@@ -5449,6 +5478,24 @@ static llparse_state_t llhttp__internal__run( + /* UNREACHABLE */; + abort(); + } ++ s_n_llhttp__internal__n_span_end_llhttp__on_chunk_parameters: { ++ const unsigned char* start; ++ int err; ++ ++ start = state->_span_pos0; ++ state->_span_pos0 = NULL; ++ err = llhttp__on_chunk_parameters(state, start, p); ++ if (err != 0) { ++ state->error = err; ++ state->error_pos = (const char*) (p + 1); ++ state->_current = (void*) (intptr_t) s_n_llhttp__internal__n_chunk_size_almost_done; ++ return s_error; ++ } ++ p++; ++ goto s_n_llhttp__internal__n_chunk_size_almost_done; ++ /* UNREACHABLE */; ++ abort(); ++ } + s_n_llhttp__internal__n_error_10: { + state->error = 0x2; + state->reason = "Invalid character in chunk parameters"; +@@ -7405,6 +7452,8 @@ enum llparse_state_e { + s_n_llhttp__internal__n_invoke_is_equal_content_length, + s_n_llhttp__internal__n_chunk_size_almost_done, + s_n_llhttp__internal__n_chunk_parameters, ++ s_n_llhttp__internal__n_span_start_llhttp__on_chunk_parameters, ++ s_n_llhttp__internal__n_chunk_parameters_ows, + s_n_llhttp__internal__n_chunk_size_otherwise, + s_n_llhttp__internal__n_chunk_size, + s_n_llhttp__internal__n_chunk_size_digit, +@@ -7575,6 +7624,10 @@ int llhttp__on_body( + llhttp__internal_t* s, const unsigned char* p, + const unsigned char* endp); + ++int llhttp__on_chunk_parameters( ++ llhttp__internal_t* s, const unsigned char* p, ++ const unsigned char* endp); ++ + int llhttp__on_status( + llhttp__internal_t* s, const unsigned char* p, + const unsigned char* endp); +@@ -8176,8 +8229,7 @@ static llparse_state_t llhttp__internal__run( + goto s_n_llhttp__internal__n_chunk_parameters; + } + case 2: { +- p++; +- goto s_n_llhttp__internal__n_chunk_size_almost_done; ++ goto s_n_llhttp__internal__n_span_end_llhttp__on_chunk_parameters; + } + default: { + goto s_n_llhttp__internal__n_error_6; +@@ -8186,6 +8238,34 @@ static llparse_state_t llhttp__internal__run( + /* UNREACHABLE */; + abort(); + } ++ case s_n_llhttp__internal__n_span_start_llhttp__on_chunk_parameters: ++ s_n_llhttp__internal__n_span_start_llhttp__on_chunk_parameters: { ++ if (p == endp) { ++ return s_n_llhttp__internal__n_span_start_llhttp__on_chunk_parameters; ++ } ++ state->_span_pos0 = (void*) p; ++ state->_span_cb0 = llhttp__on_chunk_parameters; ++ goto s_n_llhttp__internal__n_chunk_parameters; ++ /* UNREACHABLE */; ++ abort(); ++ } ++ case s_n_llhttp__internal__n_chunk_parameters_ows: ++ s_n_llhttp__internal__n_chunk_parameters_ows: { ++ if (p == endp) { ++ return s_n_llhttp__internal__n_chunk_parameters_ows; ++ } ++ switch (*p) { ++ case ' ': { ++ p++; ++ goto s_n_llhttp__internal__n_chunk_parameters_ows; ++ } ++ default: { ++ goto s_n_llhttp__internal__n_span_start_llhttp__on_chunk_parameters; ++ } ++ } ++ /* UNREACHABLE */; ++ abort(); ++ } + case s_n_llhttp__internal__n_chunk_size_otherwise: + s_n_llhttp__internal__n_chunk_size_otherwise: { + if (p == endp) { +@@ -8196,13 +8276,9 @@ static llparse_state_t llhttp__internal__run( + p++; + goto s_n_llhttp__internal__n_chunk_size_almost_done; + } +- case ' ': { +- p++; +- goto s_n_llhttp__internal__n_chunk_parameters; +- } + case ';': { + p++; +- goto s_n_llhttp__internal__n_chunk_parameters; ++ goto s_n_llhttp__internal__n_chunk_parameters_ows; + } + default: { + goto s_n_llhttp__internal__n_error_7; +@@ -12296,6 +12372,24 @@ static llparse_state_t llhttp__internal__run( + /* UNREACHABLE */; + abort(); + } ++ s_n_llhttp__internal__n_span_end_llhttp__on_chunk_parameters: { ++ const unsigned char* start; ++ int err; ++ ++ start = state->_span_pos0; ++ state->_span_pos0 = NULL; ++ err = llhttp__on_chunk_parameters(state, start, p); ++ if (err != 0) { ++ state->error = err; ++ state->error_pos = (const char*) (p + 1); ++ state->_current = (void*) (intptr_t) s_n_llhttp__internal__n_chunk_size_almost_done; ++ return s_error; ++ } ++ p++; ++ goto s_n_llhttp__internal__n_chunk_size_almost_done; ++ /* UNREACHABLE */; ++ abort(); ++ } + s_n_llhttp__internal__n_error_6: { + state->error = 0x2; + state->reason = "Invalid character in chunk parameters"; +-- +2.41.0 + +From f701cde064a9d375ea7dc531e3d61335e6c9e074 Mon Sep 17 00:00:00 2001 +From: Paolo Insogna +Date: Tue, 9 Jan 2024 18:10:04 +0100 +Subject: [PATCH 2/2] http: add maximum chunk extension size + +PR-URL: https://github.com/nodejs-private/node-private/pull/520 +Refs: https://github.com/nodejs-private/node-private/pull/518 +CVE-ID: CVE-2024-22019 +--- + doc/api/errors.md | 12 ++ + lib/_http_server.js | 7 + + src/node_http_parser.cc | 20 ++- + .../test-http-chunk-extensions-limit.js | 131 ++++++++++++++++++ + 4 files changed, 169 insertions(+), 1 deletion(-) + create mode 100644 test/parallel/test-http-chunk-extensions-limit.js + +diff --git a/doc/api/errors.md b/doc/api/errors.md +index 0fc8cfcf19..0e4ec4a9e5 100644 +--- a/doc/api/errors.md ++++ b/doc/api/errors.md +@@ -2318,6 +2318,18 @@ malconfigured clients, if more than 8KB of HTTP header data is received then + HTTP parsing will abort without a request or response object being created, and + an `Error` with this code will be emitted. + ++ ++ ++### `HPE_CHUNK_EXTENSIONS_OVERFLOW` ++ ++ ++ ++Too much data was received for a chunk extensions. In order to protect against ++malicious or malconfigured clients, if more than 16 KiB of data is received ++then an `Error` with this code will be emitted. ++ + + ### `HPE_UNEXPECTED_CONTENT_LENGTH` + +diff --git a/lib/_http_server.js b/lib/_http_server.js +index 6d587d9d04..ae3b45fcba 100644 +--- a/lib/_http_server.js ++++ b/lib/_http_server.js +@@ -636,6 +636,10 @@ const requestHeaderFieldsTooLargeResponse = Buffer.from( + `HTTP/1.1 431 ${STATUS_CODES[431]}${CRLF}` + + `Connection: close${CRLF}${CRLF}`, 'ascii' + ); ++const requestChunkExtensionsTooLargeResponse = Buffer.from( ++ `HTTP/1.1 413 ${STATUS_CODES[413]}\r\n` + ++ 'Connection: close\r\n\r\n', 'ascii', ++); + function socketOnError(e) { + // Ignore further errors + this.removeListener('error', socketOnError); +@@ -649,6 +653,9 @@ function socketOnError(e) { + case 'HPE_HEADER_OVERFLOW': + response = requestHeaderFieldsTooLargeResponse; + break; ++ case 'HPE_CHUNK_EXTENSIONS_OVERFLOW': ++ response = requestChunkExtensionsTooLargeResponse; ++ break; + case 'ERR_HTTP_REQUEST_TIMEOUT': + response = requestTimeoutResponse; + break; +diff --git a/src/node_http_parser.cc b/src/node_http_parser.cc +index d3184bb1a1..dd81982d51 100644 +--- a/src/node_http_parser.cc ++++ b/src/node_http_parser.cc +@@ -78,6 +78,8 @@ const uint32_t kOnExecute = 5; + const uint32_t kOnTimeout = 6; + // Any more fields than this will be flushed into JS + const size_t kMaxHeaderFieldsCount = 32; ++// Maximum size of chunk extensions ++const size_t kMaxChunkExtensionsSize = 16384; + + inline bool IsOWS(char c) { + return c == ' ' || c == '\t'; +@@ -202,6 +204,7 @@ class Parser : public AsyncWrap, public StreamListener { + + int on_message_begin() { + num_fields_ = num_values_ = 0; ++ chunk_extensions_nread_ = 0; + url_.Reset(); + status_message_.Reset(); + header_parsing_start_time_ = uv_hrtime(); +@@ -451,9 +454,22 @@ class Parser : public AsyncWrap, public StreamListener { + return 0; + } + +- // Reset nread for the next chunk ++ int on_chunk_extension(const char* at, size_t length) { ++ chunk_extensions_nread_ += length; ++ ++ if (chunk_extensions_nread_ > kMaxChunkExtensionsSize) { ++ llhttp_set_error_reason(&parser_, ++ "HPE_CHUNK_EXTENSIONS_OVERFLOW:Chunk extensions overflow"); ++ return HPE_USER; ++ } ++ ++ return 0; ++ } ++ ++ // Reset nread for the next chunk and also reset the extensions counter + int on_chunk_header() { + header_nread_ = 0; ++ chunk_extensions_nread_ = 0; + return 0; + } + +@@ -904,6 +920,7 @@ class Parser : public AsyncWrap, public StreamListener { + unsigned int execute_depth_ = 0; + bool pending_pause_ = false; + uint64_t header_nread_ = 0; ++ uint64_t chunk_extensions_nread_ = 0; + uint64_t max_http_header_size_; + uint64_t headers_timeout_; + uint64_t header_parsing_start_time_ = 0; +@@ -938,6 +955,7 @@ const llhttp_settings_t Parser::settings = { + Proxy::Raw, + Proxy::Raw, + Proxy::Raw, ++ Proxy::Raw, + Proxy::Raw, + Proxy::Raw, + Proxy::Raw, +diff --git a/test/parallel/test-http-chunk-extensions-limit.js b/test/parallel/test-http-chunk-extensions-limit.js +new file mode 100644 +index 0000000000..6868b3da6c +--- /dev/null ++++ b/test/parallel/test-http-chunk-extensions-limit.js +@@ -0,0 +1,131 @@ ++'use strict'; ++ ++const common = require('../common'); ++const http = require('http'); ++const net = require('net'); ++const assert = require('assert'); ++ ++// Verify that chunk extensions are limited in size when sent all together. ++{ ++ const server = http.createServer((req, res) => { ++ req.on('end', () => { ++ res.writeHead(200, { 'Content-Type': 'text/plain' }); ++ res.end('bye'); ++ }); ++ ++ req.resume(); ++ }); ++ ++ server.listen(0, () => { ++ const sock = net.connect(server.address().port); ++ let data = ''; ++ ++ sock.on('data', (chunk) => data += chunk.toString('utf-8')); ++ ++ sock.on('end', common.mustCall(function() { ++ assert.strictEqual(data, 'HTTP/1.1 413 Payload Too Large\r\nConnection: close\r\n\r\n'); ++ server.close(); ++ })); ++ ++ sock.end('' + ++ 'GET / HTTP/1.1\r\n' + ++ 'Host: localhost:8080\r\n' + ++ 'Transfer-Encoding: chunked\r\n\r\n' + ++ '2;' + 'A'.repeat(20000) + '=bar\r\nAA\r\n' + ++ '0\r\n\r\n' ++ ); ++ }); ++} ++ ++// Verify that chunk extensions are limited in size when sent in intervals. ++{ ++ const server = http.createServer((req, res) => { ++ req.on('end', () => { ++ res.writeHead(200, { 'Content-Type': 'text/plain' }); ++ res.end('bye'); ++ }); ++ ++ req.resume(); ++ }); ++ ++ server.listen(0, () => { ++ const sock = net.connect(server.address().port); ++ let remaining = 20000; ++ let data = ''; ++ ++ const interval = setInterval( ++ () => { ++ if (remaining > 0) { ++ sock.write('A'.repeat(1000)); ++ } else { ++ sock.write('=bar\r\nAA\r\n0\r\n\r\n'); ++ clearInterval(interval); ++ } ++ ++ remaining -= 1000; ++ }, ++ common.platformTimeout(20), ++ ).unref(); ++ ++ sock.on('data', (chunk) => data += chunk.toString('utf-8')); ++ ++ sock.on('end', common.mustCall(function() { ++ assert.strictEqual(data, 'HTTP/1.1 413 Payload Too Large\r\nConnection: close\r\n\r\n'); ++ server.close(); ++ })); ++ ++ sock.write('' + ++ 'GET / HTTP/1.1\r\n' + ++ 'Host: localhost:8080\r\n' + ++ 'Transfer-Encoding: chunked\r\n\r\n' + ++ '2;' ++ ); ++ }); ++} ++ ++// Verify the chunk extensions is correctly reset after a chunk ++{ ++ const server = http.createServer((req, res) => { ++ req.on('end', () => { ++ res.writeHead(200, { 'content-type': 'text/plain', 'connection': 'close', 'date': 'now' }); ++ res.end('bye'); ++ }); ++ ++ req.resume(); ++ }); ++ ++ server.listen(0, () => { ++ const sock = net.connect(server.address().port); ++ let data = ''; ++ ++ sock.on('data', (chunk) => data += chunk.toString('utf-8')); ++ ++ sock.on('end', common.mustCall(function() { ++ assert.strictEqual( ++ data, ++ 'HTTP/1.1 200 OK\r\n' + ++ 'content-type: text/plain\r\n' + ++ 'connection: close\r\n' + ++ 'date: now\r\n' + ++ 'Transfer-Encoding: chunked\r\n' + ++ '\r\n' + ++ '3\r\n' + ++ 'bye\r\n' + ++ '0\r\n' + ++ '\r\n', ++ ); ++ ++ server.close(); ++ })); ++ ++ sock.end('' + ++ 'GET / HTTP/1.1\r\n' + ++ 'Host: localhost:8080\r\n' + ++ 'Transfer-Encoding: chunked\r\n\r\n' + ++ '2;' + 'A'.repeat(10000) + '=bar\r\nAA\r\n' + ++ '2;' + 'A'.repeat(10000) + '=bar\r\nAA\r\n' + ++ '2;' + 'A'.repeat(10000) + '=bar\r\nAA\r\n' + ++ '0\r\n\r\n' ++ ); ++ }); ++} +-- +2.41.0 + diff --git a/SPECS/nodejs.spec b/SPECS/nodejs.spec index 9577eae..53670a3 100644 --- a/SPECS/nodejs.spec +++ b/SPECS/nodejs.spec @@ -26,7 +26,7 @@ %global nodejs_patch 3 %global nodejs_abi %{nodejs_major}.%{nodejs_minor} %global nodejs_version %{nodejs_major}.%{nodejs_minor}.%{nodejs_patch} -%global nodejs_release 2 +%global nodejs_release 6 %global nodejs_datadir %{_datarootdir}/nodejs @@ -42,7 +42,7 @@ # c-ares - from deps/cares/include/ares_version.h %global c_ares_major 1 -%global c_ares_minor 18 +%global c_ares_minor 19 %global c_ares_patch 1 %global c_ares_version %{c_ares_major}.%{c_ares_minor}.%{c_ares_patch} @@ -60,7 +60,7 @@ # nghttp2 - from deps/nghttp2/lib/includes/nghttp2/nghttp2ver.h %global nghttp2_major 1 -%global nghttp2_minor 42 +%global nghttp2_minor 57 %global nghttp2_patch 0 %global nghttp2_version %{nghttp2_major}.%{nghttp2_minor}.%{nghttp2_patch} @@ -177,8 +177,9 @@ Patch11: Make-icutrim.py-Python-2-compatible.patch Patch21: deps-ansi-regex-fix-potential-ReDoS.patch Patch22: deps-node-fetch-npm-backport-CVE-2022-0235-fix.patch Patch23: deps-http-cache-semantics-Don-t-use-regex-to-trim-wh.patch -Patch24: deps-cares-Add-str-len-check-in-config_sortlist-to-a.patch - +Patch24: deps-update-c-ares-to-1.19.1.patch +Patch25: deps-update-nghttp2-to-1.57.0.patch +Patch26: nodejs-CVE-2024-22019-v14.patch %{?scl:Requires: %{scl}-runtime} %{?scl:BuildRequires: %{scl}-runtime} @@ -350,7 +351,7 @@ set -ex # Node's v8 breaks with GCC 6 because of incorrect usage of methods on # NULL objects. We need to pass -fno-delete-null-pointer-checks extra_cflags=( - -g + -g1 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DZLIB_CONST @@ -558,6 +559,22 @@ python2 tools/test.py "${RUN_SUITES[@]}" || : # FIXME – disable all failing t %changelog +* Tue Mar 05 2024 Honza Horak - 14.21.3-6 +- Resolves: CVE-2024-22019 + +* Fri Oct 13 2023 Jan Staněk - 14.21.3-5 +- Update bundled nghttp2 to 1.57.0 + Resolves: CVE-2023-44487 + +* Mon Jun 12 2023 Jan Staněk - 14.21.3-4 +- Update bundled c-ares to 1.19.1 + Resolves: CVE-2023-32067 CVE-2023-31130 CVE-2023-31124 CVE-2023-31147 + +* Wed May 31 2023 Zuzana Svetlikova - 14.21.3-3 +- Decrease debuginfo verbosity to reduce memory consumption during final library linking +- Only for Firefox, need to build for i686 and ppc64 +- Related: rhbz#2153715 + * Thu Mar 16 2023 Jan Staněk - 14.21.3-2 - Rebuilt with updated provides generator Related: rhbz#2153715