Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-115988: Add missing ARM64 and RISCV filter in lzma module #115989

Open
wants to merge 20 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions Doc/library/lzma.rst
Original file line number Diff line number Diff line change
Expand Up @@ -343,12 +343,14 @@

* Branch-Call-Jump (BCJ) filters:

* :const:`FILTER_X86`

Check warning on line 346 in Doc/library/lzma.rst

View workflow job for this annotation

GitHub Actions / Docs / Docs

py:const reference target not found: FILTER_X86
* :const:`FILTER_IA64`

Check warning on line 347 in Doc/library/lzma.rst

View workflow job for this annotation

GitHub Actions / Docs / Docs

py:const reference target not found: FILTER_IA64
* :const:`FILTER_ARM`

Check warning on line 348 in Doc/library/lzma.rst

View workflow job for this annotation

GitHub Actions / Docs / Docs

py:const reference target not found: FILTER_ARM
* :const:`FILTER_ARMTHUMB`

Check warning on line 349 in Doc/library/lzma.rst

View workflow job for this annotation

GitHub Actions / Docs / Docs

py:const reference target not found: FILTER_ARMTHUMB
* :const:`FILTER_POWERPC`

Check warning on line 350 in Doc/library/lzma.rst

View workflow job for this annotation

GitHub Actions / Docs / Docs

py:const reference target not found: FILTER_POWERPC
* :const:`FILTER_SPARC`

Check warning on line 351 in Doc/library/lzma.rst

View workflow job for this annotation

GitHub Actions / Docs / Docs

py:const reference target not found: FILTER_SPARC
* :const:`FILTER_ARM64`

Check warning on line 352 in Doc/library/lzma.rst

View workflow job for this annotation

GitHub Actions / Docs / Docs

py:const reference target not found: FILTER_ARM64
ivq marked this conversation as resolved.
Show resolved Hide resolved
* :const:`FILTER_RISCV`

Check warning on line 353 in Doc/library/lzma.rst

View workflow job for this annotation

GitHub Actions / Docs / Docs

py:const reference target not found: FILTER_RISCV

A filter chain can consist of up to 4 filters, and cannot be empty. The last
filter in the chain must be a compression filter, and any other filters must be
Expand Down
1 change: 1 addition & 0 deletions Lib/lzma.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"CHECK_ID_MAX", "CHECK_UNKNOWN",
"FILTER_LZMA1", "FILTER_LZMA2", "FILTER_DELTA", "FILTER_X86", "FILTER_IA64",
"FILTER_ARM", "FILTER_ARMTHUMB", "FILTER_POWERPC", "FILTER_SPARC",
"FILTER_ARM64", "FILTER_RISCV",
"FORMAT_AUTO", "FORMAT_XZ", "FORMAT_ALONE", "FORMAT_RAW",
"MF_HC3", "MF_HC4", "MF_BT2", "MF_BT3", "MF_BT4",
"MODE_FAST", "MODE_NORMAL", "PRESET_DEFAULT", "PRESET_EXTREME",
Expand Down
16 changes: 15 additions & 1 deletion Modules/_lzmamodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@
#error "The maximum block size accepted by liblzma is SIZE_MAX."
#endif


#ifndef LZMA_FILTER_ARM64
gpshead marked this conversation as resolved.
Show resolved Hide resolved
#define LZMA_FILTER_ARM64 LZMA_VLI_C(0x0A)
#endif
#ifndef LZMA_FILTER_RISCV
#define LZMA_FILTER_RISCV LZMA_VLI_C(0x0B)
#endif

/* On success, return value >= 0
On failure, return -1 */
static inline Py_ssize_t
Expand Down Expand Up @@ -372,6 +380,8 @@ lzma_filter_converter(_lzma_state *state, PyObject *spec, void *ptr)
case LZMA_FILTER_ARM:
case LZMA_FILTER_ARMTHUMB:
case LZMA_FILTER_SPARC:
case LZMA_FILTER_ARM64:
case LZMA_FILTER_RISCV:
gpshead marked this conversation as resolved.
Show resolved Hide resolved
f->options = parse_filter_spec_bcj(state, spec);
return f->options != NULL;
default:
Expand Down Expand Up @@ -490,7 +500,9 @@ build_filter_spec(const lzma_filter *f)
case LZMA_FILTER_IA64:
case LZMA_FILTER_ARM:
case LZMA_FILTER_ARMTHUMB:
case LZMA_FILTER_SPARC: {
case LZMA_FILTER_SPARC:
case LZMA_FILTER_ARM64:
case LZMA_FILTER_RISCV: {
lzma_options_bcj *options = f->options;
if (options) {
ADD_FIELD(options, start_offset);
Expand Down Expand Up @@ -1551,6 +1563,8 @@ lzma_exec(PyObject *module)
ADD_INT_PREFIX_MACRO(module, FILTER_ARMTHUMB);
ADD_INT_PREFIX_MACRO(module, FILTER_SPARC);
ADD_INT_PREFIX_MACRO(module, FILTER_POWERPC);
ADD_INT_PREFIX_MACRO(module, FILTER_ARM64);
ADD_INT_PREFIX_MACRO(module, FILTER_RISCV);
ADD_INT_PREFIX_MACRO(module, MF_HC3);
ADD_INT_PREFIX_MACRO(module, MF_HC4);
ADD_INT_PREFIX_MACRO(module, MF_BT2);
Expand Down