diff options
author | robot-contrib <robot-contrib@yandex-team.com> | 2024-02-06 01:15:14 +0300 |
---|---|---|
committer | Alexander Smirnov <alex@ydb.tech> | 2024-02-09 19:18:11 +0300 |
commit | d8dda255108e56bd45c714be6b3a479cb49823c6 (patch) | |
tree | a3da500650f69164b8a2e78c64b1e36dce79c50b | |
parent | c29b5e57643acd331dfdacd1e3ab836b6e4b018d (diff) | |
download | ydb-d8dda255108e56bd45c714be6b3a479cb49823c6.tar.gz |
Update contrib/libs/lzma to 5.4.6
63 files changed, 1833 insertions, 625 deletions
diff --git a/contrib/libs/lzma/COPYING b/contrib/libs/lzma/COPYING index 20e60d5b24..4990c5f522 100644 --- a/contrib/libs/lzma/COPYING +++ b/contrib/libs/lzma/COPYING @@ -21,6 +21,17 @@ XZ Utils Licensing XZ Utils specific documentation files in other directories are in the public domain. + Note: The JavaScript files (under the MIT license) have + been removed from the Doxygen-generated HTML version of the + liblzma API documentation. Doxygen itself is under the GNU GPL + but the remaining files generated by Doxygen are not affected + by the licenses used in Doxygen because Doxygen licensing has + the following exception: + + "Documents produced by doxygen are derivative works + derived from the input used in their production; + they are not affected by this license." + - Translated messages are in the public domain. - The build system contains public domain files, and files that @@ -47,7 +58,8 @@ XZ Utils Licensing naturally it is not legally required. Here is an example of a good notice to put into "about box" or into documentation: - This software includes code from XZ Utils <https://tukaani.org/xz/>. + This software includes code from XZ Utils + <https://xz.tukaani.org/xz-utils/>. The following license texts are included in the following files: - COPYING.LGPLv2.1: GNU Lesser General Public License version 2.1 diff --git a/contrib/libs/lzma/COPYING.GPLv3 b/contrib/libs/lzma/COPYING.GPLv3 index 94a9ed024d..f288702d2f 100644 --- a/contrib/libs/lzma/COPYING.GPLv3 +++ b/contrib/libs/lzma/COPYING.GPLv3 @@ -1,7 +1,7 @@ GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 - Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> + Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/> Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. @@ -645,7 +645,7 @@ the "copyright" line and a pointer to where the full notice is found. 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 <http://www.gnu.org/licenses/>. + along with this program. If not, see <https://www.gnu.org/licenses/>. Also add information on how to contact you by electronic and paper mail. @@ -664,11 +664,11 @@ might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see -<http://www.gnu.org/licenses/>. +<https://www.gnu.org/licenses/>. The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read -<http://www.gnu.org/philosophy/why-not-lgpl.html>. +<https://www.gnu.org/licenses/why-not-lgpl.html>. diff --git a/contrib/libs/lzma/INSTALL b/contrib/libs/lzma/INSTALL index 67df18803f..7ef2cb467a 100644 --- a/contrib/libs/lzma/INSTALL +++ b/contrib/libs/lzma/INSTALL @@ -22,13 +22,16 @@ XZ Utils Installation 3. xzgrep and other scripts 3.1. Dependencies 3.2. PATH - 4. Troubleshooting - 4.1. "No C99 compiler was found." - 4.2. "No POSIX conforming shell (sh) was found." - 4.3. configure works but build fails at crc32_x86.S - 4.4. Lots of warnings about symbol visibility - 4.5. "make check" fails - 4.6. liblzma.so (or similar) not found when running xz + 4. Tests + 4.1 Testing in parallel + 4.2 Cross compiling + 5. Troubleshooting + 5.1. "No C99 compiler was found." + 5.2. "No POSIX conforming shell (sh) was found." + 5.3. configure works but build fails at crc32_x86.S + 5.4. Lots of warnings about symbol visibility + 5.5. "make check" fails + 5.6. liblzma.so (or similar) not found when running xz 0. Preface @@ -100,7 +103,7 @@ XZ Utils Installation XZ Utils doesn't have code to detect the amount of physical RAM and number of CPU cores on MINIX 3. - See section 4.4 in this file about symbol visibility warnings (you + See section 5.4 in this file about symbol visibility warnings (you may want to pass gl_cv_cc_visibility=no to configure). @@ -127,14 +130,14 @@ XZ Utils Installation missing from PATH (/usr/xpg4/bin or /usr/xpg6/bin). Nowadays /usr/xpg4/bin is added to the script PATH by default on Solaris (see --enable-path-for-scripts=PREFIX in section 2), but old xz - releases needed extra steps. See sections 4.5 and 3.2 for more + releases needed extra steps. See sections 5.5 and 3.2 for more information. 1.2.6. Tru64 If you try to use the native C compiler on Tru64 (passing CC=cc to - configure), you may need the workaround mention in section 4.1 in + configure), you may need the workaround mention in section 5.1 in this file (pass also ac_cv_prog_cc_c99= to configure). @@ -455,8 +458,10 @@ XZ Utils Installation win95 Use Windows 95 compatible threads. This is compatible with Windows XP and later too. This is the default for 32-bit x86 - Windows builds. The `win95' threading is - incompatible with --enable-small. + Windows builds. Unless the compiler + supports __attribute__((__constructor__)), + the `win95' threading is incompatible with + --enable-small. vista Use Windows Vista compatible threads. The resulting binaries won't run on Windows XP @@ -596,7 +601,7 @@ XZ Utils Installation a fallback xzdiff will use mkdir to securely create a temporary directory. Having mktemp available is still recommended since the mkdir fallback method isn't as robust as mktemp is. The original - mktemp can be found from <http://www.mktemp.org/>. On GNU, most will + mktemp can be found from <https://www.mktemp.org/>. On GNU, most will use the mktemp program from GNU coreutils instead of the original implementation. Both mktemp versions are fine. @@ -624,10 +629,54 @@ XZ Utils Installation src/scripts/xz*.in -4. Troubleshooting +4. Tests +-------- + + The test framework can be built and run by executing "make check" in + the build directory. The tests are a mix of executables and POSIX + shell scripts (sh). All tests should pass if the default configuration + is used. Disabling features through the configure options may cause + some tests to be skipped. If any tests do not pass, see section 5.5. + + +4.1. Testing in parallel + + The tests can be run in parallel using the "-j" make option on systems + that support it. For instance, "make -j4 check" will run up to four + tests simultaneously. + + +4.2. Cross compiling + + The tests can be built without running them: + + make check TESTS= + + The TESTS variable is the list of tests you wish to run. Leaving it + empty will compile the tests without running any. + + If the tests are copied to a target machine to execute, the test data + files in the directory tests/files must also be copied. The tests + search for the data files using the environment variable $srcdir, + expecting to find the data files under $srcdir/files/. If $srcdir + isn't set then it defaults to the current directory. + + The shell script tests can be copied from the source directory to the + target machine to execute. In addition to the test files, these tests + will expect the following relative file paths to execute properly: + + ./create_compress_files + ../config.h + ../src/xz/xz + ../src/xzdec/xzdec + ../src/scripts/xzdiff + ../src/scripts/xzgrep + + +5. Troubleshooting ------------------ -4.1. "No C99 compiler was found." +5.1. "No C99 compiler was found." You need a C99 compiler to build XZ Utils. If the configure script cannot find a C99 compiler and you think you have such a compiler @@ -642,7 +691,7 @@ XZ Utils Installation support enough C99. -4.2. "No POSIX conforming shell (sh) was found." +5.2. "No POSIX conforming shell (sh) was found." xzgrep and other scripts need a shell that (roughly) conforms to POSIX. The configure script tries to find such a shell. If @@ -652,7 +701,7 @@ XZ Utils Installation this error by passing --disable-scripts to configure. -4.3. configure works but build fails at crc32_x86.S +5.3. configure works but build fails at crc32_x86.S The easy fix is to pass --disable-assembler to the configure script. @@ -669,7 +718,7 @@ XZ Utils Installation (see INSTALL.generic). -4.4. Lots of warnings about symbol visibility +5.4. Lots of warnings about symbol visibility On some systems where symbol visibility isn't supported, GCC may still accept the visibility options and attributes, which will make @@ -681,7 +730,7 @@ XZ Utils Installation using --enable-werror. -4.5. "make check" fails +5.5. "make check" fails If the other tests pass but test_scripts.sh fails, then the problem is in the scripts in src/scripts. Comparing the contents of @@ -707,7 +756,7 @@ XZ Utils Installation information. -4.6. liblzma.so (or similar) not found when running xz +5.6. liblzma.so (or similar) not found when running xz If you installed the package with "make install" and get an error about liblzma.so (or a similarly named file) being missing, try diff --git a/contrib/libs/lzma/NEWS b/contrib/libs/lzma/NEWS index feae8a465e..5858fadded 100644 --- a/contrib/libs/lzma/NEWS +++ b/contrib/libs/lzma/NEWS @@ -2,6 +2,273 @@ XZ Utils Release Notes ====================== +5.4.6 (2024-01-26) + + * Fixed a bug involving internal function pointers in liblzma not + being initialized to NULL. The bug can only be triggered if + lzma_filters_update() is called on a LZMA1 encoder, so it does + not affect xz or any application known to us that uses liblzma. + + * xz: + + - Fixed a regression introduced in 5.4.2 that caused encoding + in the raw format to unnecessarily fail if --suffix was not + used. For instance, the following command no longer reports + that --suffix must be used: + + echo foo | xz --format=raw --lzma2 | wc -c + + - Fixed an issue on MinGW-w64 builds that prevented reading + from or writing to non-terminal character devices like NUL. + + * Added a new test. + + +5.4.5 (2023-11-01) + + * liblzma: + + - Use __attribute__((__no_sanitize_address__)) to avoid address + sanitization with CRC64 CLMUL. It uses 16-byte-aligned reads + which can extend past the bounds of the input buffer and + inherently trigger address sanitization errors. This isn't + a bug. + + - Fixed an assertion failure that could be triggered by a large + unpadded_size argument. It was verified that there was no + other bug than the assertion failure. + + - Fixed a bug that prevented building with Windows Vista + threading when __attribute__((__constructor__)) is not + supported. + + * xz now properly handles special files such as "con" or "nul" on + Windows. Before this fix, the following wrote "foo" to the + console and deleted the input file "con_xz": + + echo foo | xz > con_xz + xz --suffix=_xz --decompress con_xz + + * Build systems: + + - Allow builds with Windows win95 threading and small mode when + __attribute__((__constructor__)) is supported. + + - Added a new line to liblzma.pc for MSYS2 (Windows): + + Cflags.private: -DLZMA_API_STATIC + + When compiling code that will link against static liblzma, + the LZMA_API_STATIC macro needs to be defined on Windows. + + - CMake specific changes: + + * Fixed a bug that allowed CLOCK_MONOTONIC to be used even + if the check for it failed. + + * Fixed a bug where configuring CMake multiple times + resulted in HAVE_CLOCK_GETTIME and HAVE_CLOCK_MONOTONIC + not being set. + + * Fixed the build with MinGW-w64-based Clang/LLVM 17. + llvm-windres now has more accurate GNU windres emulation + so the GNU windres workaround from 5.4.1 is needed with + llvm-windres version 17 too. + + * The import library on Windows is now properly named + "liblzma.dll.a" instead of "libliblzma.dll.a" + + * Fixed a bug causing the Ninja Generator to fail on + UNIX-like systems. This bug was introduced in 5.4.0. + + * Added a new option to disable CLMUL CRC64. + + * A module-definition (.def) file is now created when + building liblzma.dll with MinGW-w64. + + * The pkg-config liblzma.pc file is now installed on all + builds except when using MSVC on Windows. + + * Added large file support by default for platforms that + need it to handle files larger than 2 GiB. This includes + MinGW-w64, even 64-bit builds. + + * Small fixes and improvements to the tests. + + * Updated translations: Chinese (simplified) and Esperanto. + + +5.4.4 (2023-08-02) + + * liblzma and xzdec can now build against WASI SDK when threading + support is disabled. xz and tests don't build yet. + + * CMake: + + - Fixed a bug preventing other projects from including liblzma + multiple times using find_package(). + + - Don't create broken symlinks in Cygwin and MSYS2 unless + supported by the environment. This prevented building for the + default MSYS2 environment. The problem was introduced in + xz 5.4.0. + + * Documentation: + + - Small improvements to man pages. + + - Small improvements and typo fixes for liblzma API + documentation. + + * Tests: + + - Added a new section to INSTALL to describe basic test usage + and address recent questions about building the tests when + cross compiling. + + - Small fixes and improvements to the tests. + + * Translations: + + - Fixed a mistake that caused one of the error messages to not + be translated. This only affected versions 5.4.2 and 5.4.3. + + - Updated the Chinese (simplified), Croatian, Esperanto, German, + Korean, Polish, Romanian, Spanish, Swedish, Ukrainian, and + Vietnamese translations. + + - Updated the German, Korean, Romanian, and Ukrainian man page + translations. + + +5.4.3 (2023-05-04) + + * All fixes from 5.2.12 + + * Features in the CMake build can now be disabled as CMake cache + variables, similar to the Autotools build. + + * Minor update to the Croatian translation. + + +5.4.2 (2023-03-18) + + * All fixes from 5.2.11 that were not included in 5.4.1. + + * If xz is built with support for the Capsicum sandbox but running + in an environment that doesn't support Capsicum, xz now runs + normally without sandboxing instead of exiting with an error. + + * liblzma: + + - Documentation was updated to improve the style, consistency, + and completeness of the liblzma API headers. + + - The Doxygen-generated HTML documentation for the liblzma API + header files is now included in the source release and is + installed as part of "make install". All JavaScript is + removed to simplify license compliance and to reduce the + install size. + + - Fixed a minor bug in lzma_str_from_filters() that produced + too many filters in the output string instead of reporting + an error if the input array had more than four filters. This + bug did not affect xz. + + * Build systems: + + - autogen.sh now invokes the doxygen tool via the new wrapper + script doxygen/update-doxygen, unless the command line option + --no-doxygen is used. + + - Added microlzma_encoder.c and microlzma_decoder.c to the + VS project files for Windows and to the CMake build. These + should have been included in 5.3.2alpha. + + * Tests: + + - Added a test to the CMake build that was forgotten in the + previous release. + + - Added and refactored a few tests. + + * Translations: + + - Updated the Brazilian Portuguese translation. + + - Added Brazilian Portuguese man page translation. + + +5.4.1 (2023-01-11) + + * liblzma: + + - Fixed the return value of lzma_microlzma_encoder() if the + LZMA options lc/lp/pb are invalid. Invalid lc/lp/pb options + made the function return LZMA_STREAM_END without encoding + anything instead of returning LZMA_OPTIONS_ERROR. + + - Windows / Visual Studio: Workaround a possible compiler bug + when targeting 32-bit x86 and compiling the CLMUL version of + the CRC64 code. The CLMUL code isn't enabled by the Windows + project files but it is in the CMake-based builds. + + * Build systems: + + - Windows-specific CMake changes: + + * Don't try to enable CLMUL CRC64 code if _mm_set_epi64x() + isn't available. This fixes CMake-based build with Visual + Studio 2013. + + * Created a workaround for a build failure with windres + from GNU binutils. It is used only when the C compiler + is GCC (not Clang). The workaround is incompatible + with llvm-windres, resulting in "XZx20Utils" instead + of "XZ Utils" in the resource file, but without the + workaround llvm-windres works correctly. See the + comment in CMakeLists.txt for details. + + * Included the resource files in the xz and xzdec build + rules. Building the command line tools is still + experimental but possible with MinGW-w64. + + - Visual Studio: Added stream_decoder_mt.c to the project + files. Now the threaded decompressor lzma_stream_decoder_mt() + gets built. CMake-based build wasn't affected. + + - Updated windows/INSTALL-MSVC.txt to mention that CMake-based + build is now the preferred method with Visual Studio. The + project files will probably be removed after 5.4.x releases. + + - Changes to #defines in config.h: + + * HAVE_DECL_CLOCK_MONOTONIC was replaced by + HAVE_CLOCK_MONOTONIC. The old macro was always defined + in configure-generated config.h to either 0 or 1. The + new macro is defined (to 1) only if the declaration of + CLOCK_MONOTONIC is available. This matches the way most + other config.h macros work and makes things simpler with + other build systems. + + * HAVE_DECL_PROGRAM_INVOCATION_NAME was replaced by + HAVE_PROGRAM_INVOCATION_NAME for the same reason. + + * Tests: + + - Fixed test script compatibility with ancient /bin/sh + versions. Now the five test_compress_* tests should + no longer fail on Solaris 10. + + - Added and refactored a few tests. + + * Translations: + + - Updated the Catalan and Esperanto translations. + + - Added Korean and Ukrainian man page translations. + + 5.4.0 (2022-12-13) This bumps the minor version of liblzma because new features were @@ -830,7 +1097,7 @@ XZ Utils Release Notes of the deprecated egrep and fgrep commands. - Fixed parsing of the options -E, -F, -G, -P, and -X. The - problem occurred when multiple options were specied in + problem occurred when multiple options were specified in a single argument, for example, echo foo | xzgrep -Fe foo diff --git a/contrib/libs/lzma/README b/contrib/libs/lzma/README index b9081ed455..9a29c1b217 100644 --- a/contrib/libs/lzma/README +++ b/contrib/libs/lzma/README @@ -113,8 +113,8 @@ XZ Utils Since the liblzma API has similarities to the zlib API, some people may find it useful to read the zlib docs and tutorial too: - http://zlib.net/manual.html - http://zlib.net/zlib_how.html + https://zlib.net/manual.html + https://zlib.net/zlib_how.html 2. Version numbering @@ -281,13 +281,17 @@ XZ Utils 7-Zip and the p7zip port of 7-Zip support the .xz format starting from the version 9.00alpha. - http://7-zip.org/ - http://p7zip.sourceforge.net/ + https://7-zip.org/ + https://p7zip.sourceforge.net/ XZ Embedded is a limited implementation written for use in the Linux kernel, but it is also suitable for other embedded use. - https://tukaani.org/xz/embedded.html + https://xz.tukaani.org/xz-embedded/ + + XZ for Java is a complete implementation written in pure Java. + + https://xz.tukaani.org/xz-for-java/ 6. Contact information diff --git a/contrib/libs/lzma/common/mythread.h b/contrib/libs/lzma/common/mythread.h index 4138218360..4495e017b2 100644 --- a/contrib/libs/lzma/common/mythread.h +++ b/contrib/libs/lzma/common/mythread.h @@ -79,7 +79,7 @@ do { \ } while (0) -#if !(defined(_WIN32) && !defined(__CYGWIN__)) +#if !(defined(_WIN32) && !defined(__CYGWIN__)) && !defined(__wasm__) // Use sigprocmask() to set the signal mask in single-threaded programs. #include <signal.h> @@ -100,12 +100,18 @@ mythread_sigmask(int how, const sigset_t *restrict set, // Using pthreads // //////////////////// -#include <sys/time.h> #include <pthread.h> #include <signal.h> #include <time.h> #include <errno.h> +// If clock_gettime() isn't available, use gettimeofday() from <sys/time.h> +// as a fallback. gettimeofday() is in SUSv2 and thus is supported on all +// relevant POSIX systems. +#ifndef HAVE_CLOCK_GETTIME +# include <sys/time.h> +#endif + #define MYTHREAD_RET_TYPE void * #define MYTHREAD_RET_VALUE NULL @@ -219,8 +225,8 @@ static inline int mythread_cond_init(mythread_cond *mycond) { #ifdef HAVE_CLOCK_GETTIME - // NOTE: HAVE_DECL_CLOCK_MONOTONIC is always defined to 0 or 1. -# if defined(HAVE_PTHREAD_CONDATTR_SETCLOCK) && HAVE_DECL_CLOCK_MONOTONIC +# if defined(HAVE_PTHREAD_CONDATTR_SETCLOCK) && \ + defined(HAVE_CLOCK_MONOTONIC) struct timespec ts; pthread_condattr_t condattr; @@ -294,8 +300,8 @@ static inline void mythread_condtime_set(mythread_condtime *condtime, const mythread_cond *cond, uint32_t timeout_ms) { - condtime->tv_sec = timeout_ms / 1000; - condtime->tv_nsec = (timeout_ms % 1000) * 1000000; + condtime->tv_sec = (time_t)(timeout_ms / 1000); + condtime->tv_nsec = (long)((timeout_ms % 1000) * 1000000); #ifdef HAVE_CLOCK_GETTIME struct timespec now; @@ -372,7 +378,7 @@ typedef struct { abort(); \ if (pending_) { \ func(); \ - if (!InitOnceComplete(&once, 0, NULL)) \ + if (!InitOnceComplete(&once_, 0, NULL)) \ abort(); \ } \ } while (0) diff --git a/contrib/libs/lzma/common/sysdefs.h b/contrib/libs/lzma/common/sysdefs.h index df7ecf4002..f04e45dd21 100644 --- a/contrib/libs/lzma/common/sysdefs.h +++ b/contrib/libs/lzma/common/sysdefs.h @@ -24,7 +24,15 @@ # include <config.h> #endif -// Get standard-compliant stdio functions under MinGW and MinGW-w64. +// This #define ensures that C99 and POSIX compliant stdio functions are +// available with MinGW-w64 (both 32-bit and 64-bit). Modern MinGW-w64 adds +// this automatically, for example, when the compiler is in C99 (or later) +// mode when building against msvcrt.dll. It still doesn't hurt to be explicit +// that we always want this and #define this unconditionally. +// +// With Universal CRT (UCRT) this is less important because UCRT contains +// C99-compatible stdio functions. It's still nice to #define this as UCRT +// doesn't support the POSIX thousand separator flag in printf (like "%'u"). #ifdef __MINGW32__ # define __USE_MINGW_ANSI_STDIO 1 #endif @@ -127,7 +135,7 @@ #include <stdlib.h> #include <assert.h> -// Pre-C99 systems lack stdbool.h. All the code in LZMA Utils must be written +// Pre-C99 systems lack stdbool.h. All the code in XZ Utils must be written // so that it works with fake bool type, for example: // // bool foo = (flags & 0x100) != 0; @@ -149,18 +157,8 @@ typedef unsigned char _Bool; # define __bool_true_false_are_defined 1 #endif -// string.h should be enough but let's include strings.h and memory.h too if -// they exists, since that shouldn't do any harm, but may improve portability. #include <string.h> -#ifdef HAVE_STRINGS_H -# include <strings.h> -#endif - -#ifdef HAVE_MEMORY_H -# include <memory.h> -#endif - // As of MSVC 2013, inline and restrict are supported with // non-standard keywords. #if defined(_WIN32) && defined(_MSC_VER) diff --git a/contrib/libs/lzma/common/tuklib_integer.h b/contrib/libs/lzma/common/tuklib_integer.h index b58ef68d09..6dd2a5f701 100644 --- a/contrib/libs/lzma/common/tuklib_integer.h +++ b/contrib/libs/lzma/common/tuklib_integer.h @@ -52,6 +52,12 @@ // and such functions. #if defined(__INTEL_COMPILER) && (__INTEL_COMPILER >= 1500) # include <immintrin.h> +// Only include <intrin.h> when it is needed. GCC and Clang can both +// use __builtin's, so we only need Windows instrincs when using MSVC. +// GCC and Clang can set _MSC_VER on Windows, so we need to exclude these +// cases explicitly. +#elif defined(_MSC_VER) && !TUKLIB_GNUC_REQ(3, 4) && !defined(__clang__) +# include <intrin.h> #endif @@ -189,6 +195,9 @@ // Unaligned reads and writes // //////////////////////////////// +// No-strict-align archs like x86-64 +// --------------------------------- +// // The traditional way of casting e.g. *(const uint16_t *)uint8_pointer // is bad even if the uint8_pointer is properly aligned because this kind // of casts break strict aliasing rules and result in undefined behavior. @@ -203,12 +212,115 @@ // build time. A third method, casting to a packed struct, would also be // an option but isn't provided to keep things simpler (it's already a mess). // Hopefully this is flexible enough in practice. +// +// Some compilers on x86-64 like Clang >= 10 and GCC >= 5.1 detect that +// +// buf[0] | (buf[1] << 8) +// +// reads a 16-bit value and can emit a single 16-bit load and produce +// identical code than with the memcpy() method. In other cases Clang and GCC +// produce either the same or better code with memcpy(). For example, Clang 9 +// on x86-64 can detect 32-bit load but not 16-bit load. +// +// MSVC uses unaligned access with the memcpy() method but emits byte-by-byte +// code for "buf[0] | (buf[1] << 8)". +// +// Conclusion: The memcpy() method is the best choice when unaligned access +// is supported. +// +// Strict-align archs like SPARC +// ----------------------------- +// +// GCC versions from around 4.x to to at least 13.2.0 produce worse code +// from the memcpy() method than from simple byte-by-byte shift-or code +// when reading a 32-bit integer: +// +// (1) It may be constructed on stack using using four 8-bit loads, +// four 8-bit stores to stack, and finally one 32-bit load from stack. +// +// (2) Especially with -Os, an actual memcpy() call may be emitted. +// +// This is true on at least on ARM, ARM64, SPARC, SPARC64, MIPS64EL, and +// RISC-V. Of these, ARM, ARM64, and RISC-V support unaligned access in +// some processors but not all so this is relevant only in the case when +// GCC assumes that unaligned is not supported or -mstrict-align or +// -mno-unaligned-access is used. +// +// For Clang it makes little difference. ARM64 with -O2 -mstrict-align +// was one the very few with a minor difference: the memcpy() version +// was one instruction longer. +// +// Conclusion: At least in case of GCC and Clang, byte-by-byte code is +// the best choice for strict-align archs to do unaligned access. +// +// See also: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111502 +// +// Thanks to <https://godbolt.org/> it was easy to test different compilers. +// The following is for little endian targets: +/* +#include <stdint.h> +#include <string.h> + +uint32_t bytes16(const uint8_t *b) +{ + return (uint32_t)b[0] + | ((uint32_t)b[1] << 8); +} + +uint32_t copy16(const uint8_t *b) +{ + uint16_t v; + memcpy(&v, b, sizeof(v)); + return v; +} + +uint32_t bytes32(const uint8_t *b) +{ + return (uint32_t)b[0] + | ((uint32_t)b[1] << 8) + | ((uint32_t)b[2] << 16) + | ((uint32_t)b[3] << 24); +} + +uint32_t copy32(const uint8_t *b) +{ + uint32_t v; + memcpy(&v, b, sizeof(v)); + return v; +} + +void wbytes16(uint8_t *b, uint16_t v) +{ + b[0] = (uint8_t)v; + b[1] = (uint8_t)(v >> 8); +} + +void wcopy16(uint8_t *b, uint16_t v) +{ + memcpy(b, &v, sizeof(v)); +} + +void wbytes32(uint8_t *b, uint32_t v) +{ + b[0] = (uint8_t)v; + b[1] = (uint8_t)(v >> 8); + b[2] = (uint8_t)(v >> 16); + b[3] = (uint8_t)(v >> 24); +} + +void wcopy32(uint8_t *b, uint32_t v) +{ + memcpy(b, &v, sizeof(v)); +} +*/ + + +#ifdef TUKLIB_FAST_UNALIGNED_ACCESS static inline uint16_t read16ne(const uint8_t *buf) { -#if defined(TUKLIB_FAST_UNALIGNED_ACCESS) \ - && defined(TUKLIB_USE_UNSAFE_TYPE_PUNNING) +#ifdef TUKLIB_USE_UNSAFE_TYPE_PUNNING return *(const uint16_t *)buf; #else uint16_t num; @@ -221,8 +333,7 @@ read16ne(const uint8_t *buf) static inline uint32_t read32ne(const uint8_t *buf) { -#if defined(TUKLIB_FAST_UNALIGNED_ACCESS) \ - && defined(TUKLIB_USE_UNSAFE_TYPE_PUNNING) +#ifdef TUKLIB_USE_UNSAFE_TYPE_PUNNING return *(const uint32_t *)buf; #else uint32_t num; @@ -235,8 +346,7 @@ read32ne(const uint8_t *buf) static inline uint64_t read64ne(const uint8_t *buf) { -#if defined(TUKLIB_FAST_UNALIGNED_ACCESS) \ - && defined(TUKLIB_USE_UNSAFE_TYPE_PUNNING) +#ifdef TUKLIB_USE_UNSAFE_TYPE_PUNNING return *(const uint64_t *)buf; #else uint64_t num; @@ -249,8 +359,7 @@ read64ne(const uint8_t *buf) static inline void write16ne(uint8_t *buf, uint16_t num) { -#if defined(TUKLIB_FAST_UNALIGNED_ACCESS) \ - && defined(TUKLIB_USE_UNSAFE_TYPE_PUNNING) +#ifdef TUKLIB_USE_UNSAFE_TYPE_PUNNING *(uint16_t *)buf = num; #else memcpy(buf, &num, sizeof(num)); @@ -262,8 +371,7 @@ write16ne(uint8_t *buf, uint16_t num) static inline void write32ne(uint8_t *buf, uint32_t num) { -#if defined(TUKLIB_FAST_UNALIGNED_ACCESS) \ - && defined(TUKLIB_USE_UNSAFE_TYPE_PUNNING) +#ifdef TUKLIB_USE_UNSAFE_TYPE_PUNNING *(uint32_t *)buf = num; #else memcpy(buf, &num, sizeof(num)); @@ -275,8 +383,7 @@ write32ne(uint8_t *buf, uint32_t num) static inline void write64ne(uint8_t *buf, uint64_t num) { -#if defined(TUKLIB_FAST_UNALIGNED_ACCESS) \ - && defined(TUKLIB_USE_UNSAFE_TYPE_PUNNING) +#ifdef TUKLIB_USE_UNSAFE_TYPE_PUNNING *(uint64_t *)buf = num; #else memcpy(buf, &num, sizeof(num)); @@ -288,68 +395,122 @@ write64ne(uint8_t *buf, uint64_t num) static inline uint16_t read16be(const uint8_t *buf) { -#if defined(WORDS_BIGENDIAN) || defined(TUKLIB_FAST_UNALIGNED_ACCESS) uint16_t num = read16ne(buf); return conv16be(num); -#else - uint16_t num = ((uint16_t)buf[0] << 8) | (uint16_t)buf[1]; - return num; -#endif } static inline uint16_t read16le(const uint8_t *buf) { -#if !defined(WORDS_BIGENDIAN) || defined(TUKLIB_FAST_UNALIGNED_ACCESS) uint16_t num = read16ne(buf); return conv16le(num); -#else - uint16_t num = ((uint16_t)buf[0]) | ((uint16_t)buf[1] << 8); - return num; -#endif } static inline uint32_t read32be(const uint8_t *buf) { -#if defined(WORDS_BIGENDIAN) || defined(TUKLIB_FAST_UNALIGNED_ACCESS) uint32_t num = read32ne(buf); return conv32be(num); +} + + +static inline uint32_t +read32le(const uint8_t *buf) +{ + uint32_t num = read32ne(buf); + return conv32le(num); +} + + +static inline uint64_t +read64be(const uint8_t *buf) +{ + uint64_t num = read64ne(buf); + return conv64be(num); +} + + +static inline uint64_t +read64le(const uint8_t *buf) +{ + uint64_t num = read64ne(buf); + return conv64le(num); +} + + +// NOTE: Possible byte swapping must be done in a macro to allow the compiler +// to optimize byte swapping of constants when using glibc's or *BSD's +// byte swapping macros. The actual write is done in an inline function +// to make type checking of the buf pointer possible. +#define write16be(buf, num) write16ne(buf, conv16be(num)) +#define write32be(buf, num) write32ne(buf, conv32be(num)) +#define write64be(buf, num) write64ne(buf, conv64be(num)) +#define write16le(buf, num) write16ne(buf, conv16le(num)) +#define write32le(buf, num) write32ne(buf, conv32le(num)) +#define write64le(buf, num) write64ne(buf, conv64le(num)) + #else + +#ifdef WORDS_BIGENDIAN +# define read16ne read16be +# define read32ne read32be +# define read64ne read64be +# define write16ne write16be +# define write32ne write32be +# define write64ne write64be +#else +# define read16ne read16le +# define read32ne read32le +# define read64ne read64le +# define write16ne write16le +# define write32ne write32le +# define write64ne write64le +#endif + + +static inline uint16_t +read16be(const uint8_t *buf) +{ + uint16_t num = ((uint16_t)buf[0] << 8) | (uint16_t)buf[1]; + return num; +} + + +static inline uint16_t +read16le(const uint8_t *buf) +{ + uint16_t num = ((uint16_t)buf[0]) | ((uint16_t)buf[1] << 8); + return num; +} + + +static inline uint32_t +read32be(const uint8_t *buf) +{ uint32_t num = (uint32_t)buf[0] << 24; num |= (uint32_t)buf[1] << 16; num |= (uint32_t)buf[2] << 8; num |= (uint32_t)buf[3]; return num; -#endif } static inline uint32_t read32le(const uint8_t *buf) { -#if !defined(WORDS_BIGENDIAN) || defined(TUKLIB_FAST_UNALIGNED_ACCESS) - uint32_t num = read32ne(buf); - return conv32le(num); -#else uint32_t num = (uint32_t)buf[0]; num |= (uint32_t)buf[1] << 8; num |= (uint32_t)buf[2] << 16; num |= (uint32_t)buf[3] << 24; return num; -#endif } static inline uint64_t read64be(const uint8_t *buf) { -#if defined(WORDS_BIGENDIAN) || defined(TUKLIB_FAST_UNALIGNED_ACCESS) - uint64_t num = read64ne(buf); - return conv64be(num); -#else uint64_t num = (uint64_t)buf[0] << 56; num |= (uint64_t)buf[1] << 48; num |= (uint64_t)buf[2] << 40; @@ -359,17 +520,12 @@ read64be(const uint8_t *buf) num |= (uint64_t)buf[6] << 8; num |= (uint64_t)buf[7]; return num; -#endif } static inline uint64_t read64le(const uint8_t *buf) { -#if !defined(WORDS_BIGENDIAN) || defined(TUKLIB_FAST_UNALIGNED_ACCESS) - uint64_t num = read64ne(buf); - return conv64le(num); -#else uint64_t num = (uint64_t)buf[0]; num |= (uint64_t)buf[1] << 8; num |= (uint64_t)buf[2] << 16; @@ -379,28 +535,9 @@ read64le(const uint8_t *buf) num |= (uint64_t)buf[6] << 48; num |= (uint64_t)buf[7] << 56; return num; -#endif } -// NOTE: Possible byte swapping must be done in a macro to allow the compiler -// to optimize byte swapping of constants when using glibc's or *BSD's -// byte swapping macros. The actual write is done in an inline function -// to make type checking of the buf pointer possible. -#if defined(WORDS_BIGENDIAN) || defined(TUKLIB_FAST_UNALIGNED_ACCESS) -# define write16be(buf, num) write16ne(buf, conv16be(num)) -# define write32be(buf, num) write32ne(buf, conv32be(num)) -# define write64be(buf, num) write64ne(buf, conv64be(num)) -#endif - -#if !defined(WORDS_BIGENDIAN) || defined(TUKLIB_FAST_UNALIGNED_ACCESS) -# define write16le(buf, num) write16ne(buf, conv16le(num)) -# define write32le(buf, num) write32ne(buf, conv32le(num)) -# define write64le(buf, num) write64ne(buf, conv64le(num)) -#endif - - -#ifndef write16be static inline void write16be(uint8_t *buf, uint16_t num) { @@ -408,10 +545,8 @@ write16be(uint8_t *buf, uint16_t num) buf[1] = (uint8_t)num; return; } -#endif -#ifndef write16le static inline void write16le(uint8_t *buf, uint16_t num) { @@ -419,10 +554,8 @@ write16le(uint8_t *buf, uint16_t num) buf[1] = (uint8_t)(num >> 8); return; } -#endif -#ifndef write32be static inline void write32be(uint8_t *buf, uint32_t num) { @@ -432,10 +565,8 @@ write32be(uint8_t *buf, uint32_t num) buf[3] = (uint8_t)num; return; } -#endif -#ifndef write32le static inline void write32le(uint8_t *buf, uint32_t num) { @@ -445,6 +576,37 @@ write32le(uint8_t *buf, uint32_t num) buf[3] = (uint8_t)(num >> 24); return; } + + +static inline void +write64be(uint8_t *buf, uint64_t num) +{ + buf[0] = (uint8_t)(num >> 56); + buf[1] = (uint8_t)(num >> 48); + buf[2] = (uint8_t)(num >> 40); + buf[3] = (uint8_t)(num >> 32); + buf[4] = (uint8_t)(num >> 24); + buf[5] = (uint8_t)(num >> 16); + buf[6] = (uint8_t)(num >> 8); + buf[7] = (uint8_t)num; + return; +} + + +static inline void +write64le(uint8_t *buf, uint64_t num) +{ + buf[0] = (uint8_t)num; + buf[1] = (uint8_t)(num >> 8); + buf[2] = (uint8_t)(num >> 16); + buf[3] = (uint8_t)(num >> 24); + buf[4] = (uint8_t)(num >> 32); + buf[5] = (uint8_t)(num >> 40); + buf[6] = (uint8_t)(num >> 48); + buf[7] = (uint8_t)(num >> 56); + return; +} + #endif @@ -630,7 +792,7 @@ bsr32(uint32_t n) #if defined(__INTEL_COMPILER) return _bit_scan_reverse(n); -#elif TUKLIB_GNUC_REQ(3, 4) && UINT_MAX == UINT32_MAX +#elif (TUKLIB_GNUC_REQ(3, 4) || defined(__clang__)) && UINT_MAX == UINT32_MAX // GCC >= 3.4 has __builtin_clz(), which gives good results on // multiple architectures. On x86, __builtin_clz() ^ 31U becomes // either plain BSR (so the XOR gets optimized away) or LZCNT and @@ -684,7 +846,7 @@ clz32(uint32_t n) #if defined(__INTEL_COMPILER) return _bit_scan_reverse(n) ^ 31U; -#elif TUKLIB_GNUC_REQ(3, 4) && UINT_MAX == UINT32_MAX +#elif (TUKLIB_GNUC_REQ(3, 4) || defined(__clang__)) && UINT_MAX == UINT32_MAX return (uint32_t)__builtin_clz(n); #elif defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)) @@ -736,7 +898,7 @@ ctz32(uint32_t n) #if defined(__INTEL_COMPILER) return _bit_scan_forward(n); -#elif TUKLIB_GNUC_REQ(3, 4) && UINT_MAX >= UINT32_MAX +#elif (TUKLIB_GNUC_REQ(3, 4) || defined(__clang__)) && UINT_MAX >= UINT32_MAX return (uint32_t)__builtin_ctz(n); #elif defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)) diff --git a/contrib/libs/lzma/common/tuklib_physmem.c b/contrib/libs/lzma/common/tuklib_physmem.c index fb11478f24..afe2553a36 100644 --- a/contrib/libs/lzma/common/tuklib_physmem.c +++ b/contrib/libs/lzma/common/tuklib_physmem.c @@ -73,6 +73,17 @@ #endif +// With GCC >= 8.1 with -Wextra and Clang >= 13 with -Wcast-function-type +// will warn about the Windows-specific code. +#if defined(__has_warning) +# if __has_warning("-Wcast-function-type") +# define CAN_DISABLE_WCAST_FUNCTION_TYPE 1 +# endif +#elif TUKLIB_GNUC_REQ(8,1) +# define CAN_DISABLE_WCAST_FUNCTION_TYPE 1 +#endif + + extern uint64_t tuklib_physmem(void) { @@ -87,8 +98,15 @@ tuklib_physmem(void) HMODULE kernel32 = GetModuleHandle(TEXT("kernel32.dll")); if (kernel32 != NULL) { typedef BOOL (WINAPI *gmse_type)(LPMEMORYSTATUSEX); +#ifdef CAN_DISABLE_WCAST_FUNCTION_TYPE +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wcast-function-type" +#endif gmse_type gmse = (gmse_type)GetProcAddress( kernel32, "GlobalMemoryStatusEx"); +#ifdef CAN_DISABLE_WCAST_FUNCTION_TYPE +# pragma GCC diagnostic pop +#endif if (gmse != NULL) { MEMORYSTATUSEX meminfo; meminfo.dwLength = sizeof(meminfo); diff --git a/contrib/libs/lzma/liblzma/api/lzma.h b/contrib/libs/lzma/liblzma/api/lzma.h index 8fbd9a874b..f6b9469a3d 100644 --- a/contrib/libs/lzma/liblzma/api/lzma.h +++ b/contrib/libs/lzma/liblzma/api/lzma.h @@ -1,22 +1,23 @@ /** * \file api/lzma.h * \brief The public API of liblzma data compression library + * \mainpage * * liblzma is a public domain general-purpose data compression library with * a zlib-like API. The native file format is .xz, but also the old .lzma * format and raw (no headers) streams are supported. Multiple compression * algorithms (filters) are supported. Currently LZMA2 is the primary filter. * - * liblzma is part of XZ Utils <http://tukaani.org/xz/>. XZ Utils includes - * a gzip-like command line tool named xz and some other tools. XZ Utils - * is developed and maintained by Lasse Collin. + * liblzma is part of XZ Utils <https://xz.tukaani.org/xz-utils/>. XZ Utils + * includes a gzip-like command line tool named xz and some other tools. + * XZ Utils is developed and maintained by Lasse Collin and Jia Tan. * * Major parts of liblzma are based on Igor Pavlov's public domain LZMA SDK - * <http://7-zip.org/sdk.html>. + * <https://7-zip.org/sdk.html>. * * The SHA-256 implementation is based on the public domain code found from - * 7-Zip <http://7-zip.org/>, which has a modified version of the public - * domain SHA-256 code found from Crypto++ <http://www.cryptopp.com/>. + * 7-Zip <https://7-zip.org/>, which has a modified version of the public + * domain SHA-256 code found from Crypto++ <https://www.cryptopp.com/>. * The SHA-256 code in Crypto++ was written by Kevin Springle and Wei Dai. */ @@ -181,11 +182,11 @@ * against static liblzma on them, don't worry about LZMA_API_STATIC. That * is, most developers will never need to use LZMA_API_STATIC. * - * The GCC variants are a special case on Windows (Cygwin and MinGW). + * The GCC variants are a special case on Windows (Cygwin and MinGW-w64). * We rely on GCC doing the right thing with its auto-import feature, * and thus don't use __declspec(dllimport). This way developers don't * need to worry about LZMA_API_STATIC. Also the calling convention is - * omitted on Cygwin but not on MinGW. + * omitted on Cygwin but not on MinGW-w64. */ #ifndef LZMA_API_IMPORT # if !defined(LZMA_API_STATIC) && defined(_WIN32) && !defined(__GNUC__) diff --git a/contrib/libs/lzma/liblzma/api/lzma/base.h b/contrib/libs/lzma/liblzma/api/lzma/base.h index ff2d86968e..75cdd72acf 100644 --- a/contrib/libs/lzma/liblzma/api/lzma/base.h +++ b/contrib/libs/lzma/liblzma/api/lzma/base.h @@ -1,6 +1,7 @@ /** * \file lzma/base.h * \brief Data types and functions used in many places in liblzma API + * \note Never include this file directly. Use <lzma.h> instead. */ /* @@ -8,8 +9,6 @@ * * This file has been put into the public domain. * You can do whatever you want with this file. - * - * See ../lzma.h for information about liblzma as a whole. */ #ifndef LZMA_H_INTERNAL @@ -138,7 +137,7 @@ typedef enum { */ LZMA_MEMLIMIT_ERROR = 6, - /** + /**< * \brief Memory usage limit was reached * * Decoder would need more memory than allowed by the @@ -277,7 +276,7 @@ typedef enum { * \brief The `action' argument for lzma_code() * * After the first use of LZMA_SYNC_FLUSH, LZMA_FULL_FLUSH, LZMA_FULL_BARRIER, - * or LZMA_FINISH, the same `action' must is used until lzma_code() returns + * or LZMA_FINISH, the same `action' must be used until lzma_code() returns * LZMA_STREAM_END. Also, the amount of input (that is, strm->avail_in) must * not be modified by the application until lzma_code() returns * LZMA_STREAM_END. Changing the `action' or modifying the amount of input @@ -546,9 +545,17 @@ typedef struct { * you should not touch these, because the names of these variables * may change. */ + + /** \private Reserved member. */ void *reserved_ptr1; + + /** \private Reserved member. */ void *reserved_ptr2; + + /** \private Reserved member. */ void *reserved_ptr3; + + /** \private Reserved member. */ void *reserved_ptr4; /** @@ -563,10 +570,19 @@ typedef struct { */ uint64_t seek_pos; + /** \private Reserved member. */ uint64_t reserved_int2; + + /** \private Reserved member. */ size_t reserved_int3; + + /** \private Reserved member. */ size_t reserved_int4; + + /** \private Reserved member. */ lzma_reserved_enum reserved_enum1; + + /** \private Reserved member. */ lzma_reserved_enum reserved_enum2; } lzma_stream; @@ -607,6 +623,14 @@ typedef struct { * * See the description of the coder-specific initialization function to find * out what `action' values are supported by the coder. + * + * \param strm Pointer to lzma_stream that is at least initialized + * with LZMA_STREAM_INIT. + * \param action Action for this function to take. Must be a valid + * lzma_action enum value. + * + * \return Any valid lzma_ret. See the lzma_ret enum description for more + * information. */ extern LZMA_API(lzma_ret) lzma_code(lzma_stream *strm, lzma_action action) lzma_nothrow lzma_attr_warn_unused_result; @@ -615,15 +639,15 @@ extern LZMA_API(lzma_ret) lzma_code(lzma_stream *strm, lzma_action action) /** * \brief Free memory allocated for the coder data structures * - * \param strm Pointer to lzma_stream that is at least initialized - * with LZMA_STREAM_INIT. - * * After lzma_end(strm), strm->internal is guaranteed to be NULL. No other * members of the lzma_stream structure are touched. * * \note zlib indicates an error if application end()s unfinished * stream structure. liblzma doesn't do this, and assumes that * application knows what it is doing. + * + * \param strm Pointer to lzma_stream that is at least initialized + * with LZMA_STREAM_INIT. */ extern LZMA_API(void) lzma_end(lzma_stream *strm) lzma_nothrow; @@ -642,6 +666,11 @@ extern LZMA_API(void) lzma_end(lzma_stream *strm) lzma_nothrow; * mode by taking into account the progress made by each thread. In * single-threaded mode *progress_in and *progress_out are set to * strm->total_in and strm->total_out, respectively. + * + * \param strm Pointer to lzma_stream that is at least + * initialized with LZMA_STREAM_INIT. + * \param[out] progress_in Pointer to the number of input bytes processed. + * \param[out] progress_out Pointer to the number of output bytes processed. */ extern LZMA_API(void) lzma_get_progress(lzma_stream *strm, uint64_t *progress_in, uint64_t *progress_out) lzma_nothrow; @@ -660,6 +689,9 @@ extern LZMA_API(void) lzma_get_progress(lzma_stream *strm, * this may give misleading information if decoding .xz Streams that have * multiple Blocks, because each Block can have different memory requirements. * + * \param strm Pointer to lzma_stream that is at least initialized + * with LZMA_STREAM_INIT. + * * \return How much memory is currently allocated for the filter * decoders. If no filter chain is currently allocated, * some non-zero value is still returned, which is less than @@ -679,6 +711,9 @@ extern LZMA_API(uint64_t) lzma_memusage(const lzma_stream *strm) * This function is supported only when *strm has been initialized with * a function that takes a memlimit argument. * + * \param strm Pointer to lzma_stream that is at least initialized + * with LZMA_STREAM_INIT. + * * \return On success, the current memory usage limit is returned * (always non-zero). On error, zero is returned. */ @@ -702,7 +737,8 @@ extern LZMA_API(uint64_t) lzma_memlimit_get(const lzma_stream *strm) * after LZMA_MEMLIMIT_ERROR even if the limit was increased using * lzma_memlimit_set(). Other decoders worked correctly. * - * \return - LZMA_OK: New memory usage limit successfully set. + * \return Possible lzma_ret values: + * - LZMA_OK: New memory usage limit successfully set. * - LZMA_MEMLIMIT_ERROR: The new limit is too small. * The limit was not changed. * - LZMA_PROG_ERROR: Invalid arguments, e.g. *strm doesn't diff --git a/contrib/libs/lzma/liblzma/api/lzma/bcj.h b/contrib/libs/lzma/liblzma/api/lzma/bcj.h index a1738d93b7..0c84e0cff9 100644 --- a/contrib/libs/lzma/liblzma/api/lzma/bcj.h +++ b/contrib/libs/lzma/liblzma/api/lzma/bcj.h @@ -1,6 +1,7 @@ /** * \file lzma/bcj.h * \brief Branch/Call/Jump conversion filters + * \note Never include this file directly. Use <lzma.h> instead. */ /* @@ -8,8 +9,6 @@ * * This file has been put into the public domain. * You can do whatever you want with this file. - * - * See ../lzma.h for information about liblzma as a whole. */ #ifndef LZMA_H_INTERNAL @@ -19,43 +18,44 @@ /* Filter IDs for lzma_filter.id */ +/** + * \brief Filter for x86 binaries + */ #define LZMA_FILTER_X86 LZMA_VLI_C(0x04) - /**< - * Filter for x86 binaries - */ +/** + * \brief Filter for Big endian PowerPC binaries + */ #define LZMA_FILTER_POWERPC LZMA_VLI_C(0x05) - /**< - * Filter for Big endian PowerPC binaries - */ +/** + * \brief Filter for IA-64 (Itanium) binaries + */ #define LZMA_FILTER_IA64 LZMA_VLI_C(0x06) - /**< - * Filter for IA-64 (Itanium) binaries. - */ +/** + * \brief Filter for ARM binaries + */ #define LZMA_FILTER_ARM LZMA_VLI_C(0x07) - /**< - * Filter for ARM binaries. - */ +/** + * \brief Filter for ARM-Thumb binaries + */ #define LZMA_FILTER_ARMTHUMB LZMA_VLI_C(0x08) - /**< - * Filter for ARM-Thumb binaries. - */ +/** + * \brief Filter for SPARC binaries + */ #define LZMA_FILTER_SPARC LZMA_VLI_C(0x09) - /**< - * Filter for SPARC binaries. - */ +/** + * \brief Filter for ARM64 binaries + */ #define LZMA_FILTER_ARM64 LZMA_VLI_C(0x0A) - /**< - * Filter for ARM64 binaries. - */ + /** - * \brief Options for BCJ filters (except ARM64) + * \brief Options for BCJ filters * * The BCJ filters never change the size of the data. Specifying options * for them is optional: if pointer to options is NULL, default value is diff --git a/contrib/libs/lzma/liblzma/api/lzma/block.h b/contrib/libs/lzma/liblzma/api/lzma/block.h index 082e55833e..ec5e77a69a 100644 --- a/contrib/libs/lzma/liblzma/api/lzma/block.h +++ b/contrib/libs/lzma/liblzma/api/lzma/block.h @@ -1,6 +1,7 @@ /** * \file lzma/block.h * \brief .xz Block handling + * \note Never include this file directly. Use <lzma.h> instead. */ /* @@ -8,8 +9,6 @@ * * This file has been put into the public domain. * You can do whatever you want with this file. - * - * See ../lzma.h for information about liblzma as a whole. */ #ifndef LZMA_H_INTERNAL @@ -32,19 +31,28 @@ typedef struct { * \brief Block format version * * To prevent API and ABI breakages when new features are needed, - * a version number is used to indicate which fields in this + * a version number is used to indicate which members in this * structure are in use: * - liblzma >= 5.0.0: version = 0 is supported. * - liblzma >= 5.1.4beta: Support for version = 1 was added, - * which adds the ignore_check field. + * which adds the ignore_check member. * * If version is greater than one, most Block related functions * will return LZMA_OPTIONS_ERROR (lzma_block_header_decode() works * with any version value). * * Read by: - * - All functions that take pointer to lzma_block as argument, - * including lzma_block_header_decode(). + * - lzma_block_header_size() + * - lzma_block_header_encode() + * - lzma_block_header_decode() + * - lzma_block_compressed_size() + * - lzma_block_unpadded_size() + * - lzma_block_total_size() + * - lzma_block_encoder() + * - lzma_block_decoder() + * - lzma_block_buffer_encode() + * - lzma_block_uncomp_encode() + * - lzma_block_buffer_decode() * * Written by: * - lzma_block_header_decode() @@ -52,7 +60,7 @@ typedef struct { uint32_t version; /** - * \brief Size of the Block Header field + * \brief Size of the Block Header field in bytes * * This is always a multiple of four. * @@ -68,6 +76,7 @@ typedef struct { * Written by: * - lzma_block_header_size() * - lzma_block_buffer_encode() + * - lzma_block_uncomp_encode() */ uint32_t header_size; # define LZMA_BLOCK_HEADER_SIZE_MIN 8 @@ -143,6 +152,7 @@ typedef struct { * - lzma_block_encoder() * - lzma_block_decoder() * - lzma_block_buffer_encode() + * - lzma_block_uncomp_encode() * - lzma_block_buffer_decode() */ lzma_vli compressed_size; @@ -167,6 +177,7 @@ typedef struct { * - lzma_block_encoder() * - lzma_block_decoder() * - lzma_block_buffer_encode() + * - lzma_block_uncomp_encode() * - lzma_block_buffer_decode() */ lzma_vli uncompressed_size; @@ -212,6 +223,7 @@ typedef struct { * - lzma_block_encoder() * - lzma_block_decoder() * - lzma_block_buffer_encode() + * - lzma_block_uncomp_encode() * - lzma_block_buffer_decode() */ uint8_t raw_check[LZMA_CHECK_SIZE_MAX]; @@ -223,26 +235,56 @@ typedef struct { * with the currently supported options, so it is safe to leave these * uninitialized. */ + + /** \private Reserved member. */ void *reserved_ptr1; + + /** \private Reserved member. */ void *reserved_ptr2; + + /** \private Reserved member. */ void *reserved_ptr3; + + /** \private Reserved member. */ uint32_t reserved_int1; + + /** \private Reserved member. */ uint32_t reserved_int2; + + /** \private Reserved member. */ lzma_vli reserved_int3; + + /** \private Reserved member. */ lzma_vli reserved_int4; + + /** \private Reserved member. */ lzma_vli reserved_int5; + + /** \private Reserved member. */ lzma_vli reserved_int6; + + /** \private Reserved member. */ lzma_vli reserved_int7; + + /** \private Reserved member. */ lzma_vli reserved_int8; + + /** \private Reserved member. */ lzma_reserved_enum reserved_enum1; + + /** \private Reserved member. */ lzma_reserved_enum reserved_enum2; + + /** \private Reserved member. */ lzma_reserved_enum reserved_enum3; + + /** \private Reserved member. */ lzma_reserved_enum reserved_enum4; /** * \brief A flag to Block decoder to not verify the Check field * - * This field is supported by liblzma >= 5.1.4beta if .version >= 1. + * This member is supported by liblzma >= 5.1.4beta if .version >= 1. * * If this is set to true, the integrity check won't be calculated * and verified. Unless you know what you are doing, you should @@ -260,12 +302,25 @@ typedef struct { */ lzma_bool ignore_check; + /** \private Reserved member. */ lzma_bool reserved_bool2; + + /** \private Reserved member. */ lzma_bool reserved_bool3; + + /** \private Reserved member. */ lzma_bool reserved_bool4; + + /** \private Reserved member. */ lzma_bool reserved_bool5; + + /** \private Reserved member. */ lzma_bool reserved_bool6; + + /** \private Reserved member. */ lzma_bool reserved_bool7; + + /** \private Reserved member. */ lzma_bool reserved_bool8; } lzma_block; @@ -280,7 +335,8 @@ typedef struct { * Note that if the first byte is 0x00, it indicates beginning of Index; use * this macro only when the byte is not 0x00. * - * There is no encoding macro, because Block Header encoder is enough for that. + * There is no encoding macro because lzma_block_header_size() and + * lzma_block_header_encode() should be used. */ #define lzma_block_header_size_decode(b) (((uint32_t)(b) + 1) * 4) @@ -294,17 +350,20 @@ typedef struct { * four and doesn't exceed LZMA_BLOCK_HEADER_SIZE_MAX. Increasing header_size * just means that lzma_block_header_encode() will add Header Padding. * - * \return - LZMA_OK: Size calculated successfully and stored to - * block->header_size. - * - LZMA_OPTIONS_ERROR: Unsupported version, filters or - * filter options. - * - LZMA_PROG_ERROR: Invalid values like compressed_size == 0. - * * \note This doesn't check that all the options are valid i.e. this * may return LZMA_OK even if lzma_block_header_encode() or * lzma_block_encoder() would fail. If you want to validate the * filter chain, consider using lzma_memlimit_encoder() which as * a side-effect validates the filter chain. + * + * \param block Block options + * + * \return Possible lzma_ret values: + * - LZMA_OK: Size calculated successfully and stored to + * block->header_size. + * - LZMA_OPTIONS_ERROR: Unsupported version, filters or + * filter options. + * - LZMA_PROG_ERROR: Invalid values like compressed_size == 0. */ extern LZMA_API(lzma_ret) lzma_block_header_size(lzma_block *block) lzma_nothrow lzma_attr_warn_unused_result; @@ -318,11 +377,12 @@ extern LZMA_API(lzma_ret) lzma_block_header_size(lzma_block *block) * lzma_block_header_size() is used, the Block Header will be padded to the * specified size. * - * \param out Beginning of the output buffer. This must be - * at least block->header_size bytes. * \param block Block options to be encoded. + * \param[out] out Beginning of the output buffer. This must be + * at least block->header_size bytes. * - * \return - LZMA_OK: Encoding was successful. block->header_size + * \return Possible lzma_ret values: + * - LZMA_OK: Encoding was successful. block->header_size * bytes were written to output buffer. * - LZMA_OPTIONS_ERROR: Invalid or unsupported options. * - LZMA_PROG_ERROR: Invalid arguments, for example @@ -354,14 +414,15 @@ extern LZMA_API(lzma_ret) lzma_block_header_encode( * block->filters must have been allocated, but they don't need to be * initialized (possible existing filter options are not freed). * - * \param block Destination for Block options. + * \param[out] block Destination for Block options * \param allocator lzma_allocator for custom allocator functions. * Set to NULL to use malloc() (and also free() * if an error occurs). * \param in Beginning of the input buffer. This must be * at least block->header_size bytes. * - * \return - LZMA_OK: Decoding was successful. block->header_size + * \return Possible lzma_ret values: + * - LZMA_OK: Decoding was successful. block->header_size * bytes were read from the input buffer. * - LZMA_OPTIONS_ERROR: The Block Header specifies some * unsupported options such as unsupported filters. This can @@ -398,7 +459,12 @@ extern LZMA_API(lzma_ret) lzma_block_header_decode(lzma_block *block, * field so that it can properly validate Compressed Size if it * was present in Block Header. * - * \return - LZMA_OK: block->compressed_size was set successfully. + * \param block Block options: block->header_size must + * already be set with lzma_block_header_size(). + * \param unpadded_size Unpadded Size from the Index field in bytes + * + * \return Possible lzma_ret values: + * - LZMA_OK: block->compressed_size was set successfully. * - LZMA_DATA_ERROR: unpadded_size is too small compared to * block->header_size and lzma_check_size(block->check). * - LZMA_PROG_ERROR: Some values are invalid. For example, @@ -419,6 +485,9 @@ extern LZMA_API(lzma_ret) lzma_block_compressed_size( * Compressed Size, and size of the Check field. This is where this function * is needed. * + * \param block Block options: block->header_size must already be + * set with lzma_block_header_size(). + * * \return Unpadded Size on success, or zero on error. */ extern LZMA_API(lzma_vli) lzma_block_unpadded_size(const lzma_block *block) @@ -431,6 +500,9 @@ extern LZMA_API(lzma_vli) lzma_block_unpadded_size(const lzma_block *block) * This is equivalent to lzma_block_unpadded_size() except that the returned * value includes the size of the Block Padding field. * + * \param block Block options: block->header_size must already be + * set with lzma_block_header_size(). + * * \return On success, total encoded size of the Block. On error, * zero is returned. */ @@ -444,7 +516,17 @@ extern LZMA_API(lzma_vli) lzma_block_total_size(const lzma_block *block) * Valid actions for lzma_code() are LZMA_RUN, LZMA_SYNC_FLUSH (only if the * filter chain supports it), and LZMA_FINISH. * - * \return - LZMA_OK: All good, continue with lzma_code(). + * The Block encoder encodes the Block Data, Block Padding, and Check value. + * It does NOT encode the Block Header which can be encoded with + * lzma_block_header_encode(). + * + * \param strm Pointer to lzma_stream that is at least initialized + * with LZMA_STREAM_INIT. + * \param block Block options: block->version, block->check, + * and block->filters must have been initialized. + * + * \return Possible lzma_ret values: + * - LZMA_OK: All good, continue with lzma_code(). * - LZMA_MEM_ERROR * - LZMA_OPTIONS_ERROR * - LZMA_UNSUPPORTED_CHECK: block->check specifies a Check ID @@ -463,7 +545,16 @@ extern LZMA_API(lzma_ret) lzma_block_encoder( * Valid actions for lzma_code() are LZMA_RUN and LZMA_FINISH. Using * LZMA_FINISH is not required. It is supported only for convenience. * - * \return - LZMA_OK: All good, continue with lzma_code(). + * The Block decoder decodes the Block Data, Block Padding, and Check value. + * It does NOT decode the Block Header which can be decoded with + * lzma_block_header_decode(). + * + * \param strm Pointer to lzma_stream that is at least initialized + * with LZMA_STREAM_INIT. + * \param block Block options + * + * \return Possible lzma_ret values: + * - LZMA_OK: All good, continue with lzma_code(). * - LZMA_PROG_ERROR * - LZMA_MEM_ERROR */ @@ -477,6 +568,11 @@ extern LZMA_API(lzma_ret) lzma_block_decoder( * * This is equivalent to lzma_stream_buffer_bound() but for .xz Blocks. * See the documentation of lzma_stream_buffer_bound(). + * + * \param uncompressed_size Size of the data to be encoded with the + * single-call Block encoder. + * + * \return Maximum output size in bytes for single-call Block encoding. */ extern LZMA_API(size_t) lzma_block_buffer_bound(size_t uncompressed_size) lzma_nothrow; @@ -505,13 +601,14 @@ extern LZMA_API(size_t) lzma_block_buffer_bound(size_t uncompressed_size) * Set to NULL to use malloc() and free(). * \param in Beginning of the input buffer * \param in_size Size of the input buffer - * \param out Beginning of the output buffer - * \param out_pos The next byte will be written to out[*out_pos]. + * \param[out] out Beginning of the output buffer + * \param[out] out_pos The next byte will be written to out[*out_pos]. * *out_pos is updated only if encoding succeeds. * \param out_size Size of the out buffer; the first byte into * which no data is written to is out[out_size]. * - * \return - LZMA_OK: Encoding was successful. + * \return Possible lzma_ret values: + * - LZMA_OK: Encoding was successful. * - LZMA_BUF_ERROR: Not enough output buffer space. * - LZMA_UNSUPPORTED_CHECK * - LZMA_OPTIONS_ERROR @@ -537,6 +634,25 @@ extern LZMA_API(lzma_ret) lzma_block_buffer_encode( * Since the data won't be compressed, this function ignores block->filters. * This function doesn't take lzma_allocator because this function doesn't * allocate any memory from the heap. + * + * \param block Block options: block->version, block->check, + * and block->filters must have been initialized. + * \param in Beginning of the input buffer + * \param in_size Size of the input buffer + * \param[out] out Beginning of the output buffer + * \param[out] out_pos The next byte will be written to out[*out_pos]. + * *out_pos is updated only if encoding succeeds. + * \param out_size Size of the out buffer; the first byte into + * which no data is written to is out[out_size]. + * + * \return Possible lzma_ret values: + * - LZMA_OK: Encoding was successful. + * - LZMA_BUF_ERROR: Not enough output buffer space. + * - LZMA_UNSUPPORTED_CHECK + * - LZMA_OPTIONS_ERROR + * - LZMA_MEM_ERROR + * - LZMA_DATA_ERROR + * - LZMA_PROG_ERROR */ extern LZMA_API(lzma_ret) lzma_block_uncomp_encode(lzma_block *block, const uint8_t *in, size_t in_size, @@ -550,7 +666,7 @@ extern LZMA_API(lzma_ret) lzma_block_uncomp_encode(lzma_block *block, * This is single-call equivalent of lzma_block_decoder(), and requires that * the caller has already decoded Block Header and checked its memory usage. * - * \param block Block options just like with lzma_block_decoder(). + * \param block Block options * \param allocator lzma_allocator for custom allocator functions. * Set to NULL to use malloc() and free(). * \param in Beginning of the input buffer @@ -558,13 +674,14 @@ extern LZMA_API(lzma_ret) lzma_block_uncomp_encode(lzma_block *block, * *in_pos is updated only if decoding succeeds. * \param in_size Size of the input buffer; the first byte that * won't be read is in[in_size]. - * \param out Beginning of the output buffer - * \param out_pos The next byte will be written to out[*out_pos]. + * \param[out] out Beginning of the output buffer + * \param[out] out_pos The next byte will be written to out[*out_pos]. * *out_pos is updated only if encoding succeeds. * \param out_size Size of the out buffer; the first byte into * which no data is written to is out[out_size]. * - * \return - LZMA_OK: Decoding was successful. + * \return Possible lzma_ret values: + * - LZMA_OK: Decoding was successful. * - LZMA_OPTIONS_ERROR * - LZMA_DATA_ERROR * - LZMA_MEM_ERROR diff --git a/contrib/libs/lzma/liblzma/api/lzma/check.h b/contrib/libs/lzma/liblzma/api/lzma/check.h index 6a243db0d7..b37197d2c7 100644 --- a/contrib/libs/lzma/liblzma/api/lzma/check.h +++ b/contrib/libs/lzma/liblzma/api/lzma/check.h @@ -1,6 +1,7 @@ /** * \file lzma/check.h * \brief Integrity checks + * \note Never include this file directly. Use <lzma.h> instead. */ /* @@ -8,8 +9,6 @@ * * This file has been put into the public domain. * You can do whatever you want with this file. - * - * See ../lzma.h for information about liblzma as a whole. */ #ifndef LZMA_H_INTERNAL @@ -71,12 +70,17 @@ typedef enum { /** * \brief Test if the given Check ID is supported * - * Return true if the given Check ID is supported by this liblzma build. - * Otherwise false is returned. It is safe to call this with a value that - * is not in the range [0, 15]; in that case the return value is always false. + * LZMA_CHECK_NONE and LZMA_CHECK_CRC32 are always supported (even if + * liblzma is built with limited features). + * + * \note It is safe to call this with a value that is not in the + * range [0, 15]; in that case the return value is always false. + * + * \param check Check ID * - * You can assume that LZMA_CHECK_NONE and LZMA_CHECK_CRC32 are always - * supported (even if liblzma is built with limited features). + * \return lzma_bool: + * - true if Check ID is supported by this liblzma build. + * - false otherwise. */ extern LZMA_API(lzma_bool) lzma_check_is_supported(lzma_check check) lzma_nothrow lzma_attr_const; @@ -90,7 +94,10 @@ extern LZMA_API(lzma_bool) lzma_check_is_supported(lzma_check check) * the Check field with the specified Check ID. The values are: * { 0, 4, 4, 4, 8, 8, 8, 16, 16, 16, 32, 32, 32, 64, 64, 64 } * - * If the argument is not in the range [0, 15], UINT32_MAX is returned. + * \param check Check ID + * + * \return Size of the Check field in bytes. If the argument is not in + * the range [0, 15], UINT32_MAX is returned. */ extern LZMA_API(uint32_t) lzma_check_size(lzma_check check) lzma_nothrow lzma_attr_const; @@ -126,25 +133,32 @@ extern LZMA_API(uint32_t) lzma_crc32( * * Calculate CRC64 using the polynomial from the ECMA-182 standard. * - * This function is used similarly to lzma_crc32(). See its documentation. + * This function is used similarly to lzma_crc32(). + * + * \param buf Pointer to the input buffer + * \param size Size of the input buffer + * \param crc Previously returned CRC value. This is used to + * calculate the CRC of a big buffer in smaller chunks. + * Set to zero when starting a new calculation. + * + * \return Updated CRC value, which can be passed to this function + * again to continue CRC calculation. */ extern LZMA_API(uint64_t) lzma_crc64( const uint8_t *buf, size_t size, uint64_t crc) lzma_nothrow lzma_attr_pure; -/* - * SHA-256 functions are currently not exported to public API. - * Contact Lasse Collin if you think it should be. - */ - - /** * \brief Get the type of the integrity check * * This function can be called only immediately after lzma_code() has * returned LZMA_NO_CHECK, LZMA_UNSUPPORTED_CHECK, or LZMA_GET_CHECK. * Calling this function in any other situation has undefined behavior. + * + * \param strm Pointer to lzma_stream meeting the above conditions. + * + * \return Check ID in the lzma_stream, or undefined if called improperly. */ extern LZMA_API(lzma_check) lzma_get_check(const lzma_stream *strm) lzma_nothrow; diff --git a/contrib/libs/lzma/liblzma/api/lzma/container.h b/contrib/libs/lzma/liblzma/api/lzma/container.h index 6e432a1f3b..2849fbfd3c 100644 --- a/contrib/libs/lzma/liblzma/api/lzma/container.h +++ b/contrib/libs/lzma/liblzma/api/lzma/container.h @@ -1,6 +1,7 @@ /** * \file lzma/container.h * \brief File formats + * \note Never include this file directly. Use <lzma.h> instead. */ /* @@ -8,8 +9,6 @@ * * This file has been put into the public domain. * You can do whatever you want with this file. - * - * See ../lzma.h for information about liblzma as a whole. */ #ifndef LZMA_H_INTERNAL @@ -51,7 +50,7 @@ * * This flag modifies the preset to make the encoding significantly slower * while improving the compression ratio only marginally. This is useful - * when you don't mind wasting time to get as small result as possible. + * when you don't mind spending time to get as small result as possible. * * This flag doesn't affect the memory usage requirements of the decoder (at * least not significantly). The memory usage of the encoder may be increased @@ -72,9 +71,12 @@ typedef struct { * Encoder: No flags are currently supported. * * Decoder: Bitwise-or of zero or more of the decoder flags: - * LZMA_TELL_NO_CHECK, LZMA_TELL_UNSUPPORTED_CHECK, - * LZMA_TELL_ANY_CHECK, LZMA_IGNORE_CHECK, - * LZMA_CONCATENATED, LZMA_FAIL_FAST + * - LZMA_TELL_NO_CHECK + * - LZMA_TELL_UNSUPPORTED_CHECK + * - LZMA_TELL_ANY_CHECK + * - LZMA_IGNORE_CHECK + * - LZMA_CONCATENATED + * - LZMA_FAIL_FAST */ uint32_t flags; @@ -111,7 +113,7 @@ typedef struct { /** * \brief Timeout to allow lzma_code() to return early * - * Multithreading can make liblzma to consume input and produce + * Multithreading can make liblzma consume input and produce * output in a very bursty way: it may first read a lot of input * to fill internal buffers, then no input or output occurs for * a while. @@ -128,14 +130,13 @@ typedef struct { * LZMA_OK. Reasonable values are 100 ms or more. The xz command * line tool uses 300 ms. * - * If long blocking times are fine for you, set timeout to a special - * value of 0, which will disable the timeout mechanism and will make + * If long blocking times are acceptable, set timeout to a special + * value of 0. This will disable the timeout mechanism and will make * lzma_code() block until all the input is consumed or the output * buffer has been filled. * * \note Even with a timeout, lzma_code() might sometimes take - * somewhat long time to return. No timing guarantees - * are made. + * a long time to return. No timing guarantees are made. */ uint32_t timeout; @@ -171,12 +172,25 @@ typedef struct { * with the currently supported options, so it is safe to leave these * uninitialized. */ + /** \private Reserved member. */ lzma_reserved_enum reserved_enum1; + + /** \private Reserved member. */ lzma_reserved_enum reserved_enum2; + + /** \private Reserved member. */ lzma_reserved_enum reserved_enum3; + + /** \private Reserved member. */ uint32_t reserved_int1; + + /** \private Reserved member. */ uint32_t reserved_int2; + + /** \private Reserved member. */ uint32_t reserved_int3; + + /** \private Reserved member. */ uint32_t reserved_int4; /** @@ -222,11 +236,22 @@ typedef struct { */ uint64_t memlimit_stop; + /** \private Reserved member. */ uint64_t reserved_int7; + + /** \private Reserved member. */ uint64_t reserved_int8; + + /** \private Reserved member. */ void *reserved_ptr1; + + /** \private Reserved member. */ void *reserved_ptr2; + + /** \private Reserved member. */ void *reserved_ptr3; + + /** \private Reserved member. */ void *reserved_ptr4; } lzma_mt; @@ -240,8 +265,7 @@ typedef struct { * \param preset Compression preset (level and possible flags) * * \return Number of bytes of memory required for the given - * preset when encoding. If an error occurs, for example - * due to unsupported preset, UINT64_MAX is returned. + * preset when encoding or UINT64_MAX on error. */ extern LZMA_API(uint64_t) lzma_easy_encoder_memusage(uint32_t preset) lzma_nothrow lzma_attr_pure; @@ -255,9 +279,8 @@ extern LZMA_API(uint64_t) lzma_easy_encoder_memusage(uint32_t preset) * \param preset Compression preset (level and possible flags) * * \return Number of bytes of memory required to decompress a file - * that was compressed using the given preset. If an error - * occurs, for example due to unsupported preset, UINT64_MAX - * is returned. + * that was compressed using the given preset or UINT64_MAX + * on error. */ extern LZMA_API(uint64_t) lzma_easy_decoder_memusage(uint32_t preset) lzma_nothrow lzma_attr_pure; @@ -267,7 +290,16 @@ extern LZMA_API(uint64_t) lzma_easy_decoder_memusage(uint32_t preset) * \brief Initialize .xz Stream encoder using a preset number * * This function is intended for those who just want to use the basic features - * if liblzma (that is, most developers out there). + * of liblzma (that is, most developers out there). + * + * If initialization fails (return value is not LZMA_OK), all the memory + * allocated for *strm by liblzma is always freed. Thus, there is no need + * to call lzma_end() after failed initialization. + * + * If initialization succeeds, use lzma_code() to do the actual encoding. + * Valid values for `action' (the second argument of lzma_code()) are + * LZMA_RUN, LZMA_SYNC_FLUSH, LZMA_FULL_FLUSH, and LZMA_FINISH. In future, + * there may be compression levels or flags that don't support LZMA_SYNC_FLUSH. * * \param strm Pointer to lzma_stream that is at least initialized * with LZMA_STREAM_INIT. @@ -283,7 +315,8 @@ extern LZMA_API(uint64_t) lzma_easy_decoder_memusage(uint32_t preset) * unsure. LZMA_CHECK_CRC32 is good too as long as the * uncompressed file is not many gigabytes. * - * \return - LZMA_OK: Initialization succeeded. Use lzma_code() to + * \return Possible lzma_ret values: + * - LZMA_OK: Initialization succeeded. Use lzma_code() to * encode your data. * - LZMA_MEM_ERROR: Memory allocation failed. * - LZMA_OPTIONS_ERROR: The given compression preset is not @@ -292,15 +325,6 @@ extern LZMA_API(uint64_t) lzma_easy_decoder_memusage(uint32_t preset) * supported by this liblzma build. * - LZMA_PROG_ERROR: One or more of the parameters have values * that will never be valid. For example, strm == NULL. - * - * If initialization fails (return value is not LZMA_OK), all the memory - * allocated for *strm by liblzma is always freed. Thus, there is no need - * to call lzma_end() after failed initialization. - * - * If initialization succeeds, use lzma_code() to do the actual encoding. - * Valid values for `action' (the second argument of lzma_code()) are - * LZMA_RUN, LZMA_SYNC_FLUSH, LZMA_FULL_FLUSH, and LZMA_FINISH. In future, - * there may be compression levels or flags that don't support LZMA_SYNC_FLUSH. */ extern LZMA_API(lzma_ret) lzma_easy_encoder( lzma_stream *strm, uint32_t preset, lzma_check check) @@ -321,13 +345,14 @@ extern LZMA_API(lzma_ret) lzma_easy_encoder( * Set to NULL to use malloc() and free(). * \param in Beginning of the input buffer * \param in_size Size of the input buffer - * \param out Beginning of the output buffer - * \param out_pos The next byte will be written to out[*out_pos]. + * \param[out] out Beginning of the output buffer + * \param[out] out_pos The next byte will be written to out[*out_pos]. * *out_pos is updated only if encoding succeeds. * \param out_size Size of the out buffer; the first byte into * which no data is written to is out[out_size]. * - * \return - LZMA_OK: Encoding was successful. + * \return Possible lzma_ret values: + * - LZMA_OK: Encoding was successful. * - LZMA_BUF_ERROR: Not enough output buffer space. * - LZMA_UNSUPPORTED_CHECK * - LZMA_OPTIONS_ERROR @@ -345,14 +370,16 @@ extern LZMA_API(lzma_ret) lzma_easy_buffer_encode( /** * \brief Initialize .xz Stream encoder using a custom filter chain * - * \param strm Pointer to properly prepared lzma_stream - * \param filters Array of filters. This must be terminated with - * filters[n].id = LZMA_VLI_UNKNOWN. See filter.h for - * more information. + * \param strm Pointer to lzma_stream that is at least initialized + * with LZMA_STREAM_INIT. + * \param filters Array of filters terminated with + * .id == LZMA_VLI_UNKNOWN. See filters.h for more + * information. * \param check Type of the integrity check to calculate from * uncompressed data. * - * \return - LZMA_OK: Initialization was successful. + * \return Possible lzma_ret values: + * - LZMA_OK: Initialization was successful. * - LZMA_MEM_ERROR * - LZMA_UNSUPPORTED_CHECK * - LZMA_OPTIONS_ERROR @@ -392,10 +419,12 @@ extern LZMA_API(uint64_t) lzma_stream_encoder_mt_memusage( * LZMA_FULL_BARRIER, and LZMA_FINISH. Support for LZMA_SYNC_FLUSH might be * added in the future. * - * \param strm Pointer to properly prepared lzma_stream + * \param strm Pointer to lzma_stream that is at least initialized + * with LZMA_STREAM_INIT. * \param options Pointer to multithreaded compression options * - * \return - LZMA_OK + * \return Possible lzma_ret values: + * - LZMA_OK * - LZMA_MEM_ERROR * - LZMA_UNSUPPORTED_CHECK * - LZMA_OPTIONS_ERROR @@ -421,7 +450,12 @@ extern LZMA_API(lzma_ret) lzma_stream_encoder_mt( * No kind of flushing is supported, because the file format doesn't make * it possible. * - * \return - LZMA_OK + * \param strm Pointer to lzma_stream that is at least initialized + * with LZMA_STREAM_INIT. + * \param options Pointer to encoder options + * + * \return Possible lzma_ret values: + * - LZMA_OK * - LZMA_MEM_ERROR * - LZMA_OPTIONS_ERROR * - LZMA_PROG_ERROR @@ -434,7 +468,7 @@ extern LZMA_API(lzma_ret) lzma_alone_encoder( /** * \brief Calculate output buffer size for single-call Stream encoder * - * When trying to compress uncompressible data, the encoded size will be + * When trying to compress incompressible data, the encoded size will be * slightly bigger than the input data. This function calculates how much * output buffer space is required to be sure that lzma_stream_buffer_encode() * doesn't return LZMA_BUF_ERROR. @@ -450,8 +484,13 @@ extern LZMA_API(lzma_ret) lzma_alone_encoder( * \note The limit calculated by this function applies only to * single-call encoding. Multi-call encoding may (and probably * will) have larger maximum expansion when encoding - * uncompressible data. Currently there is no function to + * incompressible data. Currently there is no function to * calculate the maximum expansion of multi-call encoding. + * + * \param uncompressed_size Size in bytes of the uncompressed + * input data + * + * \return Maximum number of bytes needed to store the compressed data. */ extern LZMA_API(size_t) lzma_stream_buffer_bound(size_t uncompressed_size) lzma_nothrow; @@ -460,22 +499,23 @@ extern LZMA_API(size_t) lzma_stream_buffer_bound(size_t uncompressed_size) /** * \brief Single-call .xz Stream encoder * - * \param filters Array of filters. This must be terminated with - * filters[n].id = LZMA_VLI_UNKNOWN. See filter.h - * for more information. + * \param filters Array of filters terminated with + * .id == LZMA_VLI_UNKNOWN. See filters.h for more + * information. * \param check Type of the integrity check to calculate from * uncompressed data. * \param allocator lzma_allocator for custom allocator functions. * Set to NULL to use malloc() and free(). * \param in Beginning of the input buffer * \param in_size Size of the input buffer - * \param out Beginning of the output buffer - * \param out_pos The next byte will be written to out[*out_pos]. + * \param[out] out Beginning of the output buffer + * \param[out] out_pos The next byte will be written to out[*out_pos]. * *out_pos is updated only if encoding succeeds. * \param out_size Size of the out buffer; the first byte into * which no data is written to is out[out_size]. * - * \return - LZMA_OK: Encoding was successful. + * \return Possible lzma_ret values: + * - LZMA_OK: Encoding was successful. * - LZMA_BUF_ERROR: Not enough output buffer space. * - LZMA_UNSUPPORTED_CHECK * - LZMA_OPTIONS_ERROR @@ -531,7 +571,12 @@ extern LZMA_API(lzma_ret) lzma_stream_buffer_encode( * uses too where many small streams are needed. XZ Embedded includes a * decoder for this format. * - * \return - LZMA_STREAM_END: All good. Check the amounts of input used + * \param strm Pointer to lzma_stream that is at least initialized + * with LZMA_STREAM_INIT. + * \param options Pointer to encoder options + * + * \return Possible lzma_ret values: + * - LZMA_STREAM_END: All good. Check the amounts of input used * and output produced. Store the amount of input used * (uncompressed size) as it needs to be known to decompress * the data. @@ -542,7 +587,8 @@ extern LZMA_API(lzma_ret) lzma_stream_buffer_encode( * output space (6 bytes) to create a valid MicroLZMA stream. */ extern LZMA_API(lzma_ret) lzma_microlzma_encoder( - lzma_stream *strm, const lzma_options_lzma *options); + lzma_stream *strm, const lzma_options_lzma *options) + lzma_nothrow; /************ @@ -648,7 +694,8 @@ extern LZMA_API(lzma_ret) lzma_microlzma_encoder( /** * \brief Initialize .xz Stream decoder * - * \param strm Pointer to properly prepared lzma_stream + * \param strm Pointer to lzma_stream that is at least initialized + * with LZMA_STREAM_INIT. * \param memlimit Memory usage limit as bytes. Use UINT64_MAX * to effectively disable the limiter. liblzma * 5.2.3 and earlier don't allow 0 here and return @@ -659,7 +706,8 @@ extern LZMA_API(lzma_ret) lzma_microlzma_encoder( * LZMA_TELL_ANY_CHECK, LZMA_IGNORE_CHECK, * LZMA_CONCATENATED, LZMA_FAIL_FAST * - * \return - LZMA_OK: Initialization was successful. + * \return Possible lzma_ret values: + * - LZMA_OK: Initialization was successful. * - LZMA_MEM_ERROR: Cannot allocate memory. * - LZMA_OPTIONS_ERROR: Unsupported flags * - LZMA_PROG_ERROR @@ -672,9 +720,6 @@ extern LZMA_API(lzma_ret) lzma_stream_decoder( /** * \brief Initialize multithreaded .xz Stream decoder * - * \param strm Pointer to properly prepared lzma_stream - * \param options Pointer to multithreaded compression options - * * The decoder can decode multiple Blocks in parallel. This requires that each * Block Header contains the Compressed Size and Uncompressed size fields * which are added by the multi-threaded encoder, see lzma_stream_encoder_mt(). @@ -688,7 +733,12 @@ extern LZMA_API(lzma_ret) lzma_stream_decoder( * This function behaves like lzma_stream_decoder() when options->threads == 1 * and options->memlimit_threading <= 1. * - * \return - LZMA_OK: Initialization was successful. + * \param strm Pointer to lzma_stream that is at least initialized + * with LZMA_STREAM_INIT. + * \param options Pointer to multithreaded compression options + * + * \return Possible lzma_ret values: + * - LZMA_OK: Initialization was successful. * - LZMA_MEM_ERROR: Cannot allocate memory. * - LZMA_MEMLIMIT_ERROR: Memory usage limit was reached. * - LZMA_OPTIONS_ERROR: Unsupported flags. @@ -715,7 +765,8 @@ extern LZMA_API(lzma_ret) lzma_stream_decoder_mt( * as it doesn't support any decoder flags. It will return LZMA_STREAM_END * after one .lzma stream.) * - * \param strm Pointer to properly prepared lzma_stream + * \param strm Pointer to lzma_stream that is at least initialized + * with LZMA_STREAM_INIT. * \param memlimit Memory usage limit as bytes. Use UINT64_MAX * to effectively disable the limiter. liblzma * 5.2.3 and earlier don't allow 0 here and return @@ -726,7 +777,8 @@ extern LZMA_API(lzma_ret) lzma_stream_decoder_mt( * LZMA_TELL_ANY_CHECK, LZMA_IGNORE_CHECK, * LZMA_CONCATENATED, LZMA_FAIL_FAST * - * \return - LZMA_OK: Initialization was successful. + * \return Possible lzma_ret values: + * - LZMA_OK: Initialization was successful. * - LZMA_MEM_ERROR: Cannot allocate memory. * - LZMA_OPTIONS_ERROR: Unsupported flags * - LZMA_PROG_ERROR @@ -739,18 +791,20 @@ extern LZMA_API(lzma_ret) lzma_auto_decoder( /** * \brief Initialize .lzma decoder (legacy file format) * - * \param strm Pointer to properly prepared lzma_stream + * Valid `action' arguments to lzma_code() are LZMA_RUN and LZMA_FINISH. + * There is no need to use LZMA_FINISH, but it's allowed because it may + * simplify certain types of applications. + * + * \param strm Pointer to lzma_stream that is at least initialized + * with LZMA_STREAM_INIT. * \param memlimit Memory usage limit as bytes. Use UINT64_MAX * to effectively disable the limiter. liblzma * 5.2.3 and earlier don't allow 0 here and return * LZMA_PROG_ERROR; later versions treat 0 as if 1 * had been specified. * - * Valid `action' arguments to lzma_code() are LZMA_RUN and LZMA_FINISH. - * There is no need to use LZMA_FINISH, but it's allowed because it may - * simplify certain types of applications. - * - * \return - LZMA_OK + * \return Possible lzma_ret values: + * - LZMA_OK * - LZMA_MEM_ERROR * - LZMA_PROG_ERROR */ @@ -762,18 +816,6 @@ extern LZMA_API(lzma_ret) lzma_alone_decoder( /** * \brief Initialize .lz (lzip) decoder (a foreign file format) * - * \param strm Pointer to properly prepared lzma_stream - * \param memlimit Memory usage limit as bytes. Use UINT64_MAX - * to effectively disable the limiter. - * \param flags Bitwise-or of flags, or zero for no flags. - * All decoder flags listed above are supported - * although only LZMA_CONCATENATED and (in very rare - * cases) LZMA_IGNORE_CHECK are actually useful. - * LZMA_TELL_NO_CHECK, LZMA_TELL_UNSUPPORTED_CHECK, - * and LZMA_FAIL_FAST do nothing. LZMA_TELL_ANY_CHECK - * is supported for consistency only as CRC32 is - * always used in the .lz format. - * * This decoder supports the .lz format version 0 and the unextended .lz * format version 1: * @@ -807,7 +849,21 @@ extern LZMA_API(lzma_ret) lzma_alone_decoder( * one should ensure that none of the first four bytes of trailing data are * equal to the magic bytes because lzip >= 1.20 requires it by default. * - * \return - LZMA_OK: Initialization was successful. + * \param strm Pointer to lzma_stream that is at least initialized + * with LZMA_STREAM_INIT. + * \param memlimit Memory usage limit as bytes. Use UINT64_MAX + * to effectively disable the limiter. + * \param flags Bitwise-or of flags, or zero for no flags. + * All decoder flags listed above are supported + * although only LZMA_CONCATENATED and (in very rare + * cases) LZMA_IGNORE_CHECK are actually useful. + * LZMA_TELL_NO_CHECK, LZMA_TELL_UNSUPPORTED_CHECK, + * and LZMA_FAIL_FAST do nothing. LZMA_TELL_ANY_CHECK + * is supported for consistency only as CRC32 is + * always used in the .lz format. + * + * \return Possible lzma_ret values: + * - LZMA_OK: Initialization was successful. * - LZMA_MEM_ERROR: Cannot allocate memory. * - LZMA_OPTIONS_ERROR: Unsupported flags * - LZMA_PROG_ERROR @@ -836,13 +892,14 @@ extern LZMA_API(lzma_ret) lzma_lzip_decoder( * *in_pos is updated only if decoding succeeds. * \param in_size Size of the input buffer; the first byte that * won't be read is in[in_size]. - * \param out Beginning of the output buffer - * \param out_pos The next byte will be written to out[*out_pos]. + * \param[out] out Beginning of the output buffer + * \param[out] out_pos The next byte will be written to out[*out_pos]. * *out_pos is updated only if decoding succeeds. * \param out_size Size of the out buffer; the first byte into * which no data is written to is out[out_size]. * - * \return - LZMA_OK: Decoding was successful. + * \return Possible lzma_ret values: + * - LZMA_OK: Decoding was successful. * - LZMA_FORMAT_ERROR * - LZMA_OPTIONS_ERROR * - LZMA_DATA_ERROR @@ -867,12 +924,13 @@ extern LZMA_API(lzma_ret) lzma_stream_buffer_decode( /** * \brief MicroLZMA decoder * - * See lzma_microlzma_decoder() for more information. + * See lzma_microlzma_encoder() for more information. * * The lzma_code() usage with this decoder is completely normal. The * special behavior of lzma_code() applies to lzma_microlzma_encoder() only. * - * \param strm Pointer to properly prepared lzma_stream + * \param strm Pointer to lzma_stream that is at least initialized + * with LZMA_STREAM_INIT. * \param comp_size Compressed size of the MicroLZMA stream. * The caller must somehow know this exactly. * \param uncomp_size Uncompressed size of the MicroLZMA stream. @@ -897,8 +955,14 @@ extern LZMA_API(lzma_ret) lzma_stream_buffer_decode( * the implementation in XZ Embedded it doesn't * affect the memory usage if one specifies bigger * dictionary than actually required.) + * + * \return Possible lzma_ret values: + * - LZMA_OK + * - LZMA_MEM_ERROR + * - LZMA_OPTIONS_ERROR + * - LZMA_PROG_ERROR */ extern LZMA_API(lzma_ret) lzma_microlzma_decoder( lzma_stream *strm, uint64_t comp_size, uint64_t uncomp_size, lzma_bool uncomp_size_is_exact, - uint32_t dict_size); + uint32_t dict_size) lzma_nothrow; diff --git a/contrib/libs/lzma/liblzma/api/lzma/delta.h b/contrib/libs/lzma/liblzma/api/lzma/delta.h index 592fc4f849..7a725bc407 100644 --- a/contrib/libs/lzma/liblzma/api/lzma/delta.h +++ b/contrib/libs/lzma/liblzma/api/lzma/delta.h @@ -1,6 +1,7 @@ /** * \file lzma/delta.h * \brief Delta filter + * \note Never include this file directly. Use <lzma.h> instead. */ /* @@ -8,8 +9,6 @@ * * This file has been put into the public domain. * You can do whatever you want with this file. - * - * See ../lzma.h for information about liblzma as a whole. */ #ifndef LZMA_H_INTERNAL @@ -57,7 +56,15 @@ typedef struct { * - 24-bit RGB image data: distance = 3 bytes */ uint32_t dist; + + /** + * \brief Minimum value for lzma_options_delta.dist. + */ # define LZMA_DELTA_DIST_MIN 1 + + /** + * \brief Maximum value for lzma_options_delta.dist. + */ # define LZMA_DELTA_DIST_MAX 256 /* @@ -67,11 +74,23 @@ typedef struct { * when type is LZMA_DELTA_TYPE_BYTE, so it is safe to leave these * uninitialized. */ + + /** \private Reserved member. */ uint32_t reserved_int1; + + /** \private Reserved member. */ uint32_t reserved_int2; + + /** \private Reserved member. */ uint32_t reserved_int3; + + /** \private Reserved member. */ uint32_t reserved_int4; + + /** \private Reserved member. */ void *reserved_ptr1; + + /** \private Reserved member. */ void *reserved_ptr2; } lzma_options_delta; diff --git a/contrib/libs/lzma/liblzma/api/lzma/filter.h b/contrib/libs/lzma/liblzma/api/lzma/filter.h index 58c83bf7ed..1d887b4f2f 100644 --- a/contrib/libs/lzma/liblzma/api/lzma/filter.h +++ b/contrib/libs/lzma/liblzma/api/lzma/filter.h @@ -1,6 +1,7 @@ /** * \file lzma/filter.h * \brief Common filter related types and functions + * \note Never include this file directly. Use <lzma.h> instead. */ /* @@ -8,8 +9,6 @@ * * This file has been put into the public domain. * You can do whatever you want with this file. - * - * See ../lzma.h for information about liblzma as a whole. */ #ifndef LZMA_H_INTERNAL @@ -29,7 +28,7 @@ /** * \brief Filter options * - * This structure is used to pass Filter ID and a pointer filter's + * This structure is used to pass a Filter ID and a pointer to the filter's * options to liblzma. A few functions work with a single lzma_filter * structure, while most functions expect a filter chain. * @@ -37,8 +36,8 @@ * The array is terminated with .id = LZMA_VLI_UNKNOWN. Thus, the filter * array must have LZMA_FILTERS_MAX + 1 elements (that is, five) to * be able to hold any arbitrary filter chain. This is important when - * using lzma_block_header_decode() from block.h, because too small - * array would make liblzma write past the end of the filters array. + * using lzma_block_header_decode() from block.h, because a filter array + * that is too small would make liblzma write past the end of the array. */ typedef struct { /** @@ -68,12 +67,12 @@ typedef struct { /** * \brief Test if the given Filter ID is supported for encoding * - * Return true if the give Filter ID is supported for encoding by this - * liblzma build. Otherwise false is returned. + * \param id Filter ID * - * There is no way to list which filters are available in this particular - * liblzma version and build. It would be useless, because the application - * couldn't know what kind of options the filter would need. + * \return lzma_bool: + * - true if the Filter ID is supported for encoding by this + * liblzma build. + * - false otherwise. */ extern LZMA_API(lzma_bool) lzma_filter_encoder_is_supported(lzma_vli id) lzma_nothrow lzma_attr_const; @@ -82,8 +81,12 @@ extern LZMA_API(lzma_bool) lzma_filter_encoder_is_supported(lzma_vli id) /** * \brief Test if the given Filter ID is supported for decoding * - * Return true if the give Filter ID is supported for decoding by this - * liblzma build. Otherwise false is returned. + * \param id Filter ID + * + * \return lzma_bool: + * - true if the Filter ID is supported for decoding by this + * liblzma build. + * - false otherwise. */ extern LZMA_API(lzma_bool) lzma_filter_decoder_is_supported(lzma_vli id) lzma_nothrow lzma_attr_const; @@ -112,7 +115,14 @@ extern LZMA_API(lzma_bool) lzma_filter_decoder_is_supported(lzma_vli id) * array and leave its contents in an undefined state if an error occurs. * liblzma 5.2.7 and newer only modify the dest array when returning LZMA_OK. * - * \return - LZMA_OK + * \param src Array of filters terminated with + * .id == LZMA_VLI_UNKNOWN. + * \param[out] dest Destination filter array + * \param allocator lzma_allocator for custom allocator functions. + * Set to NULL to use malloc() and free(). + * + * \return Possible lzma_ret values: + * - LZMA_OK * - LZMA_MEM_ERROR * - LZMA_OPTIONS_ERROR: Unsupported Filter ID and its options * is not NULL. @@ -137,8 +147,13 @@ extern LZMA_API(lzma_ret) lzma_filters_copy( * - options will be set to NULL. * - id will be set to LZMA_VLI_UNKNOWN. * - * If filters is NULL, this does nothing but remember that this never frees - * the filters array itself. + * If filters is NULL, this does nothing. Again, this never frees the + * filters array itself. + * + * \param filters Array of filters terminated with + * .id == LZMA_VLI_UNKNOWN. + * \param allocator lzma_allocator for custom allocator functions. + * Set to NULL to use malloc() and free(). */ extern LZMA_API(void) lzma_filters_free( lzma_filter *filters, const lzma_allocator *allocator) @@ -156,9 +171,7 @@ extern LZMA_API(void) lzma_filters_free( * .id == LZMA_VLI_UNKNOWN. * * \return Number of bytes of memory required for the given - * filter chain when encoding. If an error occurs, - * for example due to unsupported filter chain, - * UINT64_MAX is returned. + * filter chain when encoding or UINT64_MAX on error. */ extern LZMA_API(uint64_t) lzma_raw_encoder_memusage(const lzma_filter *filters) lzma_nothrow lzma_attr_pure; @@ -175,9 +188,7 @@ extern LZMA_API(uint64_t) lzma_raw_encoder_memusage(const lzma_filter *filters) * .id == LZMA_VLI_UNKNOWN. * * \return Number of bytes of memory required for the given - * filter chain when decoding. If an error occurs, - * for example due to unsupported filter chain, - * UINT64_MAX is returned. + * filter chain when decoding or UINT64_MAX on error. */ extern LZMA_API(uint64_t) lzma_raw_decoder_memusage(const lzma_filter *filters) lzma_nothrow lzma_attr_pure; @@ -188,14 +199,16 @@ extern LZMA_API(uint64_t) lzma_raw_decoder_memusage(const lzma_filter *filters) * * This function may be useful when implementing custom file formats. * - * \param strm Pointer to properly prepared lzma_stream - * \param filters Array of lzma_filter structures. The end of the - * array must be marked with .id = LZMA_VLI_UNKNOWN. - * * The `action' with lzma_code() can be LZMA_RUN, LZMA_SYNC_FLUSH (if the * filter chain supports it), or LZMA_FINISH. * - * \return - LZMA_OK + * \param strm Pointer to lzma_stream that is at least + * initialized with LZMA_STREAM_INIT. + * \param filters Array of filters terminated with + * .id == LZMA_VLI_UNKNOWN. + * + * \return Possible lzma_ret values: + * - LZMA_OK * - LZMA_MEM_ERROR * - LZMA_OPTIONS_ERROR * - LZMA_PROG_ERROR @@ -213,7 +226,13 @@ extern LZMA_API(lzma_ret) lzma_raw_encoder( * The `action' with lzma_code() can be LZMA_RUN or LZMA_FINISH. Using * LZMA_FINISH is not required, it is supported just for convenience. * - * \return - LZMA_OK + * \param strm Pointer to lzma_stream that is at least + * initialized with LZMA_STREAM_INIT. + * \param filters Array of filters terminated with + * .id == LZMA_VLI_UNKNOWN. + * + * \return Possible lzma_ret values: + * - LZMA_OK * - LZMA_MEM_ERROR * - LZMA_OPTIONS_ERROR * - LZMA_PROG_ERROR @@ -235,7 +254,7 @@ extern LZMA_API(lzma_ret) lzma_raw_decoder( * chain to be used for the next Block(s). * * - After LZMA_SYNC_FLUSH: Raw encoder (lzma_raw_encoder()), - * Block encocder (lzma_block_encoder()), and single-threaded .xz Stream + * Block encoder (lzma_block_encoder()), and single-threaded .xz Stream * encoder (lzma_stream_encoder()) allow changing certain filter-specific * options in the middle of encoding. The actual filters in the chain * (Filter IDs) must not be changed! Currently only the lc, lp, and pb @@ -249,7 +268,13 @@ extern LZMA_API(lzma_ret) lzma_raw_decoder( * as if LZMA_FULL_FLUSH (Stream encoders) or LZMA_SYNC_FLUSH (Raw or Block * encoder) had been used right before calling this function. * - * \return - LZMA_OK + * \param strm Pointer to lzma_stream that is at least + * initialized with LZMA_STREAM_INIT. + * \param filters Array of filters terminated with + * .id == LZMA_VLI_UNKNOWN. + * + * \return Possible lzma_ret values: + * - LZMA_OK * - LZMA_MEM_ERROR * - LZMA_MEMLIMIT_ERROR * - LZMA_OPTIONS_ERROR @@ -262,29 +287,30 @@ extern LZMA_API(lzma_ret) lzma_filters_update( /** * \brief Single-call raw encoder * - * \param filters Array of lzma_filter structures. The end of the - * array must be marked with .id = LZMA_VLI_UNKNOWN. + * \note There is no function to calculate how big output buffer + * would surely be big enough. (lzma_stream_buffer_bound() + * works only for lzma_stream_buffer_encode(); raw encoder + * won't necessarily meet that bound.) + * + * \param filters Array of filters terminated with + * .id == LZMA_VLI_UNKNOWN. * \param allocator lzma_allocator for custom allocator functions. * Set to NULL to use malloc() and free(). * \param in Beginning of the input buffer * \param in_size Size of the input buffer - * \param out Beginning of the output buffer - * \param out_pos The next byte will be written to out[*out_pos]. + * \param[out] out Beginning of the output buffer + * \param[out] out_pos The next byte will be written to out[*out_pos]. * *out_pos is updated only if encoding succeeds. * \param out_size Size of the out buffer; the first byte into * which no data is written to is out[out_size]. * - * \return - LZMA_OK: Encoding was successful. + * \return Possible lzma_ret values: + * - LZMA_OK: Encoding was successful. * - LZMA_BUF_ERROR: Not enough output buffer space. * - LZMA_OPTIONS_ERROR * - LZMA_MEM_ERROR * - LZMA_DATA_ERROR * - LZMA_PROG_ERROR - * - * \note There is no function to calculate how big output buffer - * would surely be big enough. (lzma_stream_buffer_bound() - * works only for lzma_stream_buffer_encode(); raw encoder - * won't necessarily meet that bound.) */ extern LZMA_API(lzma_ret) lzma_raw_buffer_encode( const lzma_filter *filters, const lzma_allocator *allocator, @@ -295,8 +321,8 @@ extern LZMA_API(lzma_ret) lzma_raw_buffer_encode( /** * \brief Single-call raw decoder * - * \param filters Array of lzma_filter structures. The end of the - * array must be marked with .id = LZMA_VLI_UNKNOWN. + * \param filters Array of filters terminated with + * .id == LZMA_VLI_UNKNOWN. * \param allocator lzma_allocator for custom allocator functions. * Set to NULL to use malloc() and free(). * \param in Beginning of the input buffer @@ -304,11 +330,19 @@ extern LZMA_API(lzma_ret) lzma_raw_buffer_encode( * *in_pos is updated only if decoding succeeds. * \param in_size Size of the input buffer; the first byte that * won't be read is in[in_size]. - * \param out Beginning of the output buffer - * \param out_pos The next byte will be written to out[*out_pos]. + * \param[out] out Beginning of the output buffer + * \param[out] out_pos The next byte will be written to out[*out_pos]. * *out_pos is updated only if encoding succeeds. * \param out_size Size of the out buffer; the first byte into * which no data is written to is out[out_size]. + * + * \return Possible lzma_ret values: + * - LZMA_OK: Decoding was successful. + * - LZMA_BUF_ERROR: Not enough output buffer space. + * - LZMA_OPTIONS_ERROR + * - LZMA_MEM_ERROR + * - LZMA_DATA_ERROR + * - LZMA_PROG_ERROR */ extern LZMA_API(lzma_ret) lzma_raw_buffer_decode( const lzma_filter *filters, const lzma_allocator *allocator, @@ -322,18 +356,19 @@ extern LZMA_API(lzma_ret) lzma_raw_buffer_decode( * This function may be useful when implementing custom file formats * using the raw encoder and decoder. * - * \param size Pointer to uint32_t to hold the size of the properties + * \note This function validates the Filter ID, but does not + * necessarily validate the options. Thus, it is possible + * that this returns LZMA_OK while the following call to + * lzma_properties_encode() returns LZMA_OPTIONS_ERROR. + * + * \param[out] size Pointer to uint32_t to hold the size of the properties * \param filter Filter ID and options (the size of the properties may * vary depending on the options) * - * \return - LZMA_OK + * \return Possible lzma_ret values: + * - LZMA_OK * - LZMA_OPTIONS_ERROR * - LZMA_PROG_ERROR - * - * \note This function validates the Filter ID, but does not - * necessarily validate the options. Thus, it is possible - * that this returns LZMA_OK while the following call to - * lzma_properties_encode() returns LZMA_OPTIONS_ERROR. */ extern LZMA_API(lzma_ret) lzma_properties_size( uint32_t *size, const lzma_filter *filter) lzma_nothrow; @@ -342,15 +377,6 @@ extern LZMA_API(lzma_ret) lzma_properties_size( /** * \brief Encode the Filter Properties field * - * \param filter Filter ID and options - * \param props Buffer to hold the encoded options. The size of - * buffer must have been already determined with - * lzma_properties_size(). - * - * \return - LZMA_OK - * - LZMA_OPTIONS_ERROR - * - LZMA_PROG_ERROR - * * \note Even this function won't validate more options than actually * necessary. Thus, it is possible that encoding the properties * succeeds but using the same options to initialize the encoder @@ -360,6 +386,15 @@ extern LZMA_API(lzma_ret) lzma_properties_size( * of the Filter Properties field is zero, calling * lzma_properties_encode() is not required, but it * won't do any harm either. + * + * \param filter Filter ID and options + * \param[out] props Buffer to hold the encoded options. The size of + * the buffer must have been already determined with + * lzma_properties_size(). + * + * \return Possible lzma_ret values: + * - LZMA_OK + * - LZMA_PROG_ERROR */ extern LZMA_API(lzma_ret) lzma_properties_encode( const lzma_filter *filter, uint8_t *props) lzma_nothrow; @@ -375,15 +410,16 @@ extern LZMA_API(lzma_ret) lzma_properties_encode( * it's application's responsibility to free it when * appropriate. filter->options is set to NULL if * there are no properties or if an error occurs. - * \param allocator Custom memory allocator used to allocate the - * options. Set to NULL to use the default malloc(), + * \param allocator lzma_allocator for custom allocator functions. + * Set to NULL to use malloc() and free(). * and in case of an error, also free(). * \param props Input buffer containing the properties. * \param props_size Size of the properties. This must be the exact * size; giving too much or too little input will * return LZMA_OPTIONS_ERROR. * - * \return - LZMA_OK + * \return Possible lzma_ret values: + * - LZMA_OK * - LZMA_OPTIONS_ERROR * - LZMA_MEM_ERROR */ @@ -398,18 +434,19 @@ extern LZMA_API(lzma_ret) lzma_properties_decode( * Knowing the size of Filter Flags is useful to know when allocating * memory to hold the encoded Filter Flags. * - * \param size Pointer to integer to hold the calculated size + * \note If you need to calculate size of List of Filter Flags, + * you need to loop over every lzma_filter entry. + * + * \param[out] size Pointer to integer to hold the calculated size * \param filter Filter ID and associated options whose encoded * size is to be calculated * - * \return - LZMA_OK: *size set successfully. Note that this doesn't + * \return Possible lzma_ret values: + * - LZMA_OK: *size set successfully. Note that this doesn't * guarantee that filter->options is valid, thus * lzma_filter_flags_encode() may still fail. * - LZMA_OPTIONS_ERROR: Unknown Filter ID or unsupported options. * - LZMA_PROG_ERROR: Invalid options - * - * \note If you need to calculate size of List of Filter Flags, - * you need to loop over every lzma_filter entry. */ extern LZMA_API(lzma_ret) lzma_filter_flags_size( uint32_t *size, const lzma_filter *filter) @@ -423,12 +460,13 @@ extern LZMA_API(lzma_ret) lzma_filter_flags_size( * This is due to how this function is used internally by liblzma. * * \param filter Filter ID and options to be encoded - * \param out Beginning of the output buffer - * \param out_pos out[*out_pos] is the next write position. This + * \param[out] out Beginning of the output buffer + * \param[out] out_pos out[*out_pos] is the next write position. This * is updated by the encoder. * \param out_size out[out_size] is the first byte to not write. * - * \return - LZMA_OK: Encoding was successful. + * \return Possible lzma_ret values: + * - LZMA_OK: Encoding was successful. * - LZMA_OPTIONS_ERROR: Invalid or unsupported options. * - LZMA_PROG_ERROR: Invalid options or not enough output * buffer space (you should have checked it with @@ -443,11 +481,26 @@ extern LZMA_API(lzma_ret) lzma_filter_flags_encode(const lzma_filter *filter, * \brief Decode Filter Flags from given buffer * * The decoded result is stored into *filter. The old value of - * filter->options is not free()d. + * filter->options is not free()d. If anything other than LZMA_OK + * is returned, filter->options is set to NULL. + * + * \param[out] filter Destination filter. The decoded Filter ID will + * be stored in filter->id. If options are needed + * they will be allocated and the pointer will be + * stored in filter->options. + * \param allocator lzma_allocator for custom allocator functions. + * Set to NULL to use malloc() and free(). + * \param in Beginning of the input buffer + * \param[out] in_pos The next byte will be read from in[*in_pos]. + * *in_pos is updated only if decoding succeeds. + * \param in_size Size of the input buffer; the first byte that + * won't be read is in[in_size]. * - * \return - LZMA_OK + * \return Possible lzma_ret values: + * - LZMA_OK * - LZMA_OPTIONS_ERROR * - LZMA_MEM_ERROR + * - LZMA_DATA_ERROR * - LZMA_PROG_ERROR */ extern LZMA_API(lzma_ret) lzma_filter_flags_decode( @@ -474,8 +527,9 @@ extern LZMA_API(lzma_ret) lzma_filter_flags_decode( * * By default lzma_str_to_filters() can return an error if the filter chain * as a whole isn't usable in the .xz format or in the raw encoder or decoder. - * With this flag the validation is skipped (this doesn't affect the handling - * of the individual filter options). + * With this flag, this validation is skipped. This flag doesn't affect the + * handling of the individual filter options. To allow non-.xz filters also + * LZMA_STR_ALL_FILTERS is needed. */ #define LZMA_STR_NO_VALIDATION UINT32_C(0x02) @@ -573,22 +627,40 @@ extern LZMA_API(lzma_ret) lzma_filter_flags_decode( * lzma_str_list_filters(). See the xz man page for the description * of filter names and options. * + * For command line applications, below is an example how an error message + * can be displayed. Note the use of an empty string for the field width. + * If "^" was used there it would create an off-by-one error except at + * the very beginning of the line. + * + * \code{.c} + * const char *str = ...; // From user + * lzma_filter filters[LZMA_FILTERS_MAX + 1]; + * int pos; + * const char *msg = lzma_str_to_filters(str, &pos, filters, 0, NULL); + * if (msg != NULL) { + * printf("%s: Error in XZ compression options:\n", argv[0]); + * printf("%s: %s\n", argv[0], str); + * printf("%s: %*s^\n", argv[0], errpos, ""); + * printf("%s: %s\n", argv[0], msg); + * } + * \endcode + * * \param str User-supplied string describing a preset or * a filter chain. If a default value is needed and * you don't know what would be good, use "6" since * that is the default preset in xz too. - * \param error_pos If this isn't NULL, this value will be set on + * \param[out] error_pos If this isn't NULL, this value will be set on * both success and on all errors. This tells the * location of the error in the string. This is * an int to make it straightforward to use this * as printf() field width. The value is guaranteed * to be in the range [0, INT_MAX] even if strlen(str) * somehow was greater than INT_MAX. - * \param filters An array of lzma_filter structures. There must + * \param[out] filters An array of lzma_filter structures. There must * be LZMA_FILTERS_MAX + 1 (that is, five) elements * in the array. The old contents are ignored so it * doesn't need to be initialized. This array is - * modified only if this function returns LZMA_OK. + * modified only if this function returns NULL. * Once the allocated filter options are no longer * needed, lzma_filters_free() can be used to free the * options (it doesn't free the filters array itself). @@ -600,24 +672,6 @@ extern LZMA_API(lzma_ret) lzma_filter_flags_decode( * \return On success, NULL is returned. On error, a statically-allocated * error message is returned which together with the error_pos * should give some idea what is wrong. - * - * For command line applications, below is an example how an error message - * can be displayed. Note the use of an empty string for the field width. - * If "^" was used there it would create an off-by-one error except at - * the very beginning of the line. - * - * \code{.c} - * const char *str = ...; // From user - * lzma_filter filters[LZMA_FILTERS_MAX + 1]; - * int pos; - * const char *msg = lzma_str_to_filters(str, &pos, filters, 0, NULL); - * if (msg != NULL) { - * printf("%s: Error in XZ compression options:\n", argv[0]); - * printf("%s: %s\n", argv[0], str); - * printf("%s: %*s^\n", argv[0], errpos, ""); - * printf("%s: %s\n", argv[0], msg); - * } - * \endcode */ extern LZMA_API(const char *) lzma_str_to_filters( const char *str, int *error_pos, lzma_filter *filters, @@ -646,19 +700,20 @@ extern LZMA_API(const char *) lzma_str_to_filters( * specify "6" to lzma_str_to_filters() then lzma_str_from_filters() * will produce a string containing "lzma2". * - * \param str On success *str will be set to point to an + * \param[out] str On success *str will be set to point to an * allocated string describing the given filter * chain. Old value is ignored. On error *str is * always set to NULL. - * \param filters Array of 1-4 filters and a terminating element - * with .id = LZMA_VLI_UNKNOWN. + * \param filters Array of filters terminated with + * .id == LZMA_VLI_UNKNOWN. * \param flags Bitwise-or of zero or more of the flags * LZMA_STR_ENCODER, LZMA_STR_DECODER, * LZMA_STR_GETOPT_LONG, and LZMA_STR_NO_SPACES. * \param allocator lzma_allocator for custom allocator functions. * Set to NULL to use malloc() and free(). * - * \return - LZMA_OK + * \return Possible lzma_ret values: + * - LZMA_OK * - LZMA_OPTIONS_ERROR: Empty filter chain * (filters[0].id == LZMA_VLI_UNKNOWN) or the filter chain * includes a Filter ID that is not supported by this function. @@ -676,7 +731,7 @@ extern LZMA_API(lzma_ret) lzma_str_from_filters( * * If a filter_id is given then only one line is created which contains the * filter name. If LZMA_STR_ENCODER or LZMA_STR_DECODER is used then the - * options required for encoding or decoding are listed on the same line too. + * options read by the encoder or decoder are printed on the same line. * * If filter_id is LZMA_VLI_UNKNOWN then all supported .xz-compatible filters * are listed: @@ -687,7 +742,7 @@ extern LZMA_API(lzma_ret) lzma_str_from_filters( * * - If LZMA_STR_ENCODER or LZMA_STR_DECODER is used then filters and * the supported options are listed one filter per line. There won't - * be a '\n' after the last filter. + * be a newline after the last filter. * * - If LZMA_STR_ALL_FILTERS is used then the list will include also * those filters that cannot be used in the .xz format (LZMA1). @@ -703,7 +758,8 @@ extern LZMA_API(lzma_ret) lzma_str_from_filters( * \param allocator lzma_allocator for custom allocator functions. * Set to NULL to use malloc() and free(). * - * \return - LZMA_OK + * \return Possible lzma_ret values: + * - LZMA_OK * - LZMA_OPTIONS_ERROR: Unsupported filter_id or flags * - LZMA_MEM_ERROR * - LZMA_PROG_ERROR diff --git a/contrib/libs/lzma/liblzma/api/lzma/hardware.h b/contrib/libs/lzma/liblzma/api/lzma/hardware.h index 7040aae45f..f34897d874 100644 --- a/contrib/libs/lzma/liblzma/api/lzma/hardware.h +++ b/contrib/libs/lzma/liblzma/api/lzma/hardware.h @@ -1,6 +1,7 @@ /** * \file lzma/hardware.h * \brief Hardware information + * \note Never include this file directly. Use <lzma.h> instead. * * Since liblzma can consume a lot of system resources, it also provides * ways to limit the resource usage. Applications linking against liblzma @@ -25,8 +26,6 @@ * * This file has been put into the public domain. * You can do whatever you want with this file. - * - * See ../lzma.h for information about liblzma as a whole. */ #ifndef LZMA_H_INTERNAL diff --git a/contrib/libs/lzma/liblzma/api/lzma/index.h b/contrib/libs/lzma/liblzma/api/lzma/index.h index 144d416615..6eee4d6813 100644 --- a/contrib/libs/lzma/liblzma/api/lzma/index.h +++ b/contrib/libs/lzma/liblzma/api/lzma/index.h @@ -1,6 +1,7 @@ /** * \file lzma/index.h * \brief Handling of .xz Index and related information + * \note Never include this file directly. Use <lzma.h> instead. */ /* @@ -8,8 +9,6 @@ * * This file has been put into the public domain. * You can do whatever you want with this file. - * - * See ../lzma.h for information about liblzma as a whole. */ #ifndef LZMA_H_INTERNAL @@ -50,8 +49,13 @@ typedef struct { */ const lzma_stream_flags *flags; + /** \private Reserved member. */ const void *reserved_ptr1; + + /** \private Reserved member. */ const void *reserved_ptr2; + + /** \private Reserved member. */ const void *reserved_ptr3; /** @@ -107,9 +111,17 @@ typedef struct { */ lzma_vli padding; + + /** \private Reserved member. */ lzma_vli reserved_vli1; + + /** \private Reserved member. */ lzma_vli reserved_vli2; + + /** \private Reserved member. */ lzma_vli reserved_vli3; + + /** \private Reserved member. */ lzma_vli reserved_vli4; } stream; @@ -196,25 +208,46 @@ typedef struct { */ lzma_vli total_size; + /** \private Reserved member. */ lzma_vli reserved_vli1; + + /** \private Reserved member. */ lzma_vli reserved_vli2; + + /** \private Reserved member. */ lzma_vli reserved_vli3; + + /** \private Reserved member. */ lzma_vli reserved_vli4; + /** \private Reserved member. */ const void *reserved_ptr1; + + /** \private Reserved member. */ const void *reserved_ptr2; + + /** \private Reserved member. */ const void *reserved_ptr3; + + /** \private Reserved member. */ const void *reserved_ptr4; } block; - /* + /** + * \private Internal struct. + * * Internal data which is used to store the state of the iterator. * The exact format may vary between liblzma versions, so don't * touch these in any way. */ union { + /** \private Internal member. */ const void *p; + + /** \private Internal member. */ size_t s; + + /** \private Internal member. */ lzma_vli v; } internal[6]; } lzma_index_iter; @@ -272,16 +305,21 @@ typedef enum { * \brief Calculate memory usage of lzma_index * * On disk, the size of the Index field depends on both the number of Records - * stored and how big values the Records store (due to variable-length integer + * stored and the size of the Records (due to variable-length integer * encoding). When the Index is kept in lzma_index structure, the memory usage * depends only on the number of Records/Blocks stored in the Index(es), and * in case of concatenated lzma_indexes, the number of Streams. The size in * RAM is almost always significantly bigger than in the encoded form on disk. * - * This function calculates an approximate amount of memory needed hold + * This function calculates an approximate amount of memory needed to hold * the given number of Streams and Blocks in lzma_index structure. This * value may vary between CPU architectures and also between liblzma versions * if the internal implementation is modified. + * + * \param streams Number of Streams + * \param blocks Number of Blocks + * + * \return Approximate memory in bytes needed in a lzma_index structure. */ extern LZMA_API(uint64_t) lzma_index_memusage( lzma_vli streams, lzma_vli blocks) lzma_nothrow; @@ -292,6 +330,10 @@ extern LZMA_API(uint64_t) lzma_index_memusage( * * This is a shorthand for lzma_index_memusage(lzma_index_stream_count(i), * lzma_index_block_count(i)). + * + * \param i Pointer to lzma_index structure + * + * \return Approximate memory in bytes used by the lzma_index structure. */ extern LZMA_API(uint64_t) lzma_index_memused(const lzma_index *i) lzma_nothrow; @@ -300,6 +342,9 @@ extern LZMA_API(uint64_t) lzma_index_memused(const lzma_index *i) /** * \brief Allocate and initialize a new lzma_index structure * + * \param allocator lzma_allocator for custom allocator functions. + * Set to NULL to use malloc() and free(). + * * \return On success, a pointer to an empty initialized lzma_index is * returned. If allocation fails, NULL is returned. */ @@ -311,6 +356,10 @@ extern LZMA_API(lzma_index *) lzma_index_init(const lzma_allocator *allocator) * \brief Deallocate lzma_index * * If i is NULL, this does nothing. + * + * \param i Pointer to lzma_index structure to deallocate + * \param allocator lzma_allocator for custom allocator functions. + * Set to NULL to use malloc() and free(). */ extern LZMA_API(void) lzma_index_end( lzma_index *i, const lzma_allocator *allocator) lzma_nothrow; @@ -320,8 +369,9 @@ extern LZMA_API(void) lzma_index_end( * \brief Add a new Block to lzma_index * * \param i Pointer to a lzma_index structure - * \param allocator Pointer to lzma_allocator, or NULL to - * use malloc() + * \param allocator lzma_allocator for custom allocator + * functions. Set to NULL to use malloc() + * and free(). * \param unpadded_size Unpadded Size of a Block. This can be * calculated with lzma_block_unpadded_size() * after encoding or decoding the Block. @@ -334,7 +384,8 @@ extern LZMA_API(void) lzma_index_end( * lzma_index_append() it is possible to read the next Block with * an existing iterator. * - * \return - LZMA_OK + * \return Possible lzma_ret values: + * - LZMA_OK * - LZMA_MEM_ERROR * - LZMA_DATA_ERROR: Compressed or uncompressed size of the * Stream or size of the Index field would grow too big. @@ -354,11 +405,15 @@ extern LZMA_API(lzma_ret) lzma_index_append( * lzma_index, because to decode Blocks, knowing the integrity check type * is needed. * - * The given Stream Flags are copied into internal preallocated structure - * in the lzma_index, thus the caller doesn't need to keep the *stream_flags - * available after calling this function. + * \param i Pointer to lzma_index structure + * \param stream_flags Pointer to lzma_stream_flags structure. This + * is copied into the internal preallocated + * structure, so the caller doesn't need to keep + * the flags' data available after calling this + * function. * - * \return - LZMA_OK + * \return Possible lzma_ret values: + * - LZMA_OK * - LZMA_OPTIONS_ERROR: Unsupported stream_flags->version. * - LZMA_PROG_ERROR */ @@ -376,6 +431,10 @@ extern LZMA_API(lzma_ret) lzma_index_stream_flags( * showing the Check types to the user. * * The bitmask is 1 << check_id, e.g. CRC32 is 1 << 1 and SHA-256 is 1 << 10. + * + * \param i Pointer to lzma_index structure + * + * \return Bitmask indicating which Check types are used in the lzma_index */ extern LZMA_API(uint32_t) lzma_index_checks(const lzma_index *i) lzma_nothrow lzma_attr_pure; @@ -390,7 +449,8 @@ extern LZMA_API(uint32_t) lzma_index_checks(const lzma_index *i) * * By default, the amount of Stream Padding is assumed to be zero bytes. * - * \return - LZMA_OK + * \return Possible lzma_ret values: + * - LZMA_OK * - LZMA_DATA_ERROR: The file size would grow too big. * - LZMA_PROG_ERROR */ @@ -401,6 +461,10 @@ extern LZMA_API(lzma_ret) lzma_index_stream_padding( /** * \brief Get the number of Streams + * + * \param i Pointer to lzma_index structure + * + * \return Number of Streams in the lzma_index */ extern LZMA_API(lzma_vli) lzma_index_stream_count(const lzma_index *i) lzma_nothrow lzma_attr_pure; @@ -411,6 +475,10 @@ extern LZMA_API(lzma_vli) lzma_index_stream_count(const lzma_index *i) * * This returns the total number of Blocks in lzma_index. To get number * of Blocks in individual Streams, use lzma_index_iter. + * + * \param i Pointer to lzma_index structure + * + * \return Number of blocks in the lzma_index */ extern LZMA_API(lzma_vli) lzma_index_block_count(const lzma_index *i) lzma_nothrow lzma_attr_pure; @@ -420,6 +488,10 @@ extern LZMA_API(lzma_vli) lzma_index_block_count(const lzma_index *i) * \brief Get the size of the Index field as bytes * * This is needed to verify the Backward Size field in the Stream Footer. + * + * \param i Pointer to lzma_index structure + * + * \return Size in bytes of the Index */ extern LZMA_API(lzma_vli) lzma_index_size(const lzma_index *i) lzma_nothrow lzma_attr_pure; @@ -431,6 +503,11 @@ extern LZMA_API(lzma_vli) lzma_index_size(const lzma_index *i) * If multiple lzma_indexes have been combined, this works as if the Blocks * were in a single Stream. This is useful if you are going to combine * Blocks from multiple Streams into a single new Stream. + * + * \param i Pointer to lzma_index structure + * + * \return Size in bytes of the Stream (if all Blocks are combined + * into one Stream). */ extern LZMA_API(lzma_vli) lzma_index_stream_size(const lzma_index *i) lzma_nothrow lzma_attr_pure; @@ -441,6 +518,10 @@ extern LZMA_API(lzma_vli) lzma_index_stream_size(const lzma_index *i) * * This doesn't include the Stream Header, Stream Footer, Stream Padding, * or Index fields. + * + * \param i Pointer to lzma_index structure + * + * \return Size in bytes of all Blocks in the Stream(s) */ extern LZMA_API(lzma_vli) lzma_index_total_size(const lzma_index *i) lzma_nothrow lzma_attr_pure; @@ -453,6 +534,10 @@ extern LZMA_API(lzma_vli) lzma_index_total_size(const lzma_index *i) * no Stream Padding, this function is identical to lzma_index_stream_size(). * If multiple lzma_indexes have been combined, this includes also the headers * of each separate Stream and the possible Stream Padding fields. + * + * \param i Pointer to lzma_index structure + * + * \return Total size of the .xz file in bytes */ extern LZMA_API(lzma_vli) lzma_index_file_size(const lzma_index *i) lzma_nothrow lzma_attr_pure; @@ -460,6 +545,10 @@ extern LZMA_API(lzma_vli) lzma_index_file_size(const lzma_index *i) /** * \brief Get the uncompressed size of the file + * + * \param i Pointer to lzma_index structure + * + * \return Size in bytes of the uncompressed data in the file */ extern LZMA_API(lzma_vli) lzma_index_uncompressed_size(const lzma_index *i) lzma_nothrow lzma_attr_pure; @@ -468,9 +557,6 @@ extern LZMA_API(lzma_vli) lzma_index_uncompressed_size(const lzma_index *i) /** * \brief Initialize an iterator * - * \param iter Pointer to a lzma_index_iter structure - * \param i lzma_index to which the iterator will be associated - * * This function associates the iterator with the given lzma_index, and calls * lzma_index_iter_rewind() on the iterator. * @@ -483,6 +569,9 @@ extern LZMA_API(lzma_vli) lzma_index_uncompressed_size(const lzma_index *i) * * It is safe to make copies of an initialized lzma_index_iter, for example, * to easily restart reading at some particular position. + * + * \param iter Pointer to a lzma_index_iter structure + * \param i lzma_index to which the iterator will be associated */ extern LZMA_API(void) lzma_index_iter_init( lzma_index_iter *iter, const lzma_index *i) lzma_nothrow; @@ -493,6 +582,8 @@ extern LZMA_API(void) lzma_index_iter_init( * * Rewind the iterator so that next call to lzma_index_iter_next() will * return the first Block or Stream. + * + * \param iter Pointer to a lzma_index_iter structure */ extern LZMA_API(void) lzma_index_iter_rewind(lzma_index_iter *iter) lzma_nothrow; @@ -505,11 +596,11 @@ extern LZMA_API(void) lzma_index_iter_rewind(lzma_index_iter *iter) * \param mode Specify what kind of information the caller wants * to get. See lzma_index_iter_mode for details. * - * \return If next Block or Stream matching the mode was found, *iter - * is updated and this function returns false. If no Block or - * Stream matching the mode is found, *iter is not modified - * and this function returns true. If mode is set to an unknown - * value, *iter is not modified and this function returns true. + * \return lzma_bool: + * - true if no Block or Stream matching the mode is found. + * *iter is not updated (failure). + * - false if the next Block or Stream matching the mode was + * found. *iter is updated (success). */ extern LZMA_API(lzma_bool) lzma_index_iter_next( lzma_index_iter *iter, lzma_index_iter_mode mode) @@ -523,21 +614,26 @@ extern LZMA_API(lzma_bool) lzma_index_iter_next( * the Index field(s) and use lzma_index_iter_locate() to do random-access * reading with granularity of Block size. * - * \param iter Iterator that was earlier initialized with - * lzma_index_iter_init(). - * \param target Uncompressed target offset which the caller would - * like to locate from the Stream - * * If the target is smaller than the uncompressed size of the Stream (can be * checked with lzma_index_uncompressed_size()): * - Information about the Stream and Block containing the requested * uncompressed offset is stored into *iter. * - Internal state of the iterator is adjusted so that * lzma_index_iter_next() can be used to read subsequent Blocks or Streams. - * - This function returns false. * - * If target is greater than the uncompressed size of the Stream, *iter - * is not modified, and this function returns true. + * If the target is greater than the uncompressed size of the Stream, *iter + * is not modified. + * + * \param iter Iterator that was earlier initialized with + * lzma_index_iter_init(). + * \param target Uncompressed target offset which the caller would + * like to locate from the Stream + * + * \return lzma_bool: + * - true if the target is greater than or equal to the + * uncompressed size of the Stream (failure) + * - false if the target is smaller than the uncompressed size + * of the Stream (success) */ extern LZMA_API(lzma_bool) lzma_index_iter_locate( lzma_index_iter *iter, lzma_vli target) lzma_nothrow; @@ -550,15 +646,16 @@ extern LZMA_API(lzma_bool) lzma_index_iter_locate( * multi-Stream .xz file, or when combining multiple Streams into single * Stream. * - * \param dest lzma_index after which src is appended + * \param[out] dest lzma_index after which src is appended * \param src lzma_index to be appended after dest. If this * function succeeds, the memory allocated for src * is freed or moved to be part of dest, and all * iterators pointing to src will become invalid. - * \param allocator Custom memory allocator; can be NULL to use - * malloc() and free(). +* \param allocator lzma_allocator for custom allocator functions. + * Set to NULL to use malloc() and free(). * - * \return - LZMA_OK: lzma_indexes were concatenated successfully. + * \return Possible lzma_ret values: + * - LZMA_OK: lzma_indexes were concatenated successfully. * src is now a dangling pointer. * - LZMA_DATA_ERROR: *dest would grow too big. * - LZMA_MEM_ERROR @@ -572,6 +669,10 @@ extern LZMA_API(lzma_ret) lzma_index_cat(lzma_index *dest, lzma_index *src, /** * \brief Duplicate lzma_index * + * \param i Pointer to lzma_index structure to be duplicated + * \param allocator lzma_allocator for custom allocator functions. + * Set to NULL to use malloc() and free(). + * * \return A copy of the lzma_index, or NULL if memory allocation failed. */ extern LZMA_API(lzma_index *) lzma_index_dup( @@ -588,7 +689,8 @@ extern LZMA_API(lzma_index *) lzma_index_dup( * The valid `action' values for lzma_code() are LZMA_RUN and LZMA_FINISH. * It is enough to use only one of them (you can choose freely). * - * \return - LZMA_OK: Initialization succeeded, continue with lzma_code(). + * \return Possible lzma_ret values: + * - LZMA_OK: Initialization succeeded, continue with lzma_code(). * - LZMA_MEM_ERROR * - LZMA_PROG_ERROR */ @@ -601,7 +703,7 @@ extern LZMA_API(lzma_ret) lzma_index_encoder( * \brief Initialize .xz Index decoder * * \param strm Pointer to properly prepared lzma_stream - * \param i The decoded Index will be made available via + * \param[out] i The decoded Index will be made available via * this pointer. Initially this function will * set *i to NULL (the old value is ignored). If * decoding succeeds (lzma_code() returns @@ -617,11 +719,12 @@ extern LZMA_API(lzma_ret) lzma_index_encoder( * There is no need to use LZMA_FINISH, but it's allowed because it may * simplify certain types of applications. * - * \return - LZMA_OK: Initialization succeeded, continue with lzma_code(). + * \return Possible lzma_ret values: + * - LZMA_OK: Initialization succeeded, continue with lzma_code(). * - LZMA_MEM_ERROR * - LZMA_PROG_ERROR * - * liblzma 5.2.3 and older list also LZMA_MEMLIMIT_ERROR here + * \note liblzma 5.2.3 and older list also LZMA_MEMLIMIT_ERROR here * but that error code has never been possible from this * initialization function. */ @@ -633,21 +736,23 @@ extern LZMA_API(lzma_ret) lzma_index_decoder( /** * \brief Single-call .xz Index encoder * + * \note This function doesn't take allocator argument since all + * the internal data is allocated on stack. + * * \param i lzma_index to be encoded - * \param out Beginning of the output buffer - * \param out_pos The next byte will be written to out[*out_pos]. + * \param[out] out Beginning of the output buffer + * \param[out] out_pos The next byte will be written to out[*out_pos]. * *out_pos is updated only if encoding succeeds. * \param out_size Size of the out buffer; the first byte into * which no data is written to is out[out_size]. * - * \return - LZMA_OK: Encoding was successful. + * \return Possible lzma_ret values: + * - LZMA_OK: Encoding was successful. * - LZMA_BUF_ERROR: Output buffer is too small. Use * lzma_index_size() to find out how much output * space is needed. * - LZMA_PROG_ERROR * - * \note This function doesn't take allocator argument since all - * the internal data is allocated on stack. */ extern LZMA_API(lzma_ret) lzma_index_buffer_encode(const lzma_index *i, uint8_t *out, size_t *out_pos, size_t out_size) lzma_nothrow; @@ -656,24 +761,26 @@ extern LZMA_API(lzma_ret) lzma_index_buffer_encode(const lzma_index *i, /** * \brief Single-call .xz Index decoder * - * \param i If decoding succeeds, *i will point to a new + * \param[out] i If decoding succeeds, *i will point to a new * lzma_index, which the application has to * later free with lzma_index_end(). If an error * occurs, *i will be NULL. The old value of *i * is always ignored and thus doesn't need to be * initialized by the caller. - * \param memlimit Pointer to how much memory the resulting + * \param[out] memlimit Pointer to how much memory the resulting * lzma_index is allowed to require. The value * pointed by this pointer is modified if and only * if LZMA_MEMLIMIT_ERROR is returned. - * \param allocator Pointer to lzma_allocator, or NULL to use malloc() + * \param allocator lzma_allocator for custom allocator functions. + * Set to NULL to use malloc() and free(). * \param in Beginning of the input buffer * \param in_pos The next byte will be read from in[*in_pos]. * *in_pos is updated only if decoding succeeds. * \param in_size Size of the input buffer; the first byte that * won't be read is in[in_size]. * - * \return - LZMA_OK: Decoding was successful. + * \return Possible lzma_ret values: + * - LZMA_OK: Decoding was successful. * - LZMA_MEM_ERROR * - LZMA_MEMLIMIT_ERROR: Memory usage limit was reached. * The minimum required memlimit value was stored to *memlimit. @@ -689,15 +796,6 @@ extern LZMA_API(lzma_ret) lzma_index_buffer_decode(lzma_index **i, /** * \brief Initialize a .xz file information decoder * - * \param strm Pointer to a properly prepared lzma_stream - * \param dest_index Pointer to a pointer where the decoder will put - * the decoded lzma_index. The old value - * of *dest_index is ignored (not freed). - * \param memlimit How much memory the resulting lzma_index is - * allowed to require. Use UINT64_MAX to - * effectively disable the limiter. - * \param file_size Size of the input .xz file - * * This decoder decodes the Stream Header, Stream Footer, Index, and * Stream Padding field(s) from the input .xz file and stores the resulting * combined index in *dest_index. This information can be used to get the @@ -742,7 +840,17 @@ extern LZMA_API(lzma_ret) lzma_index_buffer_decode(lzma_index **i, * - LZMA_MEMLIMIT_ERROR * - LZMA_PROG_ERROR * - * \return - LZMA_OK + * \param strm Pointer to a properly prepared lzma_stream + * \param[out] dest_index Pointer to a pointer where the decoder will put + * the decoded lzma_index. The old value + * of *dest_index is ignored (not freed). + * \param memlimit How much memory the resulting lzma_index is + * allowed to require. Use UINT64_MAX to + * effectively disable the limiter. + * \param file_size Size of the input .xz file + * + * \return Possible lzma_ret values: + * - LZMA_OK * - LZMA_MEM_ERROR * - LZMA_PROG_ERROR */ diff --git a/contrib/libs/lzma/liblzma/api/lzma/index_hash.h b/contrib/libs/lzma/liblzma/api/lzma/index_hash.h index 8ff4163365..a2d4c4845b 100644 --- a/contrib/libs/lzma/liblzma/api/lzma/index_hash.h +++ b/contrib/libs/lzma/liblzma/api/lzma/index_hash.h @@ -1,6 +1,7 @@ /** * \file lzma/index_hash.h * \brief Validate Index by using a hash function + * \note Never include this file directly. Use <lzma.h> instead. * * Hashing makes it possible to use constant amount of memory to validate * Index of arbitrary size. @@ -11,8 +12,6 @@ * * This file has been put into the public domain. * You can do whatever you want with this file. - * - * See ../lzma.h for information about liblzma as a whole. */ #ifndef LZMA_H_INTERNAL @@ -28,13 +27,21 @@ typedef struct lzma_index_hash_s lzma_index_hash; /** * \brief Allocate and initialize a new lzma_index_hash structure * - * If index_hash is NULL, a new lzma_index_hash structure is allocated, - * initialized, and a pointer to it returned. If allocation fails, NULL - * is returned. + * If index_hash is NULL, this function allocates and initializes a new + * lzma_index_hash structure and returns a pointer to it. If allocation + * fails, NULL is returned. + * + * If index_hash is non-NULL, this function reinitializes the lzma_index_hash + * structure and returns the same pointer. In this case, return value cannot + * be NULL or a different pointer than the index_hash that was given as + * an argument. * - * If index_hash is non-NULL, it is reinitialized and the same pointer - * returned. In this case, return value cannot be NULL or a different - * pointer than the index_hash that was given as an argument. + * \param index_hash Pointer to a lzma_index_hash structure or NULL. + * \param allocator lzma_allocator for custom allocator functions. + * Set to NULL to use malloc() and free(). + * + * \return Initialized lzma_index_hash structure on success or + * NULL on failure. */ extern LZMA_API(lzma_index_hash *) lzma_index_hash_init( lzma_index_hash *index_hash, const lzma_allocator *allocator) @@ -43,6 +50,10 @@ extern LZMA_API(lzma_index_hash *) lzma_index_hash_init( /** * \brief Deallocate lzma_index_hash structure + * + * \param index_hash Pointer to a lzma_index_hash structure to free. + * \param allocator lzma_allocator for custom allocator functions. + * Set to NULL to use malloc() and free(). */ extern LZMA_API(void) lzma_index_hash_end( lzma_index_hash *index_hash, const lzma_allocator *allocator) @@ -56,7 +67,8 @@ extern LZMA_API(void) lzma_index_hash_end( * \param unpadded_size Unpadded Size of a Block * \param uncompressed_size Uncompressed Size of a Block * - * \return - LZMA_OK + * \return Possible lzma_ret values: + * - LZMA_OK * - LZMA_DATA_ERROR: Compressed or uncompressed size of the * Stream or size of the Index field would grow too big. * - LZMA_PROG_ERROR: Invalid arguments or this function is being @@ -81,10 +93,11 @@ extern LZMA_API(lzma_ret) lzma_index_hash_append(lzma_index_hash *index_hash, * * \param index_hash Pointer to a lzma_index_hash structure * \param in Pointer to the beginning of the input buffer - * \param in_pos in[*in_pos] is the next byte to process + * \param[out] in_pos in[*in_pos] is the next byte to process * \param in_size in[in_size] is the first byte not to process * - * \return - LZMA_OK: So far good, but more input is needed. + * \return Possible lzma_ret values: + * - LZMA_OK: So far good, but more input is needed. * - LZMA_STREAM_END: Index decoded successfully and it matches * the Records given with lzma_index_hash_append(). * - LZMA_DATA_ERROR: Index is corrupt or doesn't match the @@ -101,6 +114,10 @@ extern LZMA_API(lzma_ret) lzma_index_hash_decode(lzma_index_hash *index_hash, * \brief Get the size of the Index field as bytes * * This is needed to verify the Backward Size field in the Stream Footer. + * + * \param index_hash Pointer to a lzma_index_hash structure + * + * \return Size of the Index field in bytes. */ extern LZMA_API(lzma_vli) lzma_index_hash_size( const lzma_index_hash *index_hash) diff --git a/contrib/libs/lzma/liblzma/api/lzma/lzma12.h b/contrib/libs/lzma/liblzma/api/lzma/lzma12.h index d34e78392b..8ef6ea5b50 100644 --- a/contrib/libs/lzma/liblzma/api/lzma/lzma12.h +++ b/contrib/libs/lzma/liblzma/api/lzma/lzma12.h @@ -1,6 +1,7 @@ /** * \file lzma/lzma12.h * \brief LZMA1 and LZMA2 filters + * \note Never include this file directly. Use <lzma.h> instead. */ /* @@ -8,8 +9,6 @@ * * This file has been put into the public domain. * You can do whatever you want with this file. - * - * See ../lzma.h for information about liblzma as a whole. */ #ifndef LZMA_H_INTERNAL @@ -57,7 +56,7 @@ * * Usually you want this instead of LZMA1. Compared to LZMA1, LZMA2 adds * support for LZMA_SYNC_FLUSH, uncompressed chunks (smaller expansion - * when trying to compress uncompressible data), possibility to change + * when trying to compress incompressible data), possibility to change * lc/lp/pb in the middle of encoding, and some other internal improvements. */ #define LZMA_FILTER_LZMA2 LZMA_VLI_C(0x21) @@ -137,16 +136,20 @@ typedef enum { /** * \brief Test if given match finder is supported * - * Return true if the given match finder is supported by this liblzma build. - * Otherwise false is returned. It is safe to call this with a value that - * isn't listed in lzma_match_finder enumeration; the return value will be - * false. + * It is safe to call this with a value that isn't listed in + * lzma_match_finder enumeration; the return value will be false. * * There is no way to list which match finders are available in this * particular liblzma version and build. It would be useless, because * a new match finder, which the application developer wasn't aware, * could require giving additional options to the encoder that the older * match finders don't need. + * + * \param match_finder Match finder ID + * + * \return lzma_bool: + * - true if the match finder is supported by this liblzma build. + * - false otherwise. */ extern LZMA_API(lzma_bool) lzma_mf_is_supported(lzma_match_finder match_finder) lzma_nothrow lzma_attr_const; @@ -181,14 +184,20 @@ typedef enum { /** * \brief Test if given compression mode is supported * - * Return true if the given compression mode is supported by this liblzma - * build. Otherwise false is returned. It is safe to call this with a value - * that isn't listed in lzma_mode enumeration; the return value will be false. + * It is safe to call this with a value that isn't listed in lzma_mode + * enumeration; the return value will be false. * * There is no way to list which modes are available in this particular * liblzma version and build. It would be useless, because a new compression * mode, which the application developer wasn't aware, could require giving * additional options to the encoder that the older modes don't need. + * + * \param mode Mode ID. + * + * \return lzma_bool: + * - true if the compression mode is supported by this liblzma + * build. + * - false otherwise. */ extern LZMA_API(lzma_bool) lzma_mode_is_supported(lzma_mode mode) lzma_nothrow lzma_attr_const; @@ -408,7 +417,7 @@ typedef struct { * like it is with LZMA_FILTER_LZMA1. Without this flag the * end marker isn't written and the application has to store * the uncompressed size somewhere outside the compressed stream. - * To decompress streams without the end marker, the appliation + * To decompress streams without the end marker, the application * has to set the correct uncompressed size in ext_size_low and * ext_size_high. * @@ -480,16 +489,38 @@ typedef struct { * with the currently supported options, so it is safe to leave these * uninitialized. */ + + /** \private Reserved member. */ uint32_t reserved_int4; + + /** \private Reserved member. */ uint32_t reserved_int5; + + /** \private Reserved member. */ uint32_t reserved_int6; + + /** \private Reserved member. */ uint32_t reserved_int7; + + /** \private Reserved member. */ uint32_t reserved_int8; + + /** \private Reserved member. */ lzma_reserved_enum reserved_enum1; + + /** \private Reserved member. */ lzma_reserved_enum reserved_enum2; + + /** \private Reserved member. */ lzma_reserved_enum reserved_enum3; + + /** \private Reserved member. */ lzma_reserved_enum reserved_enum4; + + /** \private Reserved member. */ void *reserved_ptr1; + + /** \private Reserved member. */ void *reserved_ptr2; } lzma_options_lzma; @@ -517,13 +548,22 @@ do { \ * The flags are defined in container.h, because the flags are used also * with lzma_easy_encoder(). * - * The preset values are subject to changes between liblzma versions. + * The preset levels are subject to changes between liblzma versions. * * This function is available only if LZMA1 or LZMA2 encoder has been enabled * when building liblzma. * - * \return On success, false is returned. If the preset is not - * supported, true is returned. + * If features (like certain match finders) have been disabled at build time, + * then the function may return success (false) even though the resulting + * LZMA1/LZMA2 options may not be usable for encoder initialization + * (LZMA_OPTIONS_ERROR). + * + * \param[out] options Pointer to LZMA1 or LZMA2 options to be filled + * \param preset Preset level bitwse-ORed with preset flags + * + * \return lzma_bool: + * - true if the preset is not supported (failure). + * - false otherwise (success). */ extern LZMA_API(lzma_bool) lzma_lzma_preset( lzma_options_lzma *options, uint32_t preset) lzma_nothrow; diff --git a/contrib/libs/lzma/liblzma/api/lzma/stream_flags.h b/contrib/libs/lzma/liblzma/api/lzma/stream_flags.h index bbdd408263..7622a62120 100644 --- a/contrib/libs/lzma/liblzma/api/lzma/stream_flags.h +++ b/contrib/libs/lzma/liblzma/api/lzma/stream_flags.h @@ -1,6 +1,7 @@ /** * \file lzma/stream_flags.h * \brief .xz Stream Header and Stream Footer encoder and decoder + * \note Never include this file directly. Use <lzma.h> instead. */ /* @@ -8,8 +9,6 @@ * * This file has been put into the public domain. * You can do whatever you want with this file. - * - * See ../lzma.h for information about liblzma as a whole. */ #ifndef LZMA_H_INTERNAL @@ -36,7 +35,7 @@ typedef struct { * * To prevent API and ABI breakages if new features are needed in * Stream Header or Stream Footer, a version number is used to - * indicate which fields in this structure are in use. For now, + * indicate which members in this structure are in use. For now, * version must always be zero. With non-zero version, the * lzma_stream_header_encode() and lzma_stream_footer_encode() * will return LZMA_OPTIONS_ERROR. @@ -67,7 +66,15 @@ typedef struct { * Footer have been decoded. */ lzma_vli backward_size; + + /** + * \brief Minimum value for lzma_stream_flags.backward_size + */ # define LZMA_BACKWARD_SIZE_MIN 4 + + /** + * \brief Maximum value for lzma_stream_flags.backward_size + */ # define LZMA_BACKWARD_SIZE_MAX (LZMA_VLI_C(1) << 34) /** @@ -87,19 +94,47 @@ typedef struct { * is just two bytes plus Backward Size of four bytes. But it's * nice to have the proper types when they are needed.) */ + + /** \private Reserved member. */ lzma_reserved_enum reserved_enum1; + + /** \private Reserved member. */ lzma_reserved_enum reserved_enum2; + + /** \private Reserved member. */ lzma_reserved_enum reserved_enum3; + + /** \private Reserved member. */ lzma_reserved_enum reserved_enum4; + + /** \private Reserved member. */ lzma_bool reserved_bool1; + + /** \private Reserved member. */ lzma_bool reserved_bool2; + + /** \private Reserved member. */ lzma_bool reserved_bool3; + + /** \private Reserved member. */ lzma_bool reserved_bool4; + + /** \private Reserved member. */ lzma_bool reserved_bool5; + + /** \private Reserved member. */ lzma_bool reserved_bool6; + + /** \private Reserved member. */ lzma_bool reserved_bool7; + + /** \private Reserved member. */ lzma_bool reserved_bool8; + + /** \private Reserved member. */ uint32_t reserved_int1; + + /** \private Reserved member. */ uint32_t reserved_int2; } lzma_stream_flags; @@ -111,10 +146,11 @@ typedef struct { * \param options Stream Header options to be encoded. * options->backward_size is ignored and doesn't * need to be initialized. - * \param out Beginning of the output buffer of + * \param[out] out Beginning of the output buffer of * LZMA_STREAM_HEADER_SIZE bytes. * - * \return - LZMA_OK: Encoding was successful. + * \return Possible lzma_ret values: + * - LZMA_OK: Encoding was successful. * - LZMA_OPTIONS_ERROR: options->version is not supported by * this liblzma version. * - LZMA_PROG_ERROR: Invalid options. @@ -128,10 +164,11 @@ extern LZMA_API(lzma_ret) lzma_stream_header_encode( * \brief Encode Stream Footer * * \param options Stream Footer options to be encoded. - * \param out Beginning of the output buffer of + * \param[out] out Beginning of the output buffer of * LZMA_STREAM_HEADER_SIZE bytes. * - * \return - LZMA_OK: Encoding was successful. + * \return Possible lzma_ret values: + * - LZMA_OK: Encoding was successful. * - LZMA_OPTIONS_ERROR: options->version is not supported by * this liblzma version. * - LZMA_PROG_ERROR: Invalid options. @@ -144,32 +181,33 @@ extern LZMA_API(lzma_ret) lzma_stream_footer_encode( /** * \brief Decode Stream Header * - * \param options Target for the decoded Stream Header options. - * \param in Beginning of the input buffer of - * LZMA_STREAM_HEADER_SIZE bytes. - * * options->backward_size is always set to LZMA_VLI_UNKNOWN. This is to * help comparing Stream Flags from Stream Header and Stream Footer with * lzma_stream_flags_compare(). * - * \return - LZMA_OK: Decoding was successful. - * - LZMA_FORMAT_ERROR: Magic bytes don't match, thus the given - * buffer cannot be Stream Header. - * - LZMA_DATA_ERROR: CRC32 doesn't match, thus the header - * is corrupt. - * - LZMA_OPTIONS_ERROR: Unsupported options are present - * in the header. - * * \note When decoding .xz files that contain multiple Streams, it may * make sense to print "file format not recognized" only if - * decoding of the Stream Header of the _first_ Stream gives + * decoding of the Stream Header of the \a first Stream gives * LZMA_FORMAT_ERROR. If non-first Stream Header gives * LZMA_FORMAT_ERROR, the message used for LZMA_DATA_ERROR is * probably more appropriate. + * For example, the Stream decoder in liblzma uses + * LZMA_DATA_ERROR if LZMA_FORMAT_ERROR is returned by + * lzma_stream_header_decode() when decoding non-first Stream. * - * For example, Stream decoder in liblzma uses LZMA_DATA_ERROR if - * LZMA_FORMAT_ERROR is returned by lzma_stream_header_decode() - * when decoding non-first Stream. + * \param[out] options Target for the decoded Stream Header options. + * \param in Beginning of the input buffer of + * LZMA_STREAM_HEADER_SIZE bytes. + * + * + * \return Possible lzma_ret values: + * - LZMA_OK: Decoding was successful. + * - LZMA_FORMAT_ERROR: Magic bytes don't match, thus the given + * buffer cannot be Stream Header. + * - LZMA_DATA_ERROR: CRC32 doesn't match, thus the header + * is corrupt. + * - LZMA_OPTIONS_ERROR: Unsupported options are present + * in the header. */ extern LZMA_API(lzma_ret) lzma_stream_header_decode( lzma_stream_flags *options, const uint8_t *in) @@ -179,24 +217,25 @@ extern LZMA_API(lzma_ret) lzma_stream_header_decode( /** * \brief Decode Stream Footer * - * \param options Target for the decoded Stream Header options. + * \note If Stream Header was already decoded successfully, but + * decoding Stream Footer returns LZMA_FORMAT_ERROR, the + * application should probably report some other error message + * than "file format not recognized". The file likely + * is corrupt (possibly truncated). The Stream decoder in liblzma + * uses LZMA_DATA_ERROR in this situation. + * + * \param[out] options Target for the decoded Stream Footer options. * \param in Beginning of the input buffer of * LZMA_STREAM_HEADER_SIZE bytes. * - * \return - LZMA_OK: Decoding was successful. + * \return Possible lzma_ret values: + * - LZMA_OK: Decoding was successful. * - LZMA_FORMAT_ERROR: Magic bytes don't match, thus the given * buffer cannot be Stream Footer. * - LZMA_DATA_ERROR: CRC32 doesn't match, thus the Stream Footer * is corrupt. * - LZMA_OPTIONS_ERROR: Unsupported options are present * in Stream Footer. - * - * \note If Stream Header was already decoded successfully, but - * decoding Stream Footer returns LZMA_FORMAT_ERROR, the - * application should probably report some other error message - * than "file format not recognized", since the file more likely - * is corrupt (possibly truncated). Stream decoder in liblzma - * uses LZMA_DATA_ERROR in this situation. */ extern LZMA_API(lzma_ret) lzma_stream_footer_decode( lzma_stream_flags *options, const uint8_t *in) @@ -209,7 +248,11 @@ extern LZMA_API(lzma_ret) lzma_stream_footer_decode( * backward_size values are compared only if both are not * LZMA_VLI_UNKNOWN. * - * \return - LZMA_OK: Both are equal. If either had backward_size set + * \param a Pointer to lzma_stream_flags structure + * \param b Pointer to lzma_stream_flags structure + * + * \return Possible lzma_ret values: + * - LZMA_OK: Both are equal. If either had backward_size set * to LZMA_VLI_UNKNOWN, backward_size values were not * compared or validated. * - LZMA_DATA_ERROR: The structures differ. diff --git a/contrib/libs/lzma/liblzma/api/lzma/version.h b/contrib/libs/lzma/liblzma/api/lzma/version.h index 7d37130f24..71bd8087d9 100644 --- a/contrib/libs/lzma/liblzma/api/lzma/version.h +++ b/contrib/libs/lzma/liblzma/api/lzma/version.h @@ -1,6 +1,7 @@ /** * \file lzma/version.h * \brief Version number + * \note Never include this file directly. Use <lzma.h> instead. */ /* @@ -8,8 +9,6 @@ * * This file has been put into the public domain. * You can do whatever you want with this file. - * - * See ../lzma.h for information about liblzma as a whole. */ #ifndef LZMA_H_INTERNAL @@ -17,14 +16,26 @@ #endif -/* - * Version number split into components - */ +/** \brief Major version number of the liblzma release. */ #define LZMA_VERSION_MAJOR 5 + +/** \brief Minor version number of the liblzma release. */ #define LZMA_VERSION_MINOR 4 -#define LZMA_VERSION_PATCH 0 + +/** \brief Patch version number of the liblzma release. */ +#define LZMA_VERSION_PATCH 6 + +/** + * \brief Version stability marker + * + * This will always be one of three values: + * - LZMA_VERSION_STABILITY_ALPHA + * - LZMA_VERSION_STABILITY_BETA + * - LZMA_VERSION_STABILITY_STABLE + */ #define LZMA_VERSION_STABILITY LZMA_VERSION_STABILITY_STABLE +/** \brief Commit version number of the liblzma release */ #ifndef LZMA_VERSION_COMMIT # define LZMA_VERSION_COMMIT "" #endif @@ -95,15 +106,16 @@ LZMA_VERSION_COMMIT) -/* #ifndef is needed for use with windres (MinGW or Cygwin). */ +/* #ifndef is needed for use with windres (MinGW-w64 or Cygwin). */ #ifndef LZMA_H_INTERNAL_RC /** * \brief Run-time version number as an integer * - * Return the value of LZMA_VERSION macro at the compile time of liblzma. - * This allows the application to compare if it was built against the same, + * This allows an application to compare if it was built against the same, * older, or newer version of liblzma that is currently running. + * + * \return The value of LZMA_VERSION macro at the compile time of liblzma */ extern LZMA_API(uint32_t) lzma_version_number(void) lzma_nothrow lzma_attr_const; @@ -112,8 +124,10 @@ extern LZMA_API(uint32_t) lzma_version_number(void) /** * \brief Run-time version as a string * - * This function may be useful if you want to display which version of - * liblzma your application is currently using. + * This function may be useful to display which version of liblzma an + * application is currently using. + * + * \return Run-time version of liblzma */ extern LZMA_API(const char *) lzma_version_string(void) lzma_nothrow lzma_attr_const; diff --git a/contrib/libs/lzma/liblzma/api/lzma/vli.h b/contrib/libs/lzma/liblzma/api/lzma/vli.h index 7a0a803dfc..f9ad15500d 100644 --- a/contrib/libs/lzma/liblzma/api/lzma/vli.h +++ b/contrib/libs/lzma/liblzma/api/lzma/vli.h @@ -1,6 +1,7 @@ /** * \file lzma/vli.h * \brief Variable-length integer handling + * \note Never include this file directly. Use <lzma.h> instead. * * In the .xz format, most integers are encoded in a variable-length * representation, which is sometimes called little endian base-128 encoding. @@ -19,8 +20,6 @@ * * This file has been put into the public domain. * You can do whatever you want with this file. - * - * See ../lzma.h for information about liblzma as a whole. */ #ifndef LZMA_H_INTERNAL @@ -70,7 +69,8 @@ typedef uint64_t lzma_vli; * for example in the uncompressed_size and compressed_size variables. * * \return True if the integer is representable as VLI or if it - * indicates unknown value. + * indicates unknown value. False if the integer cannot be + * represented as VLI. */ #define lzma_vli_is_valid(vli) \ ((vli) <= LZMA_VLI_MAX || (vli) == LZMA_VLI_UNKNOWN) @@ -86,12 +86,12 @@ typedef uint64_t lzma_vli; * integer has been encoded. * * \param vli Integer to be encoded - * \param vli_pos How many VLI-encoded bytes have already been written + * \param[out] vli_pos How many VLI-encoded bytes have already been written * out. When starting to encode a new integer in * multi-call mode, *vli_pos must be set to zero. * To use single-call encoding, set vli_pos to NULL. - * \param out Beginning of the output buffer - * \param out_pos The next byte will be written to out[*out_pos]. + * \param[out] out Beginning of the output buffer + * \param[out] out_pos The next byte will be written to out[*out_pos]. * \param out_size Size of the out buffer; the first byte into * which no data is written to is out[out_size]. * @@ -121,15 +121,15 @@ extern LZMA_API(lzma_ret) lzma_vli_encode(lzma_vli vli, size_t *vli_pos, * * Like lzma_vli_encode(), this function has single-call and multi-call modes. * - * \param vli Pointer to decoded integer. The decoder will + * \param[out] vli Pointer to decoded integer. The decoder will * initialize it to zero when *vli_pos == 0, so * application isn't required to initialize *vli. - * \param vli_pos How many bytes have already been decoded. When + * \param[out] vli_pos How many bytes have already been decoded. When * starting to decode a new integer in multi-call * mode, *vli_pos must be initialized to zero. To * use single-call decoding, set vli_pos to NULL. * \param in Beginning of the input buffer - * \param in_pos The next byte will be read from in[*in_pos]. + * \param[out] in_pos The next byte will be read from in[*in_pos]. * \param in_size Size of the input buffer; the first byte that * won't be read is in[in_size]. * diff --git a/contrib/libs/lzma/liblzma/check/check.h b/contrib/libs/lzma/liblzma/check/check.h index 129113d61b..6b8cd546a8 100644 --- a/contrib/libs/lzma/liblzma/check/check.h +++ b/contrib/libs/lzma/liblzma/check/check.h @@ -99,19 +99,22 @@ typedef struct { /// lzma_crc32_table[0] is needed by LZ encoder so we need to keep /// the array two-dimensional. #ifdef HAVE_SMALL +lzma_attr_visibility_hidden extern uint32_t lzma_crc32_table[1][256]; + extern void lzma_crc32_init(void); + #else + +lzma_attr_visibility_hidden extern const uint32_t lzma_crc32_table[8][256]; + +lzma_attr_visibility_hidden extern const uint64_t lzma_crc64_table[4][256]; #endif /// \brief Initialize *check depending on type -/// -/// \return LZMA_OK on success. LZMA_UNSUPPORTED_CHECK if the type is not -/// supported by the current version or build of liblzma. -/// LZMA_PROG_ERROR if type > LZMA_CHECK_ID_MAX. extern void lzma_check_init(lzma_check_state *check, lzma_check type); /// Update the check state diff --git a/contrib/libs/lzma/liblzma/check/crc64_fast.c b/contrib/libs/lzma/liblzma/check/crc64_fast.c index e3cbf1b1e9..0c8622a1f3 100644 --- a/contrib/libs/lzma/liblzma/check/crc64_fast.c +++ b/contrib/libs/lzma/liblzma/check/crc64_fast.c @@ -184,6 +184,20 @@ calc_hi(uint64_t poly, uint64_t a) MASK_H(in, mask, high) +// MSVC (VS2015 - VS2022) produces bad 32-bit x86 code from the CLMUL CRC +// code when optimizations are enabled (release build). According to the bug +// report, the ebx register is corrupted and the calculated result is wrong. +// Trying to workaround the problem with "__asm mov ebx, ebx" didn't help. +// The following pragma works and performance is still good. x86-64 builds +// aren't affected by this problem. +// +// NOTE: Another pragma after the function restores the optimizations. +// If the #if condition here is updated, the other one must be updated too. +#if defined(_MSC_VER) && !defined(__INTEL_COMPILER) && !defined(__clang__) \ + && defined(_M_IX86) +# pragma optimize("g", off) +#endif + // EDG-based compilers (Intel's classic compiler and compiler for E2K) can // define __GNUC__ but the attribute must not be used with them. // The new Clang-based ICX needs the attribute. @@ -192,6 +206,14 @@ calc_hi(uint64_t poly, uint64_t a) #if (defined(__GNUC__) || defined(__clang__)) && !defined(__EDG__) __attribute__((__target__("ssse3,sse4.1,pclmul"))) #endif +// The intrinsics use 16-byte-aligned reads from buf, thus they may read +// up to 15 bytes before or after the buffer (depending on the alignment +// of the buf argument). The values of the extra bytes are ignored. +// This unavoidably trips -fsanitize=address so address sanitizier has +// to be disabled for this function. +#if lzma_has_attribute(__no_sanitize_address__) +__attribute__((__no_sanitize_address__)) +#endif static uint64_t crc64_clmul(const uint8_t *buf, size_t size, uint64_t crc) { @@ -242,7 +264,7 @@ crc64_clmul(const uint8_t *buf, size_t size, uint64_t crc) // C = buf + size == aligned_buf + size2 // D = buf + size + skip_end == aligned_buf + size2 + skip_end const size_t skip_start = (size_t)((uintptr_t)buf & 15); - const size_t skip_end = (size_t)(-(uintptr_t)(buf + size) & 15); + const size_t skip_end = (size_t)((0U - (uintptr_t)(buf + size)) & 15); const __m128i *aligned_buf = (const __m128i *)( (uintptr_t)buf & ~(uintptr_t)15); @@ -371,6 +393,10 @@ crc64_clmul(const uint8_t *buf, size_t size, uint64_t crc) # pragma GCC diagnostic pop #endif } +#if defined(_MSC_VER) && !defined(__INTEL_COMPILER) && !defined(__clang__) \ + && defined(_M_IX86) +# pragma optimize("", on) +#endif #endif diff --git a/contrib/libs/lzma/liblzma/check/crc64_table.c b/contrib/libs/lzma/liblzma/check/crc64_table.c index 307846ab14..bac9301aa4 100644 --- a/contrib/libs/lzma/liblzma/check/crc64_table.c +++ b/contrib/libs/lzma/liblzma/check/crc64_table.c @@ -18,10 +18,8 @@ #if (defined(__x86_64__) && defined(__SSSE3__) \ && defined(__SSE4_1__) && defined(__PCLMUL__)) \ || (defined(__e2k__) && __iset__ >= 6) -// No table needed but something has to be exported to keep some toolchains -// happy. Also use a declaration to silence compiler warnings. -extern const char lzma_crc64_dummy; -const char lzma_crc64_dummy; +// No table needed. Use a typedef to avoid an empty translation unit. +typedef void lzma_crc64_dummy; #else // Having the declaration here silences clang -Wmissing-variable-declarations. diff --git a/contrib/libs/lzma/liblzma/check/sha256.c b/contrib/libs/lzma/liblzma/check/sha256.c index 5eede5ce05..6feb342565 100644 --- a/contrib/libs/lzma/liblzma/check/sha256.c +++ b/contrib/libs/lzma/liblzma/check/sha256.c @@ -8,7 +8,7 @@ /// conditionally to keep the code working on older boxes. // // This code is based on the code found from 7-Zip, which has a modified -// version of the SHA-256 found from Crypto++ <http://www.cryptopp.com/>. +// version of the SHA-256 found from Crypto++ <https://www.cryptopp.com/>. // The code was modified a little to fit into liblzma. // // Authors: Kevin Springle diff --git a/contrib/libs/lzma/liblzma/common/alone_encoder.c b/contrib/libs/lzma/liblzma/common/alone_encoder.c index c9392f3769..7d3812fa6e 100644 --- a/contrib/libs/lzma/liblzma/common/alone_encoder.c +++ b/contrib/libs/lzma/liblzma/common/alone_encoder.c @@ -75,7 +75,6 @@ alone_encoder_end(void *coder_ptr, const lzma_allocator *allocator) } -// At least for now, this is not used by any internal function. static lzma_ret alone_encoder_init(lzma_next_coder *next, const lzma_allocator *allocator, const lzma_options_lzma *options) @@ -141,16 +140,6 @@ alone_encoder_init(lzma_next_coder *next, const lzma_allocator *allocator, } -/* -extern lzma_ret -lzma_alone_encoder_init(lzma_next_coder *next, const lzma_allocator *allocator, - const lzma_options_alone *options) -{ - lzma_next_coder_init(&alone_encoder_init, next, allocator, options); -} -*/ - - extern LZMA_API(lzma_ret) lzma_alone_encoder(lzma_stream *strm, const lzma_options_lzma *options) { diff --git a/contrib/libs/lzma/liblzma/common/block_buffer_encoder.c b/contrib/libs/lzma/liblzma/common/block_buffer_encoder.c index a47342efd0..fdef02de89 100644 --- a/contrib/libs/lzma/liblzma/common/block_buffer_encoder.c +++ b/contrib/libs/lzma/liblzma/common/block_buffer_encoder.c @@ -277,7 +277,7 @@ block_buffer_encode(lzma_block *block, const lzma_allocator *allocator, if (ret != LZMA_BUF_ERROR) return ret; - // The data was uncompressible (at least with the options + // The data was incompressible (at least with the options // given to us) or the output buffer was too small. Use the // uncompressed chunks of LZMA2 to wrap the data into a valid // Block. If we haven't been given enough output space, even diff --git a/contrib/libs/lzma/liblzma/common/block_decoder.c b/contrib/libs/lzma/liblzma/common/block_decoder.c index 4827e0f046..be647d4855 100644 --- a/contrib/libs/lzma/liblzma/common/block_decoder.c +++ b/contrib/libs/lzma/liblzma/common/block_decoder.c @@ -123,7 +123,10 @@ block_decode(void *coder_ptr, const lzma_allocator *allocator, return LZMA_DATA_ERROR; } - if (!coder->ignore_check) + // Don't waste time updating the integrity check if it will be + // ignored. Also skip it if no new output was produced. This + // avoids null pointer + 0 (undefined behavior) when out == 0. + if (!coder->ignore_check && out_used > 0) lzma_check_update(&coder->check, coder->block->check, out + out_start, out_used); diff --git a/contrib/libs/lzma/liblzma/common/block_encoder.c b/contrib/libs/lzma/liblzma/common/block_encoder.c index 520ecc5a49..4a136ef65e 100644 --- a/contrib/libs/lzma/liblzma/common/block_encoder.c +++ b/contrib/libs/lzma/liblzma/common/block_encoder.c @@ -77,8 +77,11 @@ block_encode(void *coder_ptr, const lzma_allocator *allocator, // checked it at the beginning of this function. coder->uncompressed_size += in_used; - lzma_check_update(&coder->check, coder->block->check, - in + in_start, in_used); + // Call lzma_check_update() only if input was consumed. This + // avoids null pointer + 0 (undefined behavior) when in == 0. + if (in_used > 0) + lzma_check_update(&coder->check, coder->block->check, + in + in_start, in_used); if (ret != LZMA_STREAM_END || action == LZMA_SYNC_FLUSH) return ret; diff --git a/contrib/libs/lzma/liblzma/common/common.c b/contrib/libs/lzma/liblzma/common/common.c index a708fdf187..adb50d785d 100644 --- a/contrib/libs/lzma/liblzma/common/common.c +++ b/contrib/libs/lzma/liblzma/common/common.c @@ -35,7 +35,8 @@ lzma_version_string(void) // Memory allocation // /////////////////////// -extern void * lzma_attribute((__malloc__)) lzma_attr_alloc_size(1) +lzma_attr_alloc_size(1) +extern void * lzma_alloc(size_t size, const lzma_allocator *allocator) { // Some malloc() variants return NULL if called with size == 0. @@ -53,7 +54,8 @@ lzma_alloc(size_t size, const lzma_allocator *allocator) } -extern void * lzma_attribute((__malloc__)) lzma_attr_alloc_size(1) +lzma_attr_alloc_size(1) +extern void * lzma_alloc_zero(size_t size, const lzma_allocator *allocator) { // Some calloc() variants return NULL if called with size == 0. @@ -288,13 +290,21 @@ lzma_code(lzma_stream *strm, lzma_action action) strm->next_in, &in_pos, strm->avail_in, strm->next_out, &out_pos, strm->avail_out, action); - strm->next_in += in_pos; - strm->avail_in -= in_pos; - strm->total_in += in_pos; + // Updating next_in and next_out has to be skipped when they are NULL + // to avoid null pointer + 0 (undefined behavior). Do this by checking + // in_pos > 0 and out_pos > 0 because this way NULL + non-zero (a bug) + // will get caught one way or other. + if (in_pos > 0) { + strm->next_in += in_pos; + strm->avail_in -= in_pos; + strm->total_in += in_pos; + } - strm->next_out += out_pos; - strm->avail_out -= out_pos; - strm->total_out += out_pos; + if (out_pos > 0) { + strm->next_out += out_pos; + strm->avail_out -= out_pos; + strm->total_out += out_pos; + } strm->internal->avail_in = strm->avail_in; diff --git a/contrib/libs/lzma/liblzma/common/common.h b/contrib/libs/lzma/liblzma/common/common.h index 11fec52c59..378923e401 100644 --- a/contrib/libs/lzma/liblzma/common/common.h +++ b/contrib/libs/lzma/liblzma/common/common.h @@ -17,17 +17,28 @@ #include "mythread.h" #include "tuklib_integer.h" +// LZMA_API_EXPORT is used to mark the exported API functions. +// It's used to define the LZMA_API macro. +// +// lzma_attr_visibility_hidden is used for marking *declarations* of extern +// variables that are internal to liblzma (-fvisibility=hidden alone is +// enough to hide the *definitions*). Such markings allow slightly more +// efficient code to accesses those variables in ELF shared libraries. #if defined(_WIN32) || defined(__CYGWIN__) # ifdef DLL_EXPORT # define LZMA_API_EXPORT __declspec(dllexport) # else # define LZMA_API_EXPORT # endif +# define lzma_attr_visibility_hidden // Don't use ifdef or defined() below. #elif HAVE_VISIBILITY # define LZMA_API_EXPORT __attribute__((__visibility__("default"))) +# define lzma_attr_visibility_hidden \ + __attribute__((__visibility__("hidden"))) #else # define LZMA_API_EXPORT +# define lzma_attr_visibility_hidden #endif #define LZMA_API(type) LZMA_API_EXPORT type LZMA_API_CALL @@ -47,7 +58,7 @@ // to 2 then symbol versioning is done only if also PIC is defined. // By default Libtool defines PIC when building a shared library and // doesn't define it when building a static library but it can be -// overriden with --with-pic and --without-pic. configure let's rely +// overridden with --with-pic and --without-pic. configure let's rely // on PIC if neither --with-pic or --without-pic was used. #if defined(HAVE_SYMBOL_VERSIONS_LINUX) \ && (HAVE_SYMBOL_VERSIONS_LINUX == 2 && !defined(PIC)) @@ -87,6 +98,23 @@ # endif #endif +// MSVC has __forceinline which shouldn't be combined with the inline keyword +// (results in a warning). +// +// GCC 3.1 added always_inline attribute so we don't need to check +// for __GNUC__ version. Similarly, all relevant Clang versions +// support it (at least Clang 3.0.0 does already). +// Other compilers might support too which also support __has_attribute +// (Solaris Studio) so do that check too. +#if defined(_MSC_VER) +# define lzma_always_inline __forceinline +#elif defined(__GNUC__) || defined(__clang__) || defined(__INTEL_COMPILER) \ + || lzma_has_attribute(__always_inline__) +# define lzma_always_inline inline __attribute__((__always_inline__)) +#else +# define lzma_always_inline inline +#endif + // These allow helping the compiler in some often-executed branches, whose // result is almost always the same. #ifdef __GNUC__ @@ -297,14 +325,14 @@ struct lzma_internal_s { /// Allocates memory -extern void *lzma_alloc(size_t size, const lzma_allocator *allocator) - lzma_attribute((__malloc__)) lzma_attr_alloc_size(1); +lzma_attr_alloc_size(1) +extern void *lzma_alloc(size_t size, const lzma_allocator *allocator); /// Allocates memory and zeroes it (like calloc()). This can be faster /// than lzma_alloc() + memzero() while being backward compatible with /// custom allocators. -extern void * lzma_attribute((__malloc__)) lzma_attr_alloc_size(1) - lzma_alloc_zero(size_t size, const lzma_allocator *allocator); +lzma_attr_alloc_size(1) +extern void *lzma_alloc_zero(size_t size, const lzma_allocator *allocator); /// Frees memory extern void lzma_free(void *ptr, const lzma_allocator *allocator); diff --git a/contrib/libs/lzma/liblzma/common/file_info.c b/contrib/libs/lzma/liblzma/common/file_info.c index a6b7e145ae..799bb024fe 100644 --- a/contrib/libs/lzma/liblzma/common/file_info.c +++ b/contrib/libs/lzma/liblzma/common/file_info.c @@ -350,7 +350,7 @@ file_info_decode(void *coder_ptr, const lzma_allocator *allocator, // coder->temp[coder->temp_size - LZMA_STREAM_HEADER_SIZE]. // // Otherwise we will need to seek. The seeking is done so - // that Stream Footer wil be at the end of coder->temp. + // that Stream Footer will be at the end of coder->temp. // This way it's likely that we also get a complete Index // field into coder->temp without needing a separate seek // for that (unless the Index field is big). diff --git a/contrib/libs/lzma/liblzma/common/filter_encoder.c b/contrib/libs/lzma/liblzma/common/filter_encoder.c index 978b7a6bb5..c7777dfef8 100644 --- a/contrib/libs/lzma/liblzma/common/filter_encoder.c +++ b/contrib/libs/lzma/liblzma/common/filter_encoder.c @@ -37,9 +37,12 @@ typedef struct { uint64_t (*block_size)(const void *options); /// Tells the size of the Filter Properties field. If options are - /// invalid, UINT32_MAX is returned. If this is NULL, props_size_fixed - /// is used. + /// invalid, LZMA_OPTIONS_ERROR is returned and size is set to + /// UINT32_MAX. lzma_ret (*props_size_get)(uint32_t *size, const void *options); + + /// Some filters will always have the same size Filter Properties + /// field. If props_size_get is NULL, this value is used. uint32_t props_size_fixed; /// Encodes Filter Properties. @@ -216,17 +219,17 @@ lzma_filters_update(lzma_stream *strm, const lzma_filter *filters) extern lzma_ret lzma_raw_encoder_init(lzma_next_coder *next, const lzma_allocator *allocator, - const lzma_filter *options) + const lzma_filter *filters) { return lzma_raw_coder_init(next, allocator, - options, (lzma_filter_find)(&encoder_find), true); + filters, (lzma_filter_find)(&encoder_find), true); } extern LZMA_API(lzma_ret) -lzma_raw_encoder(lzma_stream *strm, const lzma_filter *options) +lzma_raw_encoder(lzma_stream *strm, const lzma_filter *filters) { - lzma_next_strm_init(lzma_raw_coder_init, strm, options, + lzma_next_strm_init(lzma_raw_coder_init, strm, filters, (lzma_filter_find)(&encoder_find), true); strm->internal->supported_actions[LZMA_RUN] = true; diff --git a/contrib/libs/lzma/liblzma/common/index.c b/contrib/libs/lzma/liblzma/common/index.c index 24ec3c10c2..8a35f4398d 100644 --- a/contrib/libs/lzma/liblzma/common/index.c +++ b/contrib/libs/lzma/liblzma/common/index.c @@ -10,6 +10,7 @@ // /////////////////////////////////////////////////////////////////////////////// +#include "common.h" #include "index.h" #include "stream_flags_common.h" @@ -660,6 +661,12 @@ lzma_index_append(lzma_index *i, const lzma_allocator *allocator, if (uncompressed_base + uncompressed_size > LZMA_VLI_MAX) return LZMA_DATA_ERROR; + // Check that the new unpadded sum will not overflow. This is + // checked again in index_file_size(), but the unpadded sum is + // passed to vli_ceil4() which expects a valid lzma_vli value. + if (compressed_base + unpadded_size > UNPADDED_SIZE_MAX) + return LZMA_DATA_ERROR; + // Check that the file size will stay within limits. if (index_file_size(s->node.compressed_base, compressed_base + unpadded_size, s->record_count + 1, diff --git a/contrib/libs/lzma/liblzma/common/index.h b/contrib/libs/lzma/liblzma/common/index.h index 64e97247dd..7b27d7004c 100644 --- a/contrib/libs/lzma/liblzma/common/index.h +++ b/contrib/libs/lzma/liblzma/common/index.h @@ -2,6 +2,13 @@ // /// \file index.h /// \brief Handling of Index +/// \note This header file does not include common.h or lzma.h because +/// this file is needed by both liblzma internally and by the +/// tests. Including common.h will include and define many things +/// the tests do not need and prevents issues with header file +/// include order. This way, if lzma.h or common.h are not +/// included before this file it will break on every OS instead +/// of causing more subtle errors. // // Author: Lasse Collin // @@ -13,8 +20,6 @@ #ifndef LZMA_INDEX_H #define LZMA_INDEX_H -#include "common.h" - /// Minimum Unpadded Size #define UNPADDED_SIZE_MIN LZMA_VLI_C(5) @@ -22,6 +27,9 @@ /// Maximum Unpadded Size #define UNPADDED_SIZE_MAX (LZMA_VLI_MAX & ~LZMA_VLI_C(3)) +/// Index Indicator based on xz specification +#define INDEX_INDICATOR 0 + /// Get the size of the Index Padding field. This is needed by Index encoder /// and decoder, but applications should have no use for this. @@ -38,7 +46,7 @@ extern void lzma_index_prealloc(lzma_index *i, lzma_vli records); static inline lzma_vli vli_ceil4(lzma_vli vli) { - assert(vli <= LZMA_VLI_MAX); + assert(vli <= UNPADDED_SIZE_MAX); return (vli + 3) & ~LZMA_VLI_C(3); } diff --git a/contrib/libs/lzma/liblzma/common/index_decoder.c b/contrib/libs/lzma/liblzma/common/index_decoder.c index b268988533..19a31b3e94 100644 --- a/contrib/libs/lzma/liblzma/common/index_decoder.c +++ b/contrib/libs/lzma/liblzma/common/index_decoder.c @@ -80,7 +80,7 @@ index_decode(void *coder_ptr, const lzma_allocator *allocator, // format". One could argue that the application should // verify the Index Indicator before trying to decode the // Index, but well, I suppose it is simpler this way. - if (in[(*in_pos)++] != 0x00) + if (in[(*in_pos)++] != INDEX_INDICATOR) return LZMA_DATA_ERROR; coder->sequence = SEQ_COUNT; @@ -203,9 +203,16 @@ index_decode(void *coder_ptr, const lzma_allocator *allocator, } out: - // Update the CRC32, - coder->crc32 = lzma_crc32(in + in_start, - *in_pos - in_start, coder->crc32); + // Update the CRC32. + // + // Avoid null pointer + 0 (undefined behavior) in "in + in_start". + // In such a case we had no input and thus in_used == 0. + { + const size_t in_used = *in_pos - in_start; + if (in_used > 0) + coder->crc32 = lzma_crc32(in + in_start, + in_used, coder->crc32); + } return ret; } diff --git a/contrib/libs/lzma/liblzma/common/index_decoder.h b/contrib/libs/lzma/liblzma/common/index_decoder.h index 1af433b58b..3fec483331 100644 --- a/contrib/libs/lzma/liblzma/common/index_decoder.h +++ b/contrib/libs/lzma/liblzma/common/index_decoder.h @@ -13,6 +13,7 @@ #ifndef LZMA_INDEX_DECODER_H #define LZMA_INDEX_DECODER_H +#include "common.h" #include "index.h" diff --git a/contrib/libs/lzma/liblzma/common/index_encoder.c b/contrib/libs/lzma/liblzma/common/index_encoder.c index ac97d0cebf..204490cc19 100644 --- a/contrib/libs/lzma/liblzma/common/index_encoder.c +++ b/contrib/libs/lzma/liblzma/common/index_encoder.c @@ -65,7 +65,7 @@ index_encode(void *coder_ptr, while (*out_pos < out_size) switch (coder->sequence) { case SEQ_INDICATOR: - out[*out_pos] = 0x00; + out[*out_pos] = INDEX_INDICATOR; ++*out_pos; coder->sequence = SEQ_COUNT; break; @@ -153,8 +153,15 @@ index_encode(void *coder_ptr, out: // Update the CRC32. - coder->crc32 = lzma_crc32(out + out_start, - *out_pos - out_start, coder->crc32); + // + // Avoid null pointer + 0 (undefined behavior) in "out + out_start". + // In such a case we had no input and thus out_used == 0. + { + const size_t out_used = *out_pos - out_start; + if (out_used > 0) + coder->crc32 = lzma_crc32(out + out_start, + out_used, coder->crc32); + } return ret; } diff --git a/contrib/libs/lzma/liblzma/common/index_hash.c b/contrib/libs/lzma/liblzma/common/index_hash.c index 34df85d72f..52c3d65077 100644 --- a/contrib/libs/lzma/liblzma/common/index_hash.c +++ b/contrib/libs/lzma/liblzma/common/index_hash.c @@ -145,7 +145,7 @@ lzma_index_hash_append(lzma_index_hash *index_hash, lzma_vli unpadded_size, lzma_vli uncompressed_size) { // Validate the arguments. - if (index_hash->sequence != SEQ_BLOCK + if (index_hash == NULL || index_hash->sequence != SEQ_BLOCK || unpadded_size < UNPADDED_SIZE_MIN || unpadded_size > UNPADDED_SIZE_MAX || uncompressed_size > LZMA_VLI_MAX) @@ -190,7 +190,7 @@ lzma_index_hash_decode(lzma_index_hash *index_hash, const uint8_t *in, switch (index_hash->sequence) { case SEQ_BLOCK: // Check the Index Indicator is present. - if (in[(*in_pos)++] != 0x00) + if (in[(*in_pos)++] != INDEX_INDICATOR) return LZMA_DATA_ERROR; index_hash->sequence = SEQ_COUNT; @@ -328,9 +328,16 @@ lzma_index_hash_decode(lzma_index_hash *index_hash, const uint8_t *in, } out: - // Update the CRC32, - index_hash->crc32 = lzma_crc32(in + in_start, - *in_pos - in_start, index_hash->crc32); + // Update the CRC32. + // + // Avoid null pointer + 0 (undefined behavior) in "in + in_start". + // In such a case we had no input and thus in_used == 0. + { + const size_t in_used = *in_pos - in_start; + if (in_used > 0) + index_hash->crc32 = lzma_crc32(in + in_start, + in_used, index_hash->crc32); + } return ret; } diff --git a/contrib/libs/lzma/liblzma/common/lzip_decoder.c b/contrib/libs/lzma/liblzma/common/lzip_decoder.c index 20794f9466..88cc7ffd23 100644 --- a/contrib/libs/lzma/liblzma/common/lzip_decoder.c +++ b/contrib/libs/lzma/liblzma/common/lzip_decoder.c @@ -186,7 +186,7 @@ lzip_decode(void *coder_ptr, const lzma_allocator *allocator, // The five lowest bits are for the base-2 logarithm of // the dictionary size and the highest three bits are // the fractional part (0/16 to 7/16) that will be - // substracted to get the final value. + // subtracted to get the final value. // // For example, with 0xB5: // b2log = 21 @@ -262,7 +262,11 @@ lzip_decode(void *coder_ptr, const lzma_allocator *allocator, coder->member_size += *in_pos - in_start; coder->uncompressed_size += out_used; - if (!coder->ignore_check) + // Don't update the CRC32 if the integrity check will be + // ignored or if there was no new output. The latter is + // important in case out == NULL to avoid null pointer + 0 + // which is undefined behavior. + if (!coder->ignore_check && out_used > 0) coder->crc32 = lzma_crc32(out + out_start, out_used, coder->crc32); diff --git a/contrib/libs/lzma/liblzma/common/memcmplen.h b/contrib/libs/lzma/liblzma/common/memcmplen.h index 5a481a02c9..99d9c519cc 100644 --- a/contrib/libs/lzma/liblzma/common/memcmplen.h +++ b/contrib/libs/lzma/liblzma/common/memcmplen.h @@ -19,6 +19,16 @@ # include <immintrin.h> #endif +// Only include <intrin.h> if it is needed. The header is only needed +// on Windows when using an MSVC compatible compiler. The Intel compiler +// can use the intrinsics without the header file. +#if defined(TUKLIB_FAST_UNALIGNED_ACCESS) \ + && defined(_MSC_VER) \ + && defined(_M_X64) \ + && !defined(__INTEL_COMPILER) +# include <intrin.h> +#endif + /// Find out how many equal bytes the two buffers have. /// @@ -39,7 +49,7 @@ /// It's rounded up to 2^n. This extra amount needs to be /// allocated in the buffers being used. It needs to be /// initialized too to keep Valgrind quiet. -static inline uint32_t lzma_attribute((__always_inline__)) +static lzma_always_inline uint32_t lzma_memcmplen(const uint8_t *buf1, const uint8_t *buf2, uint32_t len, uint32_t limit) { @@ -59,11 +69,13 @@ lzma_memcmplen(const uint8_t *buf1, const uint8_t *buf2, while (len < limit) { const uint64_t x = read64ne(buf1 + len) - read64ne(buf2 + len); if (x != 0) { -# if defined(_M_X64) // MSVC or Intel C compiler on Windows + // MSVC or Intel C compiler on Windows +# if (defined(_MSC_VER) || defined(__INTEL_COMPILER)) && defined(_M_X64) unsigned long tmp; _BitScanForward64(&tmp, x); len += (uint32_t)tmp >> 3; -# else // GCC, clang, or Intel C compiler + // GCC, Clang, or Intel C compiler +# else len += (uint32_t)__builtin_ctzll(x) >> 3; # endif return my_min(len, limit); @@ -89,7 +101,8 @@ lzma_memcmplen(const uint8_t *buf1, const uint8_t *buf2, // version isn't used on x86-64. # define LZMA_MEMCMPLEN_EXTRA 16 while (len < limit) { - const uint32_t x = 0xFFFF ^ _mm_movemask_epi8(_mm_cmpeq_epi8( + const uint32_t x = 0xFFFF ^ (uint32_t)_mm_movemask_epi8( + _mm_cmpeq_epi8( _mm_loadu_si128((const __m128i *)(buf1 + len)), _mm_loadu_si128((const __m128i *)(buf2 + len)))); diff --git a/contrib/libs/lzma/liblzma/common/microlzma_encoder.c b/contrib/libs/lzma/liblzma/common/microlzma_encoder.c index d3ef0632dd..a787ca25b8 100644 --- a/contrib/libs/lzma/liblzma/common/microlzma_encoder.c +++ b/contrib/libs/lzma/liblzma/common/microlzma_encoder.c @@ -111,7 +111,8 @@ microlzma_encoder_init(lzma_next_coder *next, const lzma_allocator *allocator, // Encode the properties byte. Bitwise-negation of it will be the // first output byte. - return_if_error(lzma_lzma_lclppb_encode(options, &coder->props)); + if (lzma_lzma_lclppb_encode(options, &coder->props)) + return LZMA_OPTIONS_ERROR; // Initialize the LZMA encoder. const lzma_filter_info filters[2] = { diff --git a/contrib/libs/lzma/liblzma/common/stream_buffer_encoder.c b/contrib/libs/lzma/liblzma/common/stream_buffer_encoder.c index af49554a6b..73157590e6 100644 --- a/contrib/libs/lzma/liblzma/common/stream_buffer_encoder.c +++ b/contrib/libs/lzma/liblzma/common/stream_buffer_encoder.c @@ -10,6 +10,7 @@ // /////////////////////////////////////////////////////////////////////////////// +#include "common.h" #include "index.h" diff --git a/contrib/libs/lzma/liblzma/common/stream_decoder.c b/contrib/libs/lzma/liblzma/common/stream_decoder.c index dcf7c1499f..64283812f2 100644 --- a/contrib/libs/lzma/liblzma/common/stream_decoder.c +++ b/contrib/libs/lzma/liblzma/common/stream_decoder.c @@ -12,6 +12,7 @@ #include "stream_decoder.h" #include "block_decoder.h" +#include "index.h" typedef struct { @@ -164,7 +165,7 @@ stream_decode(void *coder_ptr, const lzma_allocator *allocator, if (coder->pos == 0) { // Detect if it's Index. - if (in[*in_pos] == 0x00) { + if (in[*in_pos] == INDEX_INDICATOR) { coder->sequence = SEQ_INDEX; break; } diff --git a/contrib/libs/lzma/liblzma/common/stream_decoder_mt.c b/contrib/libs/lzma/liblzma/common/stream_decoder_mt.c index 5733c76489..76212b46da 100644 --- a/contrib/libs/lzma/liblzma/common/stream_decoder_mt.c +++ b/contrib/libs/lzma/liblzma/common/stream_decoder_mt.c @@ -629,7 +629,7 @@ get_thread(struct lzma_stream_coder *coder, const lzma_allocator *allocator) coder->thr = coder->threads_free; coder->threads_free = coder->threads_free->next; - // The thread is no longer in the cache so substract + // The thread is no longer in the cache so subtract // it from the cached memory usage. Don't add it // to mem_in_use though; the caller will handle it // since it knows how much memory it will actually @@ -887,7 +887,7 @@ decode_block_header(struct lzma_stream_coder *coder, if (coder->pos == 0) { // Detect if it's Index. - if (in[*in_pos] == 0x00) + if (in[*in_pos] == INDEX_INDICATOR) return LZMA_INDEX_DETECTED; // Calculate the size of the Block Header. Note that @@ -1358,9 +1358,11 @@ stream_decode_mt(void *coder_ptr, const lzma_allocator *allocator, // values after we read these as those changes can only be // towards more favorable conditions (less memory in use, // more in cache). - uint64_t mem_in_use; - uint64_t mem_cached; - struct worker_thread *thr = NULL; // Init to silence warning. + // + // These are initialized to silence warnings. + uint64_t mem_in_use = 0; + uint64_t mem_cached = 0; + struct worker_thread *thr = NULL; mythread_sync(coder->mutex) { mem_in_use = coder->mem_in_use; @@ -1423,7 +1425,7 @@ stream_decode_mt(void *coder_ptr, const lzma_allocator *allocator, } // Update the memory usage counters. Note that coder->mem_* - // may have changed since we read them so we must substract + // may have changed since we read them so we must subtract // or add the changes. mythread_sync(coder->mutex) { coder->mem_cached -= mem_freed; @@ -1436,7 +1438,7 @@ stream_decode_mt(void *coder_ptr, const lzma_allocator *allocator, // coder->mem_cached might count the same thing twice. // If so, this will get corrected in get_thread() when // a worker_thread is picked from coder->free_threads - // and its memory usage is substracted from mem_cached. + // and its memory usage is subtracted from mem_cached. coder->mem_in_use += coder->mem_next_in + coder->mem_next_filters; } diff --git a/contrib/libs/lzma/liblzma/common/stream_encoder_mt.c b/contrib/libs/lzma/liblzma/common/stream_encoder_mt.c index f4497c10b9..f64de9bdbc 100644 --- a/contrib/libs/lzma/liblzma/common/stream_encoder_mt.c +++ b/contrib/libs/lzma/liblzma/common/stream_encoder_mt.c @@ -645,7 +645,7 @@ stream_encode_in(lzma_stream_coder *coder, const lzma_allocator *allocator, } if (block_error) { - lzma_ret ret; + lzma_ret ret = LZMA_OK; // Init to silence a warning. mythread_sync(coder->mutex) { ret = coder->thread_error; @@ -743,7 +743,7 @@ stream_encode_mt(void *coder_ptr, const lzma_allocator *allocator, // These are for wait_for_work(). bool has_blocked = false; - mythread_condtime wait_abs; + mythread_condtime wait_abs = { 0 }; while (true) { mythread_sync(coder->mutex) { diff --git a/contrib/libs/lzma/liblzma/common/stream_flags_common.h b/contrib/libs/lzma/liblzma/common/stream_flags_common.h index 9f3122a3b1..84e96ba1ff 100644 --- a/contrib/libs/lzma/liblzma/common/stream_flags_common.h +++ b/contrib/libs/lzma/liblzma/common/stream_flags_common.h @@ -18,7 +18,10 @@ /// Size of the Stream Flags field #define LZMA_STREAM_FLAGS_SIZE 2 +lzma_attr_visibility_hidden extern const uint8_t lzma_header_magic[6]; + +lzma_attr_visibility_hidden extern const uint8_t lzma_footer_magic[2]; diff --git a/contrib/libs/lzma/liblzma/common/string_conversion.c b/contrib/libs/lzma/liblzma/common/string_conversion.c index 53fdff2a62..d2c1e80936 100644 --- a/contrib/libs/lzma/liblzma/common/string_conversion.c +++ b/contrib/libs/lzma/liblzma/common/string_conversion.c @@ -197,7 +197,7 @@ typedef struct { /// (default is uint32_t). /// /// Stringifying a filter is done by processing a given number of options -/// in oder from the beginning of an option_map array. The integer is +/// in order from the beginning of an option_map array. The integer is /// read from filter_options at .offset using the type from .type. /// /// If the integer is zero and .flags has OPTMAP_NO_STRFY_ZERO then the @@ -316,7 +316,7 @@ parse_lzma12_preset(const char **const str, const char *str_end, assert(*str < str_end); *preset = (uint32_t)(**str - '0'); - // NOTE: Remember to update LZMA_PRESET_STR if this is modified! + // NOTE: Remember to update LZMA12_PRESET_STR if this is modified! while (++*str < str_end) { switch (**str) { case 'e': @@ -466,9 +466,9 @@ static const struct { /// If the flag LZMA_STR_ENCODER is used then the first /// strfy_encoder elements of optmap are stringified. /// With LZMA_STR_DECODER strfy_decoder is used. - /// Currently encoders use all flags that decoders do but if + /// Currently encoders use all options that decoders do but if /// that changes then this needs to be changed too, for example, - /// add a new OPTMAP flag to skip printing some decoder-only flags. + /// add a new OPTMAP flag to skip printing some decoder-only options. const option_map *optmap; uint8_t strfy_encoder; uint8_t strfy_decoder; @@ -538,7 +538,7 @@ static const struct { /// /// The input string starts at *str and the address in str_end is the first /// char that is not part of the string anymore. So no '\0' terminator is -/// used. *str is advanced everytime something has been decoded successfully. +/// used. *str is advanced every time something has been decoded successfully. static const char * parse_options(const char **const str, const char *str_end, void *filter_options, @@ -667,7 +667,7 @@ parse_options(const char **const str, const char *str_end, && *p >= '0' && *p <= '9'); if (p < name_eq_value_end) { - // Remember this position so that it an be + // Remember this position so that it can be // used for error messages that are // specifically about the suffix. (Out of // range values are about the whole value @@ -844,7 +844,7 @@ parse_filter(const char **const str, const char *str_end, lzma_filter *filter, /// Converts the string to a filter chain (array of lzma_filter structures). /// -/// *str is advanced everytime something has been decoded successfully. +/// *str is advanced every time something has been decoded successfully. /// This way the caller knows where in the string a possible error occurred. static const char * str_to_filters(const char **const str, lzma_filter *filters, uint32_t flags, @@ -1131,6 +1131,13 @@ lzma_str_from_filters(char **output_str, const lzma_filter *filters, const char *opt_delim = (flags & LZMA_STR_GETOPT_LONG) ? "=" : ":"; for (size_t i = 0; filters[i].id != LZMA_VLI_UNKNOWN; ++i) { + // If we reach LZMA_FILTERS_MAX, then the filters array + // is too large since the ID cannot be LZMA_VLI_UNKNOWN here. + if (i == LZMA_FILTERS_MAX) { + str_free(&dest, allocator); + return LZMA_OPTIONS_ERROR; + } + // Don't add a space between filters if the caller // doesn't want them. if (i > 0 && !(flags & LZMA_STR_NO_SPACES)) diff --git a/contrib/libs/lzma/liblzma/delta/delta_decoder.c b/contrib/libs/lzma/liblzma/delta/delta_decoder.c index 13d8a28f0d..77cf65cc76 100644 --- a/contrib/libs/lzma/liblzma/delta/delta_decoder.c +++ b/contrib/libs/lzma/liblzma/delta/delta_decoder.c @@ -42,7 +42,12 @@ delta_decode(void *coder_ptr, const lzma_allocator *allocator, in, in_pos, in_size, out, out_pos, out_size, action); - decode_buffer(coder, out + out_start, *out_pos - out_start); + // out might be NULL. In that case size == 0. Null pointer + 0 is + // undefined behavior so skip the call in that case as it would + // do nothing anyway. + const size_t size = *out_pos - out_start; + if (size > 0) + decode_buffer(coder, out + out_start, size); return ret; } diff --git a/contrib/libs/lzma/liblzma/delta/delta_encoder.c b/contrib/libs/lzma/liblzma/delta/delta_encoder.c index 3841651516..056bf7468e 100644 --- a/contrib/libs/lzma/liblzma/delta/delta_encoder.c +++ b/contrib/libs/lzma/liblzma/delta/delta_encoder.c @@ -63,7 +63,12 @@ delta_encode(void *coder_ptr, const lzma_allocator *allocator, const size_t out_avail = out_size - *out_pos; const size_t size = my_min(in_avail, out_avail); - copy_and_encode(coder, in + *in_pos, out + *out_pos, size); + // in and out might be NULL. In such cases size == 0. + // Null pointer + 0 is undefined behavior so skip + // the call in that case as it would do nothing anyway. + if (size > 0) + copy_and_encode(coder, in + *in_pos, out + *out_pos, + size); *in_pos += size; *out_pos += size; @@ -78,7 +83,10 @@ delta_encode(void *coder_ptr, const lzma_allocator *allocator, in, in_pos, in_size, out, out_pos, out_size, action); - encode_in_place(coder, out + out_start, *out_pos - out_start); + // Like above, avoid null pointer + 0. + const size_t size = *out_pos - out_start; + if (size > 0) + encode_in_place(coder, out + out_start, size); } return ret; diff --git a/contrib/libs/lzma/liblzma/lz/lz_encoder.c b/contrib/libs/lzma/liblzma/lz/lz_encoder.c index 63d4aa057f..3f86c13f7b 100644 --- a/contrib/libs/lzma/liblzma/lz/lz_encoder.c +++ b/contrib/libs/lzma/liblzma/lz/lz_encoder.c @@ -549,7 +549,7 @@ lzma_lz_encoder_init(lzma_next_coder *next, const lzma_allocator *allocator, lzma_lz_options *lz_options)) { #if defined(HAVE_SMALL) && !defined(HAVE_FUNC_ATTRIBUTE_CONSTRUCTOR) - // We need that the CRC32 table has been initialized. + // The CRC32 table must be initialized. lzma_crc32_init(); #endif @@ -569,6 +569,8 @@ lzma_lz_encoder_init(lzma_next_coder *next, const lzma_allocator *allocator, coder->lz.coder = NULL; coder->lz.code = NULL; coder->lz.end = NULL; + coder->lz.options_update = NULL; + coder->lz.set_out_limit = NULL; // mf.size is initialized to silence Valgrind // when used on optimized binaries (GCC may reorder diff --git a/contrib/libs/lzma/liblzma/lz/lz_encoder.h b/contrib/libs/lzma/liblzma/lz/lz_encoder.h index 7950a2f4ef..8d9c6d6e94 100644 --- a/contrib/libs/lzma/liblzma/lz/lz_encoder.h +++ b/contrib/libs/lzma/liblzma/lz/lz_encoder.h @@ -153,9 +153,13 @@ typedef struct { /// Maximum search depth uint32_t depth; - /// TODO: Comment + /// Initial dictionary for the match finder to search. const uint8_t *preset_dict; + /// If the preset dictionary is NULL, this value is ignored. + /// Otherwise this member must indicate the preset dictionary's + /// buffer size. If this size is larger than dict_size, then only + /// the dict_size sized tail of the preset_dict will be used. uint32_t preset_dict_size; } lzma_lz_options; @@ -184,7 +188,7 @@ typedef struct { // // Algorithms such as LZMA2 first try to compress a chunk, and then check // if the encoded result is smaller than the uncompressed one. If the chunk -// was uncompressible, it is better to store it in uncompressed form in +// was incompressible, it is better to store it in uncompressed form in // the output stream. To do this, the whole uncompressed chunk has to be // still available in the history buffer. before_size achieves that. diff --git a/contrib/libs/lzma/liblzma/lz/lz_encoder_hash.h b/contrib/libs/lzma/liblzma/lz/lz_encoder_hash.h index fb15c58146..4d9971ae6a 100644 --- a/contrib/libs/lzma/liblzma/lz/lz_encoder_hash.h +++ b/contrib/libs/lzma/liblzma/lz/lz_encoder_hash.h @@ -17,6 +17,7 @@ // This is to make liblzma produce the same output on big endian // systems that it does on little endian systems. lz_encoder.c // takes care of including the actual table. + lzma_attr_visibility_hidden extern const uint32_t lzma_lz_hash_table[256]; # define hash_table lzma_lz_hash_table #else diff --git a/contrib/libs/lzma/liblzma/lz/lz_encoder_mf.c b/contrib/libs/lzma/liblzma/lz/lz_encoder_mf.c index d03657a7c9..1fdc2d7949 100644 --- a/contrib/libs/lzma/liblzma/lz/lz_encoder_mf.c +++ b/contrib/libs/lzma/liblzma/lz/lz_encoder_mf.c @@ -220,10 +220,11 @@ move_pending(lzma_mf *mf) /// of matches found. #define call_find(func, len_best) \ do { \ - matches_count = func(len_limit, pos, cur, cur_match, mf->depth, \ - mf->son, mf->cyclic_pos, mf->cyclic_size, \ + matches_count = (uint32_t)(func(len_limit, pos, cur, cur_match, \ + mf->depth, mf->son, \ + mf->cyclic_pos, mf->cyclic_size, \ matches + matches_count, len_best) \ - - matches; \ + - matches); \ move_pos(mf); \ return matches_count; \ } while (0) @@ -242,8 +243,8 @@ do { \ /// \param cur_match Start position of the current match candidate /// \param depth Maximum length of the hash chain /// \param son lzma_mf.son (contains the hash chain) -/// \param cyclic_pos -/// \param cyclic_size +/// \param cyclic_pos lzma_mf.cyclic_pos +/// \param cyclic_size lzma_mf_cyclic_size /// \param matches Array to hold the matches. /// \param len_best The length of the longest match found so far. static lzma_match * diff --git a/contrib/libs/lzma/liblzma/lzma/fastpos.h b/contrib/libs/lzma/liblzma/lzma/fastpos.h index cba442c27e..dbeb16f7e3 100644 --- a/contrib/libs/lzma/liblzma/lzma/fastpos.h +++ b/contrib/libs/lzma/liblzma/lzma/fastpos.h @@ -91,6 +91,7 @@ get_dist_slot_2(uint32_t dist) #define FASTPOS_BITS 13 +lzma_attr_visibility_hidden extern const uint8_t lzma_fastpos[1 << FASTPOS_BITS]; diff --git a/contrib/libs/lzma/liblzma/lzma/lzma_encoder.c b/contrib/libs/lzma/liblzma/lzma/lzma_encoder.c index dc62f44f1b..79fdeca290 100644 --- a/contrib/libs/lzma/liblzma/lzma/lzma_encoder.c +++ b/contrib/libs/lzma/liblzma/lzma/lzma_encoder.c @@ -633,7 +633,7 @@ lzma_lzma_encoder_create(void **coder_ptr, const lzma_allocator *allocator, // Currently the maximum encoder dictionary size // is 1.5 GiB due to lz_encoder.c and here we need // to be below 2 GiB to make the rounded up value - // fit in an uint32_t and avoid an infite while-loop + // fit in an uint32_t and avoid an infinite while-loop // (and undefined behavior due to a too large shift). // So do the same check as in LZ encoder, // limiting to 1.5 GiB. @@ -673,7 +673,7 @@ lzma_lzma_encoder_create(void **coder_ptr, const lzma_allocator *allocator, coder->uncomp_size = 0; coder->uncomp_size_ptr = NULL; - // Output size limitting is disabled by default. + // Output size limiting is disabled by default. coder->out_limit = 0; // Determine if end marker is wanted: @@ -712,6 +712,9 @@ static lzma_ret lzma_encoder_init(lzma_lz_encoder *lz, const lzma_allocator *allocator, lzma_vli id, const void *options, lzma_lz_options *lz_options) { + if (options == NULL) + return LZMA_PROG_ERROR; + lz->code = &lzma_encode; lz->set_out_limit = &lzma_lzma_set_out_limit; return lzma_lzma_encoder_create( diff --git a/contrib/libs/lzma/liblzma/rangecoder/price.h b/contrib/libs/lzma/liblzma/rangecoder/price.h index 8ae02ca747..45dbbbb20c 100644 --- a/contrib/libs/lzma/liblzma/rangecoder/price.h +++ b/contrib/libs/lzma/liblzma/rangecoder/price.h @@ -22,6 +22,7 @@ /// Lookup table for the inline functions defined in this file. +lzma_attr_visibility_hidden extern const uint8_t lzma_rc_prices[RC_PRICE_TABLE_SIZE]; diff --git a/contrib/libs/lzma/liblzma/simple/arm64.c b/contrib/libs/lzma/liblzma/simple/arm64.c index 5e7f26562d..0fe0824eb9 100644 --- a/contrib/libs/lzma/liblzma/simple/arm64.c +++ b/contrib/libs/lzma/liblzma/simple/arm64.c @@ -14,6 +14,7 @@ // // Authors: Lasse Collin // Jia Tan +// Igor Pavlov // // This file has been put into the public domain. // You can do whatever you want with this file. diff --git a/contrib/libs/lzma/liblzma/simple/simple_coder.c b/contrib/libs/lzma/liblzma/simple/simple_coder.c index 4f499befe9..ed2d7fb02c 100644 --- a/contrib/libs/lzma/liblzma/simple/simple_coder.c +++ b/contrib/libs/lzma/liblzma/simple/simple_coder.c @@ -139,9 +139,11 @@ simple_code(void *coder_ptr, const lzma_allocator *allocator, return ret; } - // Filter out[]. + // Filter out[] unless there is nothing to filter. + // This way we avoid null pointer + 0 (undefined behavior) + // when out == NULL. const size_t size = *out_pos - out_start; - const size_t filtered = call_filter( + const size_t filtered = size == 0 ? 0 : call_filter( coder, out + out_start, size); const size_t unfiltered = size - filtered; diff --git a/contrib/libs/lzma/ya.make b/contrib/libs/lzma/ya.make index b2f849cb2d..0eeab01f5b 100644 --- a/contrib/libs/lzma/ya.make +++ b/contrib/libs/lzma/ya.make @@ -1,14 +1,17 @@ -# Generated by devtools/yamaker from nixpkgs 22.05. +# Generated by devtools/yamaker from nixpkgs 22.11. LIBRARY() -LICENSE(Public-Domain) +LICENSE( + MIT AND + Public-Domain +) LICENSE_TEXTS(.yandex_meta/licenses.list.txt) -VERSION(5.4.0) +VERSION(5.4.6) -ORIGINAL_SOURCE(https://github.com/tukaani-project/xz/archive/v5.4.0.tar.gz) +ORIGINAL_SOURCE(https://github.com/tukaani-project/xz/archive/v5.4.6.tar.gz) ADDINCL( GLOBAL contrib/libs/lzma/liblzma/api |