aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2024-01-25COPYING: Add the license for the XZ logo.Jia Tan2-0/+432
2024-01-25Doxygen: Added the XZ logo and copyright information.Jia Tan3-3/+14
The PROJECT_LOGO field is now used to include the XZ logo. The footer of each page now lists the copyright information instead of the default footer. The license is also copied to statisfy the copyright and so the link in the documentation can be local.
2024-01-23xz: Use threaded mode by defaut (as if --threads=0 was used).Lasse Collin3-3/+16
This hopefully does more good than bad: + It's faster by default. + Only the threaded compressor creates files that can be decompressed in threaded mode. - Compression ratio is worse, usually not too much though. When it matters, -T1 must be used. - Memory usage increases. - Scripts that assume single-threaded mode but don't use -T1 will possibly use too much resources, for example, if they run multiple xz processes in parallel to compress multiple files. - Output from single-threaded and multi-threaded compressors differ but such changes could happen for other reasons too (they just haven't happened since 5.0.0).
2024-01-23CI: Use RISC-V filter when building with BCJ support.Jia Tan1-2/+2
2024-01-23Tests: Use smaller dictionary size in RISC-V test files.Jia Tan2-0/+0
2024-01-23Tests: Skip RISC-V test files if decoder was not built.Jia Tan1-0/+5
2024-01-23xz: Man page: Add more examples of LZMA2 options with BCJ filters.Lasse Collin1-7/+31
2024-01-23liblzma: RISC-V filter: Use byte-by-byte access.Lasse Collin1-30/+84
Not all RISC-V processors support fast unaligned access so it's better to read only one byte in the main loop. This can be faster even on x86-64 when compared to reading 32 bits at a time as half the time the address is only 16-bit aligned. The downside is larger code size on archs that do support fast unaligned access.
2024-01-23xz: Update xz -lvv for RISC-V filter.Jia Tan1-0/+10
Version 5.6.0 will be shown, even though upcoming alphas and betas will be able to support this filter. 5.6.0 looks nicer in the output and people shouldn't be encouraged to use an unstable version in production in any way.
2024-01-23Tests: Add two RISC-V Filter test files.Jia Tan3-0/+8
These test files achieve 100% code coverage in src/liblzma/simple/riscv.c. They contain all of the instructions that should be filtered and a few cases that should not.
2024-01-23xz: Update message in --long-help for RISC-V Filter.Jia Tan1-0/+1
2024-01-23xz: Update the man page for the RISC-V Filter.Jia Tan1-1/+2
A special note was added to suggest using four-byte alignment when the compressed instruction extension is not present in a RISC-V binary.
2024-01-23Tests: Add RISC-V Filter test in test_compress.sh.Jia Tan1-0/+1
2024-01-23liblzma: Update string_conversion.c to support RISC-V Filter.Jia Tan1-0/+5
2024-01-23CMake: Support RISC-V BCJ Filter for encoding and decoding.Jia Tan1-0/+1
2024-01-23liblzma: Add RISC-V BCJ filter.Jia Tan9-2/+742
The new Filter ID is 0x0B. Thanks to Chien Wong <m@xv97.com> for the initial version of the Filter, the xz CLI updates, and the Autotools build system modifications. Thanks to Igor Pavlov for his many contributions to the design of the filter.
2024-01-19Docs: Update .xz file format specification to 1.2.0.Jia Tan1-12/+17
The new RISC-V filter was added to the specification, in addition to updating the specification URL.
2024-01-19xz: Update website URLs in the man pages.Jia Tan2-5/+5
2024-01-19liblzma: Update website URL.Jia Tan2-4/+4
2024-01-19Docs: Update website URLs.Jia Tan6-15/+17
2024-01-19Build: Update website URL.Jia Tan2-2/+2
2024-01-11liblzma: CRC: Add a comment to crc_x86_clmul.h about BUILDING_ macros.Lasse Collin1-0/+6
2024-01-11liblzma: CRC: Remove crc_always_inline, use lzma_always_inline instead.Lasse Collin2-21/+1
Now crc_simd_body() in crc_x86_clmul.h is only called once in a translation unit, we no longer need to be so cautious about ensuring the always-inline behavior.
2024-01-11liblzma: CRC: Update CLMUL comments to more generic wording.Lasse Collin2-13/+13
2024-01-11liblzma: Rename arch-specific CRC functions and macros.Lasse Collin4-25/+31
CRC_CLMUL was split to CRC_ARCH_OPTIMIZED and CRC_X86_CLMUL. CRC_ARCH_OPTIMIZED is defined when an arch-optimized version is used. Currently the x86 CLMUL implementations are the only arch-optimized versions, and these also use the CRC_x86_CLMUL macro to tell when crc_x86_clmul.h needs to be included. is_clmul_supported() was renamed to is_arch_extension_supported(). crc32_clmul() and crc64_clmul() were renamed to crc32_arch_optimized() and crc64_arch_optimized(). This way the names make sense with arch-specific non-CLMUL implementations as well.
2024-01-11liblzma: Fix a comment in crc_common.h.Lasse Collin1-1/+2
2024-01-11liblzma: Avoid extern lzma_crc32_clmul() and lzma_crc64_clmul().Lasse Collin7-91/+91
A CLMUL-only build will have the crcxx_clmul() inlined into lzma_crcxx(). Previously a jump to the extern lzma_crcxx_clmul() was needed. Notes about shared liblzma on ELF platforms: - On platforms that support ifunc and -fvisibility=hidden, this was silly because CLMUL-only build would have that single extra jump instruction of extra overhead. - On platforms that support neither -fvisibility=hidden nor linker version script (liblzma*.map), jumping to lzma_crcxx_clmul() would go via PLT so a few more instructions of overhead (still not a big issue but silly nevertheless). There was a downside with static liblzma too: if an application only needs lzma_crc64(), static linking would make the linker include the CLMUL code for both CRC32 and CRC64 from crc_x86_clmul.o even though the CRC32 code wouldn't be needed, thus increasing code size of the executable (assuming that -ffunction-sections isn't used). Also, now compilers are likely to inline crc_simd_body() even if they don't support the always_inline attribute (or MSVC's __forceinline). Quite possibly all compilers that build the code do support such an attribute. But now it likely isn't a problem even if the attribute wasn't supported. Now all x86-specific stuff is in crc_x86_clmul.h. If other archs The other archs can then have their own headers with their own is_clmul_supported() and crcxx_clmul(). Another bonus is that the build system doesn't need to care if crc_clmul.c is needed. is_clmul_supported() stays as inline function as it's not needed when doing a CLMUL-only build (avoids a warning about unused function).
2024-01-11liblzma: crc_clmul.c: Add crc_attr_target macro.Lasse Collin1-14/+16
This reduces the number of the complex #if directives.
2024-01-11liblzma: Simplify existing cases with lzma_attr_no_sanitize_address.Lasse Collin1-9/+3
2024-01-11liblzma: #define crc_attr_no_sanitize_address in crc_common.h.Lasse Collin1-0/+10
2024-01-10liblzma: CRC: Add empty lines.Lasse Collin3-1/+5
And remove one too.
2024-01-10liblzma: crc_clmul.c: Tidy up the location of MSVC pragma.Lasse Collin1-2/+2
It makes no difference in practice.
2023-12-28Update THANKS.Lasse Collin1-0/+1
2023-12-28liblzma: Use 8-byte method in memcmplen.h on ARM64.Lasse Collin1-8/+10
It requires fast unaligned access to 64-bit integers and a fast instruction to count leading zeros in a 64-bit integer (__builtin_ctzll()). This perhaps should be enabled on some other archs too. Thanks to Chenxi Mao for the original patch: https://github.com/tukaani-project/xz/pull/75 (the first commit) According to the numbers there, this may improve encoding speed by about 3-5 %. This enables the 8-byte method on MSVC ARM64 too which should work but wasn't tested.
2023-12-28liblzma: Check also for __clang__ in memcmplen.h.Lasse Collin1-1/+2
This change hopefully makes no practical difference as Clang likely was detected via __GNUC__ or _MSC_VER already.
2023-12-21Translations: Update the French translation.Jia Tan1-262/+370
2023-12-21xz: Add a comment to Capsicum sandbox setup.Jia Tan1-0/+1
This comment is repeated in xzdec.c to help remind us why all the capabilities are removed from stdin in certain situations.
2023-12-21Docs: Update --enable-sandbox option in INSTALL.Jia Tan1-7/+10
xzdec now also uses the sandbox when its configured.
2023-12-21CMake: Move sandbox detection outside of xz section.Jia Tan1-80/+98
The sandbox is now enabled for xzdec as well, so it no longer belongs in just the xz section. xz and xzdec are always built, except for older MSVC versions, so there isn't a need to conditionally show the sandbox configuration. CMake will do a little unecessary work on older MSVC versions that can't build xz or xzdec, but this is a very small downside.
2023-12-20Build: Allow sandbox to be configured for just xzdec.Jia Tan1-5/+5
If xz is disabled, then xzdec can still use the sandbox.
2023-12-19xzdec: Add sandbox support for Pledge, Capsicum, and Landlock.Jia Tan1-7/+139
A very strict sandbox is used when the last file is decompressed. The likely most common use case of xzdec is to decompress a single file. The Pledge sandbox is applied to the entire process with slightly more relaxed promises, until the last file is processed. Thanks to Christian Weisgerber for the initial patch adding Pledge sandboxing.
2023-12-20liblzma: Initialize lzma_lz_encoder pointers with NULL.Jia Tan1-1/+5
This fixes the recent change to lzma_lz_encoder that used memzero instead of the NULL constant. On some compilers the NULL constant (always 0) may not equal the NULL pointer (this only needs to guarentee to not point to valid memory address). Later code compares the pointers to the NULL pointer so we must initialize them with the NULL pointer instead of 0 to guarentee code correctness.
2023-12-16liblzma: Set all values in lzma_lz_encoder to NULL after allocation.Jia Tan1-3/+1
The first member of lzma_lz_encoder doesn't necessarily need to be set to NULL since it will always be set before anything tries to use it. However the function pointer members must be set to NULL since other functions rely on this NULL value to determine if this behavior is supported or not. This fixes a somewhat serious bug, where the options_update() and set_out_limit() function pointers are not set to NULL. This seems to have been forgotten since these function pointers were added many years after the original two (code() and end()). The problem is that by not setting this to NULL we are relying on the memory allocation to zero things out if lzma_filters_update() is called on a LZMA1 encoder. The function pointer for set_out_limit() is less serious because there is not an API function that could call this in an incorrect way. set_out_limit() is only called by the MicroLZMA encoder, which must use LZMA1 where set_out_limit() is always set. Its currently not possible to call set_out_limit() on an LZMA2 encoder at this time. So calling lzma_filters_update() on an LZMA1 encoder had undefined behavior since its possible that memory could be manipulated so the options_update member pointed to a different instruction sequence. This is unlikely to be a bug in an existing application since it relies on calling lzma_filters_update() on an LZMA1 encoder in the first place. For instance, it does not affect xz because lzma_filters_update() can only be used when encoding to the .xz format. This is fixed by using memzero() to set all members of lzma_lz_encoder to NULL after it is allocated. This ensures this mistake will not occur here in the future if any additional function pointers are added.
2023-12-16liblzma: Tweak a comment.Jia Tan1-1/+1
2023-12-16liblzma: Make parameter names in function definition match declaration.Jia Tan1-4/+4
lzma_raw_encoder() and lzma_raw_encoder_init() used "options" as the parameter name instead of "filters" (used by the declaration). "filters" is more clear since the parameter represents the list of filters passed to the raw encoder, each of which contains filter options.
2023-12-16liblzma: Improve lzma encoder init function consistency.Jia Tan1-0/+3
lzma_encoder_init() did not check for NULL options, but lzma2_encoder_init() did. This is more of a code style improvement than anything else to help make lzma_encoder_init() and lzma2_encoder_init() more similar.
2023-12-16Docs: Update repository URL in Changelog.Jia Tan1-1/+1
2023-12-15CI: Update Upload Artifact Action.Jia Tan2-2/+2
2023-12-07Tests: Silence -Wsign-conversion warning on GCC version < 10.Jia Tan1-1/+1
Since GCC version 10, GCC no longer complains about simple implicit integer conversions with Arithmetic operators. For instance: uint8_t a = 5; uint32_t b = a + 5; Give a warning on GCC 9 and earlier but this: uint8_t a = 5; uint32_t b = (a + 5) * 2; Gives a warning with GCC 10+.
2023-12-07Update THANKS.Jia Tan1-0/+1
2023-12-07Tests: Minor cleanups to OSS-Fuzz files.Jia Tan7-56/+66
Most of these fixes are small typos and tweaks. A few were caused by bad advice from me. Here is the summary of what is changed: - Author line edits - Small comment changes/additions - Using the return value in the error messages in the fuzz targets' coder initialization code - Removed fuzz_encode_stream.options. This set a max length, which may prevent some worthwhile code paths from being properly exercised. - Removed the max_len option from fuzz_decode_stream.options for the same reason as fuzz_encode_stream. The alone decoder fuzz target still has this restriction. - Altered the dictionary contents for fuzz_lzma.dict. Instead of keeping the properties static and varying the dictionary size, the properties are varied and the dictionary size is kept small. The dictionary size doesn't have much impact on the code paths but the properties do. Closes: https://github.com/tukaani-project/xz/pull/73
2023-12-07Tests: Add fuzz_encode_stream ossfuzz target.Maksym Vatsyk2-0/+81
This fuzz target handles .xz stream encoding. The first byte of input is used to dynamically set the preset level in order to increase the fuzz coverage of complex critical code paths.
2023-12-07Tests: Add fuzz_decode_alone OSS-Fuzz targetMaksym Vatsyk3-0/+66
This fuzz target that handles LZMA alone decoding. A new fuzz dictionary .dict was also created with common LZMA header values to help speed up the discovery of valid headers.
2023-12-07Tests: Update OSS-Fuzz Makefile.Maksym Vatsyk1-4/+9
All .c files can be built as separate fuzz targets. This simplifies the Makefile by allowing us to use wildcards instead of having a Makefile target for each fuzz target.
2023-12-07Tests: Move common OSS-Fuzz target code to .h file.Maksym Vatsyk2-44/+71
2023-12-07Tests: Rename OSS-Fuzz files.Maksym Vatsyk4-2/+3
2023-11-30Update THANKS.Jia Tan1-0/+1
2023-11-30Tests: Fix typosKian-Meng Ang2-3/+3
2023-11-30xz: Fix typoKian-Meng Ang1-1/+1
2023-11-30Update THANKS.Jia Tan1-0/+1
2023-11-30CI: Test musl libc builds on Ubuntu runner.Jia Tan1-2/+17
2023-11-30CI: Allow ci_build.sh to set a different C compiler.Jia Tan1-1/+10
2023-11-30CMake: Use consistent indentation with check_c_source_compiles().Jia Tan1-2/+2
2023-11-30CMake: Change __attribute__((__ifunc__())) detection.Jia Tan1-8/+45
This renames ALLOW_ATTR_IFUNC to USE_ATTR_IFUNC and applies the ifunc detection changes that were made to the Autotools build. Fixes: https://github.com/tukaani-project/xz/issues/70
2023-11-30Docs: Update INSTALL for --enable_ifunc change.Jia Tan1-8/+8
2023-11-30Build: Change --enable-ifunc handling.Jia Tan1-17/+44
Some compilers support __attribute__((__ifunc__())) even though the dynamic linker does not. The compiler is able to create the binary but it will fail on startup. So it is not enough to just test if the attribute is supported. The default value for enable_ifunc is now auto, which will attempt to compile a program using __attribute__((__ifunc__())). There are additional checks in this program if glibc is being used or if it is running on FreeBSD. Setting --enable-ifunc will skip this test and always enable __attribute__((__ifunc__())), even if is not supported.
2023-11-23xz: Tweak a comment.Lasse Collin1-2/+2
2023-11-23xz: Use is_tty() in message.c.Jia Tan1-6/+1
2023-11-23xz: Create separate is_tty() function.Jia Tan2-7/+37
The new is_tty() will report if a file descriptor is a terminal or not. On POSIX systems, it is a wrapper around isatty(). However, the native Windows implementation of isatty() will return true for all character devices, not just terminals. So is_tty() has a special case for Windows so it can use alternative Windows API functions to determine if a file descriptor is a terminal. This fixes a bug with MSVC and MinGW-w64 builds that refused to read from or write to non-terminal character devices because xz thought it was a terminal. For instance: xz foo -c > /dev/null would fail because /dev/null was assumed to be a terminal.
2023-11-22tuklib_integer: Fix typo discovered by codespell.Jia Tan1-1/+1
Based on internet dictionary searches, 'choise' is an outdated spelling of 'choice'.
2023-11-18xz: Move the check for --suffix with --format=raw a few lines earlier.Lasse Collin1-22/+22
Now it reads from argv[] instead of args->arg_names.
2023-11-18Tests: Create test_suffix.sh.Jia Tan2-0/+191
This tests some complicated interactions with the --suffix= option. The suffix option must be used with --format=raw, but can optionally be used to override the default .xz suffix. This test also verifies some recent bugs have been correctly solved and to hopefully avoid further regressions in the future.
2023-11-17xz: Fix a bug with --files and --files0 in raw mode without a suffix.Jia Tan1-0/+5
The following command caused a segmentation fault: xz -Fraw --lzma1 --files=foo when foo was a valid file. The usage of --files or --files0 was not being checked when compressing or decompressing in raw mode without a suffix. The suffix checking code was meant to validate that all files to be processed are "-" (if not writing to standard out), meaning the data is only coming from standard in. In this case, there were no file names to check since --files and --files0 store their file name in a different place. Later code assumed the suffix was set and caused a segmentation fault. Now, the above command results in an error.
2023-11-17Tests: Fix typo in a comment.Jia Tan1-1/+1
2023-11-15xz: Refactor suffix test with raw format.Jia Tan1-25/+13
The previous version set opt_stdout, but this caused an issue with copying an input file to standard out when decompressing an unknown file type. The following needs to result in an error: echo foo | xz -df since -c, --stdout is not used. This fixes the previous error by not setting opt_stdout.
2023-11-14xz: Move suffix check after stdout mode is detected.Jia Tan1-8/+8
This fixes a bug introduced in cc5aa9ab138beeecaee5a1e81197591893ee9ca0 when the suffix check was initially moved. This caused a situation that previously worked: echo foo | xz -Fraw --lzma1 | wc -c to fail because the old code knew that this would write to standard out so a suffix was not needed.
2023-11-14xz: Detect when all data will be written to standard out earlier.Jia Tan1-0/+21
If the -c, --stdout argument is not used, then we can still detect when the data will be written to standard out if all of the provided filenames are "-" (denoting standard in) or if no filenames are provided.
2023-11-09liblzma: Add missing comments to lz_encoder.h.Jia Tan1-1/+5
2023-11-01Add NEWS for 5.4.5.Jia Tan1-0/+74
2023-10-31liblzma: Fix compilation of fastpos_tablegen.c.Lasse Collin1-0/+2
The macro lzma_attr_visibility_hidden has to be defined to make fastpos.h usable. The visibility attribute is irrelevant to fastpos_tablegen.c so simply #define the macro to an empty value. fastpos_tablegen.c is never built by the included build systems and so the problem wasn't noticed earlier. It's just a standalone program for generating fastpos_table.c. Fixes: https://github.com/tukaani-project/xz/pull/69 Thanks to GitHub user Jamaika1.
2023-10-31Build: Fix text wrapping in an output message.Jia Tan1-4/+5
2023-10-30liblzma: Add a note why crc_always_inline exists for now.Lasse Collin1-0/+5
Solaris Studio is a possible example (not tested) which supports the always_inline attribute but might not get detected by the common.h #ifdefs.
2023-10-30liblzma: Use lzma_always_inline in memcmplen.h.Lasse Collin1-2/+1
2023-10-30liblzma: #define lzma_always_inline in common.h.Lasse Collin1-0/+17
2023-10-30liblzma: Use lzma_attr_visibility_hidden on private extern declarations.Lasse Collin5-0/+13
These variables are internal to liblzma and not exposed in the API.
2023-10-30liblzma: #define lzma_attr_visibility_hidden in common.h.Lasse Collin1-0/+11
In ELF shared libs: -fvisibility=hidden affects definitions of symbols but not declarations.[*] This doesn't affect direct calls to functions inside liblzma as a linker can replace a call to lzma_foo@plt with a call directly to lzma_foo when -fvisibility=hidden is used. [*] It has to be like this because otherwise every installed header file would need to explictly set the symbol visibility to default. When accessing extern variables that aren't defined in the same translation unit, compiler assumes that the variable has the default visibility and thus indirection is needed. Unlike function calls, linker cannot optimize this. Using __attribute__((__visibility__("hidden"))) with the extern variable declarations tells the compiler that indirection isn't needed because the definition is in the same shared library. About 15+ years ago, someone told me that it would be good if the CRC tables would be defined in the same translation unit as the C code of the CRC functions. While I understood that it could help a tiny amount, I didn't want to change the code because a separate translation unit for the CRC tables was needed for the x86 assembly code anyway. But when visibility attributes are supported, simply marking the extern declaration with the hidden attribute will get identical result. When there are only a few affected variables, this is trivial to do. I wish I had understood this back then already.
2023-10-26liblzma: Refer to MinGW-w64 instead of MinGW in the API headers.Lasse Collin2-3/+3
MinGW (formely a MinGW.org Project, later the MinGW.OSDN Project at <https://osdn.net/projects/mingw/>) has GCC 9.2.0 as the most recent GCC package (released 2021-02-02). The project might still be alive but majority of people have switched to MinGW-w64. Thus it seems clearer to refer to MinGW-w64 in our API headers too. Building with MinGW is likely to still work but I haven't tested it in the recent years.
2023-10-26CMake: Use -D_FILE_OFFSET_BITS=64 if (and only if) needed.Lasse Collin2-1/+58
A CMake option LARGE_FILE_SUPPORT is created if and only if -D_FILE_OFFSET_BITS=64 affects sizeof(off_t). This is needed on many 32-bit platforms and even with 64-bit builds with MinGW-w64 to get support for files larger than 2 GiB.
2023-10-26CMake: Generate and install liblzma.pc if not using MSVC.Lasse Collin1-0/+21
Autotools based build uses -pthread and thus adds it to Libs.private in liblzma.pc. CMake doesn't use -pthread at all if pthread functions are available in libc so Libs.private doesn't get -pthread either.
2023-10-26CMake: Rearrange the PACKAGE_ variables.Lasse Collin1-11/+15
The windres workaround now replaces spaces with \x20 so the package name isn't repeated. These changes will help with creation of liblzma.pc.
2023-10-26liblzma: Add Cflags.private to liblzma.pc.in for MSYS2.Lasse Collin1-0/+1
It properly adds -DLZMA_API_STATIC when compiling code that will be linked against static liblzma. Having it there on systems other than Windows does no harm. See: https://www.msys2.org/docs/pkgconfig/
2023-10-26CMake: Create liblzma.def when building liblzma.dll with MinGW-w64.Lasse Collin2-0/+46
2023-10-26CMake: Change one CMAKE_CURRENT_SOURCE_DIR to CMAKE_CURRENT_LIST_DIR.Lasse Collin1-1/+1
In this case they have identical values.
2023-10-26CMake/Windows: Fix the import library filename.Lasse Collin1-0/+1
Both PREFIX and IMPORT_PERFIX have to be set to "" to get liblzma.dll and liblzma.dll.a.
2023-10-25Build: Detect -fsanitize= in CFLAGS and incompatible build options.Lasse Collin2-4/+62
Now configure will fail if -fsanitize= is found in CFLAGS and sanitizer-incompatible ifunc or Landlock sandboxing would be used. These are incompatible with one or more sanitizers. It's simpler to reject all -fsanitize= uses instead of trying to pass those that might not cause problems. CMake-based build was updated similarly. It lets the configuration finish (SEND_ERROR instead of FATAL_ERROR) so that both error messages can be seen at once.
2023-10-24CI: Disable sandboxing in fsanitize=address,undefined job.Jia Tan1-2/+6
The sandboxing on Linux now supports Landlock, which restricts all supported filesystem actions after xz opens the files it needs. The sandbox is only enabled when one file is input and we are writing to standard out. With fsanitize=address,undefined, the instrumentation needs to read additional files after the sandbox is in place. This forces all xz based test to fail, so the sandbox must instead be disabled.
2023-10-24CI: Allow disabling the sandbox in ci_build.sh.Jia Tan1-1/+4
2023-10-22CMake: Don't shadow the cache entry ENABLE_THREADS with a normal variable.Lasse Collin1-3/+7
Using set(ENABLE_THREADS "posix") is confusing because it sets a new normal variable and leaves the cache entry with the same name unchanged. The intent wasn't to change the cache entry so this switches to a different variable name.
2023-10-22Docs: Update INSTALL about sandboxing support.Lasse Collin1-1/+6
2023-10-22xz: Support basic sandboxing with Linux Landlock (ABI versions 1-3).Lasse Collin5-5/+98
It is enabled only when decompressing one file to stdout, similar to how Capsicum is used. Landlock was added in Linux 5.13.
2023-10-22CMake: Edit threading related messages.Lasse Collin1-9/+10
It's mostly to change from "thread method" to "threading method".
2023-10-22CMake: Use FATAL_ERROR if user-supplied options aren't understood.Lasse Collin1-14/+14
This way typos are caught quickly and compounding error messages are avoided (a single typo could cause more than one error). This keeps using SEND_ERROR when the system is lacking a feature (like threading library or sandboxing method). This way the whole configuration log will be generated in case someone wishes to report a problem upstream.
2023-10-22CMake: Add sandboxing support.Lasse Collin1-1/+49
2023-10-22Simplify detection of Capsicum support.Lasse Collin5-98/+9
This removes support for FreeBSD 10.0 and 10.1 which used <sys/capability.h> instead of <sys/capsicum.h>. Support for FreeBSD 10.1 ended on 2016-12-31. So now FreeBSD >= 10.2 is required to enable Capsicum support. This also removes support for Capsicum on Linux (libcaprights) which seems to have been unmaintained since 2017 and Linux 4.11: https://github.com/google/capsicum-linux
2023-10-22xz/Windows: Allow clock_gettime with POSIX threads.Lasse Collin1-3/+6
If winpthreads are used for threading, it's OK to use clock_gettime() from winpthreads too.
2023-10-22mythread.h: Make MYTHREAD_POSIX compatible with MinGW-w64's winpthreads.Lasse Collin1-1/+22
This might be almost useless but it doesn't need much extra code either.
2023-10-22CMake: Check for clock_gettime() even on Windows.Lasse Collin1-23/+21
This mirrors configure.ac although currently MinGW-w64 builds don't use clock_gettime() even if it is found.
2023-10-22Build: Check for clock_gettime() even if not using POSIX threads.Lasse Collin1-13/+18
See the new comment in the code. This also makes the check for clock_gettime() run with MinGW-w64 with which we don't want to use clock_gettime(). The previous commit already took care of this situation.
2023-10-22xz/Windows: Ensure that clock_gettime() isn't used with MinGW-w64.Lasse Collin1-2/+7
This commit alone doesn't change anything in the real-world: - configure.ac currently checks for clock_gettime() only when using pthreads. - CMakeLists.txt doesn't check for clock_gettime() on Windows. So clock_gettime() wasn't used with MinGW-w64 before either. clock_gettime() provides monotonic time and it's better than gettimeofday() in this sense. But clock_gettime() is defined in winpthreads, and liblzma or xz needs nothing else from winpthreads. By avoiding clock_gettime(), we avoid the dependency on libwinpthread-1.dll or the need to link against the static version. As a bonus, GetTickCount64() and MinGW-w64's gettimeofday() can be faster than clock_gettime(CLOCK_MONOTONIC, &tv). The resolution is more than good enough for the progress indicator in xz.
2023-10-22xz/Windows: Use GetTickCount64() with MinGW-w64 if using Vista threads.Lasse Collin1-3/+11
2023-10-21liblzma: Move is_clmul_supported() back to crc_common.h.Jia Tan4-50/+51
This partially reverts creating crc_clmul.c (8c0f9376f58c0696d5d6719705164d35542dd891) where is_clmul_supported() was moved, extern'ed, and renamed to lzma_is_clmul_supported(). This caused a problem when the function call to lzma_is_clmul_supported() results in a call through the PLT. ifunc resolvers run very early in the dynamic loading sequence, so the PLT may not be setup properly at this point. Whether the PLT is used or not for lzma_is_clmul_supported() depened upon the compiler-toolchain used and flags. In liblzma compiled with GCC, for instance, GCC will go through the PLT for function calls internal to liblzma if the version scripts and symbol visibility hiding are not used. If lazy-binding is disabled, then it would have made any program linked with liblzma fail during dynamic loading in the ifunc resolver.
2023-10-19Build: Remove check for COND_CHECK_CRC32 in check/Makefile.inc.Jia Tan1-2/+2
Currently crc32 is always enabled, so COND_CHECK_CRC32 must always be set. Because of this, it makes the recent change to conditionally compile check/crc_clmul.c appear wrong since that file has CLMUL implementations for both CRC32 and CRC64.
2023-10-19CMake: Add ALLOW_CLMUL_CRC option to enable/disable CLMUL.Jia Tan1-19/+25
The option is enabled by default, but will only be visible to a user listing cache variables or using a CMake GUI application if the immintrin.h header file is found. This mirrors our Autotools build --disable-clmul-crc functionality.
2023-10-19liblzma: Fix -fsanitize=address failure with crc_clmul functions.Jia Tan1-0/+6
After forcing crc_simd_body() to always be inlined it caused -fsanitize=address to fail for lzma_crc32_clmul() and lzma_crc64_clmul(). The __no_sanitize_address__ attribute was added to lzma_crc32_clmul() and lzma_crc64_clmul(), but not removed from crc_simd_body(). ASAN and inline functions behavior has changed over the years for GCC specifically, so while strictly required we will keep __attribute__((__no_sanitize_address__)) on crc_simd_body() in case this becomes a requirement in the future. Older GCC versions refuse to inline a function with ASAN if the caller and callee do not agree on sanitization flags (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89124#c3). If the function was forced to be inlined, it will not compile if the callee function has __no_sanitize_address__ but the caller doesn't.
2023-10-18tuklib_integer: Update the CMake test for fast unaligned access.Lasse Collin1-15/+54
2023-10-18Build: Enabled unaligned access by default on PowerPC64LE and some RISC-V.Lasse Collin2-9/+64
PowerPC64LE wasn't tested but it seems like a safe change. POWER8 supports unaligned access in little endian mode. Testing on godbolt.org shows that GCC uses unaligned access by default. The RISC-V macro __riscv_misaligned_fast is very new and not in any stable compiler release yet. Documentation in INSTALL was updated to match. Documentation about an autodetection bug when using ARM64 GCC with -mstrict-align was added to INSTALL. CMake files weren't updated yet.
2023-10-18tuklib_integer: Revise unaligned reads and writes on strict-align archs.Lasse Collin1-67/+189
In XZ Utils context this doesn't matter much because unaligned reads and writes aren't used in hot code when TUKLIB_FAST_UNALIGNED_ACCESS isn't #defined.
2023-10-18tuklib_integer: Add missing write64be and write64le fallback functions.Lasse Collin1-0/+34
2023-10-18liblzma: Set the MSVC optimization fix to only cover lzma_crc64_clmul().Jia Tan1-15/+15
After testing a 32-bit Release build on MSVC, only lzma_crc64_clmul() has the bug. crc_simd_body() and lzma_crc32_clmul() do not need the optimizations disabled.
2023-10-18liblzma: CRC_USE_GENERIC_FOR_SMALL_INPUTS cannot be used with ifunc.Lasse Collin1-1/+3
2023-10-18liblzma: Include common.h in crc_common.h.Lasse Collin2-1/+3
crc_common.h depends on common.h. The headers include common.h except when there is a reason to not do so.
2023-10-18liblzma: Add include guards to crc_common.h.Jia Tan1-0/+5
2023-10-18liblzma: Add the crc_always_inline macro to crc_simd_body().Jia Tan1-1/+1
Forcing this to be inline has a significant speed improvement at the cost of a few repeated instructions. The compilers tested on did not inline this function since it is large and is used twice in the same translation unit.
2023-10-18liblzma: Create crc_always_inline macro.Jia Tan1-0/+15
This macro must be used instead of the inline keyword. On MSVC, it is a replacement for __forceinline which is an MSVC specific keyword that should not be used with inline (it will issue a warning if it is). It does not use a build system check to determine if __attribute__((__always_inline__)) since all compilers that can use CLMUL extensions (except the special case for MSVC) should support this attribute. If this assumption is incorrect then it will result in a bug report instead of silently producing slow code.
2023-10-18liblzma: Refactor CRC comments.Jia Tan2-72/+53
A detailed description of the three dispatch methods was added. Also, duplicated comments now only appear in crc32_fast.c or were removed from both crc32_fast.c and crc64_fast.c if they appeared in crc_clmul.c.
2023-10-18liblzma: Create crc_clmul.c.Jia Tan7-423/+444
Both crc32_clmul() and crc64_clmul() are now exported from crc32_clmul.c as lzma_crc32_clmul() and lzma_crc64_clmul(). This ensures that is_clmul_supported() (now lzma_is_clmul_supported()) is not duplicated between crc32_fast.c and crc64_fast.c. Also, it encapsulates the complexity of the CLMUL implementations into a single file and reduces the complexity of crc32_fast.c and crc64_fast.c. Before, CLMUL code was present in crc32_fast.c, crc64_fast.c, and crc_common.h. During the conversion, various cleanups were applied to code (thanks to Lasse Collin) including: - Require using semicolons with MASK_/L/H/LH macros. - Variable typing and const handling improvements. - Improvements to comments. - Fixes to the pragmas used. - Removed unneeded variables. - Whitespace improvements. - Fixed CRC_USE_GENERIC_FOR_SMALL_INPUTS handling. - Silenced warnings and removed the need for some #pragmas
2023-10-18liblzma: Define CRC_USE_IFUNC in crc_common.h.Jia Tan3-4/+7
When ifunc is supported, we can define a simpler macro instead of repeating the more complex check in both crc32_fast.c and crc64_fast.c.
2023-10-13liblzma: Added crc32_clmul to crc32_fast.c.Hans Jansen2-11/+255
2023-10-13liblzma: Moved CLMUL CRC logic to crc_common.h.Hans Jansen2-247/+240
crc64_fast.c was updated to use the code from crc_common.h instead.
2023-10-13liblzma: Rename crc_macros.h to crc_common.h.Hans Jansen5-5/+5
2023-10-13CI: Bump and ref actions by commit SHA in windows-ci.ymlGabriela Gutierrez1-3/+3
Referencing actions by commit SHA in GitHub workflows guarantees you are using an immutable version. Actions referenced by tags and branches are more vulnerable to attacks, such as the tag being moved to a malicious commit or a malicious commit being pushed to the branch. It's important to make sure the SHA's are from the original repositories and not forks. For reference: https://github.com/msys2/setup-msys2/releases/tag/v2.20.1 https://github.com/msys2/setup-msys2/commit/27b3aa77f672cb6b3054121cfd80c3d22ceebb1d https://github.com/actions/checkout/releases/tag/v4.1.0 https://github.com/actions/checkout/commit/8ade135a41bc03ea155e62e844d188df1ea18608 https://github.com/actions/upload-artifact/releases/tag/v3.1.3 https://github.com/actions/upload-artifact/commit/a8a3f3ad30e3422c9c7b888a15615d19a852ae32 Signed-off-by: Gabriela Gutierrez <gabigutierrez@google.com>
2023-10-13CI: Bump and ref actions by commit SHA in ci.ymlGabriela Gutierrez1-2/+2
Referencing actions by commit SHA in GitHub workflows guarantees you are using an immutable version. Actions referenced by tags and branches are more vulnerable to attacks, such as the tag being moved to a malicious commit or a malicious commit being pushed to the branch. It's important to make sure the SHA's are from the original repositories and not forks. For reference: https://github.com/actions/checkout/releases/tag/v4.1.0 https://github.com/actions/checkout/commit/8ade135a41bc03ea155e62e844d188df1ea18608 https://github.com/actions/upload-artifact/releases/tag/v3.1.3 https://github.com/actions/upload-artifact/commit/a8a3f3ad30e3422c9c7b888a15615d19a852ae32 Signed-off-by: Gabriela Gutierrez <gabigutierrez@google.com>
2023-10-12Build: Update visibility.m4 from Gnulib.Jia Tan1-2/+7
Updating from version 6 -> 8 from upstream. Declarations for variables and function bodies were added to avoid unnecessary failures with -Werror.
2023-10-06Update THANKS.Lasse Collin1-0/+1
2023-10-06CMake/Windows: Fix when the windres workaround is applied.Lasse Collin1-3/+3
CMake doesn't set WIN32 on CYGWIN but the workaround is probably needed on Cygwin too. Same for MSYS and MSYS2. The workaround must not be used with Clang that is acting in MSVC mode. This fixes it by checking for the known environments that need the workaround instead of using "NOT MSVC". Thanks to Martin Storsjö. https://github.com/tukaani-project/xz/commit/0570308ddd9c0e39e85597ebc0e31d4fc81d436f#commitcomment-129098431
2023-09-29CI: Disable CLANG64 MSYS2 environment until bug is resolved.Jia Tan1-3/+5
lld 17.0.1 searches for libraries to link first in the toolchain directories before the local directory when building. The is a problem for us because liblzma.a is installed in MSYS2 CLANG64 by default and xz.exe will thus use the installed library instead of the one being built. This causes tests to fail when they are expecting features to be disabled. More importantly, it will compile xz.exe with an incorrect liblzma and could cause unexpected behavior by being unable to update liblzma code in static builds. The CLANG64 environment can be tested again once this is fixed. Link to bug: https://github.com/llvm/llvm-project/issues/67779.
2023-09-29CMake: Rename xz and man page symlink custom targets.Jia Tan1-3/+3
The Ninja Generator for CMake cannot have a custom target and its BYPRODUCTS have the same name. This has prevented Ninja builds on Unix-like systems since the xz symlinks were introduced in 80a1a8bb838842a2be343bd88ad1462c21c5e2c9.
2023-09-29CMake: Specify LINKER_LANGUAGE for libgnu target to fix Ninja Generator.Jia Tan1-0/+6
CMake is unable to guess the linker language for just a header file so it must be explicitly set.
2023-09-27CMake: Fix Windows build with Clang/LLVM 17.Lasse Collin1-12/+14
llvm-windres 17.0.0 has more accurate emulation of GNU windres, so the hack for GNU windres must now be used with llvm-windres too. LLVM 16.0.6 has the old behavior and there likely won't be more 16.x releases. So we can simply check for >= 17.0.0. See also: https://github.com/llvm/llvm-project/commit/2bcc0fdc58a220cb9921b47ec8a32c85f2511a47
2023-09-26liblzma: Update a comment.Lasse Collin1-2/+1
The C standards don't allow an empty translation unit which can be avoided by declaring something, without exporting any symbols. When I committed f644473a211394447824ea00518d0a214ff3f7f2 I had a feeling that some specific toolchain somewhere didn't like empty object files (assembler or maybe "ar" complained) but I cannot find anything to confirm this now. Quite likely I remembered nonsense. I leave this here as a note to my future self. :-)
2023-09-27liblzma: Avoid compiler warning without creating extra symbol.Jia Tan1-2/+1
When the generic fast crc64 method is used, then we omit lzma_crc64_table[][]. Similar to d9166b52cf3458a4da3eb92224837ca8fc208d79, we can avoid compiler warnings with -Wempty-translation-unit (Clang) or -pedantic (GCC) by creating a never used typedef instead of an extra symbol.
2023-09-26Build: Update the comment about -Werror usage in checks.Lasse Collin1-2/+8
2023-09-26Build: Fix __attribute__((ifunc(...))) detection with clang -Wall.Lasse Collin2-0/+16
Now if user-supplied CFLAGS contains -Wall -Wextra -Wpedantic the two checks that need -Werror will still work. At CMake side there is add_compile_options(-Wall -Wextra) but it didn't affect the -Werror tests. So with both Autotools and CMake only user-supplied CFLAGS could make the checks fail when they shouldn't. This is not a full fix as things like -Wunused-macros in user-supplied CFLAGS will still cause problems with both GCC and Clang.
2023-09-26Build: Fix underquoted AC_LANG_SOURCE.Lasse Collin1-1/+1
It made no practical difference in this case.
2023-09-26Build: Silence two Autoconf warnings.Lasse Collin1-5/+4
There were two uses of AC_COMPILE_IFELSE that didn't use AC_LANG_SOURCE and Autoconf warned about these. The omission had been intentional but it turned out that this didn't do what I thought it would. Autoconf 2.71 manual gives an impression that AC_LANG_SOURCE inserts all #defines that have been made with AC_DEFINE so far (confdefs.h). The idea was that omitting AC_LANG_SOURCE would mean that only the exact code included in the AC_COMPILE_IFELSE call would be compiled. With C programs this is not true: the #defines get added without AC_LANG_SOURCE too. There seems to be no neat way to avoid this. Thus, with the C language at least, adding AC_LANG_SOURCE makes no other difference than silencing a warning from Autoconf. The generated "configure" remains identical. (Docs of AC_LANG_CONFTEST say that the #defines have been inserted since Autoconf 2.63b and that AC_COMPILE_IFELSE uses AC_LANG_CONFTEST. So the behavior is documented if one also reads the docs of macros that one isn't calling directly.) Any extra code, including #defines, can cause problems for these two tests because these tests must use -Werror. CC=clang CFLAGS=-Weverything is the most extreme example. It enables -Wreserved-macro-identifier which warns about #define __EXTENSIONS__ 1 because it begins with two underscores. It's possible to write a test file that passes -Weverything but it becomes impossible when Autoconf inserts confdefs.h. So this commit adds AC_LANG_SOURCE to silence Autoconf warnings. A different solution is needed for -Werror tests.
2023-09-26CMake: Remove accidental extra newline.Jia Tan1-1/+0
2023-09-26Build: Remove Gnulib dependency from tests.Jia Tan1-6/+1
The tests do not use any Gnulib replacements so they do not need to link libgnu.a or have /lib in the include path.
2023-09-26CMake: Remove /lib from tests include path.Jia Tan1-1/+0
The tests never included anything from /lib, so this was not needed.
2023-09-24Scripts: Change quoting style from `...' to '...'.Jia Tan2-2/+2
2023-09-24xz: Change quoting style from `...' to '...'.Jia Tan7-18/+18
2023-09-24liblzma: Change quoting style from `...' to '...'.Jia Tan7-24/+24
This was done for both internal and API headers.
2023-09-24Build: Change quoting style from `...' to '...'.Jia Tan5-15/+15
2023-09-24Docs: Change quoting style from `...' to '...'.Jia Tan3-12/+12
These days the ` and ' do not look symmetric. This quoting style has been changed in various apps over the years including the GNU tools.
2023-09-24lib: Silence -Wsign-conversion in getopt.c.Jia Tan1-3/+3
2023-09-24Build: Update getopt.m4 from Gnulib.Jia Tan1-40/+39
This file was modified from upstream since we do not need to replace getopt() and can avoid complexity and feature tests.
2023-09-26CMake: Add /lib to include path.Jia Tan1-0/+5
2023-09-24CMake: Update libgnu target with new header files.Jia Tan1-0/+5
2023-09-23lib: Update Makefile.am for new header files.Jia Tan1-1/+11
2023-09-24lib: Update getopt1.c from Gnulib.Jia Tan1-34/+22
The only difference was maintaining the conditional inclusion for config.h.
2023-09-23lib: Update getopt.in.h from Gnulib with modifications.Jia Tan1-199/+29
We can still avoid modifying the contents of this file during configuration to simplify the build systems. Gnulib added replacements for inclusions guards for Cygwin. Cygwin should not need getopt_long replacement so this feature can be omitted. <unistd.h> is conditionally included to avoid MSVC since it is not available. The definition for _GL_ARG_NONNULL was also copied into this file from Gnulib since this stage is usually done during gnulib-tool.
2023-09-23lib: Update getopt_int.h from Gnulib.Jia Tan1-61/+48
2023-09-23lib: Update getopt.c from Gnulib with modifications.Jia Tan1-757/+377
The code maintains the prior modifications of conditionally including config.h and disabling NLS support. _GL_UNUSED is repalced with the simple cast to void trick. _GL_UNUSED is only used for these two parameters so its simpler than having to define it.
2023-09-23lib: Add getopt-cdefs.h for getopt_long update.Jia Tan1-0/+70
This was modified slightly from Gnulib. In Gnulib, it expects the @HAVE_SYS_CDEFS_H@ to be replaced. Instead, we can set HAVE_SYS_CDEFS_H on systems that have it and avoid copying another file into the build directory. Since we are not using gnulib-tool, copying extra files requires extra build system updates (and special handling with CMake) so we should avoid when possible.
2023-09-23lib: Copy new header files from Gnulib without modification.Jia Tan4-0/+309
The getopt related files have changed from Gnulib by splitting up getopt.in.h into more modular header files. We could have kept everything in just getopt.in.h, but this will help us continue to update in the future.
2023-09-24Windows: Update the version requirement comments from Win95 to W2k.Lasse Collin2-9/+7
2023-09-24tuklib_physmem: Comment out support for Windows versions older than 2000.Lasse Collin1-11/+9
2023-09-24sysdefs.h: Update the comment about __USE_MINGW_ANSI_STDIO.Lasse Collin1-1/+9
2023-09-22xz: Windows: Don't (de)compress to special files like "con" or "nul".Lasse Collin1-7/+28
Before this commit, the following writes "foo" to the console and deletes the input file: echo foo | xz > con_xz xz --suffix=_xz --decompress con_xz It cannot happen without --suffix because names like con.xz are also special and so attempting to decompress con.xz (or compress con to con.xz) will already fail when opening the input file. Similar thing is possible when compressing. The following writes to "nul" and the input file "n" is deleted. echo foo | xz > n xz --suffix=ul n Now xz checks if the destination is a special file before continuing. DOS/DJGPP version had a check for this but Windows (and OS/2) didn't.
2023-09-22CMake: Wrap two overlong lines that are possible to wrap.Lasse Collin1-2/+4
2023-09-22CMake: Add a comment about threads on Cygwin.Lasse Collin1-0/+1
2023-09-22MSVC: Remove Visual Studio project files and update INSTALL-MSVC.txt.Lasse Collin13-2928/+12
CMake is now the preferred build file generator when building with MSVC.
2023-09-22CMake: Require VS2015 or later for building xzdec.Lasse Collin1-1/+1
xzdec might build with VS2013 but it hasn't been tested. It was never supported before and VS2013 is old anyway so for simplicity only liblzma is supported with VS2013.
2023-09-22CMake: Allow building xz with Visual Studio 2015 and later.Lasse Collin1-1/+1
Building the command line tools xz and xzdec with the combination of CMake + Visual Studio 2015/2017/2019/2022 works now. VS2013 update 2 should still be able to build liblzma. VS2013 cannot build the xz command line tool because xz needs snprintf() that roughly conforms to C99. VS2013 is old and no extra code will be added to support it. Thanks to Kelvin Lee and Jia Tan for testing.
2023-09-22MSVC: #define inline and restrict only when needed.Lasse Collin1-5/+8
This also drops the check for _WIN32 as that shouldn't be needed.
2023-09-22CMake: Add support for replacement getopt_long (lib/getopt*).Lasse Collin1-7/+47
Thanks to Jia Tan for the initial work. I added the libgnu target and made a few related minor edits.
2023-09-22CMake: Bump maximum policy version to 3.27.Lasse Collin1-1/+1
There are several new policies. CMP0149 may affect the Windows SDK version that CMake will choose by default. The new behavior is more predictable, always choosing the latest SDK version by default. The other new policies shouldn't affect this package.
2023-09-22lib/getopt*.c: Include <config.h> only HAVE_CONFIG_H is defined.Lasse Collin2-2/+6
The CMake-based build doesn't use config.h. Up-to-date getopt_long in Gnulib is LGPLv2 so at some point it could be included in XZ Utils too but for now this commit is enough to make CMake-based build possible.
2023-09-22Doxygen: Add more C macro names to PREDEFINED.Lasse Collin1-2/+5
2023-09-22liblzma: Move a few __attribute__ uses in function declarations.Lasse Collin3-7/+10
The API headers have many attributes but these were left as is for now.
2023-09-22xz, xzdec, lzmainfo: Use tuklib_attr_noreturn.Lasse Collin7-25/+37
For compatibility with C23's [[noreturn]], tuklib_attr_noreturn must be at the beginning of declaration (before "extern" or "static", and even before any GNU C's __attribute__). This commit also moves all other function attributes to the beginning of function declarations. "extern" is kept at the beginning of a line so the attributes are listed on separate lines before "extern" or "static".
2023-09-22Remove incorrect uses of __attribute__((__malloc__)).Lasse Collin3-6/+6
xrealloc() is obviously incorrect, modern GCC docs even mention realloc() as an example where this attribute cannot be used. liblzma's lzma_alloc() and lzma_alloc_zero() would be correct uses most of the time but custom allocators may use a memory pool or otherwise hold the pointer so aliasing issues could happen in theory. The xstrdup() case likely was correct but I removed it anyway. Now there are no __malloc__ attributes left in the code. The allocations aren't in hot paths so this should make no practical difference.
2023-09-22Build: Omit -Wc99-c11-compat since it warns about _Noreturn.Lasse Collin1-1/+0
2023-09-22tuklib: Update tuklib_attr_noreturn for C11/C17 and C23.Lasse Collin2-3/+23
This makes no difference for GCC or Clang as they support GNU C's __attribute__((__noreturn__)) but this helps with MSVC: - VS 2019 version 16.7 and later support _Noreturn if the options /std:c11 or /std:c17 are used. This gets handled with the check for __STDC_VERSION__ >= 201112. - When MSVC isn't in C11/C17 mode, __declspec(noreturn) is used. C23 will deprecate _Noreturn (and <stdnoreturn.h>) for [[noreturn]]. This commit anticipates that but the final __STDC_VERSION__ value isn't known yet.
2023-09-22Update THANKS.Lasse Collin1-0/+1
2023-09-22MSVC: xz: Make file_io.c and file_io.h compatible with MSVC.Lasse Collin2-0/+36
Thanks to Kelvin Lee for the original patches and testing the modifications I made.
2023-09-22MSVC: xz: Use GetTickCount64() to implement mytime_now().Lasse Collin1-2/+9
It's available since Windows Vista.
2023-09-22MSVC: xz: Use _stricmp() instead of strcasecmp() in suffix.c.Kelvin Lee1-2/+8
2023-09-22MSVC: xz: Use _isatty() from <io.h> to implement isatty().Kelvin Lee2-0/+10
2023-09-22MSVC: xz: Use _fileno() instead of fileno().Kelvin Lee1-0/+4
2023-09-22MSVC: xzdec: Use _fileno and _setmode.Kelvin Lee1-0/+4
2023-09-22MSVC: Don't #include <unistd.h>.Kelvin Lee4-4/+14
2023-09-19Update THANKS.Lasse Collin1-0/+1
2023-09-14CI: Enable CLMUL in address sanitization test.Jia Tan1-8/+4
The crc64_clmul() function should be ignored by the address sanitizer now so these builds should still pass.
2023-09-14Update THANKS.Lasse Collin1-0/+1
2023-09-14liblzma: Mark crc64_clmul() with __attribute__((__no_sanitize_address__)).Lasse Collin1-0/+8
Thanks to Agostino Sarubbo. Fixes: https://github.com/tukaani-project/xz/issues/62
2023-09-12CMake: Fix time.h checks not running on second CMake run.Jia Tan1-8/+10
If CMake was configured more than once, HAVE_CLOCK_GETTIME and HAVE_CLOCK_MONOTONIC would not be set as compile definitions. The check for librt being needed to provide HAVE_CLOCK_GETTIME was also simplified.
2023-09-12CMake: Fix unconditionally defining HAVE_CLOCK_MONOTONIC.Jia Tan1-5/+3
If HAVE_CLOCK_GETTIME was defined, then HAVE_CLOCK_MONOTONIC was always added as a compile definition even if the check for it failed.
2023-08-31xz: Refactor thousand separator detection and disable it on MSVC.Lasse Collin1-44/+45
Now the two variations of the format strings are created with a macro, and the whole detection code can be easily disabled on platforms where thousand separator formatting is known to not work (MSVC has no support, and on DJGPP 2.05 it can have problems in some cases).
2023-08-31xz: Fix a too relaxed assertion and remove uses of SSIZE_MAX.Lasse Collin2-5/+4
SSIZE_MAX isn't readily available on MSVC. Removing it means that there is one thing less to worry when porting to MSVC.
2023-08-28Tests: Improve invalid unpadded size check in test_lzma_index_append().Jia Tan1-3/+23
This check was extended to test the code added to fix a failing assert in ae5c07b22a6b3766b84f409f1b6b5c100469068a.