All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lei Wen <adrian.wenl@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH V2 3/6] lib: zlib: include deflate into zlib build
Date: Fri, 28 Sep 2012 07:26:44 -0700	[thread overview]
Message-ID: <1348842407-20355-4-git-send-email-leiwen@marvell.com> (raw)
In-Reply-To: <1332690817-31759-1-git-send-email-adrian.wenl@gmail.com>

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>
---
Changelog:
No change

 include/u-boot/zlib.h |   40 +++++++++++++++++++++++++++++++++++-----
 lib/zlib/trees.c      |    8 ++++----
 lib/zlib/zlib.c       |    8 ++++++++
 lib/zlib/zutil.h      |    4 ++++
 4 files changed, 51 insertions(+), 9 deletions(-)

diff --git a/include/u-boot/zlib.h b/include/u-boot/zlib.h
index fbb08a3..b611fe7 100644
--- a/include/u-boot/zlib.h
+++ b/include/u-boot/zlib.h
@@ -513,11 +513,41 @@ typedef gz_header FAR *gz_headerp;
    If the first character differs, the library code actually used is
    not compatible with the zlib.h header file used by the application.
    This check is automatically made by deflateInit and inflateInit.
- */
-
-ZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm, const char *version,
-				int stream_size));
-
+   */
+
+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));
+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));
 /*
     inflate decompresses as much data as possible, and stops when the input
diff --git a/lib/zlib/trees.c b/lib/zlib/trees.c
index 56e9bb1..a0078d0 100644
--- a/lib/zlib/trees.c
+++ b/lib/zlib/trees.c
@@ -1168,14 +1168,14 @@ local int detect_data_type(s)
  * method would use a table)
  * IN assertion: 1 <= len <= 15
  */
-local unsigned bi_reverse(code, len)
-    unsigned code; /* the value to invert */
+local unsigned bi_reverse(value, len)
+    unsigned value; /* the value to invert */
     int len;       /* its bit length */
 {
     register unsigned res = 0;
     do {
-        res |= code & 1;
-        code >>= 1, res <<= 1;
+        res |= value & 1;
+        value >>= 1, res <<= 1;
     } while (--len > 0);
     return res >> 1;
 }
diff --git a/lib/zlib/zlib.c b/lib/zlib/zlib.c
index 230d0df..7e15702 100644
--- a/lib/zlib/zlib.c
+++ b/lib/zlib/zlib.c
@@ -12,6 +12,14 @@
  * - added inflateIncomp
  */
 
+#include <common.h>
+
+#ifdef CONFIG_GZIP_COMPRESSED
+#define NO_DUMMY_DECL
+#include "deflate.c"
+#include "trees.c"
+#endif
+
 #include "zutil.h"
 #include "inftrees.h"
 #include "inflate.h"
diff --git a/lib/zlib/zutil.h b/lib/zlib/zutil.h
index 114cb74..7e05c3b 100644
--- a/lib/zlib/zutil.h
+++ b/lib/zlib/zutil.h
@@ -83,6 +83,10 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
 /* The minimum and maximum match lengths */
 
 	 /* 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>
 #define zmemcpy memcpy
-- 
1.7.5.4

  parent reply	other threads:[~2012-09-28 14:26 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-25 15:53 [U-Boot] [PATCH 0/6] add zip command support for uboot adrian.wenl at gmail.com
2012-03-25 15:53 ` [U-Boot] [PATCH 1/6] lib: zlib: import deflate source file from 1.2.5 adrian.wenl at gmail.com
2012-03-25 15:53 ` [U-Boot] [PATCH 2/6] lib: zlib: import trees " adrian.wenl at gmail.com
2012-03-25 15:53 ` [U-Boot] [PATCH 3/6] lib: zlib: include deflate into zlib build adrian.wenl at gmail.com
2012-03-25 15:53 ` [U-Boot] [PATCH 4/6] lib: zlib: remove the limitation for cannot using 0 as start adrian.wenl at gmail.com
2012-03-25 15:53 ` [U-Boot] [PATCH 5/6] lib: add gzip lib function callback adrian.wenl at gmail.com
2012-03-25 15:53 ` [U-Boot] [PATCH 6/6] common: add zip command support adrian.wenl at gmail.com
2012-03-27  8:04 ` [U-Boot] [PATCH 0/6] add zip command support for uboot Lei Wen
2012-03-27 18:12   ` Tom Rini
2012-03-28  2:23     ` Lei Wen
2012-04-02 14:16       ` Lei Wen
2012-04-02 19:17   ` Mike Frysinger
2012-04-03  9:31     ` Lei Wen
2012-04-10  4:37       ` Mike Frysinger
2012-04-10  5:05         ` Lei Wen
2012-04-10 22:11           ` Mike Frysinger
2012-04-11  1:24             ` Lei Wen
2012-05-08 12:57               ` Lei Wen
2012-06-21 19:12               ` Wolfgang Denk
2012-09-06  4:18 ` Marek Vasut
2012-09-06  4:49   ` Lei Wen
2012-09-06  6:23     ` Marek Vasut
2012-09-06  8:18       ` Lukasz Majewski
2012-09-06  8:49         ` Marek Vasut
2012-09-06 10:41           ` Lukasz Majewski
2012-09-06 10:49             ` Marek Vasut
2012-09-26  6:41               ` Lei Wen
2012-09-26 15:34                 ` Marek Vasut
2012-09-26 16:20                   ` Tom Rini
2012-09-27  2:05                     ` Lei Wen
2012-09-27 15:22                       ` Tom Rini
2012-09-28 14:29                         ` Lei Wen
2012-09-27  2:12                   ` Lei Wen
2012-09-28 14:26 ` [U-Boot] [PATCH V2 " Lei Wen
2012-09-29 14:51   ` Tom Rini
2012-09-28 14:26 ` [U-Boot] [PATCH V2 1/6] lib: zlib: import deflate source file from 1.2.5 Lei Wen
2012-09-28 14:26 ` [U-Boot] [PATCH V2 2/6] lib: zlib: import trees " Lei Wen
2012-09-28 14:26 ` Lei Wen [this message]
2012-09-28 14:26 ` [U-Boot] [PATCH V2 4/6] lib: zlib: remove the limitation for cannot using 0 as start Lei Wen
2012-09-28 14:26 ` [U-Boot] [PATCH V2 5/6] lib: add gzip lib function callback Lei Wen
2012-09-28 14:26 ` [U-Boot] [PATCH V2 6/6] common: add zip command support Lei Wen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1348842407-20355-4-git-send-email-leiwen@marvell.com \
    --to=adrian.wenl@gmail.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.