lib: zlib: include deflate into zlib build

Add a new config CONFIG_GZIP_ENABLED, if enabled, the uboot bin would
include zlib's deflate method which could be used for compressing.

Signed-off-by: Lei Wen <leiwen@marvell.com>
This commit is contained in:
Lei Wen 2012-09-28 04:26:44 +00:00 committed by Tom Rini
parent e9a128d8e9
commit 7a32b98dac
4 changed files with 49 additions and 7 deletions

View file

@ -515,9 +515,39 @@ typedef gz_header FAR *gz_headerp;
This check is automatically made by deflateInit and inflateInit. This check is automatically made by deflateInit and inflateInit.
*/ */
ZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm, const char *version, ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush));
ZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level,
const char *version, int stream_size));
ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm));
ZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int level, int method,
int windowBits, int memLevel,
int strategy, const char *version,
int stream_size)); int stream_size));
ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm));
ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm,
const Bytef *dictionary,
uInt dictLength));
ZEXTERN int ZEXPORT deflateSetHeader OF((z_streamp strm,
gz_headerp head));
ZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm,
int bits,
int value));
ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm,
int level,
int strategy));
ZEXTERN int ZEXPORT deflateTune OF((z_streamp strm,
int good_length,
int max_lazy,
int nice_length,
int max_chain));
ZEXTERN uLong ZEXPORT deflateBound OF((z_streamp strm,
uLong sourceLen));
ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest,
z_streamp source));
ZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm,
const char *version, int stream_size));
ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush)); ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush));
/* /*
inflate decompresses as much data as possible, and stops when the input inflate decompresses as much data as possible, and stops when the input

View file

@ -1168,14 +1168,14 @@ local int detect_data_type(s)
* method would use a table) * method would use a table)
* IN assertion: 1 <= len <= 15 * IN assertion: 1 <= len <= 15
*/ */
local unsigned bi_reverse(code, len) local unsigned bi_reverse(value, len)
unsigned code; /* the value to invert */ unsigned value; /* the value to invert */
int len; /* its bit length */ int len; /* its bit length */
{ {
register unsigned res = 0; register unsigned res = 0;
do { do {
res |= code & 1; res |= value & 1;
code >>= 1, res <<= 1; value >>= 1, res <<= 1;
} while (--len > 0); } while (--len > 0);
return res >> 1; return res >> 1;
} }

View file

@ -12,6 +12,14 @@
* - added inflateIncomp * - added inflateIncomp
*/ */
#include <common.h>
#ifdef CONFIG_GZIP_COMPRESSED
#define NO_DUMMY_DECL
#include "deflate.c"
#include "trees.c"
#endif
#include "zutil.h" #include "zutil.h"
#include "inftrees.h" #include "inftrees.h"
#include "inflate.h" #include "inflate.h"

View file

@ -83,6 +83,10 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
/* The minimum and maximum match lengths */ /* The minimum and maximum match lengths */
/* functions */ /* functions */
#ifdef CONFIG_GZIP_COMPRESSED
#define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */
# define OS_CODE 0x03 /* assume Unix */
#endif
#include <linux/string.h> #include <linux/string.h>
#define zmemcpy memcpy #define zmemcpy memcpy