Update lzma to current version of LZMA SDK
Subsystems (2)
cover Update lzma to current version of LZMA SDK
Hey all,
A long while ago, Darek reported that our copy of the LZMA SDK library is quite old and so vulnerable to at least one possible security issue he found that was fixed upstream.
This RFC series does a few things. First, we introduce a Kconfig option to enable LZMA's size reduction option, and enable it on gardena-smart-gateway-mt7688. This is not critical at the start, but is as we move forward. Next, we remove some files from our initial import of the library that do not make sense to keep in-tree. After that, the next 5 patches update us from the imported version to the current release of 25.01. This is split up such that few have the very few places where the update requires some slight changes to our code be more visible. This in turn is mainly that the file that says the license has changed, and that we need to guard around some unused upstream code that also conflicts with our own code. Finally, we restore the spacing changes that our copy of the code had, and then improve things by adding SPDX tags to the LZMA code so the license is more visible overall.
I've marked this as RFC in part because I plan to follow-up with v1 shortly where patches 2 through 8 are squashed together as they're mainly separate right now for ease of review, but the split doesn't make sense I believe to preserve in git as our changes are so isolated.
Signature · 1 line
Tom
RFC PATCH 1/9 lzma: Add Kconfig options to optimize for size
Currently, our LZMA library has an option for optimizing for size, rather than speed. It is a minimal savings today, and has not been worth enabling. As this will change in the near future, add options now to allow disabling it in full U-Boot or in SPL, and enable these on gardena-smart-gateway-mt7688 which is very close to the size limit today.
---
Cc: Stefan Roese <[email protected]>
--- configs/gardena-smart-gateway-mt7688_defconfig | 2 ++ lib/Kconfig | 14 ++++++++++++++ lib/lzma/Makefile | 1 + 3 files changed, 17 insertions(+)
configs/gardena-smart-gateway-mt7688_defconfig +2 -0
@@ -101,4 +101,6 @@ CONFIG_MT7621_SPI=y CONFIG_WDT=y CONFIG_WDT_MT7621=y CONFIG_LZMA=y +CONFIG_LZMA_SIZE_OPTIMIZATION=y CONFIG_SPL_LZMA=y +CONFIG_SPL_LZMA_SIZE_OPTIMIZATION=y
lib/Kconfig +14 -0
@@ -838,6 +838,13 @@ config LZMA ratio and fairly fast decompression speed. See also CONFIG_CMD_LZMADEC which provides a decode command. +config LZMA_SIZE_OPTIMIZATION + bool "Optimize the LZMA algorithm for smaller binary size" + help + This enables building the LZMA library optimized for size, rather + than performance. This can be a loss of 15-20% in decompression + speed, but a savings of close to two kilobytes in many cases. + config LZO bool "Enable LZO decompression support" help
@@ -932,6 +939,13 @@ config SPL_LZMA help This enables support for LZMA compression algorithm for SPL boot. +config SPL_LZMA_SIZE_OPTIMIZATION + bool "Optimize the LZMA algorithm for smaller binary size in SPL" + help + This enables building the LZMA library optimized for size, rather + than performance. This can be a loss of 15-20% in decompression + speed, but a savings of close to two kilobytes in many cases. + config TPL_LZMA bool "Enable LZMA decompression support for TPL build" depends on TPL
lib/lzma/Makefile +1 -0
@@ -7,5 +7,6 @@ # Wolfgang Denk, DENX Software Engineering, [email protected]. ccflags-y += -D_LZMA_PROB32 +ccflags-$(CONFIG_$(PHASE_)LZMA_SIZE_OPTIMIZATION) += -D_LZMA_SIZE_OPT obj-y += LzmaDec.o LzmaTools.o
Signature · 1 line
2.43.0
RFC PATCH 2/9 lzma: Remove extra files and explain where our library comes from
In reply to Tom RiniThe original import of the LZMA SDK included a script to update the library. This is no longer possible, due to important local changes, so remove it. We also remove a number of extra text files that should be unchanged from upstream, but provide no direct value to the project. Instead, have the help text for LZMA note that this comes from the LZMA SDK.
--- lib/Kconfig | 5 +- lib/lzma/README.txt | 28 -- lib/lzma/history.txt | 271 ----------------- lib/lzma/import_lzmasdk.sh | 36 --- lib/lzma/lzma.txt | 598 ------------------------------------- 5 files changed, 3 insertions(+), 935 deletions(-) delete mode 100644 lib/lzma/README.txt delete mode 100644 lib/lzma/history.txt delete mode 100644 lib/lzma/import_lzmasdk.sh delete mode 100644 lib/lzma/lzma.txt
lib/Kconfig +3 -2
@@ -835,8 +835,9 @@ config LZMA help This enables support for LZMA (Lempel-Ziv-Markov chain algorithm), a dictionary compression algorithm that provides a high compression - ratio and fairly fast decompression speed. See also - CONFIG_CMD_LZMADEC which provides a decode command. + ratio and fairly fast decompression speed. Our implementation comes + from the LZMA SDK. See also CONFIG_CMD_LZMADEC which provides a + decode command. config LZMA_SIZE_OPTIMIZATION bool "Optimize the LZMA algorithm for smaller binary size"
lib/lzma/README.txt deleted +0 -28
@@ -1,28 +0,0 @@ -The lib_lzma functionality was written by Igor Pavlov. -The original source cames from the LZMA SDK web page: - -URL: http://www.7-zip.org/sdk.html -Author: Igor Pavlov - -The import is made using the import_lzmasdk.sh script that: - -* untars the lzmaXYY.tar.bz2 file (from the download web page) -* copies the files LzmaDec.h, Types.h, LzmaDec.c, history.txt, - and lzma.txt from source archive into the lib_lzma directory (pwd). - -Example: - - . import_lzmasdk.sh ~/lzma465.tar.bz2 - -Notice: The files from lzma sdk are _not modified_ by this script! - -The files LzmaTools.{c,h} are provided to export the lzmaBuffToBuffDecompress() -function that wraps the complex LzmaDecode() function from the LZMA SDK. The -do_bootm() function uses the lzmaBuffToBuffDecopress() function to expand the -compressed image. - -The directory U-BOOT/include/lzma contains stubs files that permit to use the -library directly from U-BOOT code without touching the original LZMA SDK's -files. - -Luigi 'Comio' Mantellini <[email protected]>
lib/lzma/history.txt deleted +0 -271
271 lines not on this page · raw message
lib/lzma/import_lzmasdk.sh deleted +0 -36
@@ -1,36 +0,0 @@ -#!/bin/sh - -usage() { - echo "Usage: $0 lzmaVERSION.tar.bz2" >&2 - echo >&2 - exit 1 -} - -if [ "$1" = "" ] ; then - usage -fi - -if [ ! -f $1 ] ; then - echo "$1 doesn't exist!" >&2 - exit 1 -fi - -BASENAME=`basename $1 .tar.bz2` -TMPDIR=/tmp/tmp_lib_$BASENAME -FILES="C/LzmaDec.h - C/Types.h - C/LzmaDec.c - history.txt - lzma.txt" - -mkdir -p $TMPDIR -echo "Untar $1 -> $TMPDIR" -tar -jxf $1 -C $TMPDIR - -for i in $FILES; do - echo Copying $TMPDIR/$i \-\> `basename $i` - cp $TMPDIR/$i . - chmod -x `basename $i` -done - -echo "done!"
lib/lzma/lzma.txt deleted +0 -598
598 lines not on this page · raw message
Signature · 1 line
2.43.0
RFC PATCH 3/9 lzma: Update 9.20 -> 9.22
In reply to Tom RiniThese are only upstream changes and nothing local.
--- lib/lzma/LzmaDec.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-)
lib/lzma/LzmaDec.c +8 -13
@@ -1,5 +1,5 @@/* LzmaDec.c -- LZMA Decoder -2009-09-20 : Igor Pavlov : Public domain */ +2010-12-15 : Igor Pavlov : Public domain */ #include <config.h> #include <watchdog.h>
@@ -455,8 +455,9 @@ static void MY_FAST_CALL LzmaDec_WriteRem(CLzmaDec *p, SizeT limit) p->processedPos += len; p->remainLen -= len; -while (len-- !=0 ) +while (len !=0 ) { + len--; dic[dicPos] = dic[(dicPos - rep0) + ((dicPos < rep0) ? dicBufSize :0 )]; dicPos++; }
@@ -984,28 +985,22 @@ SRes LzmaDecode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen, {CLzmaDec p;SRes res; -SizeT inSize = *srcLen; -SizeT outSize = *destLen; - *srcLen = *destLen =0 ; +SizeT outSize = *destLen, inSize = *srcLen; + *destLen = *srcLen =0 ; + *status =LZMA_STATUS_NOT_SPECIFIED ;if (inSize <RC_INIT_SIZE )return SZ_ERROR_INPUT_EOF ; -LzmaDec_Construct (&p); - res =LzmaDec_AllocateProbs (&p, propData, propSize, alloc); -if (res !=0 ) -return res; +RINOK (LzmaDec_AllocateProbs (&p, propData, propSize, alloc)); p.dic = dest; p.dicBufSize = outSize; -LzmaDec_Init (&p); - *srcLen = inSize; res =LzmaDec_DecodeToDic (&p, outSize, src, srcLen, finishMode, status); + *destLen = p.dicPos;if (res ==SZ_OK && *status ==LZMA_STATUS_NEEDS_MORE_INPUT ) res =SZ_ERROR_INPUT_EOF ; - - (*destLen) = p.dicPos;LzmaDec_FreeProbs (&p, alloc);return res; }
Signature · 1 line
2.43.0
RFC PATCH 4/9 lzma: Update 9.22 -> 9.38
In reply to Tom RiniOf note is that the license for this code is now found in the "7zC.txt" file upstream, so include that.
---
include/lzma/LzmaTypes.h | 2 +-
lib/lzma/7zC.txt | 187 ++++++++++++++++++++++++++++++++
lib/lzma/{Types.h => 7zTypes.h} | 14 ++-
lib/lzma/Compiler.h | 28 +++++
lib/lzma/LzmaDec.c | 48 ++++++--
lib/lzma/LzmaDec.h | 4 +-
lib/lzma/Precomp.h | 10 ++
lib/lzma/license.txt | 3 -
8 files changed, 275 insertions(+), 21 deletions(-)
create mode 100644 lib/lzma/7zC.txt
rename lib/lzma/{Types.h => 7zTypes.h} (96%)
create mode 100644 lib/lzma/Compiler.h
create mode 100644 lib/lzma/Precomp.h
delete mode 100644 lib/lzma/license.txtinclude/lzma/LzmaTypes.h +1 -1
@@ -14,6 +14,6 @@*/ #define Byte LZByte -#include "../../lib/lzma/Types.h" +#include "../../lib/lzma/7zTypes.h" #endif
lib/lzma/7zC.txt new file +187 -0
187 lines not on this page · raw message
lib/lzma/7zTypes.h renamed from lib/lzma/Types.h +8 -6
@@ -1,15 +1,15 @@ -/* Types.h -- Basic types -2010-10-09 : Igor Pavlov : Public domain */ +/* 7zTypes.h -- Basic types +2013-11-12 : Igor Pavlov : Public domain */ #ifndef __7Z_TYPES_H#define __7Z_TYPES_H -#include <stddef.h> -#ifdef _WIN32 -#include <windows.h> +/* #include <windows.h> */ #endif +#include <stddef.h> +#define SZ_OK 0#define SZ_ERROR_DATA 1
@@ -31,7 +31,8 @@typedef int SRes ;#ifdef _WIN32 -typedef DWORD WRes ; +/* typedef DWORD WRes; */ +typedef unsigned WRes ;#else typedef int WRes ;#endif
@@ -97,6 +98,7 @@ typedef int Bool;#else +#define MY_NO_INLINE #define MY_CDECL #define MY_FAST_CALL
lib/lzma/Compiler.h new file +28 -0
@@ -0,0 +1,28 @@ +/* Compiler.h -- Compiler ypes +2013-11-12 : Igor Pavlov : Public domain */ + +#ifndef __7Z_COMPILER_H +#define __7Z_COMPILER_H + +#ifdef _MSC_VER + +#ifdef UNDER_CE +#define RPC_NO_WINDOWS_H +/* #pragma warning(disable : 4115) // '_RPC_ASYNC_STATE' : named type definition in parentheses */ +#pragma warning(disable : 4201) // nonstandard extension used : nameless struct/union +#pragma warning(disable : 4214) // nonstandard extension used : bit field types other than int +#endif + +#if _MSC_VER >=1300 +#pragma warning(disable : 4996) // This function or variable may be unsafe +#else +#pragma warning(disable : 4511) // copy constructor could not be generated +#pragma warning(disable : 4512) // assignment operator could not be generated +#pragma warning(disable : 4702) // unreachable code +#pragma warning(disable : 4710) // not inlined +#pragma warning(disable : 4786) // identifier was truncated to '255' characters in the debug information +#endif + +#endif + +#endif
lib/lzma/LzmaDec.c +39 -9
76 lines not on this page · raw message
lib/lzma/LzmaDec.h +2 -2
@@ -1,10 +1,10 @@/* LzmaDec.h -- LZMA Decoder -2009-02-07 : Igor Pavlov : Public domain */ +2013-01-18 : Igor Pavlov : Public domain */ #ifndef __LZMA_DEC_H#define __LZMA_DEC_H -#include "Types.h" +#include "7zTypes.h" /* #define _LZMA_PROB32 */ /* _LZMA_PROB32 can increase the speed on some CPUs,
lib/lzma/Precomp.h new file +10 -0
@@ -0,0 +1,10 @@ +/* Precomp.h -- StdAfx +2013-11-12 : Igor Pavlov : Public domain */ + +#ifndef __7Z_PRECOMP_H +#define __7Z_PRECOMP_H + +#include "Compiler.h" +/* #include "7zTypes.h" */ + +#endif
lib/lzma/license.txt deleted +0 -3
@@ -1,3 +0,0 @@ - License - -LZMA SDK is placed in the public domain.
Signature · 1 line
2.43.0
RFC PATCH 5/9 lzma: Update 9.38 -> 18.06
In reply to Tom RiniThese are only upstream changes and nothing local.
--- lib/lzma/7zTypes.h | 249 +++++++++++++++---- lib/lzma/Compiler.h | 9 +- lib/lzma/LzmaDec.c | 571 +++++++++++++++++++++++++++---------------- lib/lzma/LzmaDec.h | 57 +++-- lib/lzma/LzmaTools.c | 4 +- 5 files changed, 605 insertions(+), 285 deletions(-)
lib/lzma/7zTypes.h +195 -54
@@ -1,5 +1,5 @@/* 7zTypes.h -- Basic types -2013-11-12 : Igor Pavlov : Public domain */ +2018-08-04 : Igor Pavlov : Public domain */ #ifndef __7Z_TYPES_H#define __7Z_TYPES_H
@@ -10,6 +10,18 @@#include <stddef.h> +#ifndef EXTERN_C_BEGIN +#ifdef __cplusplus +#define EXTERN_C_BEGIN extern "C" { +#define EXTERN_C_END } +#else +#define EXTERN_C_BEGIN +#define EXTERN_C_END +#endif +#endif + +EXTERN_C_BEGIN +#define SZ_OK 0#define SZ_ERROR_DATA 1
@@ -30,13 +42,23 @@typedef int SRes ; +#ifdef _WIN32 +/* typedef DWORD WRes; */ typedef unsigned WRes ; +#define MY_SRes_HRESULT_FROM_WRes (x) HRESULT_FROM_WIN32(x) +#else +typedef int WRes ; +#define MY__FACILITY_WIN32 7 +#define MY__FACILITY__WRes MY__FACILITY_WIN32 +#define MY_SRes_HRESULT_FROM_WRes (x) ((HRESULT)(x) <= 0 ? ((HRESULT)(x)) : ((HRESULT) (((x) & 0x0000FFFF) | (MY__FACILITY__WRes << 16) | 0x80000000))) +#endif +#ifndef RINOK #define RINOK (x) { int __result__ = (x); if (__result__ != 0) return __result__; }#endif
@@ -81,10 +103,18 @@ typedef UInt32 SizeT;typedef size_t SizeT ;#endif -typedef int Bool ; +typedef int BoolInt ; +/* typedef BoolInt Bool; */ #define True 1#define False 0 + +#ifdef _WIN32 +#define MY_STD_CALL __stdcall +#else +#define MY_STD_CALL +#endif +#ifdef _MSC_VER#if _MSC_VER >=1300
@@ -93,47 +123,72 @@ typedef int Bool;#define MY_NO_INLINE #endif +#define MY_FORCE_INLINE __forceinline +#define MY_CDECL __cdecl#define MY_FAST_CALL __fastcall#else #define MY_NO_INLINE +#define MY_FORCE_INLINE #define MY_CDECL #define MY_FAST_CALL +/* inline keyword : for C++ / C99 */ + +/* GCC, clang: */ +/* +#if defined (__GNUC__) && (__GNUC__ >= 4) +#define MY_FORCE_INLINE __attribute__((always_inline)) +#define MY_NO_INLINE __attribute__((noinline)) +#endif +*/ +#endif +/* The following interfaces use first parameter as pointer to structure */ -typedef struct +typedef struct IByteIn IByteIn ; +struct IByteIn { -Byte (*Read)(void *p);/* reads one byte, returns 0 in case of EOF or error */ -}IByteIn ; +Byte (*Read)(const IByteIn *p);/* reads one byte, returns 0 in case of EOF or error */ +}; +#define IByteIn_Read (p) (p)->Read(p) -typedef struct + +typedef struct IByteOut IByteOut ; +struct IByteOut { -void (*Write)(void *p,Byte b); -}IByteOut ; +void (*Write)(const IByteOut *p,Byte b); +}; +#define IByteOut_Write (p, b) (p)->Write(p, b) -typedef struct + +typedef struct ISeqInStream ISeqInStream ; +struct ISeqInStream { -SRes (*Read)(void *p,void *buf,size_t *size); +SRes (*Read)(const ISeqInStream *p,void *buf,size_t *size);/* if (input(*size) != 0 && output(*size) == 0) means end_of_stream. (output(*size) < input(*size)) is allowed */ -}ISeqInStream ; +}; +#define ISeqInStream_Read (p, buf, size) (p)->Read(p, buf, size)/* it can return SZ_ERROR_INPUT_EOF */ -SRes SeqInStream_Read (ISeqInStream *stream,void *buf,size_t size); -SRes SeqInStream_Read2 (ISeqInStream *stream,void *buf,size_t size,SRes errorType); -SRes SeqInStream_ReadByte (ISeqInStream *stream,Byte *buf); +SRes SeqInStream_Read (const ISeqInStream *stream,void *buf,size_t size); +SRes SeqInStream_Read2 (const ISeqInStream *stream,void *buf,size_t size,SRes errorType); +SRes SeqInStream_ReadByte (const ISeqInStream *stream,Byte *buf); -typedef struct + +typedef struct ISeqOutStream ISeqOutStream ; +struct ISeqOutStream { -size_t (*Write)(void *p,const void *buf,size_t size); +size_t (*Write)(const ISeqOutStream *p,const void *buf,size_t size);/* Returns: result - the number of actually written bytes. (result < size) means error */ -}ISeqOutStream ; +}; +#define ISeqOutStream_Write (p, buf, size) (p)->Write(p, buf, size) typedef enum {
@@ -142,78 +197,162 @@ typedef enum SZ_SEEK_END = 2 } ESzSeek; -typedef struct + +typedef struct ISeekInStream ISeekInStream ; +struct ISeekInStream { -SRes (*Read)(void *p,void *buf,size_t *size);/* same as ISeqInStream::Read */ -SRes (*Seek)(void *p,Int64 *pos,ESzSeek origin); -}ISeekInStream ; +SRes (*Read)(const ISeekInStream *p,void *buf,size_t *size);/* same as ISeqInStream::Read */ +SRes (*Seek)(const ISeekInStream *p,Int64 *pos,ESzSeek origin); +}; +#define ISeekInStream_Read (p, buf, size) (p)->Read(p, buf, size) +#define ISeekInStream_Seek (p, pos, origin) (p)->Seek(p, pos, origin) -typedef struct + +typedef struct ILookInStream ILookInStream ; +struct ILookInStream { -SRes (*Look)(void *p,const void **buf,size_t *size); +SRes (*Look)(const ILookInStream *p,const void **buf,size_t *size);/* if (input(*size) != 0 && output(*size) == 0) means end_of_stream. (output(*size) > input(*size)) is not allowed (output(*size) < input(*size)) is allowed */ -SRes (*Skip)(void *p,size_t offset); +SRes (*Skip)(const ILookInStream *p,size_t offset);/* offset must be <= output(*size) of Look */ -SRes (*Read)(void *p,void *buf,size_t *size); +SRes (*Read)(const ILookInStream *p,void *buf,size_t *size);/* reads directly (without buffer). It's same as ISeqInStream::Read */ -SRes (*Seek)(void *p,Int64 *pos,ESzSeek origin); -}ILookInStream ; +SRes (*Seek)(const ILookInStream *p,Int64 *pos,ESzSeek origin); +}; + +#define ILookInStream_Look (p, buf, size) (p)->Look(p, buf, size) +#define ILookInStream_Skip (p, offset) (p)->Skip(p, offset) +#define ILookInStream_Read (p, buf, size) (p)->Read(p, buf, size) +#define ILookInStream_Seek (p, pos, origin) (p)->Seek(p, pos, origin) + -SRes LookInStream_LookRead (ILookInStream *stream,void *buf,size_t *size); -SRes LookInStream_SeekTo (ILookInStream *stream,UInt64 offset); +SRes LookInStream_LookRead (const ILookInStream *stream,void *buf,size_t *size); +SRes LookInStream_SeekTo (const ILookInStream *stream,UInt64 offset);/* reads via ILookInStream::Read */ -SRes LookInStream_Read2 (ILookInStream *stream,void *buf,size_t size,SRes errorType); -SRes LookInStream_Read (ILookInStream *stream,void *buf,size_t size); +SRes LookInStream_Read2 (const ILookInStream *stream,void *buf,size_t size,SRes errorType); +SRes LookInStream_Read (const ILookInStream *stream,void *buf,size_t size); + -#define LookToRead_BUF_SIZE (1 << 14)typedef struct { -ILookInStream s; -ISeekInStream *realStream; +ILookInStream vt; +const ISeekInStream *realStream; +size_t pos; -size_t size; -Byte buf[LookToRead_BUF_SIZE]; -}CLookToRead ; +size_t size;/* it's data size */ + +/* the following variables must be set outside */ +Byte *buf; +size_t bufSize; +}CLookToRead2 ; + +void LookToRead2_CreateVTable (CLookToRead2 *p,int lookahead); + +#define LookToRead2_Init (p) { (p)->pos = (p)->size = 0; } -void LookToRead_CreateVTable (CLookToRead *p,int lookahead); -void LookToRead_Init (CLookToRead *p);typedef struct { -ISeqInStream s; -ILookInStream *realStream; +ISeqInStream vt; +const ILookInStream *realStream; }CSecToLook ;void SecToLook_CreateVTable (CSecToLook *p); + +typedef struct { -ISeqInStream s; -ILookInStream *realStream; +ISeqInStream vt; +const ILookInStream *realStream; }CSecToRead ;void SecToRead_CreateVTable (CSecToRead *p); -typedef struct + +typedef struct ICompressProgress ICompressProgress ; + +struct ICompressProgress { -SRes (*Progress)(void *p,UInt64 inSize,UInt64 outSize); +SRes (*Progress)(const ICompressProgress *p,UInt64 inSize,UInt64 outSize);/* Returns: result. (result != SZ_OK) means break. Value (UInt64)(Int64)-1 for size means unknown value. */ -}ICompressProgress ; +}; +#define ICompressProgress_Progress (p, inSize, outSize) (p)->Progress(p, inSize, outSize) -typedef struct + + +typedef struct ISzAlloc ISzAlloc ; +typedef const ISzAlloc *ISzAllocPtr ; + +struct ISzAlloc { -void *(*Alloc)(void *p,size_t size); -void (*Free)(void *p,void *address);/* address can be 0 */ -}ISzAlloc ; +void *(*Alloc)(ISzAllocPtr p,size_t size); +void (*Free)(ISzAllocPtr p,void *address);/* address can be 0 */ +}; + +#define ISzAlloc_Alloc (p, size) (p)->Alloc(p, size) +#define ISzAlloc_Free (p, a) (p)->Free(p, a) + +/* deprecated */ +#define IAlloc_Alloc (p, size) ISzAlloc_Alloc(p, size) +#define IAlloc_Free (p, a) ISzAlloc_Free(p, a) + + + + + +#ifndef MY_offsetof +#ifdef offsetof +#define MY_offsetof (type, m) offsetof(type, m) +/* +#define MY_offsetof(type, m) FIELD_OFFSET(type, m) +*/ +#else +#define MY_offsetof (type, m) ((size_t)&(((type *)0)->m)) +#endif +#endif + + + +#ifndef MY_container_of + +/* +#define MY_container_of(ptr, type, m) container_of(ptr, type, m) +#define MY_container_of(ptr, type, m) CONTAINING_RECORD(ptr, type, m) +#define MY_container_of(ptr, type, m) ((type *)((char *)(ptr) - offsetof(type, m))) +#define MY_container_of(ptr, type, m) (&((type *)0)->m == (ptr), ((type *)(((char *)(ptr)) - MY_offsetof(type, m)))) +*/ + +/* +GCC shows warning: "perhaps the 'offsetof' macro was used incorrectly" +GCC 3.4.4 : classes with constructor +GCC 4.8.1 : classes with non-public variable members" +*/ + +#define MY_container_of (ptr, type, m) ((type *)((char *)(1 ? (ptr) : &((type *)0)->m) - MY_offsetof(type, m))) + + +#endif + +#define CONTAINER_FROM_VTBL_SIMPLE (ptr, type, m) ((type *)(ptr)) + +/* +#define CONTAINER_FROM_VTBL(ptr, type, m) CONTAINER_FROM_VTBL_SIMPLE(ptr, type, m) +*/ +#define CONTAINER_FROM_VTBL (ptr, type, m) MY_container_of(ptr, type, m) + +#define CONTAINER_FROM_VTBL_CLS (ptr, type, m) CONTAINER_FROM_VTBL_SIMPLE(ptr, type, m) +/* +#define CONTAINER_FROM_VTBL_CLS(ptr, type, m) CONTAINER_FROM_VTBL(ptr, type, m) +*/ + -#define IAlloc_Alloc (p, size) (p)->Alloc((p), size) -#define IAlloc_Free (p, a) (p)->Free((p), a)#ifdef _WIN32
@@ -225,10 +364,12 @@ typedef struct#else #define CHAR_PATH_SEPARATOR '/' -#define WCHAR_PATH_SEPARATOR u'/' +#define WCHAR_PATH_SEPARATOR L'/'#define STRING_PATH_SEPARATOR "/" -#define WSTRING_PATH_SEPARATOR u"/" +#define WSTRING_PATH_SEPARATOR L"/"#endif +EXTERN_C_END +#endif
lib/lzma/Compiler.h +7 -2
@@ -1,5 +1,5 @@ -/* Compiler.h -- Compiler ypes -2013-11-12 : Igor Pavlov : Public domain */ +/* Compiler.h +2017-04-03 : Igor Pavlov : Public domain */ #ifndef __7Z_COMPILER_H#define __7Z_COMPILER_H
@@ -18,11 +18,16 @@#else #pragma warning(disable : 4511) // copy constructor could not be generated#pragma warning(disable : 4512) // assignment operator could not be generated +#pragma warning(disable : 4514) // unreferenced inline function has been removed#pragma warning(disable : 4702) // unreachable code#pragma warning(disable : 4710) // not inlined +#pragma warning(disable : 4714) // function marked as __forceinline not inlined#pragma warning(disable : 4786) // identifier was truncated to '255' characters in the debug information#endif #endif +#define UNUSED_VAR (x) (void)x; +/* #define UNUSED_VAR(x) x=x; */ +#endif
lib/lzma/LzmaDec.c +364 -207
1,036 lines not on this page · raw message
lib/lzma/LzmaDec.h +37 -20
150 lines not on this page · raw message
lib/lzma/LzmaTools.c +2 -2
@@ -33,8 +33,8 @@#include <linux/string.h> #include <malloc.h> -static void *SzAlloc (void *p,size_t size) {return malloc (size); } -static void SzFree (void *p,void *address) {free (address); } +static void *SzAlloc (ISzAllocPtr p,size_t size) {return malloc (size); } +static void SzFree (ISzAllocPtr p,void *address) {free (address); }int lzmaBuffToBuffDecompress (unsigned char *outStream,SizeT *uncompressedSize,const unsigned char *inStream,SizeT length)
Signature · 1 line
2.43.0
RFC PATCH 6/9 lzma: Update 18.06 -> 21.07
In reply to Tom RiniOf note, add guards around TEXT macro and LONG typedef, both are unused in the code but cause problems on MIPS.
--- lib/lzma/7zTypes.h | 192 +++++++++++++++++++-- lib/lzma/Compiler.h | 12 +- lib/lzma/LzmaDec.c | 412 +++++++++++++++++++++++++++++++------------- lib/lzma/LzmaDec.h | 4 +- 4 files changed, 482 insertions(+), 138 deletions(-)
lib/lzma/7zTypes.h +173 -19
@@ -1,11 +1,13 @@/* 7zTypes.h -- Basic types -2018-08-04 : Igor Pavlov : Public domain */ +2021-12-25 : Igor Pavlov : Public domain */ #ifndef __7Z_TYPES_H#define __7Z_TYPES_H#ifdef _WIN32/* #include <windows.h> */ +#else +#include <errno.h> #endif #include <stddef.h>
@@ -43,18 +45,118 @@ EXTERN_C_BEGINtypedef int SRes ; +#ifdef _MSC_VER +#if _MSC_VER >1200 +#define MY_ALIGN (n) __declspec(align(n)) +#else +#define MY_ALIGN (n) +#endif +#else +#define MY_ALIGN (n) __attribute__ ((aligned(n))) +#endif + +#ifdef _WIN32/* typedef DWORD WRes; */ typedef unsigned WRes ;#define MY_SRes_HRESULT_FROM_WRes (x) HRESULT_FROM_WIN32(x) -#else +// #define MY_HRES_ERROR__INTERNAL_ERROR MY_SRes_HRESULT_FROM_WRes(ERROR_INTERNAL_ERROR) + +#else // _WIN32 +// #define ENV_HAVE_LSTAT typedef int WRes ; -#define MY__FACILITY_WIN32 7 -#define MY__FACILITY__WRes MY__FACILITY_WIN32 -#define MY_SRes_HRESULT_FROM_WRes (x) ((HRESULT)(x) <= 0 ? ((HRESULT)(x)) : ((HRESULT) (((x) & 0x0000FFFF) | (MY__FACILITY__WRes << 16) | 0x80000000))) + +// (FACILITY_ERRNO = 0x800) is 7zip's FACILITY constant to represent (errno) errors in HRESULT +#define MY__FACILITY_ERRNO 0x800 +#define MY__FACILITY_WIN32 7 +#define MY__FACILITY__WRes MY__FACILITY_ERRNO + +#define MY_HRESULT_FROM_errno_CONST_ERROR (x) ((HRESULT)( \ + ( (HRESULT)(x) & 0x0000FFFF) \ + | (MY__FACILITY__WRes << 16) \ + | (HRESULT)0x80000000 )) + +#define MY_SRes_HRESULT_FROM_WRes (x) \ + ((HRESULT)(x) <= 0 ? ((HRESULT)(x)) : MY_HRESULT_FROM_errno_CONST_ERROR(x)) + +// we call macro HRESULT_FROM_WIN32 for system errors (WRes) that are (errno) +#define HRESULT_FROM_WIN32 (x) MY_SRes_HRESULT_FROM_WRes(x) + +/* +#define ERROR_FILE_NOT_FOUND 2L +#define ERROR_ACCESS_DENIED 5L +#define ERROR_NO_MORE_FILES 18L +#define ERROR_LOCK_VIOLATION 33L +#define ERROR_FILE_EXISTS 80L +#define ERROR_DISK_FULL 112L +#define ERROR_NEGATIVE_SEEK 131L +#define ERROR_ALREADY_EXISTS 183L +#define ERROR_DIRECTORY 267L +#define ERROR_TOO_MANY_POSTS 298L + +#define ERROR_INTERNAL_ERROR 1359L +#define ERROR_INVALID_REPARSE_DATA 4392L +#define ERROR_REPARSE_TAG_INVALID 4393L +#define ERROR_REPARSE_TAG_MISMATCH 4394L +*/ + +// we use errno equivalents for some WIN32 errors: + +#define ERROR_INVALID_PARAMETER EINVAL +#define ERROR_INVALID_FUNCTION EINVAL +#define ERROR_ALREADY_EXISTS EEXIST +#define ERROR_FILE_EXISTS EEXIST +#define ERROR_PATH_NOT_FOUND ENOENT +#define ERROR_FILE_NOT_FOUND ENOENT +#define ERROR_DISK_FULL ENOSPC +// #define ERROR_INVALID_HANDLE EBADF + +// we use FACILITY_WIN32 for errors that has no errno equivalent +// Too many posts were made to a semaphore. +#define ERROR_TOO_MANY_POSTS ((HRESULT)0x8007012AL) +#define ERROR_INVALID_REPARSE_DATA ((HRESULT)0x80071128L) +#define ERROR_REPARSE_TAG_INVALID ((HRESULT)0x80071129L) + +// if (MY__FACILITY__WRes != FACILITY_WIN32), +// we use FACILITY_WIN32 for COM errors: +#define E_OUTOFMEMORY ((HRESULT)0x8007000EL) +#define E_INVALIDARG ((HRESULT)0x80070057L) +#define MY__E_ERROR_NEGATIVE_SEEK ((HRESULT)0x80070083L) + +/* +// we can use FACILITY_ERRNO for some COM errors, that have errno equivalents: +#define E_OUTOFMEMORY MY_HRESULT_FROM_errno_CONST_ERROR(ENOMEM) +#define E_INVALIDARG MY_HRESULT_FROM_errno_CONST_ERROR(EINVAL) +#define MY__E_ERROR_NEGATIVE_SEEK MY_HRESULT_FROM_errno_CONST_ERROR(EINVAL) +*/ + +// gcc / clang : (sizeof(long) == sizeof(void*)) in 32/64 bits +typedef long INT_PTR ; +typedef unsigned long UINT_PTR ; + +#ifndef __UBOOT__ +#define TEXT (quote) quote +#endif + +#define FILE_ATTRIBUTE_READONLY 0x0001 +#define FILE_ATTRIBUTE_HIDDEN 0x0002 +#define FILE_ATTRIBUTE_SYSTEM 0x0004 +#define FILE_ATTRIBUTE_DIRECTORY 0x0010 +#define FILE_ATTRIBUTE_ARCHIVE 0x0020 +#define FILE_ATTRIBUTE_DEVICE 0x0040 +#define FILE_ATTRIBUTE_NORMAL 0x0080 +#define FILE_ATTRIBUTE_TEMPORARY 0x0100 +#define FILE_ATTRIBUTE_SPARSE_FILE 0x0200 +#define FILE_ATTRIBUTE_REPARSE_POINT 0x0400 +#define FILE_ATTRIBUTE_COMPRESSED 0x0800 +#define FILE_ATTRIBUTE_OFFLINE 0x1000 +#define FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 0x2000 +#define FILE_ATTRIBUTE_ENCRYPTED 0x4000 + +#define FILE_ATTRIBUTE_UNIX_EXTENSION 0x8000/* trick for Unix */ #endif
@@ -63,6 +165,10 @@ typedef int WRes;#define RINOK (x) { int __result__ = (x); if (__result__ != 0) return __result__; }#endif +#ifndef RINOK_WRes +#define RINOK_WRes (x) { WRes __result__ = (x); if (__result__ != 0) return __result__; } +#endif +typedef unsigned char Byte ;typedef short Int16 ;typedef unsigned short UInt16 ;
@@ -75,6 +181,42 @@ typedef int Int32;typedef unsigned int UInt32 ;#endif + +#ifndef _WIN32 + +typedef int INT ; +typedef Int32 INT32 ; +typedef unsigned int UINT ; +typedef UInt32 UINT32 ; +#ifndef __UBOOT__ +typedef INT32 LONG ;// LONG, ULONG and DWORD must be 32-bit for _WIN32 compatibility +#endif +typedef UINT32 ULONG ; + +#undef DWORD +typedef UINT32 DWORD ; + +#define VOID void + +#define HRESULT LONG + +typedef void *LPVOID ; +// typedef void VOID; +// typedef ULONG_PTR DWORD_PTR, *PDWORD_PTR; +// gcc / clang on Unix : sizeof(long==sizeof(void*) in 32 or 64 bits) +typedef long INT_PTR ; +typedef unsigned long UINT_PTR ; +typedef long LONG_PTR ; +typedef unsigned long DWORD_PTR ; + +typedef size_t SIZE_T ; + +#endif // _WIN32 + + +#define MY_HRES_ERROR__INTERNAL_ERROR ((HRESULT)0x8007054FL) + +#ifdef _SZ_NO_INT_64/* define _SZ_NO_INT_64, if your compiler doesn't support 64-bit integers.
@@ -128,25 +270,37 @@ typedef int BoolInt;#define MY_CDECL __cdecl#define MY_FAST_CALL __fastcall -#else +#else // _MSC_VER +#if (defined(__GNUC__) && (__GNUC__ >=4 )) \ + || (defined(__clang__) && (__clang_major__ >=4 )) \ + || defined(__INTEL_COMPILER) \ + || defined(__xlC__) +#define MY_NO_INLINE __attribute__((noinline)) +// #define MY_FORCE_INLINE __attribute__((always_inline)) inline +#else #define MY_NO_INLINE +#endif +#define MY_FORCE_INLINE -#define MY_CDECL -#define MY_FAST_CALL -/* inline keyword : for C++ / C99 */ -/* GCC, clang: */ -/* -#if defined (__GNUC__) && (__GNUC__ >= 4) -#define MY_FORCE_INLINE __attribute__((always_inline)) -#define MY_NO_INLINE __attribute__((noinline)) -#endif -*/ +#define MY_CDECL +#if defined(_M_IX86) \ + || defined(__i386__) +// #define MY_FAST_CALL __attribute__((fastcall)) +// #define MY_FAST_CALL __attribute__((cdecl)) +#define MY_FAST_CALL +#elif defined(MY_CPU_AMD64 ) +// #define MY_FAST_CALL __attribute__((ms_abi)) +#define MY_FAST_CALL +#else +#define MY_FAST_CALL #endif +#endif // _MSC_VER +/* The following interfaces use first parameter as pointer to structure */
@@ -335,12 +489,11 @@ struct ISzAllocGCC 4.8.1 : classes with non-public variable members" */ -#define MY_container_of (ptr, type, m) ((type *)((char *)(1 ? (ptr) : &((type *)0)->m) - MY_offsetof(type, m))) - +#define MY_container_of (ptr, type, m) ((type *)(void *)((char *)(void *)(1 ? (ptr) : &((type *)0)->m) - MY_offsetof(type, m)))#endif -#define CONTAINER_FROM_VTBL_SIMPLE (ptr, type, m) ((type *)(ptr)) +#define CONTAINER_FROM_VTBL_SIMPLE (ptr, type, m) ((type *)(void *)(ptr))/* #define CONTAINER_FROM_VTBL(ptr, type, m) CONTAINER_FROM_VTBL_SIMPLE(ptr, type, m)
@@ -353,6 +506,7 @@ struct ISzAlloc*/ +#define MY_memset_0_ARRAY (a) memset((a), 0, sizeof(a))#ifdef _WIN32
lib/lzma/Compiler.h +11 -1
@@ -1,9 +1,13 @@/* Compiler.h -2017-04-03 : Igor Pavlov : Public domain */ +2021-01-05 : Igor Pavlov : Public domain */ #ifndef __7Z_COMPILER_H#define __7Z_COMPILER_H +#ifdef __clang__ +#pragma clang diagnostic ignored "-Wunused-private-field" +#endif +#ifdef _MSC_VER#ifdef UNDER_CE
@@ -25,6 +29,12 @@#pragma warning(disable : 4786) // identifier was truncated to '255' characters in the debug information#endif +#ifdef __clang__ +#pragma clang diagnostic ignored "-Wdeprecated-declarations" +#pragma clang diagnostic ignored "-Wmicrosoft-exception-spec" +// #pragma clang diagnostic ignored "-Wreserved-id-macro" +#endif +#endif #define UNUSED_VAR (x) (void)x;
lib/lzma/LzmaDec.c +295 -117
659 lines not on this page · raw message
lib/lzma/LzmaDec.h +3 -1
@@ -1,5 +1,5 @@/* LzmaDec.h -- LZMA Decoder -2018-04-21 : Igor Pavlov : Public domain */ +2020-03-19 : Igor Pavlov : Public domain */ #ifndef __LZMA_DEC_H#define __LZMA_DEC_H
@@ -181,6 +181,7 @@ Returns:LZMA_STATUS_NEEDS_MORE_INPUT LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK SZ_ERROR_DATA - Data error +SZ_ERROR_FAIL - Some unexpected error: internal error of code, memory corruption or hardware failure */ SRes LzmaDec_DecodeToDic(CLzmaDec *p, SizeT dicLimit,
@@ -223,6 +224,7 @@ Returns:SZ_ERROR_MEM - Memory allocation error SZ_ERROR_UNSUPPORTED - Unsupported properties SZ_ERROR_INPUT_EOF - It needs more bytes in input buffer (src). +SZ_ERROR_FAIL - Some unexpected error: internal error of code, memory corruption or hardware failure */ SRes LzmaDecode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen,
Signature · 1 line
2.43.0
RFC PATCH 7/9 lzma: Update 21.07 -> 25.01
In reply to Tom RiniThese are only upstream changes and nothing local.
--- lib/lzma/7zTypes.h | 270 ++++++++++++++++++++++++++++---------------- lib/lzma/Compiler.h | 247 ++++++++++++++++++++++++++++++++++++---- lib/lzma/LzmaDec.c | 190 +++++++++++++++---------------- lib/lzma/LzmaDec.h | 17 +-- lib/lzma/Makefile | 4 +- lib/lzma/Precomp.h | 127 ++++++++++++++++++++- 6 files changed, 626 insertions(+), 229 deletions(-)
lib/lzma/7zTypes.h +173 -97
@@ -1,8 +1,8 @@/* 7zTypes.h -- Basic types -2021-12-25 : Igor Pavlov : Public domain */ +2024-01-24 : Igor Pavlov : Public domain */ -#ifndef __7Z_TYPES_H -#define __7Z_TYPES_H +#ifndef ZIP7_7Z_TYPES_H +#define ZIP7_7Z_TYPES_H #ifdef _WIN32/* #include <windows.h> */
@@ -52,6 +52,11 @@ typedef int SRes;#define MY_ALIGN (n)#endif #else +/* +// C11/C++11: +#include <stdalign.h> +#define MY_ALIGN(n) alignas(n) +*/ #define MY_ALIGN (n) __attribute__ ((aligned(n)))#endif
@@ -62,7 +67,7 @@ typedef int SRes;typedef unsigned WRes ;#define MY_SRes_HRESULT_FROM_WRes (x) HRESULT_FROM_WIN32(x) -// #define MY_HRES_ERROR__INTERNAL_ERROR MY_SRes_HRESULT_FROM_WRes(ERROR_INTERNAL_ERROR) +// #define MY_HRES_ERROR_INTERNAL_ERROR MY_SRes_HRESULT_FROM_WRes(ERROR_INTERNAL_ERROR) #else // _WIN32
@@ -70,13 +75,13 @@ typedef unsigned WRes;typedef int WRes ;// (FACILITY_ERRNO = 0x800) is 7zip's FACILITY constant to represent (errno) errors in HRESULT -#define MY__FACILITY_ERRNO 0x800 -#define MY__FACILITY_WIN32 7 -#define MY__FACILITY__WRes MY__FACILITY_ERRNO +#define MY_FACILITY_ERRNO 0x800 +#define MY_FACILITY_WIN32 7 +#define MY_FACILITY_WRes MY_FACILITY_ERRNO#define MY_HRESULT_FROM_errno_CONST_ERROR (x) ((HRESULT)( \ ( (HRESULT)(x) & 0x0000FFFF) \ - | (MY__FACILITY__WRes << 16) \ + | (MY_FACILITY_WRes << 16) \ | (HRESULT)0x80000000 ))#define MY_SRes_HRESULT_FROM_WRes (x) \
@@ -120,17 +125,17 @@ typedef int WRes;#define ERROR_INVALID_REPARSE_DATA ((HRESULT)0x80071128L)#define ERROR_REPARSE_TAG_INVALID ((HRESULT)0x80071129L) -// if (MY__FACILITY__WRes != FACILITY_WIN32), +// if (MY_FACILITY_WRes != FACILITY_WIN32), // we use FACILITY_WIN32 for COM errors: #define E_OUTOFMEMORY ((HRESULT)0x8007000EL)#define E_INVALIDARG ((HRESULT)0x80070057L) -#define MY__E_ERROR_NEGATIVE_SEEK ((HRESULT)0x80070083L) +#define MY_E_ERROR_NEGATIVE_SEEK ((HRESULT)0x80070083L)/* // we can use FACILITY_ERRNO for some COM errors, that have errno equivalents: #define E_OUTOFMEMORY MY_HRESULT_FROM_errno_CONST_ERROR(ENOMEM) #define E_INVALIDARG MY_HRESULT_FROM_errno_CONST_ERROR(EINVAL) -#define MY__E_ERROR_NEGATIVE_SEEK MY_HRESULT_FROM_errno_CONST_ERROR(EINVAL) +#define MY_E_ERROR_NEGATIVE_SEEK MY_HRESULT_FROM_errno_CONST_ERROR(EINVAL) */ // gcc / clang : (sizeof(long) == sizeof(void*)) in 32/64 bits
@@ -162,18 +167,18 @@ typedef unsigned long UINT_PTR;#ifndef RINOK -#define RINOK (x) { int __result__ = (x); if (__result__ != 0) return __result__; } +#define RINOK (x) { const int _result_ = (x); if (_result_ != 0) return _result_; }#endif #ifndef RINOK_WRes -#define RINOK_WRes (x) { WRes __result__ = (x); if (__result__ != 0) return __result__; } +#define RINOK_WRes (x) { const WRes _result_ = (x); if (_result_ != 0) return _result_; }#endif typedef unsigned char Byte ;typedef short Int16 ;typedef unsigned short UInt16 ; -#ifdef _LZMA_UINT32_IS_ULONG +#ifdef Z7_DECL_Int32_AS_longtypedef long Int32 ;typedef unsigned long UInt32 ;#else
@@ -214,37 +219,51 @@ typedef size_t SIZE_T;#endif // _WIN32 -#define MY_HRES_ERROR__INTERNAL_ERROR ((HRESULT)0x8007054FL) +#define MY_HRES_ERROR_INTERNAL_ERROR ((HRESULT)0x8007054FL) -#ifdef _SZ_NO_INT_64 - -/* define _SZ_NO_INT_64, if your compiler doesn't support 64-bit integers. -NOTES: Some code will work incorrectly in that case! */ +#ifdef Z7_DECL_Int64_AS_longtypedef long Int64 ;typedef unsigned long UInt64 ;#else -#if defined(_MSC_VER) || defined(__BORLANDC__) +#if (defined(_MSC_VER) || defined(__BORLANDC__)) && !defined(__clang__)typedef __int64 Int64 ;typedef unsigned __int64 UInt64 ; -#define UINT64_CONST (n) n +#else +#if defined(__clang__) || defined(__GNUC__) +#include <stdint.h> +typedef int64_t Int64 ; +typedef uint64_t UInt64 ;#else typedef long long int Int64 ;typedef unsigned long long int UInt64 ; -#define UINT64_CONST (n) n ## ULL +// #define UINT64_CONST(n) n ## ULL +#endif #endif #endif -#ifdef _LZMA_NO_SYSTEM_SIZE_T -typedef UInt32 SizeT ; +#define UINT64_CONST (n) n + + +#ifdef Z7_DECL_SizeT_AS_unsigned_int +typedef unsigned int SizeT ;#else typedef size_t SizeT ;#endif +/* +#if (defined(_MSC_VER) && _MSC_VER <= 1200) +typedef size_t MY_uintptr_t; +#else +#include <stdint.h> +typedef uintptr_t MY_uintptr_t; +#endif +*/ +typedef int BoolInt ;/* typedef BoolInt Bool; */ #define True 1
@@ -252,23 +271,23 @@ typedef int BoolInt;#ifdef _WIN32 -#define MY_STD_CALL __stdcall +#define Z7_STDCALL __stdcall#else -#define MY_STD_CALL +#define Z7_STDCALL #endif #ifdef _MSC_VER#if _MSC_VER >=1300 -#define MY_NO_INLINE __declspec(noinline) +#define Z7_NO_INLINE __declspec(noinline)#else -#define MY_NO_INLINE +#define Z7_NO_INLINE #endif -#define MY_FORCE_INLINE __forceinline +#define Z7_FORCE_INLINE __forceinline -#define MY_CDECL __cdecl -#define MY_FAST_CALL __fastcall +#define Z7_CDECL __cdecl +#define Z7_FASTCALL __fastcall#else // _MSC_VER
@@ -276,27 +295,25 @@ typedef int BoolInt; || (defined(__clang__) && (__clang_major__ >= 4)) \ || defined(__INTEL_COMPILER) \ || defined(__xlC__) -#define MY_NO_INLINE __attribute__((noinline)) -// #define MY_FORCE_INLINE __attribute__((always_inline)) inline +#define Z7_NO_INLINE __attribute__((noinline)) +#define Z7_FORCE_INLINE __attribute__((always_inline)) inline#else -#define MY_NO_INLINE +#define Z7_NO_INLINE +#define Z7_FORCE_INLINE #endif -#define MY_FORCE_INLINE - - -#define MY_CDECL +#define Z7_CDECL #if defined(_M_IX86) \ || defined(__i386__) -// #define MY_FAST_CALL __attribute__((fastcall)) -// #define MY_FAST_CALL __attribute__((cdecl)) -#define MY_FAST_CALL +// #define Z7_FASTCALL __attribute__((fastcall)) +// #define Z7_FASTCALL __attribute__((cdecl)) +#define Z7_FASTCALL #elif defined(MY_CPU_AMD64 ) -// #define MY_FAST_CALL __attribute__((ms_abi)) -#define MY_FAST_CALL +// #define Z7_FASTCALL __attribute__((ms_abi)) +#define Z7_FASTCALL #else -#define MY_FAST_CALL +#define Z7_FASTCALL #endif #endif // _MSC_VER
@@ -304,41 +321,49 @@ typedef int BoolInt;/* The following interfaces use first parameter as pointer to structure */ -typedef struct IByteIn IByteIn ; -struct IByteIn +// #define Z7_C_IFACE_CONST_QUAL +#define Z7_C_IFACE_CONST_QUAL const + +#define Z7_C_IFACE_DECL (a) \ + struct a ## _; \ + typedef Z7_C_IFACE_CONST_QUAL struct a ## _ * a ## Ptr; \ + typedef struct a ## _ a; \ + struct a ## _ + + +Z7_C_IFACE_DECL (IByteIn) { -Byte (*Read)(const IByteIn *p);/* reads one byte, returns 0 in case of EOF or error */ +Byte (*Read)(IByteInPtr p);/* reads one byte, returns 0 in case of EOF or error */ };#define IByteIn_Read (p) (p)->Read(p) -typedef struct IByteOut IByteOut ; -struct IByteOut +Z7_C_IFACE_DECL (IByteOut) { -void (*Write)(const IByteOut *p,Byte b); +void (*Write)(IByteOutPtr p,Byte b); };#define IByteOut_Write (p, b) (p)->Write(p, b) -typedef struct ISeqInStream ISeqInStream ; -struct ISeqInStream +Z7_C_IFACE_DECL (ISeqInStream) { -SRes (*Read)(const ISeqInStream *p,void *buf,size_t *size); +SRes (*Read)(ISeqInStreamPtr p,void *buf,size_t *size);/* if (input(*size) != 0 && output(*size) == 0) means end_of_stream. (output(*size) < input(*size)) is allowed */ };#define ISeqInStream_Read (p, buf, size) (p)->Read(p, buf, size) +/* try to read as much as avail in stream and limited by (*processedSize) */ +SRes SeqInStream_ReadMax (ISeqInStreamPtr stream,void *buf,size_t *processedSize);/* it can return SZ_ERROR_INPUT_EOF */ -SRes SeqInStream_Read (const ISeqInStream *stream,void *buf,size_t size); -SRes SeqInStream_Read2 (const ISeqInStream *stream,void *buf,size_t size,SRes errorType); -SRes SeqInStream_ReadByte (const ISeqInStream *stream,Byte *buf); +// SRes SeqInStream_Read(ISeqInStreamPtr stream, void *buf, size_t size); +// SRes SeqInStream_Read2(ISeqInStreamPtr stream, void *buf, size_t size, SRes errorType); +SRes SeqInStream_ReadByte (ISeqInStreamPtr stream,Byte *buf); -typedef struct ISeqOutStream ISeqOutStream ; -struct ISeqOutStream +Z7_C_IFACE_DECL (ISeqOutStream) { -size_t (*Write)(const ISeqOutStream *p,const void *buf,size_t size); +size_t (*Write)(ISeqOutStreamPtr p,const void *buf,size_t size);/* Returns: result - the number of actually written bytes. (result < size) means error */ };
@@ -352,29 +377,26 @@ typedef enum } ESzSeek; -typedef struct ISeekInStream ISeekInStream ; -struct ISeekInStream +Z7_C_IFACE_DECL (ISeekInStream) { -SRes (*Read)(const ISeekInStream *p,void *buf,size_t *size);/* same as ISeqInStream::Read */ -SRes (*Seek)(const ISeekInStream *p,Int64 *pos,ESzSeek origin); +SRes (*Read)(ISeekInStreamPtr p,void *buf,size_t *size);/* same as ISeqInStream::Read */ +SRes (*Seek)(ISeekInStreamPtr p,Int64 *pos,ESzSeek origin); };#define ISeekInStream_Read (p, buf, size) (p)->Read(p, buf, size)#define ISeekInStream_Seek (p, pos, origin) (p)->Seek(p, pos, origin) -typedef struct ILookInStream ILookInStream ; -struct ILookInStream +Z7_C_IFACE_DECL (ILookInStream) { -SRes (*Look)(const ILookInStream *p,const void **buf,size_t *size); +SRes (*Look)(ILookInStreamPtr p,const void **buf,size_t *size);/* if (input(*size) != 0 && output(*size) == 0) means end_of_stream. (output(*size) > input(*size)) is not allowed (output(*size) < input(*size)) is allowed */ -SRes (*Skip)(const ILookInStream *p,size_t offset); +SRes (*Skip)(ILookInStreamPtr p,size_t offset);/* offset must be <= output(*size) of Look */ - -SRes (*Read)(const ILookInStream *p,void *buf,size_t *size); +SRes (*Read)(ILookInStreamPtr p,void *buf,size_t *size);/* reads directly (without buffer). It's same as ISeqInStream::Read */ -SRes (*Seek)(const ILookInStream *p,Int64 *pos,ESzSeek origin); +SRes (*Seek)(ILookInStreamPtr p,Int64 *pos,ESzSeek origin); };#define ILookInStream_Look (p, buf, size) (p)->Look(p, buf, size)
@@ -383,19 +405,18 @@ struct ILookInStream#define ILookInStream_Seek (p, pos, origin) (p)->Seek(p, pos, origin) -SRes LookInStream_LookRead (const ILookInStream *stream,void *buf,size_t *size); -SRes LookInStream_SeekTo (const ILookInStream *stream,UInt64 offset); +SRes LookInStream_LookRead (ILookInStreamPtr stream,void *buf,size_t *size); +SRes LookInStream_SeekTo (ILookInStreamPtr stream,UInt64 offset);/* reads via ILookInStream::Read */ -SRes LookInStream_Read2 (const ILookInStream *stream,void *buf,size_t size,SRes errorType); -SRes LookInStream_Read (const ILookInStream *stream,void *buf,size_t size); - +SRes LookInStream_Read2 (ILookInStreamPtr stream,void *buf,size_t size,SRes errorType); +SRes LookInStream_Read (ILookInStreamPtr stream,void *buf,size_t size); typedef struct { ILookInStream vt; - const ISeekInStream *realStream; + ISeekInStreamPtr realStream; size_t pos; size_t size; /* it's data size */
@@ -407,13 +428,13 @@ typedef structvoid LookToRead2_CreateVTable (CLookToRead2 *p,int lookahead); -#define LookToRead2_Init (p) { (p)->pos = (p)->size = 0; } +#define LookToRead2_INIT (p) { (p)->pos = (p)->size = 0; }typedef struct {ISeqInStream vt; -const ILookInStream *realStream; +ILookInStreamPtr realStream; }CSecToLook ;void SecToLook_CreateVTable (CSecToLook *p);
@@ -423,20 +444,19 @@ void SecToLook_CreateVTable(CSecToLook *p);typedef struct {ISeqInStream vt; -const ILookInStream *realStream; +ILookInStreamPtr realStream; }CSecToRead ;void SecToRead_CreateVTable (CSecToRead *p); -typedef struct ICompressProgress ICompressProgress ; - -struct ICompressProgress +Z7_C_IFACE_DECL (ICompressProgress) { -SRes (*Progress)(const ICompressProgress *p,UInt64 inSize,UInt64 outSize); +SRes (*Progress)(ICompressProgressPtr p,UInt64 inSize,UInt64 outSize);/* Returns: result. (result != SZ_OK) means break. Value (UInt64)(Int64)-1 for size means unknown value. */ }; +#define ICompressProgress_Progress (p, inSize, outSize) (p)->Progress(p, inSize, outSize)
@@ -474,13 +494,13 @@ struct ISzAlloc -#ifndef MY_container_of +#ifndef Z7_container_of/* -#define MY_container_of(ptr, type, m) container_of(ptr, type, m) -#define MY_container_of(ptr, type, m) CONTAINING_RECORD(ptr, type, m) -#define MY_container_of(ptr, type, m) ((type *)((char *)(ptr) - offsetof(type, m))) -#define MY_container_of(ptr, type, m) (&((type *)0)->m == (ptr), ((type *)(((char *)(ptr)) - MY_offsetof(type, m)))) +#define Z7_container_of(ptr, type, m) container_of(ptr, type, m) +#define Z7_container_of(ptr, type, m) CONTAINING_RECORD(ptr, type, m) +#define Z7_container_of(ptr, type, m) ((type *)((char *)(ptr) - offsetof(type, m))) +#define Z7_container_of(ptr, type, m) (&((type *)0)->m == (ptr), ((type *)(((char *)(ptr)) - MY_offsetof(type, m)))) */ /*
@@ -489,24 +509,64 @@ struct ISzAllocGCC 4.8.1 : classes with non-public variable members" */ -#define MY_container_of (ptr, type, m) ((type *)(void *)((char *)(void *)(1 ? (ptr) : &((type *)0)->m) - MY_offsetof(type, m))) +#define Z7_container_of (ptr, type, m) \ + ((type *)(void *)((char *)(void *) \ + (1 ? (ptr) : &((type *)NULL)->m) - MY_offsetof(type, m))) -#endif - -#define CONTAINER_FROM_VTBL_SIMPLE (ptr, type, m) ((type *)(void *)(ptr)) +#define Z7_container_of_CONST (ptr, type, m) \ + ((const type *)(const void *)((const char *)(const void *) \ + (1 ? (ptr) : &((type *)NULL)->m) - MY_offsetof(type, m)))/* -#define CONTAINER_FROM_VTBL(ptr, type, m) CONTAINER_FROM_VTBL_SIMPLE(ptr, type, m) +#define Z7_container_of_NON_CONST_FROM_CONST(ptr, type, m) \ +((type *)(void *)(const void *)((const char *)(const void *) \ +(1 ? (ptr) : &((type *)NULL)->m) - MY_offsetof(type, m))) */ -#define CONTAINER_FROM_VTBL (ptr, type, m) MY_container_of(ptr, type, m) -#define CONTAINER_FROM_VTBL_CLS (ptr, type, m) CONTAINER_FROM_VTBL_SIMPLE(ptr, type, m) +#endif + +#define Z7_CONTAINER_FROM_VTBL_SIMPLE (ptr, type, m) ((type *)(void *)(ptr)) + +// #define Z7_CONTAINER_FROM_VTBL(ptr, type, m) Z7_CONTAINER_FROM_VTBL_SIMPLE(ptr, type, m) +#define Z7_CONTAINER_FROM_VTBL (ptr, type, m) Z7_container_of(ptr, type, m) +// #define Z7_CONTAINER_FROM_VTBL(ptr, type, m) Z7_container_of_NON_CONST_FROM_CONST(ptr, type, m) + +#define Z7_CONTAINER_FROM_VTBL_CONST (ptr, type, m) Z7_container_of_CONST(ptr, type, m) + +#define Z7_CONTAINER_FROM_VTBL_CLS (ptr, type, m) Z7_CONTAINER_FROM_VTBL_SIMPLE(ptr, type, m)/* -#define CONTAINER_FROM_VTBL_CLS(ptr, type, m) CONTAINER_FROM_VTBL(ptr, type, m) +#define Z7_CONTAINER_FROM_VTBL_CLS(ptr, type, m) Z7_CONTAINER_FROM_VTBL(ptr, type, m) */ +#if defined (__clang__) || defined(__GNUC__) +#define Z7_DIAGNOSTIC_IGNORE_BEGIN_CAST_QUAL \ + _Pragma("GCC diagnostic push") \ + _Pragma("GCC diagnostic ignored \"-Wcast-qual\"") +#define Z7_DIAGNOSTIC_IGNORE_END_CAST_QUAL \ + _Pragma("GCC diagnostic pop") +#else +#define Z7_DIAGNOSTIC_IGNORE_BEGIN_CAST_QUAL +#define Z7_DIAGNOSTIC_IGNORE_END_CAST_QUAL +#endif + +#define Z7_CONTAINER_FROM_VTBL_TO_DECL_VAR (ptr, type, m, p) \ + Z7_DIAGNOSTIC_IGNORE_BEGIN_CAST_QUAL \ + type *p = Z7_CONTAINER_FROM_VTBL(ptr, type, m); \ + Z7_DIAGNOSTIC_IGNORE_END_CAST_QUAL + +#define Z7_CONTAINER_FROM_VTBL_TO_DECL_VAR_pp_vt_p (type) \ + Z7_CONTAINER_FROM_VTBL_TO_DECL_VAR(pp, type, vt, p) + +// #define ZIP7_DECLARE_HANDLE(name) typedef void *name; +#define Z7_DECLARE_HANDLE (name) struct name##_dummy{int unused;}; typedef struct name##_dummy *name; + + +#define Z7_memset_0_ARRAY (a) memset((a), 0, sizeof(a)) + +#ifndef Z7_ARRAY_SIZE +#define Z7_ARRAY_SIZE (a) (sizeof(a) / sizeof((a)[0])) +#endif -#define MY_memset_0_ARRAY (a) memset((a), 0, sizeof(a))#ifdef _WIN32
@@ -524,6 +584,22 @@ struct ISzAlloc#endif +#define k_PropVar_TimePrec_0 0 +#define k_PropVar_TimePrec_Unix 1 +#define k_PropVar_TimePrec_DOS 2 +#define k_PropVar_TimePrec_HighPrec 3 +#define k_PropVar_TimePrec_Base 16 +#define k_PropVar_TimePrec_100ns (k_PropVar_TimePrec_Base + 7) +#define k_PropVar_TimePrec_1ns (k_PropVar_TimePrec_Base + 9) + EXTERN_C_END#endif + +/* +#ifndef Z7_ST +#ifdef _7ZIP_ST +#define Z7_ST +#endif +#endif +*/
lib/lzma/Compiler.h +225 -22
261 lines not on this page · raw message
lib/lzma/LzmaDec.c +95 -95
541 lines not on this page · raw message
lib/lzma/LzmaDec.h +9 -8
@@ -1,19 +1,19 @@/* LzmaDec.h -- LZMA Decoder -2020-03-19 : Igor Pavlov : Public domain */ +2023-04-02 : Igor Pavlov : Public domain */ -#ifndef __LZMA_DEC_H -#define __LZMA_DEC_H +#ifndef ZIP7_INC_LZMA_DEC_H +#define ZIP7_INC_LZMA_DEC_H #include "7zTypes.h" EXTERN_C_BEGIN -/* #define _LZMA_PROB32 */ -/* _LZMA_PROB32 can increase the speed on some CPUs, +/* #define Z7_LZMA_PROB32 */ +/* Z7_LZMA_PROB32 can increase the speed on some CPUs, but memory usage for CLzmaDec::probs will be doubled in that case */ typedef -#ifdef _LZMA_PROB32 +#ifdef Z7_LZMA_PROB32 UInt32 #else UInt16
@@ -25,7 +25,7 @@ typedef#define LZMA_PROPS_SIZE 5 -typedef struct _CLzmaProps +typedef struct { Byte lc; Byte lp;
@@ -73,7 +73,8 @@ typedef structByte tempBuf[LZMA_REQUIRED_INPUT_MAX ]; } CLzmaDec; -#define LzmaDec_Construct (p) { (p)->dic = NULL; (p)->probs = NULL; } +#define LzmaDec_CONSTRUCT (p) { (p)->dic = NULL; (p)->probs = NULL; } +#define LzmaDec_Construct (p) LzmaDec_CONSTRUCT(p)void LzmaDec_Init (CLzmaDec *p);
lib/lzma/Makefile +2 -2
@@ -6,7 +6,7 @@ # (C) Copyright 2003-2006 # Wolfgang Denk, DENX Software Engineering, [email protected]. -ccflags-y += -D_LZMA_PROB32 -ccflags-$(CONFIG_$(PHASE_)LZMA_SIZE_OPTIMIZATION) += -D_LZMA_SIZE_OPT +ccflags-y += -DZ7_LZMA_PROB32 +ccflags-$(CONFIG_$(PHASE_)LZMA_SIZE_OPTIMIZATION) += -DZ7_LZMA_SIZE_OPT obj-y += LzmaDec.o LzmaTools.o
lib/lzma/Precomp.h +122 -5
132 lines not on this page · raw message
Signature · 1 line
2.43.0
RFC PATCH 8/9 lzma: Restore spacing fixes
In reply to Tom RiniThis once again removes all trailing blanks and extra empty new lines to bring the code closer to our normal coding style.
--- lib/lzma/7zTypes.h | 36 ++---------------------------------- lib/lzma/Compiler.h | 8 +------- lib/lzma/LzmaDec.c | 18 ------------------ lib/lzma/LzmaDec.h | 6 ------ lib/lzma/Precomp.h | 2 -- 5 files changed, 3 insertions(+), 67 deletions(-)
lib/lzma/7zTypes.h +2 -34
@@ -44,7 +44,6 @@ EXTERN_C_BEGINtypedef int SRes ; -#ifdef _MSC_VER#if _MSC_VER >1200 #define MY_ALIGN (n) __declspec(align(n))
@@ -60,7 +59,6 @@ typedef int SRes;#define MY_ALIGN (n) __attribute__ ((aligned(n)))#endif -#ifdef _WIN32/* typedef DWORD WRes; */
@@ -165,7 +163,6 @@ typedef unsigned long UINT_PTR;#endif -#ifndef RINOK #define RINOK (x) { const int _result_ = (x); if (_result_ != 0) return _result_; }#endif
@@ -186,7 +183,6 @@ typedef int Int32;typedef unsigned int UInt32 ;#endif -#ifndef _WIN32typedef int INT ;
@@ -218,10 +214,8 @@ typedef size_t SIZE_T;#endif // _WIN32 -#define MY_HRES_ERROR_INTERNAL_ERROR ((HRESULT)0x8007054FL) -#ifdef Z7_DECL_Int64_AS_longtypedef long Int64 ;
@@ -248,7 +242,6 @@ typedef unsigned long long int UInt64;#define UINT64_CONST (n) n -#ifdef Z7_DECL_SizeT_AS_unsigned_inttypedef unsigned int SizeT ;#else
@@ -269,7 +262,6 @@ typedef int BoolInt;#define True 1#define False 0 -#ifdef _WIN32#define Z7_STDCALL __stdcall#else
@@ -318,7 +310,6 @@ typedef int BoolInt;#endif // _MSC_VER -/* The following interfaces use first parameter as pointer to structure */ // #define Z7_C_IFACE_CONST_QUAL
@@ -330,21 +321,18 @@ typedef int BoolInt; typedef struct a ## _ a; \ struct a ## _ -Z7_C_IFACE_DECL (IByteIn ) {Byte (*Read)(IByteInPtr p);/* reads one byte, returns 0 in case of EOF or error */ };#define IByteIn_Read (p) (p)->Read(p) -Z7_C_IFACE_DECL (IByteOut) {void (*Write)(IByteOutPtr p,Byte b); };#define IByteOut_Write (p, b) (p)->Write(p, b) -Z7_C_IFACE_DECL (ISeqInStream) {SRes (*Read)(ISeqInStreamPtr p,void *buf,size_t *size);
@@ -360,7 +348,6 @@ SRes SeqInStream_ReadMax(ISeqInStreamPtr stream, void *buf, size_t *processedSiz// SRes SeqInStream_Read2(ISeqInStreamPtr stream, void *buf, size_t size, SRes errorType); SRes SeqInStream_ReadByte (ISeqInStreamPtr stream,Byte *buf); -Z7_C_IFACE_DECL (ISeqOutStream) {size_t (*Write)(ISeqOutStreamPtr p,const void *buf,size_t size);
@@ -376,7 +363,6 @@ typedef enum SZ_SEEK_END = 2 } ESzSeek; -Z7_C_IFACE_DECL (ISeekInStream) {SRes (*Read)(ISeekInStreamPtr p,void *buf,size_t *size);/* same as ISeqInStream::Read */
@@ -385,7 +371,6 @@ Z7_C_IFACE_DECL (ISeekInStream)#define ISeekInStream_Read (p, buf, size) (p)->Read(p, buf, size)#define ISeekInStream_Seek (p, pos, origin) (p)->Seek(p, pos, origin) -Z7_C_IFACE_DECL (ILookInStream) {SRes (*Look)(ILookInStreamPtr p,const void **buf,size_t *size);
@@ -404,7 +389,6 @@ Z7_C_IFACE_DECL (ILookInStream)#define ILookInStream_Read (p, buf, size) (p)->Read(p, buf, size)#define ILookInStream_Seek (p, pos, origin) (p)->Seek(p, pos, origin) -SRes LookInStream_LookRead (ILookInStreamPtr stream,void *buf,size_t *size);SRes LookInStream_SeekTo (ILookInStreamPtr stream,UInt64 offset);
@@ -412,15 +396,14 @@ SRes LookInStream_SeekTo(ILookInStreamPtr stream, UInt64 offset);SRes LookInStream_Read2 (ILookInStreamPtr stream,void *buf,size_t size,SRes errorType);SRes LookInStream_Read (ILookInStreamPtr stream,void *buf,size_t size); - typedef struct { ILookInStream vt; ISeekInStreamPtr realStream; - + size_t pos; size_t size; /* it's data size */ - + /* the following variables must be set outside */ Byte *buf; size_t bufSize;
@@ -430,7 +413,6 @@ void LookToRead2_CreateVTable(CLookToRead2 *p, int lookahead);#define LookToRead2_INIT (p) { (p)->pos = (p)->size = 0; } - typedef struct { ISeqInStream vt;
@@ -439,8 +421,6 @@ typedef structvoid SecToLook_CreateVTable (CSecToLook *p); - - typedef struct { ISeqInStream vt;
@@ -449,7 +429,6 @@ typedef structvoid SecToRead_CreateVTable (CSecToRead *p); -Z7_C_IFACE_DECL (ICompressProgress) {SRes (*Progress)(ICompressProgressPtr p,UInt64 inSize,UInt64 outSize);
@@ -459,8 +438,6 @@ Z7_C_IFACE_DECL (ICompressProgress)#define ICompressProgress_Progress (p, inSize, outSize) (p)->Progress(p, inSize, outSize) - -typedef struct ISzAlloc ISzAlloc ;typedef const ISzAlloc *ISzAllocPtr ;
@@ -477,10 +454,6 @@ struct ISzAlloc#define IAlloc_Alloc (p, size) ISzAlloc_Alloc(p, size)#define IAlloc_Free (p, a) ISzAlloc_Free(p, a) - - - -#ifndef MY_offsetof#ifdef offsetof#define MY_offsetof (type, m) offsetof(type, m)
@@ -492,8 +465,6 @@ struct ISzAlloc#endif #endif - -#ifndef Z7_container_of/*
@@ -556,18 +527,15 @@ struct ISzAlloc#define Z7_CONTAINER_FROM_VTBL_TO_DECL_VAR_pp_vt_p (type) \ Z7_CONTAINER_FROM_VTBL_TO_DECL_VAR(pp, type, vt, p) -// #define ZIP7_DECLARE_HANDLE(name) typedef void *name; #define Z7_DECLARE_HANDLE (name) struct name##_dummy{int unused;}; typedef struct name##_dummy *name; -#define Z7_memset_0_ARRAY (a) memset((a), 0, sizeof(a))#ifndef Z7_ARRAY_SIZE #define Z7_ARRAY_SIZE (a) (sizeof(a) / sizeof((a)[0]))#endif -#ifdef _WIN32#define CHAR_PATH_SEPARATOR '\\'
lib/lzma/Compiler.h +1 -7
@@ -100,7 +100,6 @@ typedef void (*Z7_void_Function)(void);#endif #endif -#ifdef _MSC_VER#ifdef UNDER_CE
@@ -122,7 +121,7 @@ typedef void (*Z7_void_Function)(void);// winnt.h: 'Int64ShllMod32' #pragma warning(disable : 4514) // unreferenced inline function has been removed#endif - +#if _MSC_VER <1300 // #pragma warning(disable : 4702) // unreachable code // Bra.c : -O1:
@@ -163,7 +162,6 @@ typedef void (*Z7_void_Function)(void);#endif // _MSC_VER > 1200 #endif // _MSC_VER -#if defined(__clang__) && (__clang_major__ >=4 )#define Z7_PRAGMA_OPT_DISABLE_LOOP_UNROLL_VECTORIZE \ _Pragma("clang loop unroll(disable)") \
@@ -191,8 +189,6 @@ typedef void (*Z7_void_Function)(void);#define Z7_PRAGMA_OPTIMIZE_DEFAULT #endif - -#if defined(MY_CPU_X86_OR_AMD64 ) && ( \ defined(__clang__) && (__clang_major__ >=4 ) \ || defined(__GNUC__) && (__GNUC__ >=5 ))
@@ -205,7 +201,6 @@ typedef void (*Z7_void_Function)(void);Z7_ATTRIB_NO_VECTORIZE \ Z7_ATTRIB_NO_SSE -#if defined(__clang__) && (__clang_major__ >=8 ) \ || defined(__GNUC__) && (__GNUC__ >=1000 ) \/* || defined(_MSC_VER) && (_MSC_VER >= 1920) */
@@ -220,7 +215,6 @@ typedef void (*Z7_void_Function)(void);// #define Z7_likely #endif -#if (defined(Z7_CLANG_VERSION ) && (Z7_CLANG_VERSION >=30600 ))#if (Z7_CLANG_VERSION <130000 )
lib/lzma/LzmaDec.c +0 -18
@@ -68,7 +68,6 @@#endif // Z7_LZMA_DEC_OPT -#define NORMALIZE_CHECK if (range < kTopValue) { if (buf >= bufLimit) return DUMMY_INPUT_EOF; range <<= 8; code = (code << 8) | (*buf++); }#define IF_BIT_0_CHECK (p) ttt = *(p); NORMALIZE_CHECK bound = (range >> kNumBitModelTotalBits) * (UInt32)ttt; if (code < bound)
@@ -81,12 +80,10 @@#define TREE_DECODE_CHECK (probs, limit, i) \ { i = 1; do { GET_BIT_CHECK(probs + i, i) } while (i < limit); i -= limit; } -#define REV_BIT_CHECK (p, i, m) IF_BIT_0_CHECK(p + i) \ { UPDATE_0_CHECK i += m; m += m; } else \ { UPDATE_1_CHECK m += m; i += m; } -#define kNumPosBitsMax 4#define kNumPosStatesMax (1 << kNumPosBitsMax)
@@ -160,12 +157,10 @@#error Stop_Compiling_Bad_LZMA_PROBS#endif -#define LZMA_LIT_SIZE 0x300#define LzmaProps_GetNumProbs (p) (NUM_BASE_PROBS + ((UInt32)LZMA_LIT_SIZE << ((p)->lc + (p)->lp))) -#define CALC_POS_STATE (processedPos, pbMask) (((processedPos) & (pbMask)) << 4)#define COMBINED_PS_STATE (posState + state)#define GET_LEN_STATE (posState)
@@ -225,7 +220,6 @@ Out:p->reps[*] : undefined */ -#ifdef Z7_LZMA_DEC_OPT int Z7_FASTCALL LZMA_DECODE_REAL(CLzmaDec *p, SizeT limit, const Byte *bufLimit);
@@ -619,8 +613,6 @@ int Z7_FASTCALL LZMA_DECODE_REAL(CLzmaDec *p, SizeT limit, const Byte *bufLimit) }#endif - - static void Z7_FASTCALL LzmaDec_WriteRem(CLzmaDec *p, SizeT limit) {unsigned len = (unsigned )p->remainLen;
@@ -659,7 +651,6 @@ static void Z7_FASTCALL LzmaDec_WriteRem(CLzmaDec *p, SizeT limit) } } -/* At staring of new stream we have one of the following symbols: - Literal - is allowed
@@ -675,7 +666,6 @@ We use early check of (RangeCoder:Code) over kBadRepCode to simplify main decodi#error Stop_Compiling_Bad_LZMA_Check#endif -/* LzmaDec_DecodeReal2(): It calls LZMA_DECODE_REAL() and it adjusts limit according (p->checkDicSize).
@@ -707,8 +697,6 @@ static int Z7_FASTCALL LzmaDec_DecodeReal2(CLzmaDec *p, SizeT limit, const Byte } } - - typedef enum { DUMMY_INPUT_EOF, /* need more input data */
@@ -717,7 +705,6 @@ typedef enum DUMMY_REP } ELzmaDummy; -#define IS_DUMMY_END_MARKER_POSSIBLE (dummyRes) ((dummyRes) == DUMMY_MATCH)static ELzmaDummy LzmaDec_TryDummy (const CLzmaDec *p,const Byte *buf,const Byte **bufOut)
@@ -933,7 +920,6 @@ void LzmaDec_Init(CLzmaDec *p)LzmaDec_InitDicAndState (p, True, True); } -/* LZMA supports optional end_marker. So the decoder can lookahead for one additional LZMA-Symbol to check end_marker.
@@ -950,13 +936,11 @@ When the decoder lookahead, and the lookahead symbol is not end_marker, we haveLZMA_STATUS_FINISHED_WITH_MARK or LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK. */ -#define RETURN_NOT_FINISHED_FOR_FINISH \ *status = LZMA_STATUS_NOT_FINISHED; \ return SZ_ERROR_DATA; // for strict mode// return SZ_OK; // for relaxed mode -SRes LzmaDec_DecodeToDic (CLzmaDec *p,SizeT dicLimit,const Byte *src,SizeT *srcLen,ELzmaFinishMode finishMode,ELzmaStatus *status) {
@@ -1203,8 +1187,6 @@ SRes LzmaDec_DecodeToDic(CLzmaDec *p, SizeT dicLimit, const Byte *src, SizeT *srreturn SZ_ERROR_FAIL ; } - -SRes LzmaDec_DecodeToBuf (CLzmaDec *p,Byte *dest,SizeT *destLen,const Byte *src,SizeT *srcLen,ELzmaFinishMode finishMode,ELzmaStatus *status) {SizeT outSize = *destLen;
lib/lzma/LzmaDec.h +0 -6
@@ -20,7 +20,6 @@ typedef#endif CLzmaProb; -/* ---------- LZMA Properties ---------- */ #define LZMA_PROPS_SIZE 5
@@ -42,7 +41,6 @@ Returns:SRes LzmaProps_Decode (CLzmaProps *p,const Byte *data,unsigned size); -/* ---------- LZMA Decoder state ---------- */ /* LZMA_REQUIRED_INPUT_MAX = number of required input bytes for worst case.
@@ -114,7 +112,6 @@ typedef enum/* ELzmaStatus is used only as output value for function call */ -/* ---------- Interfaces ---------- */ /* There are 3 levels of interfaces:
@@ -124,7 +121,6 @@ typedef enumYou can select any of these interfaces, but don't mix functions from different groups for same object. */ -/* There are two variants to allocate state for Dictionary Interface: 1) LzmaDec_Allocate / LzmaDec_Free 2) LzmaDec_AllocateProbs / LzmaDec_FreeProbs
@@ -188,7 +184,6 @@ Returns:SRes LzmaDec_DecodeToDic (CLzmaDec *p,SizeT dicLimit,const Byte *src,SizeT *srcLen,ELzmaFinishMode finishMode,ELzmaStatus *status); -/* ---------- Buffer Interface ---------- */ /* It's zlib-like interface.
@@ -205,7 +200,6 @@ finishMode:SRes LzmaDec_DecodeToBuf (CLzmaDec *p,Byte *dest,SizeT *destLen,const Byte *src,SizeT *srcLen,ELzmaFinishMode finishMode,ELzmaStatus *status); -/* ---------- One Call Interface ---------- */ /* LzmaDecode
lib/lzma/Precomp.h +0 -2
@@ -84,7 +84,6 @@#endif #endif // Z7_WIN32_WINNT_MIN -#ifndef Z7_DO_NOT_DEFINE_WIN32_WINNT #ifdef _WIN32_WINNT// #error Stop_Compiling_Bad_WIN32_WINNT
@@ -101,7 +100,6 @@ Z7_DIAGNOSTIC_IGNORE_END_RESERVED_MACRO_IDENTIFIER#endif #endif // Z7_DO_NOT_DEFINE_WIN32_WINNT -#ifndef _MBCS#ifndef Z7_NO_UNICODE // UNICODE and _UNICODE are used by <windows.h> and by 7-zip code.
Signature · 1 line
2.43.0
RFC PATCH 9/9 lzma: Add SPDX-License-Identifier lines
In reply to Tom RiniAfter consulting https://spdx.org/licenses/ this code should be tagged with the LZMA-SDK-9.22 identifer, so add them.
--- lib/lzma/7zTypes.h | 1 + lib/lzma/Compiler.h | 1 + lib/lzma/LzmaDec.c | 1 + lib/lzma/LzmaDec.h | 1 + lib/lzma/Precomp.h | 1 + 5 files changed, 5 insertions(+)
lib/lzma/7zTypes.h +1 -0
@@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LZMA-SDK-9.22 */ /* 7zTypes.h -- Basic types 2024-01-24 : Igor Pavlov : Public domain */
lib/lzma/Compiler.h +1 -0
@@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LZMA-SDK-9.22 */ /* Compiler.h : Compiler specific defines and pragmas : Igor Pavlov : Public domain */
lib/lzma/LzmaDec.c +1 -0
@@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LZMA-SDK-9.22 /* LzmaDec.c -- LZMA Decoder 2023-04-07 : Igor Pavlov : Public domain */
lib/lzma/LzmaDec.h +1 -0
@@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LZMA-SDK-9.22 */ /* LzmaDec.h -- LZMA Decoder 2023-04-02 : Igor Pavlov : Public domain */
lib/lzma/Precomp.h +1 -0
@@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LZMA-SDK-9.22 */ /* Precomp.h -- precompilation file 2024-01-25 : Igor Pavlov : Public domain */
Signature · 1 line
2.43.0
cover lzma: Update to 25.01 release of LZMA SDK
In reply to Tom RiniHey all,
As I mentioned in the RFC cover letter, the RFC version of this patch set was expanded for easier review of the changes. This series is intended for merge and so I've squashed all of the updates together. There is no actual change between the two otherwise.
As potential future work, the LZMA SDK now includes an optimized assembly routine for decompression for aarch64 and x86, of which the aarch64 one at least at first glance looks possible to integrate with our codebase.
Signature · 1 line
Tom
PATCH 1/3 lzma: Add Kconfig options to optimize for size
Currently, our LZMA library has an option for optimizing for size, rather than speed. It is a minimal savings today, and has not been worth enabling. As this will change in the near future, add options now to allow disabling it in full U-Boot or in SPL, and enable these on gardena-smart-gateway-mt7688 which is very close to the size limit today.
---
Cc: Stefan Roese <[email protected]>
--- configs/gardena-smart-gateway-mt7688_defconfig | 2 ++ lib/Kconfig | 14 ++++++++++++++ lib/lzma/Makefile | 1 + 3 files changed, 17 insertions(+)
configs/gardena-smart-gateway-mt7688_defconfig +2 -0
@@ -101,4 +101,6 @@ CONFIG_MT7621_SPI=y CONFIG_WDT=y CONFIG_WDT_MT7621=y CONFIG_LZMA=y +CONFIG_LZMA_SIZE_OPTIMIZATION=y CONFIG_SPL_LZMA=y +CONFIG_SPL_LZMA_SIZE_OPTIMIZATION=y
lib/Kconfig +14 -0
@@ -838,6 +838,13 @@ config LZMA ratio and fairly fast decompression speed. See also CONFIG_CMD_LZMADEC which provides a decode command. +config LZMA_SIZE_OPTIMIZATION + bool "Optimize the LZMA algorithm for smaller binary size" + help + This enables building the LZMA library optimized for size, rather + than performance. This can be a loss of 15-20% in decompression + speed, but a savings of close to two kilobytes in many cases. + config LZO bool "Enable LZO decompression support" help
@@ -932,6 +939,13 @@ config SPL_LZMA help This enables support for LZMA compression algorithm for SPL boot. +config SPL_LZMA_SIZE_OPTIMIZATION + bool "Optimize the LZMA algorithm for smaller binary size in SPL" + help + This enables building the LZMA library optimized for size, rather + than performance. This can be a loss of 15-20% in decompression + speed, but a savings of close to two kilobytes in many cases. + config TPL_LZMA bool "Enable LZMA decompression support for TPL build" depends on TPL
lib/lzma/Makefile +1 -0
@@ -7,5 +7,6 @@ # Wolfgang Denk, DENX Software Engineering, [email protected]. ccflags-y += -D_LZMA_PROB32 +ccflags-$(CONFIG_$(PHASE_)LZMA_SIZE_OPTIMIZATION) += -D_LZMA_SIZE_OPT obj-y += LzmaDec.o LzmaTools.o
Signature · 1 line
2.43.0
Re: [PATCHv1 1/3] lzma: Add Kconfig options to optimize for size
Quoted 10 lines · Tom Rini
Currently, our LZMA library has an option for optimizing for size, rather than speed. It is a minimal savings today, and has not been worth enabling. As this will change in the near future, add options now to allow disabling it in full U-Boot or in SPL, and enable these on gardena-smart-gateway-mt7688 which is very close to the size limit today.
Signed-off-by Tom Rini <[email protected]>---
Cc: Stefan Roese <[email protected]>
Thanks,
Stefan
Quoted 60 lines
--- configs/gardena-smart-gateway-mt7688_defconfig | 2 ++ lib/Kconfig | 14 ++++++++++++++ lib/lzma/Makefile | 1 + 3 files changed, 17 insertions(+)configs/gardena-smart-gateway-mt7688_defconfig +2
-0@@ -101,4 +101,6 @@ CONFIG_MT7621_SPI=y CONFIG_WDT=y CONFIG_WDT_MT7621=y CONFIG_LZMA=y +CONFIG_LZMA_SIZE_OPTIMIZATION=y CONFIG_SPL_LZMA=y +CONFIG_SPL_LZMA_SIZE_OPTIMIZATION=ylib/Kconfig +14
-0@@ -838,6 +838,13 @@ config LZMA ratio and fairly fast decompression speed. See also CONFIG_CMD_LZMADEC which provides a decode command. +config LZMA_SIZE_OPTIMIZATION + bool "Optimize the LZMA algorithm for smaller binary size" + help + This enables building the LZMA library optimized for size, rather + than performance. This can be a loss of 15-20% in decompression + speed, but a savings of close to two kilobytes in many cases. + config LZO bool "Enable LZO decompression support" help@@ -932,6 +939,13 @@ config SPL_LZMA help This enables support for LZMA compression algorithm for SPL boot. +config SPL_LZMA_SIZE_OPTIMIZATION + bool "Optimize the LZMA algorithm for smaller binary size in SPL" + help + This enables building the LZMA library optimized for size, rather + than performance. This can be a loss of 15-20% in decompression + speed, but a savings of close to two kilobytes in many cases. + config TPL_LZMA bool "Enable LZMA decompression support for TPL build" depends on TPLlib/lzma/Makefile +1
-0@@ -7,5 +7,6 @@ # Wolfgang Denk, DENX Software Engineering, [email protected]. ccflags-y += -D_LZMA_PROB32 +ccflags-$(CONFIG_$(PHASE_)LZMA_SIZE_OPTIMIZATION) += -D_LZMA_SIZE_OPT obj-y += LzmaDec.o LzmaTools.o
Re: [PATCHv1 1/3] lzma: Add Kconfig options to optimize for size
In reply to Tom RiniQuoted 8 lines · Tom Rini
Currently, our LZMA library has an option for optimizing for size, rather than speed. It is a minimal savings today, and has not been worth enabling. As this will change in the near future, add options now to allow disabling it in full U-Boot or in SPL, and enable these on gardena-smart-gateway-mt7688 which is very close to the size limit today.
[...]
Applied to u-boot/master, thanks!
[1/3] lzma: Add Kconfig options to optimize for size
commit: e7797f450ad26bca32c12ae55e3d43438b74f910
[2/3] lzma: Update LZMA SDK code from 9.20 to 25.01
commit: 33c9db62d49306805bf7ccfb7e6c6e53238ad0c0
[3/3] lzma: Add SPDX-License-Identifier lines
commit: 45c5bc2ca515684dedce4cea3d66a109fba5144dSignature · 1 line
Tom
PATCH 2/3 lzma: Update LZMA SDK code from 9.20 to 25.01
In reply to Tom RiniCurrently, we have a copy of the LZMA SDK code, version 9.20, with small updates. The original import of the LZMA SDK included a script to update the library. This is no longer possible, due to important local changes, so remove it. We also remove a number of extra text files that should be unchanged from upstream, but provide no direct value to the project. Instead, have the help text for LZMA note that this comes from the LZMA SDK.
Next, we move our code up to the current release, 25.01. There are a number of new header files, and some performance improvements made to the code, at the cost of between 2 to 3 kilobytes in binary size. As there is now a Kconfig option to disable this and retain similar speed to what we have currently, the default option is to make this trade-off. Our changes to the code around calling schedule() to avoid the watchdog being triggered are kept. We add __UBOOT__ guards in two places to prevent conflict with our own usage of these words on MIPS.
--- include/lzma/LzmaTypes.h | 2 +- lib/Kconfig | 5 +- lib/lzma/7zC.txt | 187 +++++++ lib/lzma/7zTypes.h | 573 ++++++++++++++++++++ lib/lzma/Compiler.h | 240 +++++++++ lib/lzma/LzmaDec.c | 1022 ++++++++++++++++++++++++------------ lib/lzma/LzmaDec.h | 68 ++- lib/lzma/LzmaTools.c | 4 +- lib/lzma/Makefile | 4 +- lib/lzma/Precomp.h | 125 +++++ lib/lzma/README.txt | 28 - lib/lzma/Types.h | 232 -------- lib/lzma/history.txt | 271 ---------- lib/lzma/import_lzmasdk.sh | 36 -- lib/lzma/license.txt | 3 - lib/lzma/lzma.txt | 598 --------------------- 16 files changed, 1856 insertions(+), 1542 deletions(-) create mode 100644 lib/lzma/7zC.txt create mode 100644 lib/lzma/7zTypes.h create mode 100644 lib/lzma/Compiler.h create mode 100644 lib/lzma/Precomp.h delete mode 100644 lib/lzma/README.txt delete mode 100644 lib/lzma/Types.h delete mode 100644 lib/lzma/history.txt delete mode 100644 lib/lzma/import_lzmasdk.sh delete mode 100644 lib/lzma/license.txt delete mode 100644 lib/lzma/lzma.txt
include/lzma/LzmaTypes.h +1 -1
@@ -14,6 +14,6 @@*/ #define Byte LZByte -#include "../../lib/lzma/Types.h" +#include "../../lib/lzma/7zTypes.h" #endif
lib/Kconfig +3 -2
@@ -835,8 +835,9 @@ config LZMA help This enables support for LZMA (Lempel-Ziv-Markov chain algorithm), a dictionary compression algorithm that provides a high compression - ratio and fairly fast decompression speed. See also - CONFIG_CMD_LZMADEC which provides a decode command. + ratio and fairly fast decompression speed. Our implementation comes + from the LZMA SDK. See also CONFIG_CMD_LZMADEC which provides a + decode command. config LZMA_SIZE_OPTIMIZATION bool "Optimize the LZMA algorithm for smaller binary size"
lib/lzma/7zC.txt new file +187 -0
187 lines not on this page · raw message
lib/lzma/7zTypes.h new file +573 -0
573 lines not on this page · raw message
lib/lzma/Compiler.h new file +240 -0
240 lines not on this page · raw message
lib/lzma/LzmaDec.c +682 -340
1,562 lines not on this page · raw message
lib/lzma/LzmaDec.h +41 -27
135 lines not on this page · raw message
lib/lzma/LzmaTools.c +2 -2
@@ -33,8 +33,8 @@#include <linux/string.h> #include <malloc.h> -static void *SzAlloc (void *p,size_t size) {return malloc (size); } -static void SzFree (void *p,void *address) {free (address); } +static void *SzAlloc (ISzAllocPtr p,size_t size) {return malloc (size); } +static void SzFree (ISzAllocPtr p,void *address) {free (address); }int lzmaBuffToBuffDecompress (unsigned char *outStream,SizeT *uncompressedSize,const unsigned char *inStream,SizeT length)
lib/lzma/Makefile +2 -2
@@ -6,7 +6,7 @@ # (C) Copyright 2003-2006 # Wolfgang Denk, DENX Software Engineering, [email protected]. -ccflags-y += -D_LZMA_PROB32 -ccflags-$(CONFIG_$(PHASE_)LZMA_SIZE_OPTIMIZATION) += -D_LZMA_SIZE_OPT +ccflags-y += -DZ7_LZMA_PROB32 +ccflags-$(CONFIG_$(PHASE_)LZMA_SIZE_OPTIMIZATION) += -DZ7_LZMA_SIZE_OPT obj-y += LzmaDec.o LzmaTools.o
lib/lzma/Precomp.h new file +125 -0
125 lines not on this page · raw message
lib/lzma/README.txt deleted +0 -28
@@ -1,28 +0,0 @@ -The lib_lzma functionality was written by Igor Pavlov. -The original source cames from the LZMA SDK web page: - -URL: http://www.7-zip.org/sdk.html -Author: Igor Pavlov - -The import is made using the import_lzmasdk.sh script that: - -* untars the lzmaXYY.tar.bz2 file (from the download web page) -* copies the files LzmaDec.h, Types.h, LzmaDec.c, history.txt, - and lzma.txt from source archive into the lib_lzma directory (pwd). - -Example: - - . import_lzmasdk.sh ~/lzma465.tar.bz2 - -Notice: The files from lzma sdk are _not modified_ by this script! - -The files LzmaTools.{c,h} are provided to export the lzmaBuffToBuffDecompress() -function that wraps the complex LzmaDecode() function from the LZMA SDK. The -do_bootm() function uses the lzmaBuffToBuffDecopress() function to expand the -compressed image. - -The directory U-BOOT/include/lzma contains stubs files that permit to use the -library directly from U-BOOT code without touching the original LZMA SDK's -files. - -Luigi 'Comio' Mantellini <[email protected]>
lib/lzma/Types.h deleted +0 -232
113 lines not on this page · raw message
lib/lzma/history.txt deleted +0 -271
271 lines not on this page · raw message
lib/lzma/lzma.txt deleted +0 -598
598 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.43.0
Part of the diff is not shown here. View the raw message.
PATCH 3/3 lzma: Add SPDX-License-Identifier lines
In reply to Tom RiniAfter consulting https://spdx.org/licenses/ this code should be tagged with the LZMA-SDK-9.22 identifer, so add them.
--- lib/lzma/7zTypes.h | 1 + lib/lzma/Compiler.h | 1 + lib/lzma/LzmaDec.c | 1 + lib/lzma/LzmaDec.h | 1 + lib/lzma/Precomp.h | 1 + 5 files changed, 5 insertions(+)
lib/lzma/7zTypes.h +1 -0
@@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LZMA-SDK-9.22 */ /* 7zTypes.h -- Basic types 2024-01-24 : Igor Pavlov : Public domain */
lib/lzma/Compiler.h +1 -0
@@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LZMA-SDK-9.22 */ /* Compiler.h : Compiler specific defines and pragmas : Igor Pavlov : Public domain */
lib/lzma/LzmaDec.c +1 -0
@@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LZMA-SDK-9.22 /* LzmaDec.c -- LZMA Decoder 2023-04-07 : Igor Pavlov : Public domain */
lib/lzma/LzmaDec.h +1 -0
@@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LZMA-SDK-9.22 */ /* LzmaDec.h -- LZMA Decoder 2023-04-02 : Igor Pavlov : Public domain */
lib/lzma/Precomp.h +1 -0
@@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LZMA-SDK-9.22 */ /* Precomp.h -- precompilation file 2024-01-25 : Igor Pavlov : Public domain */
Signature · 1 line
2.43.0
Quoted 7 lines · Tom Rini
Hey all,
A long while ago, Darek reported that our copy of the LZMA SDK library is quite old and so vulnerable to at least one possible security issue he found that was fixed upstream.
Quoted 13 lines
This RFC series does a few things. First, we introduce a
Kconfigoption to enable LZMA's size reduction option, and enable it on gardena-smart-gateway-mt7688. This is not critical at the start, but is as we move forward. Next, we remove some files from our initial import of the library that do not make sense to keep in-tree. After that, the next 5 patches update us from the imported version to the current release of 25.01. This is split up such that few have the very few places where the update requires some slight changes to our code be more visible. This in turn is mainly that the file that says the license has changed, and that we need to guard around some unused upstream code that also conflicts with our own code. Finally, we restore the spacing changes that our copy of the code had, and then improve things by adding SPDX tags to the LZMA code so the license is more visible overall.
Does it make sense to try and get the SPDX bits back upstream so we have less delta the next time we rebase?
Quoted 9 lines
I've marked this as RFC in part because I plan to follow-up with v1 shortly where patches 2 through 8 are squashed together as they're mainly separate right now for ease of review, but the split doesn't make sense I believe to preserve in git as our changes are so isolated.
--
Tom
Quoted 22 lines · Peter Robinson
Quoted 7 lines · Tom Rini
Hey all,
A long while ago, Darek reported that our copy of the LZMA SDK library is quite old and so vulnerable to at least one possible security issue he found that was fixed upstream.
Quoted 13 lines
This RFC series does a few things. First, we introduce a
Kconfigoption to enable LZMA's size reduction option, and enable it on gardena-smart-gateway-mt7688. This is not critical at the start, but is as we move forward. Next, we remove some files from our initial import of the library that do not make sense to keep in-tree. After that, the next 5 patches update us from the imported version to the current release of 25.01. This is split up such that few have the very few places where the update requires some slight changes to our code be more visible. This in turn is mainly that the file that says the license has changed, and that we need to guard around some unused upstream code that also conflicts with our own code. Finally, we restore the spacing changes that our copy of the code had, and then improve things by adding SPDX tags to the LZMA code so the license is more visible overall.
Quoted 2 lines
Does it make sense to try and get the SPDX bits back upstream so we have less delta the next time we rebase?
Upstream seems to be done very much as a one person as they like it project. There is an issue tracker. I'll sign up and file a request at least.
Signature · 1 line
Tom