diff options
author | Alexandru Gagniuc <mr.nuke.me@gmail.com> | 2014-01-29 16:50:40 -0600 |
---|---|---|
committer | Alexandru Gagniuc <mr.nuke.me@gmail.com> | 2014-03-02 05:14:30 +0100 |
commit | 5edfa3779dd3fc18ec182bc4f0085c0aa1e1474e (patch) | |
tree | 718cf89c2f8719ed096bfab075f035c44d466911 | |
parent | 5ca914bc64829f097629661c2f48492c81cfd77e (diff) | |
download | coreboot-5edfa3779dd3fc18ec182bc4f0085c0aa1e1474e.tar.xz |
cbfstool/lzma: Remove dead code under #ifdefs
Remove a bunch of dead code which depends either on commented out
#defines, or compiler definitions. Use this opportunity to remove the
need for "-D_7ZIP_ST" in the compiler flags.
Change-Id: Ib6629002be7bf4cee6d95d7baa724893b5e8ba32
Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
Reviewed-on: http://review.coreboot.org/5083
Tested-by: build bot (Jenkins)
Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net>
Reviewed-by: Ronald G. Minnich <rminnich@gmail.com>
Reviewed-by: Edward O'Callaghan <eocallaghan@alterapraxis.com>
-rw-r--r-- | util/cbfstool/Makefile | 1 | ||||
-rw-r--r-- | util/cbfstool/Makefile.inc | 2 | ||||
-rw-r--r-- | util/cbfstool/lzma/C/LzmaEnc.c | 128 |
3 files changed, 2 insertions, 129 deletions
diff --git a/util/cbfstool/Makefile b/util/cbfstool/Makefile index 0df5c97631..bc49c64002 100644 --- a/util/cbfstool/Makefile +++ b/util/cbfstool/Makefile @@ -2,7 +2,6 @@ obj ?= $(shell pwd) HOSTCC ?= $(CC) CFLAGS ?= -g -CFLAGS += -D_7ZIP_ST CFLAGS += -Wall -Wundef -Wstrict-prototypes -Wmissing-prototypes CFLAGS += -Wwrite-strings -Wredundant-decls -Wno-trigraphs CFLAGS += -Wstrict-aliasing -Werror diff --git a/util/cbfstool/Makefile.inc b/util/cbfstool/Makefile.inc index f3596fba71..c19b7d9070 100644 --- a/util/cbfstool/Makefile.inc +++ b/util/cbfstool/Makefile.inc @@ -17,7 +17,7 @@ cbfsobj += LzmaEnc.o cbfsobj += linux_trampoline.o cbfsobj += cbfs-payload-linux.o -CBFSTOOLFLAGS=-D_7ZIP_ST -g +CBFSTOOLFLAGS= -g ifeq ($(shell uname -s | cut -c-7 2>/dev/null), MINGW32) CBFSTOOLFLAGS+=-mno-ms-bitfields diff --git a/util/cbfstool/lzma/C/LzmaEnc.c b/util/cbfstool/lzma/C/LzmaEnc.c index 583b45500e..e7d14c59a8 100644 --- a/util/cbfstool/lzma/C/LzmaEnc.c +++ b/util/cbfstool/lzma/C/LzmaEnc.c @@ -3,23 +3,9 @@ #include <string.h> -/* #define SHOW_STAT */ -/* #define SHOW_STAT2 */ - -#if defined(SHOW_STAT) || defined(SHOW_STAT2) -#include <stdio.h> -#endif - #include "LzmaEnc.h" #include "LzFind.h" -#ifndef _7ZIP_ST -#include "LzFindMt.h" -#endif - -#ifdef SHOW_STAT -static int ttt = 0; -#endif #define kBlockSizeMax ((1 << LZMA_NUM_BLOCK_SIZE_BITS) - 1) @@ -65,12 +51,7 @@ void LzmaEncProps_Normalize(struct CLzmaEncProps *p) if (p->numHashBytes < 0) p->numHashBytes = 4; if (p->mc == 0) p->mc = (16 + (p->fb >> 1)) >> (p->btMode ? 0 : 1); if (p->numThreads < 0) - p->numThreads = - #ifndef _7ZIP_ST - ((p->btMode && p->algo) ? 2 : 1); - #else - 1; - #endif + p->numThreads = 1; } uint32_t LzmaEncProps_GetDictSize(const struct CLzmaEncProps *props2) @@ -80,27 +61,6 @@ uint32_t LzmaEncProps_GetDictSize(const struct CLzmaEncProps *props2) return props.dictSize; } -/* #define LZMA_LOG_BSR */ -/* Define it for Intel's CPU */ - - -#ifdef LZMA_LOG_BSR - -#define kDicLogSizeMaxCompress 30 - -#define BSR2_RET(pos, res) { unsigned long i; _BitScanReverse(&i, (pos)); res = (i + i) + ((pos >> (i - 1)) & 1); } - -uint32_t GetPosSlot1(uint32_t pos) -{ - uint32_t res; - BSR2_RET(pos, res); - return res; -} -#define GetPosSlot2(pos, res) { BSR2_RET(pos, res); } -#define GetPosSlot(pos, res) { if (pos < 2) res = pos; else BSR2_RET(pos, res); } - -#else - #define kNumLogBits (9 + (int)sizeof(size_t) / 2) #define kDicLogSizeMaxCompress ((kNumLogBits - 1) * 2 + 7) @@ -132,9 +92,6 @@ static void LzmaEnc_FastPosInit(uint8_t *g_FastPos) #define GetPosSlot2(pos, res) { BSR2_RET(pos, res); } #define GetPosSlot(pos, res) { if (pos < kNumFullDistances) res = p->g_FastPos[pos]; else BSR2_RET(pos, res); } -#endif - - #define LZMA_NUM_REPS 4 typedef unsigned CState; @@ -256,17 +213,8 @@ struct CLzmaEnc struct IMatchFinder matchFinder; void *matchFinderObj; - #ifndef _7ZIP_ST - bool mtMode; - CMatchFinderMt matchFinderMt; - #endif - struct CMatchFinder matchFinderBase; - #ifndef _7ZIP_ST - uint8_t pad[128]; - #endif - uint32_t optimumEndIndex; uint32_t optimumCurrentIndex; @@ -425,17 +373,6 @@ SRes LzmaEnc_SetProps(CLzmaEncHandle pp, const struct CLzmaEncProps *props2) p->writeEndMark = props.writeEndMark; - #ifndef _7ZIP_ST - /* - if (newMultiThread != _multiThread) - { - ReleaseMatchFinder(); - _multiThread = newMultiThread; - } - */ - p->multiThread = (props.numThreads > 1); - #endif - return SZ_OK; } @@ -799,10 +736,6 @@ static void LenEnc_Encode2(struct CLenPriceEnc *p, struct CRangeEnc *rc, uint32_ static void MovePos(struct CLzmaEnc *p, uint32_t num) { - #ifdef SHOW_STAT - ttt += num; - printf("\n MovePos %d", num); - #endif if (num != 0) { p->additionalOffset += num; @@ -815,15 +748,6 @@ static uint32_t ReadMatchDistances(struct CLzmaEnc *p, uint32_t *numDistancePair uint32_t lenRes = 0, numPairs; p->numAvail = p->matchFinder.GetNumAvailableBytes(p->matchFinderObj); numPairs = p->matchFinder.GetMatches(p->matchFinderObj, p->matches); - #ifdef SHOW_STAT - printf("\n i = %d numPairs = %d ", ttt, numPairs / 2); - ttt++; - { - uint32_t i; - for (i = 0; i < numPairs; i += 2) - printf("%2d %6d | ", p->matches[i], p->matches[i + 1]); - } - #endif if (numPairs > 0) { lenRes = p->matches[numPairs - 2]; @@ -1108,16 +1032,6 @@ static uint32_t GetOptimum(struct CLzmaEnc *p, uint32_t position, uint32_t *back cur = 0; - #ifdef SHOW_STAT2 - if (position >= 0) - { - unsigned i; - printf("\n pos = %4X", position); - for (i = cur; i <= lenEnd; i++) - printf("\nprice[%4X] = %d", position - cur + i, p->opt[i].price); - } - #endif - for (;;) { uint32_t numAvailFull, newLen, posPrev, state, startLen; @@ -1669,10 +1583,6 @@ static void LzmaEnc_Construct(struct CLzmaEnc *p) { RangeEnc_Construct(&p->rc); MatchFinder_Construct(&p->matchFinderBase); - #ifndef _7ZIP_ST - MatchFinderMt_Construct(&p->matchFinderMt); - p->matchFinderMt.MatchFinder = &p->matchFinderBase; - #endif { struct CLzmaEncProps props; @@ -1708,9 +1618,6 @@ static void LzmaEnc_FreeLits(struct CLzmaEnc *p, struct ISzAlloc *alloc) static void LzmaEnc_Destruct(struct CLzmaEnc *p, struct ISzAlloc *alloc, struct ISzAlloc *allocBig) { - #ifndef _7ZIP_ST - MatchFinderMt_Destruct(&p->matchFinderMt, allocBig); - #endif MatchFinder_Free(&p->matchFinderBase, allocBig); LzmaEnc_FreeLits(p, alloc); RangeEnc_Free(&p->rc, alloc); @@ -1763,10 +1670,6 @@ static SRes LzmaEnc_CodeOneBlock(struct CLzmaEnc *p, bool useLimits, uint32_t ma else len = GetOptimum(p, nowPos32, &pos); - #ifdef SHOW_STAT2 - printf("\n pos = %4X, len = %d pos = %d", nowPos32, len, pos); - #endif - posState = nowPos32 & p->pbMask; if (len == 1 && pos == (uint32_t)-1) { @@ -1889,15 +1792,8 @@ static SRes LzmaEnc_CodeOneBlock(struct CLzmaEnc *p, bool useLimits, uint32_t ma static SRes LzmaEnc_Alloc(struct CLzmaEnc *p, uint32_t keepWindowSize, struct ISzAlloc *alloc, struct ISzAlloc *allocBig) { uint32_t beforeSize = kNumOpts; - #ifndef _7ZIP_ST - bool btMode; - #endif if (!RangeEnc_Alloc(&p->rc, alloc)) return SZ_ERROR_MEM; - #ifndef _7ZIP_ST - btMode = (p->matchFinderBase.btMode != 0); - p->mtMode = (p->multiThread && !p->fastMode && btMode); - #endif { unsigned lclp = p->lc + p->lp; @@ -1920,15 +1816,6 @@ static SRes LzmaEnc_Alloc(struct CLzmaEnc *p, uint32_t keepWindowSize, struct IS if (beforeSize + p->dictSize < keepWindowSize) beforeSize = keepWindowSize - p->dictSize; - #ifndef _7ZIP_ST - if (p->mtMode) - { - RINOK(MatchFinderMt_Create(&p->matchFinderMt, p->dictSize, beforeSize, p->numFastuint8_ts, LZMA_MATCH_LEN_MAX, allocBig)); - p->matchFinderObj = &p->matchFinderMt; - MatchFinderMt_CreateVTable(&p->matchFinderMt, &p->matchFinder); - } - else - #endif { if (!MatchFinder_Create(&p->matchFinderBase, p->dictSize, beforeSize, p->numFastuint8_ts, LZMA_MATCH_LEN_MAX, allocBig)) return SZ_ERROR_MEM; @@ -2067,13 +1954,7 @@ static SRes LzmaEnc_MemPrepare(CLzmaEncHandle pp, const uint8_t *src, size_t src static void LzmaEnc_Finish(CLzmaEncHandle pp) { - #ifndef _7ZIP_ST - CLzmaEnc *p = (CLzmaEnc *)pp; - if (p->mtMode) - MatchFinderMt_ReleaseStream(&p->matchFinderMt); - #else (void)pp; - #endif } struct CSeqOutStreamBuf @@ -2149,13 +2030,6 @@ static SRes LzmaEnc_Encode2(struct CLzmaEnc *p, struct ICompressProgress *progre { SRes res = SZ_OK; - #ifndef _7ZIP_ST - uint8_t allocaDummy[0x300]; - int i = 0; - for (i = 0; i < 16; i++) - allocaDummy[i] = (uint8_t)i; - #endif - for (;;) { res = LzmaEnc_CodeOneBlock(p, false, 0, 0); |