source: freewrt/tools/lzma/lzma-zlib.patch@ 8e4e7a3

freewrt_1_0 freewrt_2_0
Last change on this file since 8e4e7a3 was 131a9d7, checked in by Waldemar Brodkorb <wbx@…>, 19 years ago

move tools like sed, trx, lzma, which does not belong to the toolchain (gcc,binutils,gdb,libc) to a separate directory, all stuff is compiled with the host compiler

git-svn-id: svn://www.freewrt.org/trunk/freewrt@194 afb5a338-a214-0410-bd46-81f09a774fd1

  • Property mode set to 100644
File size: 15.2 KB
  • C/7zip/Compress/LZMA/LZMADecoder.cpp

    $FreeWRT$
    
    diff -Nur lzma/C/7zip/Compress/LZMA/LZMADecoder.cpp lzma.patched/C/7zip/Compress/LZMA/LZMADecoder.cpp
    old new  
    274274  Byte remainder = (Byte)(properties[0] / 9);
    275275  int lp = remainder % 5;
    276276  int pb = remainder / 5;
    277   if (pb > NLength::kNumPosStatesBitsMax)
    278     return E_INVALIDARG;
    279   _posStateMask = (1 << pb) - 1;
    280277  UInt32 dictionarySize = 0;
    281278  for (int i = 0; i < 4; i++)
    282279    dictionarySize += ((UInt32)(properties[1 + i])) << (i * 8);
     280  return SetDecoderPropertiesRaw(lc, lp, pb, dictionarySize);
     281}
     282
     283STDMETHODIMP CDecoder::SetDecoderPropertiesRaw(int lc, int lp, int pb, UInt32 dictionarySize)
     284{
     285  if (pb > NLength::kNumPosStatesBitsMax)
     286    return E_INVALIDARG;
     287  _posStateMask = (1 << pb) - 1;
    283288  if (!_outWindowStream.Create(dictionarySize))
    284289    return E_OUTOFMEMORY;
    285290  if (!_literalDecoder.Create(lp, lc))
  • C/7zip/Compress/LZMA/LZMADecoder.h

    diff -Nur lzma/C/7zip/Compress/LZMA/LZMADecoder.h lzma.patched/C/7zip/Compress/LZMA/LZMADecoder.h
    old new  
    228228      ICompressProgressInfo *progress);
    229229
    230230  STDMETHOD(SetDecoderProperties2)(const Byte *data, UInt32 size);
     231  STDMETHOD(SetDecoderPropertiesRaw)(int lc, int lp, int pb, UInt32 dictionarySize);
    231232
    232233  STDMETHOD(GetInStreamProcessedSize)(UInt64 *value);
    233234
  • C/7zip/Compress/LZMA_Lib/makefile

    diff -Nur lzma/C/7zip/Compress/LZMA_Lib/makefile lzma.patched/C/7zip/Compress/LZMA_Lib/makefile
    old new  
     1PROG = liblzma.a
     2CXX = g++ -O3 -Wall
     3AR = ar
     4RM = rm -f
     5CFLAGSX = $(CFLAGS) -c  -I ../../../
     6
     7OBJS = \
     8  ZLib.o \
     9  LZMADecoder.o \
     10  LZMAEncoder.o \
     11  LZInWindow.o \
     12  LZOutWindow.o \
     13  RangeCoderBit.o \
     14  InBuffer.o \
     15  OutBuffer.o \
     16  FileStreams.o \
     17  Alloc.o \
     18  C_FileIO.o \
     19  CommandLineParser.o \
     20  CRC.o \
     21  StreamUtils.o \
     22  String.o \
     23  StringConvert.o \
     24  StringToInt.o \
     25  Vector.o \
     26
     27
     28all: $(PROG)
     29
     30$(PROG): $(OBJS)
     31        $(AR) r $(PROG) $(OBJS)
     32
     33ZLib.o: ZLib.cpp
     34        $(CXX) $(CFLAGSX) ZLib.cpp
     35
     36LZMADecoder.o: ../LZMA/LZMADecoder.cpp
     37        $(CXX) $(CFLAGSX) ../LZMA/LZMADecoder.cpp
     38
     39LZMAEncoder.o: ../LZMA/LZMAEncoder.cpp
     40        $(CXX) $(CFLAGSX) ../LZMA/LZMAEncoder.cpp
     41
     42LZInWindow.o: ../LZ/LZInWindow.cpp
     43        $(CXX) $(CFLAGSX) ../LZ/LZInWindow.cpp
     44
     45LZOutWindow.o: ../LZ/LZOutWindow.cpp
     46        $(CXX) $(CFLAGSX) ../LZ/LZOutWindow.cpp
     47
     48RangeCoderBit.o: ../RangeCoder/RangeCoderBit.cpp
     49        $(CXX) $(CFLAGSX) ../RangeCoder/RangeCoderBit.cpp
     50
     51InBuffer.o: ../../Common/InBuffer.cpp
     52        $(CXX) $(CFLAGSX) ../../Common/InBuffer.cpp
     53
     54OutBuffer.o: ../../Common/OutBuffer.cpp
     55        $(CXX) $(CFLAGSX) ../../Common/OutBuffer.cpp
     56
     57StreamUtils.o: ../../Common/StreamUtils.cpp
     58        $(CXX) $(CFLAGSX) ../../Common/StreamUtils.cpp
     59
     60FileStreams.o: ../../Common/FileStreams.cpp
     61        $(CXX) $(CFLAGSX) ../../Common/FileStreams.cpp
     62
     63Alloc.o: ../../../Common/Alloc.cpp
     64        $(CXX) $(CFLAGSX) ../../../Common/Alloc.cpp
     65
     66C_FileIO.o: ../../../Common/C_FileIO.cpp
     67        $(CXX) $(CFLAGSX) ../../../Common/C_FileIO.cpp
     68
     69CommandLineParser.o: ../../../Common/CommandLineParser.cpp
     70        $(CXX) $(CFLAGSX) ../../../Common/CommandLineParser.cpp
     71
     72CRC.o: ../../../Common/CRC.cpp
     73        $(CXX) $(CFLAGSX) ../../../Common/CRC.cpp
     74
     75MyWindows.o: ../../../Common/MyWindows.cpp
     76        $(CXX) $(CFLAGSX) ../../../Common/MyWindows.cpp
     77
     78String.o: ../../../Common/String.cpp
     79        $(CXX) $(CFLAGSX) ../../../Common/String.cpp
     80
     81StringConvert.o: ../../../Common/StringConvert.cpp
     82        $(CXX) $(CFLAGSX) ../../../Common/StringConvert.cpp
     83
     84StringToInt.o: ../../../Common/StringToInt.cpp
     85        $(CXX) $(CFLAGSX) ../../../Common/StringToInt.cpp
     86
     87Vector.o: ../../../Common/Vector.cpp
     88        $(CXX) $(CFLAGSX) ../../../Common/Vector.cpp
     89
     90clean:
     91        -$(RM) $(PROG) $(OBJS)
     92
  • C/7zip/Compress/LZMA_Lib/ZLib.cpp

    diff -Nur lzma/C/7zip/Compress/LZMA_Lib/ZLib.cpp lzma.patched/C/7zip/Compress/LZMA_Lib/ZLib.cpp
    old new  
     1/*
     2 * lzma zlib simplified wrapper
     3 *
     4 * Copyright (c) 2005-2006 Oleg I. Vdovikin <oleg@cs.msu.su>
     5 *
     6 * This library is free software; you can redistribute
     7 * it and/or modify it under the terms of the GNU Lesser
     8 * General Public License as published by the Free Software
     9 * Foundation; either version 2.1 of the License, or
     10 * (at your option) any later version.
     11 *
     12 * This library is distributed in the hope that it will be
     13 * useful, but WITHOUT ANY WARRANTY; without even the implied
     14 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
     15 * PURPOSE. See the GNU Lesser General Public License
     16 * for more details.
     17 *
     18 * You should have received a copy of the GNU Lesser General
     19 * Public License along with this library; if not, write to
     20 * the Free Software Foundation, Inc., 59 Temple Place,
     21 * Suite 330, Boston, MA 02111-1307 USA
     22 */
     23
     24/*
     25 * default values for encoder/decoder used by wrapper
     26 */
     27
     28#include <zlib.h>
     29
     30#define ZLIB_LC 3
     31#define ZLIB_LP 0
     32#define ZLIB_PB 2
     33
     34#ifdef WIN32
     35#include <initguid.h>
     36#else
     37#define INITGUID
     38#endif
     39
     40#include "../../../Common/MyWindows.h"
     41#include "../LZMA/LZMADecoder.h"
     42#include "../LZMA/LZMAEncoder.h"
     43
     44#define STG_E_SEEKERROR                  ((HRESULT)0x80030019L)
     45#define STG_E_MEDIUMFULL                 ((HRESULT)0x80030070L)
     46
     47class CInMemoryStream:
     48  public IInStream,
     49  public IStreamGetSize,
     50  public CMyUnknownImp
     51{
     52public:
     53  CInMemoryStream(const Bytef *data, UInt64 size) :
     54          m_data(data), m_size(size), m_offset(0) {}
     55
     56  virtual ~CInMemoryStream() {}
     57
     58  MY_UNKNOWN_IMP2(IInStream, IStreamGetSize)
     59
     60  STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize)
     61  {
     62          if (size > m_size - m_offset)
     63                  size = m_size - m_offset;
     64
     65          if (size) {
     66                  memcpy(data, m_data + m_offset, size);
     67          }
     68
     69          m_offset += size;
     70
     71          if (processedSize)
     72                  *processedSize = size;
     73
     74          return S_OK;
     75  }
     76
     77  STDMETHOD(ReadPart)(void *data, UInt32 size, UInt32 *processedSize)
     78  {
     79        return Read(data, size, processedSize);
     80  }
     81
     82  STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition)
     83  {
     84          UInt64 _offset;
     85
     86          if (seekOrigin == STREAM_SEEK_SET) _offset = offset;
     87          else if (seekOrigin == STREAM_SEEK_CUR) _offset = m_offset + offset;
     88          else if (seekOrigin == STREAM_SEEK_END) _offset = m_size;
     89          else return STG_E_INVALIDFUNCTION;
     90
     91          if (_offset < 0 || _offset > m_size)
     92                  return STG_E_SEEKERROR;
     93
     94          m_offset = _offset;
     95
     96          if (newPosition)
     97                  *newPosition = m_offset;
     98
     99          return S_OK;
     100  }
     101
     102  STDMETHOD(GetSize)(UInt64 *size)
     103  {
     104          *size = m_size;
     105          return S_OK;
     106  }
     107protected:
     108        const Bytef *m_data;
     109        UInt64 m_size;
     110        UInt64 m_offset;
     111};
     112
     113class COutMemoryStream:
     114  public IOutStream,
     115  public CMyUnknownImp
     116{
     117public:
     118  COutMemoryStream(Bytef *data, UInt64 maxsize) :
     119          m_data(data), m_size(0), m_maxsize(maxsize), m_offset(0) {}
     120  virtual ~COutMemoryStream() {}
     121 
     122  MY_UNKNOWN_IMP1(IOutStream)
     123
     124  STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize)
     125  {
     126          if (size > m_maxsize - m_offset)
     127                  size = m_maxsize - m_offset;
     128
     129          if (size) {
     130                  memcpy(m_data + m_offset, data, size);
     131          }
     132
     133          m_offset += size;
     134
     135          if (m_offset > m_size)
     136                m_size = m_offset;
     137
     138          if (processedSize)
     139                  *processedSize = size;
     140
     141          return S_OK;
     142  }
     143 
     144  STDMETHOD(WritePart)(const void *data, UInt32 size, UInt32 *processedSize)
     145  {
     146          return Write(data, size, processedSize);
     147  }
     148
     149  STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition)
     150  {
     151          UInt64 _offset;
     152
     153          if (seekOrigin == STREAM_SEEK_SET) _offset = offset;
     154          else if (seekOrigin == STREAM_SEEK_CUR) _offset = m_offset + offset;
     155          else if (seekOrigin == STREAM_SEEK_END) _offset = m_size;
     156          else return STG_E_INVALIDFUNCTION;
     157
     158          if (_offset < 0 || _offset > m_maxsize)
     159                  return STG_E_SEEKERROR;
     160
     161          m_offset = _offset;
     162
     163          if (newPosition)
     164                  *newPosition = m_offset;
     165
     166          return S_OK;
     167  }
     168 
     169  STDMETHOD(SetSize)(Int64 newSize)
     170  {
     171          if ((UInt64)newSize > m_maxsize)
     172                  return STG_E_MEDIUMFULL;
     173
     174          return S_OK;
     175  }
     176protected:
     177        Bytef *m_data;
     178        UInt64 m_size;
     179        UInt64 m_maxsize;
     180        UInt64 m_offset;
     181};
     182
     183ZEXTERN int ZEXPORT compress2 OF((Bytef *dest,   uLongf *destLen,
     184                                  const Bytef *source, uLong sourceLen,
     185                                  int level))
     186{
     187        CInMemoryStream *inStreamSpec = new CInMemoryStream(source, sourceLen);
     188        CMyComPtr<ISequentialInStream> inStream = inStreamSpec;
     189       
     190        COutMemoryStream *outStreamSpec = new COutMemoryStream(dest, *destLen);
     191        CMyComPtr<ISequentialOutStream> outStream = outStreamSpec;
     192       
     193        NCompress::NLZMA::CEncoder *encoderSpec =
     194                new NCompress::NLZMA::CEncoder;
     195        CMyComPtr<ICompressCoder> encoder = encoderSpec;
     196       
     197        PROPID propIDs[] =
     198        {
     199                NCoderPropID::kDictionarySize,
     200                NCoderPropID::kPosStateBits,
     201                NCoderPropID::kLitContextBits,
     202                NCoderPropID::kLitPosBits,
     203                NCoderPropID::kAlgorithm,
     204                NCoderPropID::kNumFastBytes,
     205                NCoderPropID::kMatchFinder,
     206                NCoderPropID::kEndMarker
     207        };
     208        const int kNumProps = sizeof(propIDs) / sizeof(propIDs[0]);
     209       
     210        PROPVARIANT properties[kNumProps];
     211        for (int p = 0; p < 6; p++)
     212                properties[p].vt = VT_UI4;
     213        properties[0].ulVal = UInt32(1 << (level + 14));
     214        properties[1].ulVal = UInt32(ZLIB_PB);
     215        properties[2].ulVal = UInt32(ZLIB_LC); // for normal files
     216        properties[3].ulVal = UInt32(ZLIB_LP); // for normal files
     217        properties[4].ulVal = UInt32(2);
     218        properties[5].ulVal = UInt32(128);
     219       
     220        properties[6].vt = VT_BSTR;
     221        properties[6].bstrVal = (BSTR)(const wchar_t *)L"BT4";
     222       
     223        properties[7].vt = VT_BOOL;
     224        properties[7].boolVal = VARIANT_TRUE;
     225       
     226        if (encoderSpec->SetCoderProperties(propIDs, properties, kNumProps) != S_OK)
     227                return Z_MEM_ERROR; // should not happen
     228       
     229        HRESULT result = encoder->Code(inStream, outStream, 0, 0, 0);
     230        if (result == E_OUTOFMEMORY)
     231        {
     232                return Z_MEM_ERROR;
     233        }   
     234        else if (result != S_OK)
     235        {
     236                return Z_BUF_ERROR;     // should not happen
     237        }   
     238       
     239        UInt64 fileSize;
     240        outStreamSpec->Seek(0, STREAM_SEEK_END, &fileSize);
     241        *destLen = fileSize;
     242       
     243        return Z_OK;
     244}
     245
     246ZEXTERN int ZEXPORT uncompress OF((Bytef *dest,   uLongf *destLen,
     247                                   const Bytef *source, uLong sourceLen))
     248{
     249        CInMemoryStream *inStreamSpec = new CInMemoryStream(source, sourceLen);
     250        CMyComPtr<ISequentialInStream> inStream = inStreamSpec;
     251       
     252        COutMemoryStream *outStreamSpec = new COutMemoryStream(dest, *destLen);
     253        CMyComPtr<ISequentialOutStream> outStream = outStreamSpec;
     254       
     255        NCompress::NLZMA::CDecoder *decoderSpec =
     256                new NCompress::NLZMA::CDecoder;
     257        CMyComPtr<ICompressCoder> decoder = decoderSpec;
     258       
     259        if (decoderSpec->SetDecoderPropertiesRaw(ZLIB_LC,
     260                ZLIB_LP, ZLIB_PB, (1 << 23)) != S_OK) return Z_DATA_ERROR;
     261       
     262        UInt64 fileSize = *destLen;
     263       
     264        if (decoder->Code(inStream, outStream, 0, &fileSize, 0) != S_OK)
     265        {
     266                return Z_DATA_ERROR;
     267        }
     268       
     269        outStreamSpec->Seek(0, STREAM_SEEK_END, &fileSize);
     270        *destLen = fileSize;
     271       
     272        return Z_OK;
     273}
  • lzma/C/7zip/Compress/LZMA_Alone/makefile.gcc

    old new  
    11PROG = lzma
    22CXX = g++ -O2 -Wall
    3 CXX_C = gcc -O2 -Wall
     3CXX_C = $(CC) -O2 -Wall
    44LIB = -lm
    55RM = rm -f
    6 CFLAGS = -c -I ../../../
     6CFLAGSX = $(CFLAGS) -c -I ../../../
    77
    88OBJS = \
    99  LzmaAlone.o \
    $(PROG): $(OBJS)  
    3737        $(CXX) -o $(PROG) $(LDFLAGS) $(OBJS) $(LIB)
    3838
    3939LzmaAlone.o: LzmaAlone.cpp
    40         $(CXX) $(CFLAGS) LzmaAlone.cpp
     40        $(CXX) $(CFLAGSX) LzmaAlone.cpp
    4141
    4242LzmaBench.o: LzmaBench.cpp
    43         $(CXX) $(CFLAGS) LzmaBench.cpp
     43        $(CXX) $(CFLAGSX) LzmaBench.cpp
    4444
    4545LzmaRam.o: LzmaRam.cpp
    46         $(CXX) $(CFLAGS) LzmaRam.cpp
     46        $(CXX) $(CFLAGSX) LzmaRam.cpp
    4747
    4848LzmaRamDecode.o: LzmaRamDecode.c
    49         $(CXX_C) $(CFLAGS) LzmaRamDecode.c
     49        $(CXX_C) $(CFLAGSX) LzmaRamDecode.c
    5050
    5151LzmaDecode.o: ../LZMA_C/LzmaDecode.c
    52         $(CXX_C) $(CFLAGS) ../LZMA_C/LzmaDecode.c
     52        $(CXX_C) $(CFLAGSX) ../LZMA_C/LzmaDecode.c
    5353
    5454BranchX86.o: ../Branch/BranchX86.c
    55         $(CXX_C) $(CFLAGS) ../Branch/BranchX86.c
     55        $(CXX_C) $(CFLAGSX) ../Branch/BranchX86.c
    5656
    5757LZMADecoder.o: ../LZMA/LZMADecoder.cpp
    58         $(CXX) $(CFLAGS) ../LZMA/LZMADecoder.cpp
     58        $(CXX) $(CFLAGSX) ../LZMA/LZMADecoder.cpp
    5959
    6060LZMAEncoder.o: ../LZMA/LZMAEncoder.cpp
    61         $(CXX) $(CFLAGS) ../LZMA/LZMAEncoder.cpp
     61        $(CXX) $(CFLAGSX) ../LZMA/LZMAEncoder.cpp
    6262
    6363LZInWindow.o: ../LZ/LZInWindow.cpp
    64         $(CXX) $(CFLAGS) ../LZ/LZInWindow.cpp
     64        $(CXX) $(CFLAGSX) ../LZ/LZInWindow.cpp
    6565
    6666LZOutWindow.o: ../LZ/LZOutWindow.cpp
    67         $(CXX) $(CFLAGS) ../LZ/LZOutWindow.cpp
     67        $(CXX) $(CFLAGSX) ../LZ/LZOutWindow.cpp
    6868
    6969RangeCoderBit.o: ../RangeCoder/RangeCoderBit.cpp
    70         $(CXX) $(CFLAGS) ../RangeCoder/RangeCoderBit.cpp
     70        $(CXX) $(CFLAGSX) ../RangeCoder/RangeCoderBit.cpp
    7171
    7272InBuffer.o: ../../Common/InBuffer.cpp
    73         $(CXX) $(CFLAGS) ../../Common/InBuffer.cpp
     73        $(CXX) $(CFLAGSX) ../../Common/InBuffer.cpp
    7474
    7575OutBuffer.o: ../../Common/OutBuffer.cpp
    76         $(CXX) $(CFLAGS) ../../Common/OutBuffer.cpp
     76        $(CXX) $(CFLAGSX) ../../Common/OutBuffer.cpp
    7777
    7878FileStreams.o: ../../Common/FileStreams.cpp
    79         $(CXX) $(CFLAGS) ../../Common/FileStreams.cpp
     79        $(CXX) $(CFLAGSX) ../../Common/FileStreams.cpp
    8080
    8181StreamUtils.o: ../../Common/StreamUtils.cpp
    82         $(CXX) $(CFLAGS) ../../Common/StreamUtils.cpp
     82        $(CXX) $(CFLAGSX) ../../Common/StreamUtils.cpp
    8383
    8484Alloc.o: ../../../Common/Alloc.cpp
    85         $(CXX) $(CFLAGS) ../../../Common/Alloc.cpp
     85        $(CXX) $(CFLAGSX) ../../../Common/Alloc.cpp
    8686
    8787C_FileIO.o: ../../../Common/C_FileIO.cpp
    88         $(CXX) $(CFLAGS) ../../../Common/C_FileIO.cpp
     88        $(CXX) $(CFLAGSX) ../../../Common/C_FileIO.cpp
    8989
    9090CommandLineParser.o: ../../../Common/CommandLineParser.cpp
    91         $(CXX) $(CFLAGS) ../../../Common/CommandLineParser.cpp
     91        $(CXX) $(CFLAGSX) ../../../Common/CommandLineParser.cpp
    9292
    9393CRC.o: ../../../Common/CRC.cpp
    94         $(CXX) $(CFLAGS) ../../../Common/CRC.cpp
     94        $(CXX) $(CFLAGSX) ../../../Common/CRC.cpp
    9595
    9696MyWindows.o: ../../../Common/MyWindows.cpp
    97         $(CXX) $(CFLAGS) ../../../Common/MyWindows.cpp
     97        $(CXX) $(CFLAGSX) ../../../Common/MyWindows.cpp
    9898
    9999String.o: ../../../Common/String.cpp
    100         $(CXX) $(CFLAGS) ../../../Common/String.cpp
     100        $(CXX) $(CFLAGSX) ../../../Common/String.cpp
    101101
    102102StringConvert.o: ../../../Common/StringConvert.cpp
    103         $(CXX) $(CFLAGS) ../../../Common/StringConvert.cpp
     103        $(CXX) $(CFLAGSX) ../../../Common/StringConvert.cpp
    104104
    105105StringToInt.o: ../../../Common/StringToInt.cpp
    106         $(CXX) $(CFLAGS) ../../../Common/StringToInt.cpp
     106        $(CXX) $(CFLAGSX) ../../../Common/StringToInt.cpp
    107107
    108108Vector.o: ../../../Common/Vector.cpp
    109         $(CXX) $(CFLAGS) ../../../Common/Vector.cpp
     109        $(CXX) $(CFLAGSX) ../../../Common/Vector.cpp
    110110
    111111clean:
    112112        -$(RM) $(PROG) $(OBJS)
Note: See TracBrowser for help on using the repository browser.