Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 141918 Details for
Bug 207737
sys-fs/squashfs-tools - add lzma support
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
squashfs-tools-3.3-sqlzma1-449.patch
squashfs-tools-3.3-sqlzma1-449.patch (text/plain), 19.36 KB, created by
Russell Harmon
on 2008-01-27 19:23:10 UTC
(
hide
)
Description:
squashfs-tools-3.3-sqlzma1-449.patch
Filename:
MIME Type:
Creator:
Russell Harmon
Created:
2008-01-27 19:23:10 UTC
Size:
19.36 KB
patch
obsolete
>Index: lzma449/C/Compress/Lzma/kmod.mk >=================================================================== >RCS file: lzma449/C/Compress/Lzma/kmod.mk >diff -N lzma449/C/Compress/Lzma/kmod.mk >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ lzma449/C/Compress/Lzma/kmod.mk 5 Nov 2007 05:43:35 -0000 1.1 >@@ -0,0 +1,40 @@ >+ >+# Copyright (C) 2006-2007 Junjiro Okajima >+# Copyright (C) 2006-2007 Tomas Matejicek, slax.org >+# >+# LICENSE follows the described one in lzma.txt. >+ >+# $Id: kmod.mk,v 1.1 2007/11/05 05:43:35 jro Exp $ >+ >+ifndef Sqlzma >+$(error Sqlzma is not defined) >+endif >+ifndef KDir >+$(error KDir is not defined) >+endif >+ >+#include makefile.gcc >+ >+Kmod = kmod >+EXTRA_CFLAGS += -Wall -Werror -I${CURDIR} -I${Sqlzma} >+# -D_LZMA_PROB32 >+EXTRA_CFLAGS += $(shell ${CPP} ${CFLAGS} -P testflags.c) >+ >+all: ${Kmod}/uncomp.c >+ ${MAKE} EXTRA_CFLAGS="${EXTRA_CFLAGS}" M=${CURDIR}/${Kmod} \ >+ -C ${KDir} C=0 V=0 modules >+ >+${Kmod}/uncomp.c: uncomp.c >+ ln $< $@ >+ >+clean: clean_kmod >+clean_kmod: >+ ${MAKE} -C ${KDir} M=${CURDIR}/${Kmod} V=0 clean >+ ${RM} ${Kmod}/*~ >+ -@test -e ${Kmod}/uncomp.c && \ >+ diff -q ${Kmod}/uncomp.c uncomp.c > /dev/null && \ >+ find ${Kmod}/uncomp.c -links +1 | xargs -r ${RM} >+ >+# Local variables: ; >+# compile-command: (concat "make Sqlzma=../../../../.. KDir=/lib/modules/`uname -r`/build -f " (file-name-nondirectory (buffer-file-name))); >+# End: ; >Index: lzma449/C/Compress/Lzma/sqlzma.mk >=================================================================== >RCS file: lzma449/C/Compress/Lzma/sqlzma.mk >diff -N lzma449/C/Compress/Lzma/sqlzma.mk >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ lzma449/C/Compress/Lzma/sqlzma.mk 5 Nov 2007 05:43:36 -0000 1.1 >@@ -0,0 +1,47 @@ >+ >+# Copyright (C) 2006-2007 Junjiro Okajima >+# Copyright (C) 2006-2007 Tomas Matejicek, slax.org >+# >+# LICENSE follows the described one in lzma.txt. >+ >+# $Id: sqlzma.mk,v 1.1 2007/11/05 05:43:36 jro Exp $ >+ >+ifndef Sqlzma >+$(error Sqlzma is not defined) >+endif >+ >+#include makefile.gcc >+CFLAGS = -c -O2 -Wall -pedantic -D _LZMA_PROB32 >+ >+ifdef KDir >+include kmod.mk >+endif >+ >+ifdef UseDebugFlags >+DebugFlags = -O0 -g -UNDEBUG >+endif >+CFLAGS += -DNDEBUG ${DebugFlags} >+Tgt = libunlzma.a libunlzma_r.a >+ >+all: ${Tgt} >+ >+%_r.c: %.c >+ ln $< $@ >+# -pthread >+%_r.o: CFLAGS += -D_REENTRANT -include pthread.h >+ >+uncomp.o uncomp_r.o: CFLAGS += -I${Sqlzma} >+uncomp.o: uncomp.c ${Sqlzma}/sqlzma.h >+ >+libunlzma.a: uncomp.o LzmaDecode.o >+ ${AR} cr $@ $^ >+libunlzma_r.a: uncomp_r.o LzmaDecode_r.o >+ ${AR} cr $@ $^ >+ >+clean: clean_sqlzma >+clean_sqlzma: >+ $(RM) ${Tgt} uncomp.o uncomp_r.o LzmaDecode_r.o LzmaDecode.o *~ >+ >+# Local variables: ; >+# compile-command: (concat "make Sqlzma=../../../../.. -f " (file-name-nondirectory (buffer-file-name))); >+# End: ; >Index: lzma449/C/Compress/Lzma/testflags.c >=================================================================== >RCS file: lzma449/C/Compress/Lzma/testflags.c >diff -N lzma449/C/Compress/Lzma/testflags.c >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ lzma449/C/Compress/Lzma/testflags.c 5 Nov 2007 05:43:36 -0000 1.1 >@@ -0,0 +1,5 @@ >+#ifdef _LZMA_PROB32 >+-D_LZMA_PROB32 >+#else >+-U_LZMA_PROB32 >+#endif >Index: lzma449/C/Compress/Lzma/uncomp.c >=================================================================== >RCS file: lzma449/C/Compress/Lzma/uncomp.c >diff -N lzma449/C/Compress/Lzma/uncomp.c >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ lzma449/C/Compress/Lzma/uncomp.c 5 Nov 2007 05:43:36 -0000 1.1 >@@ -0,0 +1,221 @@ >+/* >+ * Copyright (C) 2006, 2007 Junjiro Okajima >+ * Copyright (C) 2006, 2007 Tomas Matejicek, slax.org >+ * >+ * LICENSE follows the described one in lzma.txt. >+ */ >+ >+/* $Id: uncomp.c,v 1.1 2007/11/05 05:43:36 jro Exp $ */ >+ >+/* extract some parts from lzma443/C/7zip/Compress/LZMA_C/LzmaTest.c */ >+ >+#ifndef __KERNEL__ >+#include <stdio.h> >+#include <stdlib.h> >+#include <string.h> >+#include <errno.h> >+#include <assert.h> >+#include <pthread.h> >+#define unlikely(x) __builtin_expect(!!(x), 0) >+#define BUG_ON(x) assert(!(x)) >+/* sqlzma buffers are always larger than a page. true? */ >+#define kmalloc(sz,gfp) malloc(sz) >+#define kfree(p) free(p) >+#define zlib_inflate(s, f) inflate(s, f) >+#define zlib_inflateInit(s) inflateInit(s) >+#define zlib_inflateReset(s) inflateReset(s) >+#define zlib_inflateEnd(s) inflateEnd(s) >+#else >+#include <linux/init.h> >+#include <linux/module.h> >+#include <linux/kernel.h> >+#include <linux/vmalloc.h> >+#ifndef WARN_ON_ONCE >+#define WARN_ON_ONCE(b) WARN_ON(b) >+#endif >+#endif /* __KERNEL__ */ >+ >+#include "sqlzma.h" >+#include "LzmaDecode.h" >+ >+static int LzmaUncompress(struct sqlzma_un *un) >+{ >+ int err, i, ret; >+ SizeT outSize, inProcessed, outProcessed, srclen; >+ /* it's about 24-80 bytes structure, if int is 32-bit */ >+ CLzmaDecoderState state; >+ unsigned char *dst, *src, a[8]; >+ struct sized_buf *sbuf; >+ >+ /* Decode LZMA properties and allocate memory */ >+ err = -EINVAL; >+ src = un->un_cmbuf; >+ ret = LzmaDecodeProperties(&state.Properties, src, LZMA_PROPERTIES_SIZE); >+ src += LZMA_PROPERTIES_SIZE; >+ if (unlikely(ret != LZMA_RESULT_OK)) >+ goto out; >+ i = LzmaGetNumProbs(&state.Properties); >+ if (unlikely(i <= 0)) >+ i = 1; >+ i *= sizeof(CProb); >+ sbuf = un->un_a + SQUN_PROB; >+ if (unlikely(sbuf->sz < i)) { >+ if (sbuf->buf && sbuf->buf != un->un_prob) >+ kfree(sbuf->buf); >+#ifdef __KERNEL__ >+ printk("%s:%d: %d --> %d\n", __func__, __LINE__, sbuf->sz, i); >+#else >+ printf("%d --> %d\n", sbuf->sz, i); >+#endif >+ err = -ENOMEM; >+ sbuf->sz = 0; >+ sbuf->buf = kmalloc(i, GFP_ATOMIC); >+ if (unlikely(!sbuf->buf)) >+ goto out; >+ sbuf->sz = i; >+ } >+ state.Probs = (void*)sbuf->buf; >+ >+ /* Read uncompressed size */ >+ memcpy(a, src, sizeof(a)); >+ src += sizeof(a); >+ outSize = a[0] | (a[1] << 8) | (a[2] << 16) | (a[3] << 24); >+ >+ err = -EINVAL; >+ dst = un->un_resbuf; >+ if (unlikely(!dst || outSize > un->un_reslen)) >+ goto out; >+ un->un_reslen = outSize; >+ srclen = un->un_cmlen - (src - un->un_cmbuf); >+ >+ /* Decompress */ >+ err = LzmaDecode(&state, src, srclen, &inProcessed, dst, outSize, >+ &outProcessed); >+ if (err) >+ err = -EINVAL; >+ >+ out: >+#ifndef __KERNEL__ >+ if (err) >+ fprintf(stderr, "err %d\n", err); >+#endif >+ return err; >+} >+ >+int sqlzma_un(struct sqlzma_un *un, struct sized_buf *src, >+ struct sized_buf *dst) >+{ >+ int err, by_lzma = 0; >+ if (un->un_lzma && is_lzma(*src->buf)) { >+ by_lzma = 1; >+ un->un_cmbuf = src->buf; >+ un->un_cmlen = src->sz; >+ un->un_resbuf = dst->buf; >+ un->un_reslen = dst->sz; >+ >+ /* this library is thread-safe */ >+ err = LzmaUncompress(un); >+ goto out; >+ } >+ >+ err = zlib_inflateReset(&un->un_stream); >+ if (unlikely(err != Z_OK)) >+ goto out; >+ un->un_stream.next_in = src->buf; >+ un->un_stream.avail_in = src->sz; >+ un->un_stream.next_out = dst->buf; >+ un->un_stream.avail_out = dst->sz; >+ err = zlib_inflate(&un->un_stream, Z_FINISH); >+ if (err == Z_STREAM_END) >+ err = 0; >+ >+ out: >+ if (err) { >+#ifdef __KERNEL__ >+ WARN_ON_ONCE(1); >+#else >+ char a[64] = "ZLIB "; >+ if (by_lzma) { >+ strcpy(a, "LZMA "); >+#ifdef _REENTRANT >+ strerror_r(err, a + 5, sizeof(a) - 5); >+#else >+ strncat(a, strerror(err), sizeof(a) - 5); >+#endif >+ } else >+ strncat(a, zError(err), sizeof(a) - 5); >+ fprintf(stderr, "%s: %.*s\n", __func__, sizeof(a), a); >+#endif >+ } >+ return err; >+} >+ >+int sqlzma_init(struct sqlzma_un *un, int do_lzma, unsigned int res_sz) >+{ >+ int err; >+ >+ err = -ENOMEM; >+ un->un_lzma = do_lzma; >+ memset(un->un_a, 0, sizeof(un->un_a)); >+ un->un_a[SQUN_PROB].buf = un->un_prob; >+ un->un_a[SQUN_PROB].sz = sizeof(un->un_prob); >+ if (res_sz) { >+ un->un_a[SQUN_RESULT].buf = kmalloc(res_sz, GFP_KERNEL); >+ if (unlikely(!un->un_a[SQUN_RESULT].buf)) >+ return err; >+ un->un_a[SQUN_RESULT].sz = res_sz; >+ } >+ >+ un->un_stream.next_in = NULL; >+ un->un_stream.avail_in = 0; >+#ifdef __KERNEL__ >+ un->un_stream.workspace = kmalloc(zlib_inflate_workspacesize(), GFP_KERNEL); >+ if (unlikely(!un->un_stream.workspace)) >+ return err; >+#else >+ un->un_stream.opaque = NULL; >+ un->un_stream.zalloc = Z_NULL; >+ un->un_stream.zfree = Z_NULL; >+#endif >+ err = zlib_inflateInit(&un->un_stream); >+ if (unlikely(err == Z_MEM_ERROR)) >+ return -ENOMEM; >+ BUG_ON(err); >+ return err; >+} >+ >+void sqlzma_fin(struct sqlzma_un *un) >+{ >+ int i; >+ for (i = 0; i < SQUN_LAST; i++) >+ if (un->un_a[i].buf && un->un_a[i].buf != un->un_prob) >+ kfree(un->un_a[i].buf); >+ BUG_ON(zlib_inflateEnd(&un->un_stream) != Z_OK); >+} >+ >+#ifdef __KERNEL__ >+EXPORT_SYMBOL(sqlzma_un); >+EXPORT_SYMBOL(sqlzma_init); >+EXPORT_SYMBOL(sqlzma_fin); >+ >+#if 0 >+static int __init sqlzma_init(void) >+{ >+ return 0; >+} >+ >+static void __exit sqlzma_exit(void) >+{ >+} >+ >+module_init(sqlzma_init); >+module_exit(sqlzma_exit); >+#endif >+ >+MODULE_LICENSE("GPL"); >+MODULE_AUTHOR("Junjiro Okajima <sfjro at users dot sf dot net>"); >+MODULE_VERSION("$Id: uncomp.c,v 1.1 2007/11/05 05:43:36 jro Exp $"); >+MODULE_DESCRIPTION("LZMA uncompress for squashfs. " >+ "Some functions for squashfs to support LZMA and " >+ "a tiny wrapper for LzmaDecode.c in LZMA SDK from www.7-zip.org."); >+#endif >Index: lzma449/C/Compress/Lzma/kmod/Makefile >=================================================================== >RCS file: lzma449/C/Compress/Lzma/kmod/Makefile >diff -N lzma449/C/Compress/Lzma/kmod/Makefile >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ lzma449/C/Compress/Lzma/kmod/Makefile 5 Nov 2007 05:43:36 -0000 1.1 >@@ -0,0 +1,11 @@ >+ >+# Copyright (C) 2006-2007 Junjiro Okajima >+# Copyright (C) 2006-2007 Tomas Matejicek, slax.org >+# >+# LICENSE follows the described one in lzma.txt. >+ >+# $Id: Makefile,v 1.1 2007/11/05 05:43:36 jro Exp $ >+ >+obj-m += unlzma.o sqlzma.o >+unlzma-y := module.o >+sqlzma-y := uncomp.o >Index: lzma449/C/Compress/Lzma/kmod/module.c >=================================================================== >RCS file: lzma449/C/Compress/Lzma/kmod/module.c >diff -N lzma449/C/Compress/Lzma/kmod/module.c >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ lzma449/C/Compress/Lzma/kmod/module.c 5 Nov 2007 05:43:36 -0000 1.1 >@@ -0,0 +1,36 @@ >+ >+/* >+ * Copyright (C) 2006-2007 Junjiro Okajima >+ * Copyright (C) 2006-2007 Tomas Matejicek, slax.org >+ * >+ * LICENSE follows the described one in lzma.txt. >+ */ >+ >+/* $Id: module.c,v 1.1 2007/11/05 05:43:36 jro Exp $ */ >+ >+#include <linux/init.h> >+#include <linux/module.h> >+ >+#include "../LzmaDecode.c" >+ >+EXPORT_SYMBOL(LzmaDecodeProperties); >+EXPORT_SYMBOL(LzmaDecode); >+ >+#if 0 >+static int __init unlzma_init(void) >+{ >+ return 0; >+} >+ >+static void __exit unlzma_exit(void) >+{ >+} >+ >+module_init(unlzma_init); >+module_exit(unlzma_exit); >+#endif >+ >+MODULE_LICENSE("GPL"); >+MODULE_VERSION("$Id: module.c,v 1.1 2007/11/05 05:43:36 jro Exp $"); >+MODULE_DESCRIPTION("LZMA uncompress. " >+ "A tiny wrapper for LzmaDecode.c in LZMA SDK from www.7-zip.org."); >Index: lzma449/CPP/7zip/Compress/LZMA_Alone/comp.cc >=================================================================== >RCS file: lzma449/CPP/7zip/Compress/LZMA_Alone/comp.cc >diff -N lzma449/CPP/7zip/Compress/LZMA_Alone/comp.cc >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ lzma449/CPP/7zip/Compress/LZMA_Alone/comp.cc 13 Nov 2007 13:27:23 -0000 1.3 >@@ -0,0 +1,260 @@ >+/* >+ * Copyright (C) 2006-2007 Junjiro Okajima >+ * Copyright (C) 2006-2007 Tomas Matejicek, slax.org >+ * >+ * LICENSE follows the described one in lzma.txt. >+ */ >+ >+/* $Id: comp.cc,v 1.3 2007/11/13 13:27:23 jro Exp $ */ >+ >+// extract some parts from lzma443/C/7zip/Compress/LZMA_Alone/LzmaAlone.cpp >+ >+#include <stdio.h> >+#include <stdlib.h> >+#include <assert.h> >+#include <errno.h> >+ >+#include "StdAfx.h" >+#include "../../../Common/MyInitGuid.h" >+//#include "../../../Common/MyWindows.h" >+#include "../../../Common/StringConvert.h" >+//#include "../../../Common/StringToInt.h" >+//#include "../../Common/StreamUtils.h" >+#include "../LZMA/LZMAEncoder.h" >+ >+#include <pthread.h> >+#include <zlib.h> >+#include "sqlzma.h" >+ >+////////////////////////////////////////////////////////////////////// >+ >+class CMemoryStream { >+protected: >+ Bytef *m_data; >+ UInt64 m_limit; >+ UInt64 m_pos; >+ >+public: >+ CMemoryStream(Bytef *data, UInt64 size) >+ : m_data(data), m_limit(size), m_pos(0) {} >+ >+ virtual ~CMemoryStream() {} >+}; >+ >+class CInMemoryStream : public CMemoryStream, public IInStream, >+ public CMyUnknownImp { >+//protected: >+ CMyComPtr<ISequentialInStream> m_stream; >+ >+public: >+ MY_UNKNOWN_IMP1(IInStream); >+ >+ CInMemoryStream(Bytef *data, UInt64 size) >+ : CMemoryStream(data, size), m_stream(this) {} >+ >+ virtual ~CInMemoryStream() {} >+ >+ STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize) >+ { >+ UInt64 room = m_limit - m_pos; >+ if (size > room) >+ size = room; >+ if (size) { >+ memcpy(data, m_data + m_pos, size); >+ m_pos += size; >+ } >+ if (processedSize) >+ *processedSize = size; >+ return S_OK; >+ } >+ >+ // disabled all >+ STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition) { >+ assert(0); >+ return E_NOTIMPL; >+ } >+}; >+ >+class COutMemoryStream : public CMemoryStream, public IOutStream, >+ public CMyUnknownImp { >+//protected: >+ CMyComPtr<ISequentialOutStream> m_stream; >+ >+public: >+ MY_UNKNOWN_IMP1(IOutStream); >+ >+ COutMemoryStream(Bytef *data, UInt64 size) >+ : CMemoryStream(data, size), m_stream(this) {} >+ >+ virtual ~COutMemoryStream() {} >+ >+ UInt32 GetSize() {return m_pos;} >+ >+ STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize) { >+ if (m_pos + size > m_limit) >+ return -ENOSPC; >+ memcpy(m_data + m_pos, data, size); >+ m_pos += size; >+ if (processedSize) >+ *processedSize = size; >+ return S_OK; >+ } >+ >+ // disabled all >+ STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition) { >+ assert(0); >+ return E_NOTIMPL; >+ } >+ STDMETHOD(SetSize)(Int64 newSize) { >+ assert(0); >+ return E_NOTIMPL; >+ } >+}; >+ >+////////////////////////////////////////////////////////////////////// >+ >+static int >+LzmaCompress(Bytef *next_in, uInt avail_in, Bytef *next_out, uInt avail_out, >+ struct sqlzma_opts *opts, uLong *total_out) >+{ >+ int err; >+ HRESULT res; >+ const Byte a[] = { >+ avail_in, avail_in >> 8, avail_in >> 16, avail_in >> 24, >+ 0, 0, 0, 0 >+ }; >+ >+ NCompress::NLZMA::CEncoder encoderSpec; >+ CMyComPtr<ICompressCoder> encoder = &encoderSpec; >+ encoder->AddRef(); >+ CInMemoryStream inStreamSpec(next_in, avail_in); >+ CMyComPtr<ISequentialInStream> inStream = &inStreamSpec; >+ inStream->AddRef(); >+ COutMemoryStream outStreamSpec(next_out, avail_out); >+ CMyComPtr<ISequentialOutStream> outStream = &outStreamSpec; >+ outStream->AddRef(); >+ >+ // these values are dpending upon is_lzma() macro in sqlzma.h >+ const UInt32 dictionary = opts->dicsize; >+ //fprintf(stderr, "dic %u\n", dictionary); >+ const UString mf = L"BT4"; >+ const UInt32 posStateBits = 2; >+ const UInt32 litContextBits = 3; // for normal files >+ // UInt32 litContextBits = 0; // for 32-bit data >+ const UInt32 litPosBits = 0; >+ // UInt32 litPosBits = 2; // for 32-bit data >+ //const UInt32 algorithm = 2; >+ const UInt32 algorithm = 1; >+ const UInt32 numFastBytes = 128; >+ const UInt32 matchFinderCycles = 16 + numFastBytes / 2; >+ //const bool matchFinderCyclesDefined = false; >+ const PROPID propIDs[] = { >+ NCoderPropID::kDictionarySize, >+ NCoderPropID::kPosStateBits, >+ NCoderPropID::kLitContextBits, >+ NCoderPropID::kLitPosBits, >+ NCoderPropID::kAlgorithm, >+ NCoderPropID::kNumFastBytes, >+ NCoderPropID::kMatchFinder, >+ NCoderPropID::kEndMarker, >+ NCoderPropID::kNumThreads, >+ NCoderPropID::kMatchFinderCycles >+ }; >+ const int kNumPropsMax = sizeof(propIDs) / sizeof(propIDs[0]); >+ PROPVARIANT properties[kNumPropsMax]; >+ for (int p = 0; p < 6; p++) >+ properties[p].vt = VT_UI4; >+ properties[0].ulVal = UInt32(dictionary); >+ properties[1].ulVal = UInt32(posStateBits); >+ properties[2].ulVal = UInt32(litContextBits); >+ properties[3].ulVal = UInt32(litPosBits); >+ properties[4].ulVal = UInt32(algorithm); >+ properties[5].ulVal = UInt32(numFastBytes); >+ >+ properties[6].vt = VT_BSTR; >+ properties[6].bstrVal = (BSTR)(const wchar_t *)mf; >+ properties[7].vt = VT_BOOL; >+ properties[7].boolVal = VARIANT_FALSE; // EOS >+ properties[8].vt = VT_UI4; >+ properties[8].ulVal = 1; // numThreads >+ properties[9].vt = VT_UI4; >+ properties[9].ulVal = UInt32(matchFinderCycles); >+ >+ err = -EINVAL; >+ res = encoderSpec.SetCoderProperties(propIDs, properties, >+ kNumPropsMax - 1); >+ if (res) >+ goto out; >+ res = encoderSpec.WriteCoderProperties(outStream); >+ if (res) >+ goto out; >+ >+ UInt32 r; >+ res = outStream->Write(a, sizeof(a), &r); >+ if (res || r != sizeof(a)) >+ goto out; >+ >+ err = encoder->Code(inStream, outStream, 0, /*broken*/0, 0); >+ if (err) >+ goto out; >+ *total_out = outStreamSpec.GetSize(); >+ >+ out: >+ return err; >+} >+ >+////////////////////////////////////////////////////////////////////// >+ >+#define Failure(p) do { \ >+ fprintf(stderr, "%s:%d: please report to jro " \ >+ "{%02x, %02x, %02x, %02x, %02x, %02x, %02x, %02x}\n", \ >+ __func__, __LINE__, \ >+ p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7]); \ >+ abort(); \ >+} while(0) >+ >+extern "C" int >+sqlzma_cm(struct sqlzma_opts *opts, z_stream *stream, Bytef *next_in, uInt >+ avail_in, Bytef *next_out, uInt avail_out) >+{ >+ int err; >+ Bytef *p = next_out; >+ uInt l = avail_out; >+ >+ stream->next_in = next_in; >+ stream->avail_in = avail_in; >+ stream->next_out = p; >+ stream->avail_out = l; >+ err = deflate(stream, Z_FINISH); >+ if (err != Z_STREAM_END && err != Z_OK) >+ goto out_err; >+ if (avail_in < stream->total_out) >+ return err; >+ if (is_lzma(*p)) >+ Failure(p); >+ >+ if (opts->try_lzma) { >+ unsigned char a[stream->total_out]; >+ uLong processed; >+ >+ memcpy(a, p, stream->total_out); >+ >+ // malloc family in glibc and stdc++ seems to be thread-safe >+ err = LzmaCompress(next_in, avail_in, p, l, opts, &processed); >+ if (!err && processed <= stream->total_out) { >+ if (!is_lzma(*next_out)) >+ Failure(next_out); >+ stream->total_out = processed; >+ err = Z_STREAM_END; >+ } else { >+ //puts("by zlib"); >+ memcpy(p, a, stream->total_out); >+ err = Z_STREAM_END; >+ } >+ } >+ return err; >+ >+ out_err: >+ fprintf(stderr, "%s: ZLIB err %s\n", __func__, zError(err)); >+ return err; >+} >Index: lzma449/CPP/7zip/Compress/LZMA_Alone/sqlzma.mk >=================================================================== >RCS file: lzma449/CPP/7zip/Compress/LZMA_Alone/sqlzma.mk >diff -N lzma449/CPP/7zip/Compress/LZMA_Alone/sqlzma.mk >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ lzma449/CPP/7zip/Compress/LZMA_Alone/sqlzma.mk 5 Nov 2007 05:43:36 -0000 1.1 >@@ -0,0 +1,57 @@ >+ >+# Copyright (C) 2006-2007 Junjiro Okajima >+# Copyright (C) 2006-2007 Tomas Matejicek, slax.org >+# >+# LICENSE follows the described one in lzma.txt. >+ >+# $Id: sqlzma.mk,v 1.1 2007/11/05 05:43:36 jro Exp $ >+ >+ifndef Sqlzma >+$(error Sqlzma is not defined) >+endif >+ >+include makefile.gcc >+ >+ifdef UseDebugFlags >+DebugFlags = -Wall -O0 -g -UNDEBUG >+endif >+# -pthread >+CXXFLAGS = ${CFLAGS} -D_REENTRANT -include pthread.h -DNDEBUG ${DebugFlags} >+Tgt = liblzma_r.a >+ >+all: ${Tgt} >+ >+RObjs = LZMAEncoder_r.o Alloc_r.o StreamUtils_r.o MatchFinder_r.o \ >+ RangeCoderBit_r.o OutBuffer_r.o 7zCrc_r.o >+ >+%_r.cc: ../LZMA/%.cpp >+ ln $< $@ >+%_r.c: ../../../../C/%.c >+ ln $< $@ >+%_r.c: ../../../../C/Compress/Lz/%.c >+ ln $< $@ >+%_r.cc: ../../Common/%.cpp >+ ln $< $@ >+%_r.cc: ../RangeCoder/%.cpp >+ ln $< $@ >+LZMAEncoder_r.o: CXXFLAGS += -I../LZMA >+Alloc_r.o: CFLAGS += -I../../../../C >+StreamUtils_r.o: CXXFLAGS += -I../../Common >+MatchFinder_r.o: CFLAGS += -I../../../../C/Compress/Lz >+RangeCoderBit_r.o: CXXFLAGS += -I../RangeCoder >+OutBuffer_r.o: CXXFLAGS += -I../../Common >+7zCrc_r.o: CFLAGS += -I../../../../C >+ >+comp.o: CXXFLAGS += -I${Sqlzma} >+comp.o: comp.cc ${Sqlzma}/sqlzma.h >+ >+liblzma_r.a: ${RObjs} comp.o >+ ${AR} cr $@ $^ >+ >+clean: clean_sqlzma >+clean_sqlzma: >+ $(RM) comp.o *_r.o ${Tgt} *~ >+ >+# Local variables: ; >+# compile-command: (concat "make Sqlzma=../../../../.. -f " (file-name-nondirectory (buffer-file-name))); >+# End: ;
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 207737
:
141916
| 141918 |
141919
|
141920
|
141922
|
149004
|
171877
|
171897
|
171910
|
196292
|
212452
|
212454
|
212455