Commit Graph

975 Commits

Author SHA1 Message Date
Lasse Collin cfabb62a48 Revert "liblzma: CLMUL CRC64: Workaround a bug in MSVC (VS2015-2022)."
This reverts commit 36edc65ab4.

It was reported that it wasn't a good enough fix and MSVC
still produced (different kind of) bad code when building
for 32-bit x86 if optimizations are enabled.

Thanks to Iouri Kharon.
2023-01-10 12:47:16 +02:00
Lasse Collin 0b64215170 sysdefs.h: Don't include strings.h anymore.
On some platforms src/xz/suffix.c may need <strings.h> for
strcasecmp() but suffix.c includes the header when it needs it.

Unless there is an old system that otherwise supports enough C99
to build XZ Utils but doesn't have C89/C90-compatible <string.h>,
there should be no need to include <strings.h> in sysdefs.h.
2023-01-10 11:56:11 +02:00
Lasse Collin ec2fc39fe4 xz: Include <strings.h> in suffix.c if needed for strcasecmp().
SUSv2 and POSIX.1‐2017 declare only a few functions in <strings.h>.
Of these, strcasecmp() is used on some platforms in suffix.c.
Nothing else in the project needs <strings.h> (at least if
building on a modern system).

sysdefs.h currently includes <strings.h> if HAVE_STRINGS_H is
defined and suffix.c relied on this.

Note that dos/config.h doesn't #define HAVE_STRINGS_H even though
DJGPP does have strings.h. It isn't needed with DJGPP as strcasecmp()
is also in <string.h> in DJGPP.
2023-01-10 11:23:41 +02:00
Lasse Collin 7049c4a76c sysdefs.h: Fix a comment. 2023-01-10 10:05:13 +02:00
Lasse Collin 194a5fab69 sysdefs.h: Don't include memory.h anymore even if it were available.
It quite probably was never needed, that is, any system where memory.h
was required likely couldn't compile XZ Utils for other reasons anyway.

XZ Utils 5.2.6 and later source packages were generated using
Autoconf 2.71 which no longer defines HAVE_MEMORY_H. So the code
being removed is no longer used anyway.
2023-01-10 10:04:06 +02:00
Lasse Collin 36edc65ab4 liblzma: CLMUL CRC64: Workaround a bug in MSVC (VS2015-2022).
I haven't tested with MSVC myself and there doesn't seem to be
information about the problem online, so I'm relying on the bug report.

Thanks to Iouri Kharon for the bug report and the patch.
2023-01-09 12:22:05 +02:00
Jia Tan 6fd39664de
Merge pull request #7 from tukaani-project/tuktest_index_hash
Tuktest index hash
2023-01-07 00:10:50 +08:00
Jia Tan 78e0561dfe Style: Change #if !defined() to #ifndef in mythread.h. 2023-01-06 20:43:31 +08:00
Jia Tan 84f9687cba liblzma: Remove common.h include from common/index.h.
common/index.h is needed by liblzma internally and tests. common.h will
include and define many things that are not needed by the tests. Also,
this prevents include order problems because common.h will redefine
LZMA_API resulting in a warning.
2023-01-05 20:57:25 +08:00
Lasse Collin 4103a2e78a Bump version and soname for 5.5.0alpha.
5.5.0alpha won't be released, it's just to mark that
the branch is not for stable 5.4.x.

Once again there is no API/ABI stability for new features
in devel versions. The major soname won't be bumped even
if API/ABI of new features breaks between devel releases.
2023-01-02 17:20:47 +02:00
Jia Tan bb740e3b11
Build: Only define HAVE_PROGRAM_INVOCATION_NAME if it is set to 1.
HAVE_DECL_PROGRAM_INVOCATION_NAME is renamed to
HAVE_PROGRAM_INVOCATION_NAME. Previously,
HAVE_DECL_PROGRAM_INVOCATION_NAME was always set when
building with autotools. CMake would only set this when it was 1, and the
dos/config.h did not define it. The new macro definition is consistent
across build systems.
2023-01-02 22:33:48 +08:00
Jia Tan f16e12d5e7 liblzma: Add NULL check to lzma_index_hash_append.
This is for consistency with lzma_index_append.
2023-01-02 22:20:04 +08:00
Jia Tan 203b008eb2 liblzma: Replaced hardcoded 0x0 index indicator byte with macro 2023-01-02 22:20:04 +08:00
Jia Tan 2fcba17fc4 xz: Includes <time.h> and <sys/time.h> conditionally in mytime.c.
Previously, mytime.c depended on mythread.h for <time.h> to be included.
2022-12-30 23:34:31 +08:00
Jia Tan f82294c831 liblzma: Includes sys/time.h conditionally in mythread
Previously, <sys/time.h> was always included, even if mythread only used
clock_gettime. <time.h> is still needed even if clock_gettime is not used
though because struct timespec is needed for mythread_condtime.
2022-12-30 23:34:31 +08:00
Jia Tan 74dae7d300 Build: No longer require HAVE_DECL_CLOCK_MONOTONIC to always be set.
Previously, if threading was enabled HAVE_DECL_CLOCK_MONOTONIC would always
be set to 0 or 1. However, this macro was needed in xz so if xz was not
built with threading and HAVE_DECL_CLOCK_MONOTONIC was not defined but
HAVE_CLOCK_GETTIME was, it caused a warning during build. Now,
HAVE_DECL_CLOCK_MONOTONIC has been renamed to HAVE_CLOCK_MONOTONIC and
will only be set if it is 1.
2022-12-30 23:34:31 +08:00
Jia Tan 1275ebfba7 liblzma: Update documentation for lzma_filter_encoder. 2022-12-30 23:34:31 +08:00
Jia Tan 5f7ce42a16 liblzma: Fix lzma_microlzma_encoder() return value.
Using return_if_error on lzma_lzma_lclppb_encode was improper because
return_if_error is expecting an lzma_ret value, but
lzma_lzma_lclppb_encode returns a boolean. This could result in
lzma_microlzma_encoder, which would be misleading for applications.
2022-12-30 23:34:31 +08:00
Lasse Collin 8fd225a2c1 liblzma: Update authors list in arm64.c. 2022-12-16 18:30:02 +02:00
Lasse Collin b69da6d4bb Bump version to 5.4.0 and soname to 5.4.0. 2022-12-13 20:46:41 +02:00
Lasse Collin 854f2f5946 xz: Rename --experimental-arm64 to --arm64. 2022-12-11 21:13:57 +02:00
Lasse Collin 31dbd1e5fb liblzma: Change LZMA_FILTER_ARM64 to the official Filter ID 0x0A. 2022-12-11 21:13:06 +02:00
Lasse Collin 01b3549e52 xz: Make args_info.files_name a const pointer. 2022-12-08 19:24:22 +02:00
Lasse Collin bc665b84ea xz: Don't modify argv[].
The code that parses --memlimit options and --block-list modified
the argv[] when parsing the option string from optarg. This was
visible in "ps auxf" and such and could be confusing. I didn't
understand it back in the day when I wrote that code. Now a copy
is allocated when modifiable strings are needed.
2022-12-08 19:18:16 +02:00
Lasse Collin ac2a747e93 liblzma: Check for unexpected NULL pointers in block_header_decode().
The API docs gave an impression that such checks are done
but they actually weren't done. In practice it made little
difference since the calling code has a bug if these are NULL.

Thanks to Jia Tan for the original patch that checked for
block->filters == NULL.
2022-12-08 17:30:09 +02:00
Lasse Collin 24790f49ae Bump version number for 5.3.5beta.
This also sorts the symbol names alphabetically in liblzma_*.map.
2022-12-01 20:59:32 +02:00
Lasse Collin 62b270988e liblzma: Use __has_attribute(__symver__) to fix Clang detection.
If someone sets up Clang to define __GNUC__ to 10 or greater
then symvers broke. __has_attribute is supported by such GCC
and Clang versions that don't support __symver__ so this should
be much better and simpler way to detect if __symver__ is
actually supported.

Thanks to Tomasz Gajc for the bug report.
2022-12-01 20:55:21 +02:00
Lasse Collin f9ca7d4516 liblzma: Omit zero-skipping from ARM64 filter.
It has some complicated downsides and its usefulness is more limited
than I originally thought. So this change is bad for certain very
specific situations but a generic solution that works for other
filters (and is otherwise better too) is planned anyway. And this
way 7-Zip can use the same compatible filter for the .7z format.

This is still marked as experimental with a new temporary Filter ID.
2022-12-01 18:55:00 +02:00
Lasse Collin 5baec3f0a9 xz: Omit the special notes about ARM64 filter on the man page. 2022-12-01 18:13:27 +02:00
Lasse Collin 0c3627b518 liblzma: Don't be over-specific in lzma_str_to_filters API doc. 2022-12-01 18:12:03 +02:00
Lasse Collin 94adf057f2 liblzma: Silence unused variable warning when BCJ filters are disabled.
Thanks to Jia Tan for the original patch.
2022-12-01 17:54:23 +02:00
Jia Tan 7c16e312cb xz: Remove message_filters_to_str function prototype from message.h.
This was forgotten from 7484744af6.
2022-11-30 18:12:35 +02:00
Jia Tan 0a72b9ca2f liblzma: Improve documentation for string to filter functions. 2022-11-29 22:29:15 +02:00
Lasse Collin a6e21fcede liblzma: Two fixes to lzma_str_list_filters() API docs.
Thanks to Jia Tan.
2022-11-29 22:27:42 +02:00
Lasse Collin 7484744af6 xz: Use lzma_str_from_filters().
Two uses: Displaying encoder filter chain when compressing with -vv,
and displaying the decoder filter chain in --list -vv.
2022-11-28 22:05:32 +02:00
Lasse Collin cedeeca2ea liblzma: Add lzma_str_to_filters, _from_filters, and _list_filters.
lzma_str_to_filters() uses static error messages which makes
them not very precise. It tells the position in the string
where an error occurred though which helps quite a bit if
applications take advantage of it. Dynamic error messages can
be added later with a new flag if it seems important enough.
2022-11-28 21:54:24 +02:00
Lasse Collin 072ebf7b13 liblzma: Make lzma_validate_chain() available outside filter_common.c. 2022-11-28 21:02:19 +02:00
Lasse Collin 5f22bd2d37 liblzma: Remove lzma_lz_decoder_uncompressed() as it's now unused. 2022-11-28 10:51:03 +02:00
Lasse Collin cee8320646 liblzma: Use LZMA1EXT feature in lzma_microlzma_decoder().
Here too this avoids the slightly ugly method to set
the uncompressed size.

Also moved the setting of dict_size to the struct initializer.
2022-11-28 10:48:53 +02:00
Lasse Collin e310e8b6a4 liblzma: Use LZMA1EXT feature in lzma_alone_decoder().
This avoids the need to use the slightly ugly method to
set the uncompressed size.
2022-11-28 10:28:20 +02:00
Lasse Collin 33b8a24b66 liblzma: Add LZMA_FILTER_LZMA1EXT to support LZMA1 without end marker.
Some file formats need support for LZMA1 streams that don't use
the end of payload marker (EOPM) alias end of stream (EOS) marker.
So far liblzma API has supported decompressing such streams via
lzma_alone_decoder() when .lzma header specifies a known
uncompressed size. Encoding support hasn't been available in the API.

Instead of adding a new LZMA1-only API for this purpose, this commit
adds a new filter ID for use with raw encoder and decoder. The main
benefit of this approach is that then also filter chains are possible,
for example, if someone wants to implement support for .7z files that
use the x86 BCJ filter with LZMA1 (not BCJ2 as that isn't supported
in liblzma).
2022-11-27 23:16:21 +02:00
Lasse Collin 9a304bf1e4 liblzma: Avoid unneeded use of void pointer in LZMA decoder. 2022-11-27 18:43:07 +02:00
Lasse Collin 218394958c liblzma: Pass the Filter ID to LZ encoder and decoder.
This allows using two Filter IDs with the same
initialization function and data structures.
2022-11-27 18:20:33 +02:00
Lasse Collin 1663c7676b liblzma: Remove two FIXME comments. 2022-11-27 01:03:16 +02:00
Lasse Collin 11fe708db7 xz: Use lzma_filters_free(). 2022-11-26 22:25:30 +02:00
Lasse Collin e782af9110 liblzma: Use lzma_filters_free() in more places. 2022-11-26 22:21:13 +02:00
Lasse Collin 90caaded2d liblzma: Omit simple coder init functions if they are disabled. 2022-11-25 18:04:37 +02:00
Lasse Collin 5cd9f0df78 xz: Allow nice_len 2 and 3 even if match finder requires 3 or 4.
Now that liblzma accepts these, we avoid the extra check and
there's one message less for translators too.
2022-11-24 23:24:59 +02:00
Lasse Collin 3be88ae071 liblzma: Allow nice_len 2 and 3 even if match finder requires 3 or 4.
That is, if the specified nice_len is smaller than the minimum
of the match finder, silently use the match finder's minimum value
instead of reporting an error. The old behavior is annoying to users
and it complicates xz options handling too.
2022-11-24 23:23:55 +02:00
Lasse Collin 93439cfafe liblzma: Add lzma_filters_update() support to the multi-threaded encoder.
A tiny downside of this is that now a 1-4 tiny allocations are made
for every Block because each worker thread needs its own copy of
the filter chain.
2022-11-24 16:25:10 +02:00