From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16305 invoked by alias); 27 Jan 2009 22:37:09 -0000 Received: (qmail 16292 invoked by uid 22791); 27 Jan 2009 22:37:07 -0000 X-SWARE-Spam-Status: No, hits=-2.6 required=5.0 tests=BAYES_00,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mail-qy0-f20.google.com (HELO mail-qy0-f20.google.com) (209.85.221.20) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 27 Jan 2009 22:36:59 +0000 Received: by qyk13 with SMTP id 13so9228152qyk.6 for ; Tue, 27 Jan 2009 14:36:57 -0800 (PST) Received: by 10.214.181.12 with SMTP id d12mr2146379qaf.140.1233095817238; Tue, 27 Jan 2009 14:36:57 -0800 (PST) Received: from ?192.168.1.2? (pool-173-64-79-150.bltmmd.fios.verizon.net [173.64.79.150]) by mx.google.com with ESMTPS id 9sm4869829yws.14.2009.01.27.14.36.54 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 27 Jan 2009 14:36:55 -0800 (PST) Message-ID: <497F8C75.6070400@gmail.com> Date: Tue, 27 Jan 2009 22:37:00 -0000 From: Nathan Heijermans User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1b3pre) Gecko/20081204 Thunderbird/3.0b1 MIME-Version: 1.0 To: ecos-patches@ecos.sourceware.org Subject: zlib package usability issues Content-Type: multipart/mixed; boundary="------------010102070407060609070605" Mailing-List: contact ecos-patches-help@ecos.sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: ecos-patches-owner@ecos.sourceware.org X-SW-Source: 2009-01/txt/msg00025.txt.bz2 This is a multi-part message in MIME format. --------------010102070407060609070605 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 1892 Hi all, I recently needed to use the zlib package, but ran into some issues with it in its current state. I have attached a patch that resolved the issues for me, but there may be some issues that need to be resolved that I am not aware of. I do not have an in-depth understanding of the inner workings of zlib, but have read through the relevant portions of zlib.h to understand the various compile-time configuration macros they allow. My goal was to be able to use the routines in gzio.c to read and write compressed files. The first problem arose from the fact that MAX_WBITS is defined as `15+16` (instead of `(15+16)`). The gzopen() call in gzio.c called deflateInit2() with windowBits=-15+16, which is not a valid value. Fixing the definition of MAX_WBITS resulted in deflateInit2() being called with a value of -31. This is also invalid. Disabling the CDL option controlling the MAX_WBITS value also didn't work, because it completely disable deflate() functionality. Eliminating the definition of MAX_WBITS altogether, and using the default value of 15, resolved this problem. I then began trying to add support for the various configuration macros provided by zlib, and realized that defining MAX_WBITS to be in the -8..-15 (enabling raw deflate()/inflate()) or (8..15)+16 (enabling gzip deflate()) ranges is also problematic when using the gz* routines in gzio.c. gzopen() passes -MAX_WBITS to deflateInit2(), while deflate() passes MAX_WBITS. This is why I totally eliminated the option for "inflate() to compress gzip compatible output". If somebody really needs this, a change will probably need to be made to the upstream zlib code to separately define the MAX_WBITS used in gzio.c from the one used in deflate.c, or else pass MAX_WBITS in both cases. That's all; I hope that this made sense and will help somebody... Sincerely, Nathan Heijermans --------------010102070407060609070605 Content-Type: text/x-patch; name="compress_zlib.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="compress_zlib.diff" Content-length: 2673 diff --git a/packages/services/compress/zlib/current/cdl/compress_zlib.cdl b/packages/services/compress/zlib/current/cdl/compress_zlib.cdl index cb0a749..50252e9 100644 --- a/packages/services/compress/zlib/current/cdl/compress_zlib.cdl +++ b/packages/services/compress/zlib/current/cdl/compress_zlib.cdl @@ -65,13 +65,35 @@ cdl_package CYGPKG_COMPRESS_ZLIB { display "Override memory allocation routines." } - cdl_option CYGSEM_COMPRESS_ZLIB_DEFLATE_MAKES_GZIP { - display "Should deflate() produce 'gzip' compatible output?" - flavor bool - default_value 1 + cdl_option CYGSEM_COMPRESS_ZLIB_ENABLE_COMPRESSION { + display "Enable Compression" + flavor bool + default_value 1 description " - If this option is set then the output of calling deflate() - will be wrapped up as a 'gzip' compatible file." + If this option is disabled, zlib will be compiled without the + ability to compress. This is useful when decompression is needed, + but compression is not." + + cdl_option CYGOPT_COMPRESS_ZLIB_MAX_WBITS { + display "#define MAX_WBITS" + define MAX_WBITS + flavor data + default_value 15 + legal_values 8 to 15 + description " + MAX_WBITS controls the maximum window size (i.e. the size of + the history buffer, which is 2^MAX_WBITS) used by the deflate() + call." + } + } + + cdl_option CYGSEM_COMPRESS_ZLIB_ENABLE_GZIP { + display "Enable gzip encoding and decoding" + flavor bool + default_value 1 + description " + If this option is disabled, zlib will be compiled without the + ability to encode and decode gzip streams." } cdl_option CYGSEM_COMPRESS_ZLIB_NEEDS_MALLOC { diff --git a/packages/services/compress/zlib/current/include/zconf.h b/packages/services/compress/zlib/current/include/zconf.h index 09608dc..1284fe1 100644 --- a/packages/services/compress/zlib/current/include/zconf.h +++ b/packages/services/compress/zlib/current/include/zconf.h @@ -16,13 +16,15 @@ #if CYGINT_COMPRESS_ZLIB_LOCAL_ALLOC != 0 #define MY_ZCALLOC #endif -#ifdef CYGSEM_COMPRESS_ZLIB_DEFLATE_MAKES_GZIP -#undef MAX_WBITS -#define MAX_WBITS 15+16 /* 32K LZ77 window */ -#else -#define NO_GZIP -#define NO_GZCOMPRESS + +#ifndef CYGSEM_COMPRESS_ZLIB_ENABLE_COMPRESSION +# define NO_GZCOMPRESS #endif + +#ifndef CYGSEM_COMPRESS_ZLIB_ENABLE_GZIP +# define NO_GZIP +#endif + // #endif /* --------------010102070407060609070605--