2003-06-05 19:33:49

by Jörn Engel

[permalink] [raw]
Subject: [Patch] 2.5.70-bk9 kick FAR out of the zlib

A while back:

On Fri, 30 May 2003 14:38:07 -0700, Linus Torvalds wrote:
> On Fri, 30 May 2003, J?rn Engel wrote:
> >
> > How about an all or nothing approach? If you really want to get rid
> > of K&R, change indentation as well, rip out some of the rather
> > tasteless macros (ZEXPORT, ZEXPORTVA, ZEXTERN, FAR, ...) and so on.
>
> I'd love to, but I suspect we lack the motivation to do so, and there
> aren't any obvious upsides. Yes, the code is ugly, but it's also fairly
> stable so people seldom need to look at it.

Today was a lazy day and that is often motivation enough. The patch
below removes FAR, the typedefs using FAR (Bytef and friends) and the
function prototypes for zalloc and zfree that should have gone earlier
already.

Hope you like it.

J?rn

--
When you close your hand, you own nothing. When you open it up, you
own the whole world.
-- Li Mu Bai in Tiger & Dragon


--- linux-2.5.70-bk9/include/linux/zconf.h~zlib_cleanup_FAR 2003-04-07 19:32:18.000000000 +0200
+++ linux-2.5.70-bk9/include/linux/zconf.h 2003-06-05 21:35:04.000000000 +0200
@@ -66,21 +66,10 @@
#ifndef ZEXTERN
# define ZEXTERN extern
#endif
-#ifndef FAR
-# define FAR
-#endif

typedef unsigned char Byte; /* 8 bits */
typedef unsigned int uInt; /* 16 bits or more */
typedef unsigned long uLong; /* 32 bits or more */
-
-typedef Byte FAR Bytef;
-typedef char FAR charf;
-typedef int FAR intf;
-typedef uInt FAR uIntf;
-typedef uLong FAR uLongf;
-
-typedef void FAR *voidpf;
typedef void *voidp;

#include <linux/types.h> /* for off_t */
--- linux-2.5.70-bk9/include/linux/zlib.h~zlib_cleanup_FAR 2003-06-05 18:26:01.000000000 +0200
+++ linux-2.5.70-bk9/include/linux/zlib.h 2003-06-05 21:30:48.000000000 +0200
@@ -60,22 +60,19 @@
crash even in case of corrupted input.
*/

-typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size));
-typedef void (*free_func) OF((voidpf opaque, voidpf address));
-
struct internal_state;

typedef struct z_stream_s {
- Bytef *next_in; /* next input byte */
+ Byte *next_in; /* next input byte */
uInt avail_in; /* number of bytes available at next_in */
uLong total_in; /* total nb of input bytes read so far */

- Bytef *next_out; /* next output byte should be put there */
+ Byte *next_out; /* next output byte should be put there */
uInt avail_out; /* remaining free space at next_out */
uLong total_out; /* total nb of bytes output so far */

char *msg; /* last error message, NULL if no error */
- struct internal_state FAR *state; /* not visible by applications */
+ struct internal_state *state; /* not visible by applications */

void *workspace; /* memory allocated for this stream */
int ws_num; /* index in the internal workspace array */
@@ -85,7 +82,7 @@
uLong reserved; /* reserved for future use */
} z_stream;

-typedef z_stream FAR *z_streamp;
+typedef z_stream *z_streamp;

/*
The application must update next_in and avail_in when avail_in has
@@ -465,7 +462,7 @@
*/

ZEXTERN int ZEXPORT zlib_deflateSetDictionary OF((z_streamp strm,
- const Bytef *dictionary,
+ const Byte *dictionary,
uInt dictLength));
/*
Initializes the compression dictionary from the given byte sequence
@@ -574,7 +571,7 @@
*/

ZEXTERN int ZEXPORT zlib_inflateSetDictionary OF((z_streamp strm,
- const Bytef *dictionary,
+ const Byte *dictionary,
uInt dictLength));
/*
Initializes the decompression dictionary from the given uncompressed byte
@@ -656,9 +653,9 @@
struct internal_state {int dummy;}; /* hack for buggy compilers */
#endif

-ZEXTERN const char * ZEXPORT zlib_zError OF((int err));
-ZEXTERN int ZEXPORT zlib_inflateSyncPoint OF((z_streamp z));
-ZEXTERN const uLongf * ZEXPORT zlib_get_crc_table OF((void));
+ZEXTERN const char * ZEXPORT zlib_zError OF((int err));
+ZEXTERN int ZEXPORT zlib_inflateSyncPoint OF((z_streamp z));
+ZEXTERN const uLong * ZEXPORT zlib_get_crc_table OF((void));

#ifdef __cplusplus
}
--- linux-2.5.70-bk9/include/linux/zutil.h~zlib_cleanup_FAR 2003-06-05 18:26:01.000000000 +0200
+++ linux-2.5.70-bk9/include/linux/zutil.h 2003-06-05 21:18:26.000000000 +0200
@@ -24,9 +24,7 @@
/* compile with -Dlocal if your debugger can't find static symbols */

typedef unsigned char uch;
-typedef uch FAR uchf;
typedef unsigned short ush;
-typedef ush FAR ushf;
typedef unsigned long ulg;

/* common constants */
@@ -64,7 +62,7 @@

/* functions */

-typedef uLong (ZEXPORT *check_func) OF((uLong check, const Bytef *buf,
+typedef uLong (ZEXPORT *check_func) OF((uLong check, const Byte *buf,
uInt len));


@@ -96,7 +94,7 @@
if (adler != original_adler) error();
*/
static inline uLong zlib_adler32(uLong adler,
- const Bytef *buf,
+ const Byte *buf,
uInt len)
{
unsigned long s1 = adler & 0xffff;
--- linux-2.5.70-bk9/lib/zlib_deflate/deflate.c~zlib_cleanup_FAR 2003-06-05 20:54:12.000000000 +0200
+++ linux-2.5.70-bk9/lib/zlib_deflate/deflate.c 2003-06-05 21:20:57.000000000 +0200
@@ -73,7 +73,7 @@
local void lm_init OF((deflate_state *s));
local void putShortMSB OF((deflate_state *s, uInt b));
local void flush_pending OF((z_streamp strm));
-local int read_buf OF((z_streamp strm, Bytef *buf, unsigned size));
+local int read_buf OF((z_streamp strm, Byte *buf, unsigned size));
local uInt longest_match OF((deflate_state *s, IPos cur_match));

#ifdef DEBUG_ZLIB
@@ -161,7 +161,7 @@
*/
#define CLEAR_HASH(s) \
s->head[s->hash_size-1] = NIL; \
- memset((charf *)s->head, 0, (unsigned)(s->hash_size-1)*sizeof(*s->head));
+ memset((char *)s->head, 0, (unsigned)(s->hash_size-1)*sizeof(*s->head));

/* ========================================================================= */
int zlib_deflateInit_(
@@ -194,7 +194,7 @@
static char* my_version = ZLIB_VERSION;
deflate_workspace *mem;

- ushf *overlay;
+ ush *overlay;
/* We overlay pending_buf and d_buf+l_buf. This works since the average
* output size for (length,distance) codes is <= 24 bits.
*/
@@ -222,7 +222,7 @@
return Z_STREAM_ERROR;
}
s = (deflate_state *) &(mem->deflate_memory);
- strm->state = (struct internal_state FAR *)s;
+ strm->state = (struct internal_state *)s;
s->strm = strm;

s->noheader = noheader;
@@ -235,14 +235,14 @@
s->hash_mask = s->hash_size - 1;
s->hash_shift = ((s->hash_bits+MIN_MATCH-1)/MIN_MATCH);

- s->window = (Bytef *) mem->window_memory;
- s->prev = (Posf *) mem->prev_memory;
- s->head = (Posf *) mem->head_memory;
+ s->window = (Byte *) mem->window_memory;
+ s->prev = (Pos *) mem->prev_memory;
+ s->head = (Pos *) mem->head_memory;

s->lit_bufsize = 1 << (memLevel + 6); /* 16K elements by default */

- overlay = (ushf *) mem->overlay_memory;
- s->pending_buf = (uchf *) overlay;
+ overlay = (ush *) mem->overlay_memory;
+ s->pending_buf = (uch *) overlay;
s->pending_buf_size = (ulg)s->lit_bufsize * (sizeof(ush)+2L);

s->d_buf = overlay + s->lit_bufsize/sizeof(ush);
@@ -258,7 +258,7 @@
/* ========================================================================= */
int zlib_deflateSetDictionary(
z_streamp strm,
- const Bytef *dictionary,
+ const Byte *dictionary,
uInt dictLength
)
{
@@ -282,7 +282,7 @@
dictionary += dictLength - length; /* use the tail of the dictionary */
#endif
}
- memcpy((charf *)s->window, dictionary, length);
+ memcpy((char *)s->window, dictionary, length);
s->strstart = length;
s->block_start = (long)length;

@@ -583,7 +583,7 @@
#else
deflate_state *ds;
deflate_state *ss;
- ushf *overlay;
+ ush *overlay;
deflate_workspace *mem;


@@ -599,15 +599,15 @@

ds = &(mem->deflate_memory);

- dest->state = (struct internal_state FAR *) ds;
+ dest->state = (struct internal_state *) ds;
*ds = *ss;
ds->strm = dest;

- ds->window = (Bytef *) mem->window_memory;
- ds->prev = (Posf *) mem->prev_memory;
- ds->head = (Posf *) mem->head_memory;
- overlay = (ushf *) mem->overlay_memory;
- ds->pending_buf = (uchf *) overlay;
+ ds->window = (Byte *) mem->window_memory;
+ ds->prev = (Pos *) mem->prev_memory;
+ ds->head = (Pos *) mem->head_memory;
+ overlay = (ush *) mem->overlay_memory;
+ ds->pending_buf = (uch *) overlay;

memcpy(ds->window, ss->window, ds->w_size * 2 * sizeof(Byte));
memcpy(ds->prev, ss->prev, ds->w_size * sizeof(Pos));
@@ -635,7 +635,7 @@
*/
local int read_buf(
z_streamp strm,
- Bytef *buf,
+ Byte *buf,
unsigned size
)
{
@@ -698,8 +698,8 @@
IPos cur_match; /* current match */
{
unsigned chain_length = s->max_chain_length;/* max hash chain length */
- register Bytef *scan = s->window + s->strstart; /* current string */
- register Bytef *match; /* matched string */
+ register Byte *scan = s->window + s->strstart; /* current string */
+ register Byte *match; /* matched string */
register int len; /* length of current match */
int best_len = s->prev_length; /* best match length so far */
int nice_match = s->nice_match; /* stop if match long enough */
@@ -708,18 +708,18 @@
/* Stop when cur_match becomes <= limit. To simplify the code,
* we prevent matches with the string of window index 0.
*/
- Posf *prev = s->prev;
+ Pos *prev = s->prev;
uInt wmask = s->w_mask;

#ifdef UNALIGNED_OK
/* Compare two bytes at a time. Note: this is not always beneficial.
* Try with and without -DUNALIGNED_OK to check.
*/
- register Bytef *strend = s->window + s->strstart + MAX_MATCH - 1;
- register ush scan_start = *(ushf*)scan;
- register ush scan_end = *(ushf*)(scan+best_len-1);
+ register Byte *strend = s->window + s->strstart + MAX_MATCH - 1;
+ register ush scan_start = *(ush*)scan;
+ register ush scan_end = *(ush*)(scan+best_len-1);
#else
- register Bytef *strend = s->window + s->strstart + MAX_MATCH;
+ register Byte *strend = s->window + s->strstart + MAX_MATCH;
register Byte scan_end1 = scan[best_len-1];
register Byte scan_end = scan[best_len];
#endif
@@ -751,8 +751,8 @@
/* This code assumes sizeof(unsigned short) == 2. Do not use
* UNALIGNED_OK if your compiler uses a different size.
*/
- if (*(ushf*)(match+best_len-1) != scan_end ||
- *(ushf*)match != scan_start) continue;
+ if (*(ush*)(match+best_len-1) != scan_end ||
+ *(ush*)match != scan_start) continue;

/* It is not necessary to compare scan[2] and match[2] since they are
* always equal when the other bytes match, given that the hash keys
@@ -766,10 +766,10 @@
Assert(scan[2] == match[2], "scan[2]?");
scan++, match++;
do {
- } while (*(ushf*)(scan+=2) == *(ushf*)(match+=2) &&
- *(ushf*)(scan+=2) == *(ushf*)(match+=2) &&
- *(ushf*)(scan+=2) == *(ushf*)(match+=2) &&
- *(ushf*)(scan+=2) == *(ushf*)(match+=2) &&
+ } while (*(ush*)(scan+=2) == *(ush*)(match+=2) &&
+ *(ush*)(scan+=2) == *(ush*)(match+=2) &&
+ *(ush*)(scan+=2) == *(ush*)(match+=2) &&
+ *(ush*)(scan+=2) == *(ush*)(match+=2) &&
scan < strend);
/* The funny "do {}" generates better code on most compilers */

@@ -818,7 +818,7 @@
best_len = len;
if (len >= nice_match) break;
#ifdef UNALIGNED_OK
- scan_end = *(ushf*)(scan+best_len-1);
+ scan_end = *(ush*)(scan+best_len-1);
#else
scan_end1 = scan[best_len-1];
scan_end = scan[best_len];
@@ -841,8 +841,8 @@
int length;
{
/* check that the match is indeed a match */
- if (memcmp((charf *)s->window + match,
- (charf *)s->window + start, length) != EQUAL) {
+ if (memcmp((char *)s->window + match,
+ (char *)s->window + start, length) != EQUAL) {
fprintf(stderr, " start %u, match %u, length %d\n",
start, match, length);
do {
@@ -873,7 +873,7 @@
deflate_state *s;
{
register unsigned n, m;
- register Posf *p;
+ register Pos *p;
unsigned more; /* Amount of free space at the end of the window. */
uInt wsize = s->w_size;

@@ -895,7 +895,7 @@
*/
} else if (s->strstart >= wsize+MAX_DIST(s)) {

- memcpy((charf *)s->window, (charf *)s->window+wsize,
+ memcpy((char *)s->window, (char *)s->window+wsize,
(unsigned)wsize);
s->match_start -= wsize;
s->strstart -= wsize; /* we now have strstart >= MAX_DIST */
@@ -964,8 +964,8 @@
*/
#define FLUSH_BLOCK_ONLY(s, eof) { \
zlib_tr_flush_block(s, (s->block_start >= 0L ? \
- (charf *)&s->window[(unsigned)s->block_start] : \
- (charf *)Z_NULL), \
+ (char *)&s->window[(unsigned)s->block_start] : \
+ (char *)Z_NULL), \
(ulg)((long)s->strstart - s->block_start), \
(eof)); \
s->block_start = s->strstart; \
--- linux-2.5.70-bk9/lib/zlib_deflate/deftree.c~zlib_cleanup_FAR 2003-06-05 17:48:50.000000000 +0200
+++ linux-2.5.70-bk9/lib/zlib_deflate/deftree.c 2003-06-05 21:23:40.000000000 +0200
@@ -113,7 +113,7 @@

struct static_tree_desc_s {
const ct_data *static_tree; /* static tree or NULL */
- const intf *extra_bits; /* extra bits for each code or NULL */
+ const int *extra_bits; /* extra bits for each code or NULL */
int extra_base; /* base index for extra_bits */
int elems; /* max number of elements in the tree */
int max_length; /* max bit length for the codes */
@@ -136,7 +136,7 @@
local void init_block OF((deflate_state *s));
local void pqdownheap OF((deflate_state *s, ct_data *tree, int k));
local void gen_bitlen OF((deflate_state *s, tree_desc *desc));
-local void gen_codes OF((ct_data *tree, int max_code, ushf *bl_count));
+local void gen_codes OF((ct_data *tree, int max_code, ush *bl_count));
local void build_tree OF((deflate_state *s, tree_desc *desc));
local void scan_tree OF((deflate_state *s, ct_data *tree, int max_code));
local void send_tree OF((deflate_state *s, ct_data *tree, int max_code));
@@ -149,7 +149,7 @@
local unsigned bi_reverse OF((unsigned value, int length));
local void bi_windup OF((deflate_state *s));
local void bi_flush OF((deflate_state *s));
-local void copy_block OF((deflate_state *s, charf *buf, unsigned len,
+local void copy_block OF((deflate_state *s, char *buf, unsigned len,
int header));

#ifndef DEBUG_ZLIB
@@ -414,7 +414,7 @@
ct_data *tree = desc->dyn_tree;
int max_code = desc->max_code;
const ct_data *stree = desc->stat_desc->static_tree;
- const intf *extra = desc->stat_desc->extra_bits;
+ const int *extra = desc->stat_desc->extra_bits;
int base = desc->stat_desc->extra_base;
int max_length = desc->stat_desc->max_length;
int h; /* heap index */
@@ -497,7 +497,7 @@
local void gen_codes(
ct_data *tree, /* the tree to decorate */
int max_code, /* largest code with non zero frequency */
- ushf *bl_count /* number of codes at each bit length */
+ ush *bl_count /* number of codes at each bit length */
)
{
ush next_code[MAX_BITS+1]; /* next code value for each bit length */
@@ -793,7 +793,7 @@
*/
void zlib_tr_stored_block(
deflate_state *s,
- charf *buf, /* input block */
+ char *buf, /* input block */
ulg stored_len, /* length of input block */
int eof /* true if this is the last block for a file */
)
@@ -857,7 +857,7 @@
*/
ulg zlib_tr_flush_block(
deflate_state *s,
- charf *buf, /* input block, or NULL if too old */
+ char *buf, /* input block, or NULL if too old */
ulg stored_len, /* length of input block */
int eof /* true if this is the last block for a file */
)
@@ -914,7 +914,7 @@
if (stored_len <= opt_lenb && eof && s->compressed_len==0L && seekable()) {
# endif
/* Since LIT_BUFSIZE <= 2*WSIZE, the input data must be there: */
- if (buf == (charf*)0) error ("block vanished");
+ if (buf == (char*)0) error ("block vanished");

copy_block(s, buf, (unsigned)stored_len, 0); /* without header */
s->compressed_len = stored_len << 3;
@@ -1090,7 +1090,7 @@
*/
local void copy_block(
deflate_state *s,
- charf *buf, /* the input data */
+ char *buf, /* the input data */
unsigned len, /* its length */
int header /* true if block header must be written */
)
--- linux-2.5.70-bk9/lib/zlib_deflate/defutil.h~zlib_cleanup_FAR 2003-06-05 20:54:12.000000000 +0200
+++ linux-2.5.70-bk9/lib/zlib_deflate/defutil.h 2003-06-05 21:22:04.000000000 +0200
@@ -46,7 +46,7 @@
ush dad; /* father node in Huffman tree */
ush len; /* length of bit string */
} dl;
-} FAR ct_data;
+} ct_data;

#define Freq fc.freq
#define Code fc.code
@@ -59,10 +59,9 @@
ct_data *dyn_tree; /* the dynamic tree */
int max_code; /* largest code with non zero frequency */
static_tree_desc *stat_desc; /* the corresponding static tree */
-} FAR tree_desc;
+} tree_desc;

typedef ush Pos;
-typedef Pos FAR Posf;
typedef unsigned IPos;

/* A Pos is an index in the character window. We use short instead of int to
@@ -72,9 +71,9 @@
typedef struct deflate_state {
z_streamp strm; /* pointer back to this zlib stream */
int status; /* as the name implies */
- Bytef *pending_buf; /* output still pending */
+ Byte *pending_buf; /* output still pending */
ulg pending_buf_size; /* size of pending_buf */
- Bytef *pending_out; /* next pending byte to output to the stream */
+ Byte *pending_out; /* next pending byte to output to the stream */
int pending; /* nb of bytes in the pending buffer */
int noheader; /* suppress zlib header and adler32 */
Byte data_type; /* UNKNOWN, BINARY or ASCII */
@@ -87,7 +86,7 @@
uInt w_bits; /* log2(w_size) (8..16) */
uInt w_mask; /* w_size - 1 */

- Bytef *window;
+ Byte *window;
/* Sliding window. Input bytes are read into the second half of the window,
* and move to the first half later to keep a dictionary of at least wSize
* bytes. With this organization, matches are limited to a distance of
@@ -102,13 +101,13 @@
* is directly used as sliding window.
*/

- Posf *prev;
+ Pos *prev;
/* Link to older string with same hash index. To limit the size of this
* array to 64K, this link is maintained only for the last 32K strings.
* An index in this array is thus a window index modulo 32K.
*/

- Posf *head; /* Heads of the hash chains or NIL. */
+ Pos *head; /* Heads of the hash chains or NIL. */

uInt ins_h; /* hash index of string to be inserted */
uInt hash_size; /* number of elements in hash table */
@@ -188,7 +187,7 @@
/* Depth of each subtree used as tie breaker for trees of equal frequency
*/

- uchf *l_buf; /* buffer for literals or lengths */
+ uch *l_buf; /* buffer for literals or lengths */

uInt lit_bufsize;
/* Size of match buffer for literals/lengths. There are 4 reasons for
@@ -212,7 +211,7 @@

uInt last_lit; /* running index in l_buf */

- ushf *d_buf;
+ ush *d_buf;
/* Buffer for distances. To simplify the code, d_buf and l_buf have
* the same number of elements. To use different lengths, an extra flag
* array would be necessary.
@@ -237,7 +236,7 @@
* are always zero.
*/

-} FAR deflate_state;
+} deflate_state;

typedef struct deflate_workspace {
/* State memory for the deflator */
@@ -267,10 +266,10 @@
/* in trees.c */
void zlib_tr_init OF((deflate_state *s));
int zlib_tr_tally OF((deflate_state *s, unsigned dist, unsigned lc));
-ulg zlib_tr_flush_block OF((deflate_state *s, charf *buf, ulg stored_len,
+ulg zlib_tr_flush_block OF((deflate_state *s, char *buf, ulg stored_len,
int eof));
void zlib_tr_align OF((deflate_state *s));
-void zlib_tr_stored_block OF((deflate_state *s, charf *buf, ulg stored_len,
+void zlib_tr_stored_block OF((deflate_state *s, char *buf, ulg stored_len,
int eof));
void zlib_tr_stored_type_only OF((deflate_state *));

--- linux-2.5.70-bk9/lib/zlib_inflate/infcodes.c~zlib_cleanup_FAR 2003-06-05 17:48:50.000000000 +0200
+++ linux-2.5.70-bk9/lib/zlib_inflate/infcodes.c 2003-06-05 21:12:06.000000000 +0200
@@ -47,11 +47,11 @@
uInt e; /* extra bits or operation */
uLong b; /* bit buffer */
uInt k; /* bits in bit buffer */
- Bytef *p; /* input data pointer */
+ Byte *p; /* input data pointer */
uInt n; /* bytes available there */
- Bytef *q; /* output window write pointer */
+ Byte *q; /* output window write pointer */
uInt m; /* bytes to end of window or read pointer */
- Bytef *f; /* pointer to copy strings from */
+ Byte *f; /* pointer to copy strings from */
inflate_codes_statef *c = s->sub.decode.codes; /* codes state */

/* copy input/output information to locals (UPDATE macro restores) */
--- linux-2.5.70-bk9/lib/zlib_inflate/infcodes.h~zlib_cleanup_FAR 2003-04-07 19:30:59.000000000 +0200
+++ linux-2.5.70-bk9/lib/zlib_inflate/infcodes.h 2003-06-05 21:34:12.000000000 +0200
@@ -14,7 +14,7 @@
#include "infblock.h"

struct inflate_codes_state;
-typedef struct inflate_codes_state FAR inflate_codes_statef;
+typedef struct inflate_codes_state inflate_codes_statef;

extern inflate_codes_statef *zlib_inflate_codes_new OF((
uInt, uInt,
--- linux-2.5.70-bk9/lib/zlib_inflate/inftrees.c~zlib_cleanup_FAR 2003-06-05 20:54:12.000000000 +0200
+++ linux-2.5.70-bk9/lib/zlib_inflate/inftrees.c 2003-06-05 21:26:36.000000000 +0200
@@ -23,16 +23,16 @@


local int huft_build OF((
- uIntf *, /* code lengths in bits */
+ uInt *, /* code lengths in bits */
uInt, /* number of codes */
uInt, /* number of "simple" codes */
- const uIntf *, /* list of base values for non-simple codes */
- const uIntf *, /* list of extra bits for non-simple codes */
- inflate_huft * FAR*,/* result: starting table */
- uIntf *, /* maximum lookup bits (returns actual) */
+ const uInt *, /* list of base values for non-simple codes */
+ const uInt *, /* list of extra bits for non-simple codes */
+ inflate_huft **, /* result: starting table */
+ uInt *, /* maximum lookup bits (returns actual) */
inflate_huft *, /* space for trees */
uInt *, /* hufts used in space */
- uIntf * )); /* space for values */
+ uInt * )); /* space for values */

/* Tables for deflate from PKZIP's appnote.txt. */
local const uInt cplens[31] = { /* Copy lengths for literal codes 257..285 */
@@ -88,16 +88,16 @@
#define BMAX 15 /* maximum bit length of any code */

local int huft_build(
- uIntf *b, /* code lengths in bits (all assumed <= BMAX) */
- uInt n, /* number of codes (assumed <= 288) */
- uInt s, /* number of simple-valued codes (0..s-1) */
- const uIntf *d, /* list of base values for non-simple codes */
- const uIntf *e, /* list of extra bits for non-simple codes */
- inflate_huft * FAR *t, /* result: starting table */
- uIntf *m, /* maximum lookup bits, returns actual */
- inflate_huft *hp, /* space for trees */
- uInt *hn, /* hufts used in space */
- uIntf *v /* working area: values in order of bit length */
+ uInt *b, /* code lengths in bits (all assumed <= BMAX) */
+ uInt n, /* number of codes (assumed <= 288) */
+ uInt s, /* number of simple-valued codes (0..s-1) */
+ const uInt *d, /* list of base values for non-simple codes */
+ const uInt *e, /* list of extra bits for non-simple codes */
+ inflate_huft **t, /* result: starting table */
+ uInt *m, /* maximum lookup bits, returns actual */
+ inflate_huft *hp, /* space for trees */
+ uInt *hn, /* hufts used in space */
+ uInt *v /* working area: values in order of bit length */
)
/* Given a list of code lengths and a maximum table size, make a set of
tables to decode that set of codes. Return Z_OK on success, Z_BUF_ERROR
@@ -116,13 +116,13 @@
register int k; /* number of bits in current code */
int l; /* bits per table (returned in m) */
uInt mask; /* (1 << w) - 1, to avoid cc -O bug on HP */
- register uIntf *p; /* pointer into c[], b[], or v[] */
+ register uInt *p; /* pointer into c[], b[], or v[] */
inflate_huft *q; /* points to current table */
struct inflate_huft_s r; /* table entry for structure assignment */
inflate_huft *u[BMAX]; /* table stack */
register int w; /* bits before this table == (l * h) */
uInt x[BMAX+1]; /* bit offsets, then code stack */
- uIntf *xp; /* pointer into x */
+ uInt *xp; /* pointer into x */
int y; /* number of dummy codes added */
uInt z; /* number of entries in current table */

@@ -290,19 +290,19 @@


int zlib_inflate_trees_bits(
- uIntf *c, /* 19 code lengths */
- uIntf *bb, /* bits tree desired/actual depth */
- inflate_huft * FAR *tb, /* bits tree result */
+ uInt *c, /* 19 code lengths */
+ uInt *bb, /* bits tree desired/actual depth */
+ inflate_huft **tb, /* bits tree result */
inflate_huft *hp, /* space for trees */
z_streamp z /* for messages */
)
{
int r;
uInt hn = 0; /* hufts used in space */
- uIntf *v; /* work area for huft_build */
+ uInt *v; /* work area for huft_build */

v = WS(z)->tree_work_area_1;
- r = huft_build(c, 19, 19, (uIntf*)Z_NULL, (uIntf*)Z_NULL,
+ r = huft_build(c, 19, 19, (uInt*)Z_NULL, (uInt*)Z_NULL,
tb, bb, hp, &hn, v);
if (r == Z_DATA_ERROR)
z->msg = (char*)"oversubscribed dynamic bit lengths tree";
@@ -317,18 +317,18 @@
int zlib_inflate_trees_dynamic(
uInt nl, /* number of literal/length codes */
uInt nd, /* number of distance codes */
- uIntf *c, /* that many (total) code lengths */
- uIntf *bl, /* literal desired/actual bit depth */
- uIntf *bd, /* distance desired/actual bit depth */
- inflate_huft * FAR *tl, /* literal/length tree result */
- inflate_huft * FAR *td, /* distance tree result */
+ uInt *c, /* that many (total) code lengths */
+ uInt *bl, /* literal desired/actual bit depth */
+ uInt *bd, /* distance desired/actual bit depth */
+ inflate_huft **tl, /* literal/length tree result */
+ inflate_huft **td, /* distance tree result */
inflate_huft *hp, /* space for trees */
z_streamp z /* for messages */
)
{
int r;
uInt hn = 0; /* hufts used in space */
- uIntf *v; /* work area for huft_build */
+ uInt *v; /* work area for huft_build */

/* allocate work area */
v = WS(z)->tree_work_area_2;
@@ -380,10 +380,10 @@


int zlib_inflate_trees_fixed(
- uIntf *bl, /* literal desired/actual bit depth */
- uIntf *bd, /* distance desired/actual bit depth */
- inflate_huft * FAR *tl, /* literal/length tree result */
- inflate_huft * FAR *td, /* distance tree result */
+ uInt *bl, /* literal desired/actual bit depth */
+ uInt *bd, /* distance desired/actual bit depth */
+ inflate_huft **tl, /* literal/length tree result */
+ inflate_huft **td, /* distance tree result */
z_streamp z /* for memory allocation */
)
{
--- linux-2.5.70-bk9/lib/zlib_inflate/inftrees.h~zlib_cleanup_FAR 2003-06-05 20:54:12.000000000 +0200
+++ linux-2.5.70-bk9/lib/zlib_inflate/inftrees.h 2003-06-05 21:34:42.000000000 +0200
@@ -14,7 +14,7 @@
#ifndef _INFTREES_H
#define _INFTREES_H

-typedef struct inflate_huft_s FAR inflate_huft;
+typedef struct inflate_huft_s inflate_huft;

struct inflate_huft_s {
union {
@@ -36,28 +36,28 @@
#define MANY 1440

extern int zlib_inflate_trees_bits OF((
- uIntf *, /* 19 code lengths */
- uIntf *, /* bits tree desired/actual depth */
- inflate_huft * FAR *, /* bits tree result */
+ uInt *, /* 19 code lengths */
+ uInt *, /* bits tree desired/actual depth */
+ inflate_huft **, /* bits tree result */
inflate_huft *, /* space for trees */
z_streamp)); /* for messages */

extern int zlib_inflate_trees_dynamic OF((
uInt, /* number of literal/length codes */
uInt, /* number of distance codes */
- uIntf *, /* that many (total) code lengths */
- uIntf *, /* literal desired/actual bit depth */
- uIntf *, /* distance desired/actual bit depth */
- inflate_huft * FAR *, /* literal/length tree result */
- inflate_huft * FAR *, /* distance tree result */
+ uInt *, /* that many (total) code lengths */
+ uInt *, /* literal desired/actual bit depth */
+ uInt *, /* distance desired/actual bit depth */
+ inflate_huft **, /* literal/length tree result */
+ inflate_huft **, /* distance tree result */
inflate_huft *, /* space for trees */
z_streamp)); /* for messages */

extern int zlib_inflate_trees_fixed OF((
- uIntf *, /* literal desired/actual bit depth */
- uIntf *, /* distance desired/actual bit depth */
- inflate_huft * FAR *, /* literal/length tree result */
- inflate_huft * FAR *, /* distance tree result */
+ uInt *, /* literal desired/actual bit depth */
+ uInt *, /* distance desired/actual bit depth */
+ inflate_huft **, /* literal/length tree result */
+ inflate_huft **, /* distance tree result */
z_streamp)); /* for memory allocation */

#endif /* _INFTREES_H */
--- linux-2.5.70-bk9/lib/zlib_inflate/infblock.c~zlib_cleanup_FAR 2003-06-05 17:48:50.000000000 +0200
+++ linux-2.5.70-bk9/lib/zlib_inflate/infblock.c 2003-06-05 21:28:38.000000000 +0200
@@ -68,7 +68,7 @@
void zlib_inflate_blocks_reset(
inflate_blocks_statef *s,
z_streamp z,
- uLongf *c
+ uLong *c
)
{
if (c != Z_NULL)
@@ -80,7 +80,7 @@
s->bitb = 0;
s->read = s->write = s->window;
if (s->checkfn != Z_NULL)
- z->adler = s->check = (*s->checkfn)(0L, (const Bytef *)Z_NULL, 0);
+ z->adler = s->check = (*s->checkfn)(0L, (const Byte *)Z_NULL, 0);
}

inflate_blocks_statef *zlib_inflate_blocks_new(
@@ -111,9 +111,9 @@
uInt t; /* temporary storage */
uLong b; /* bit buffer */
uInt k; /* bits in bit buffer */
- Bytef *p; /* input data pointer */
+ Byte *p; /* input data pointer */
uInt n; /* bytes available there */
- Bytef *q; /* output window write pointer */
+ Byte *q; /* output window write pointer */
uInt m; /* bytes to end of window or read pointer */

/* copy input/output information to locals (UPDATE macro restores) */
@@ -340,7 +340,7 @@

void zlib_inflate_set_dictionary(
inflate_blocks_statef *s,
- const Bytef *d,
+ const Byte *d,
uInt n
)
{
--- linux-2.5.70-bk9/lib/zlib_inflate/inffast.c~zlib_cleanup_FAR 2003-06-05 17:48:50.000000000 +0200
+++ linux-2.5.70-bk9/lib/zlib_inflate/inffast.c 2003-06-05 21:15:43.000000000 +0200
@@ -38,15 +38,15 @@
uInt e; /* extra bits or operation */
uLong b; /* bit buffer */
uInt k; /* bits in bit buffer */
- Bytef *p; /* input data pointer */
+ Byte *p; /* input data pointer */
uInt n; /* bytes available there */
- Bytef *q; /* output window write pointer */
+ Byte *q; /* output window write pointer */
uInt m; /* bytes to end of window or read pointer */
uInt ml; /* mask for literal/length tree */
uInt md; /* mask for distance tree */
uInt c; /* bytes to copy */
uInt d; /* distance back to copy from */
- Bytef *r; /* copy source pointer */
+ Byte *r; /* copy source pointer */

/* load input, output, bit values */
LOAD
--- linux-2.5.70-bk9/lib/zlib_inflate/infutil.h~zlib_cleanup_FAR 2003-04-07 19:32:17.000000000 +0200
+++ linux-2.5.70-bk9/lib/zlib_inflate/infutil.h 2003-06-05 21:27:33.000000000 +0200
@@ -40,7 +40,7 @@
struct {
uInt table; /* table lengths (14 bits) */
uInt index; /* index into blens (or border) */
- uIntf *blens; /* bit lengths of codes */
+ uInt *blens; /* bit lengths of codes */
uInt bb; /* bit length tree depth */
inflate_huft *tb; /* bit length decoding tree */
} trees; /* if DTREE, decoding info for trees */
@@ -55,10 +55,10 @@
uInt bitk; /* bits in bit buffer */
uLong bitb; /* bit buffer */
inflate_huft *hufts; /* single malloc for tree space */
- Bytef *window; /* sliding window */
- Bytef *end; /* one byte after sliding window */
- Bytef *read; /* window read pointer */
- Bytef *write; /* window write pointer */
+ Byte *window; /* sliding window */
+ Byte *end; /* one byte after sliding window */
+ Byte *read; /* window read pointer */
+ Byte *write; /* window write pointer */
check_func checkfn; /* check function */
uLong check; /* check on output */

--- linux-2.5.70-bk9/lib/zlib_inflate/infutil.c~zlib_cleanup_FAR 2003-06-05 17:48:50.000000000 +0200
+++ linux-2.5.70-bk9/lib/zlib_inflate/infutil.c 2003-06-05 21:17:26.000000000 +0200
@@ -27,8 +27,8 @@
)
{
uInt n;
- Bytef *p;
- Bytef *q;
+ Byte *p;
+ Byte *q;

/* local copies of source and destination pointers */
p = z->next_out;
--- linux-2.5.70-bk9/lib/zlib_inflate/infblock.h~zlib_cleanup_FAR 2003-04-07 19:31:47.000000000 +0200
+++ linux-2.5.70-bk9/lib/zlib_inflate/infblock.h 2003-06-05 21:34:33.000000000 +0200
@@ -12,7 +12,7 @@
#define _INFBLOCK_H

struct inflate_blocks_state;
-typedef struct inflate_blocks_state FAR inflate_blocks_statef;
+typedef struct inflate_blocks_state inflate_blocks_statef;

extern inflate_blocks_statef * zlib_inflate_blocks_new OF((
z_streamp z,
@@ -27,7 +27,7 @@
extern void zlib_inflate_blocks_reset OF((
inflate_blocks_statef *,
z_streamp ,
- uLongf *)); /* check value on output */
+ uLong *)); /* check value on output */

extern int zlib_inflate_blocks_free OF((
inflate_blocks_statef *,
@@ -35,7 +35,7 @@

extern void zlib_inflate_set_dictionary OF((
inflate_blocks_statef *s,
- const Bytef *d, /* dictionary */
+ const Byte *d, /* dictionary */
uInt n)); /* dictionary length */

extern int zlib_inflate_blocks_sync_point OF((


2003-06-05 19:56:36

by Jörn Engel

[permalink] [raw]
Subject: [Patch] 2.5.70-bk9 zlib cleanup #2 ZEXTERN

Hi Linus!

This one was just simple s/ZEXTERN/extern/g.

J?rn

--
When in doubt, use brute force.
-- Ken Thompson

--- linux-2.5.70-bk9/include/linux/zconf.h~zlib_cleanup_ZEXTERN 2003-06-05 21:35:04.000000000 +0200
+++ linux-2.5.70-bk9/include/linux/zconf.h 2003-06-05 22:00:53.000000000 +0200
@@ -63,9 +63,6 @@
#ifndef ZEXPORTVA
# define ZEXPORTVA
#endif
-#ifndef ZEXTERN
-# define ZEXTERN extern
-#endif

typedef unsigned char Byte; /* 8 bits */
typedef unsigned int uInt; /* 16 bits or more */
--- linux-2.5.70-bk9/lib/zlib_deflate/deflate.c~zlib_cleanup_ZEXTERN 2003-06-05 21:20:57.000000000 +0200
+++ linux-2.5.70-bk9/lib/zlib_deflate/deflate.c 2003-06-05 21:59:09.000000000 +0200
@@ -1255,7 +1255,7 @@
return flush == Z_FINISH ? finish_done : block_done;
}

-ZEXTERN int ZEXPORT zlib_deflate_workspacesize ()
+extern int ZEXPORT zlib_deflate_workspacesize ()
{
return sizeof(deflate_workspace);
}
--- linux-2.5.70-bk9/include/linux/zlib.h~zlib_cleanup_ZEXTERN 2003-06-05 21:30:48.000000000 +0200
+++ linux-2.5.70-bk9/include/linux/zlib.h 2003-06-05 22:00:33.000000000 +0200
@@ -162,14 +162,14 @@

/* basic functions */

-ZEXTERN const char * ZEXPORT zlib_zlibVersion OF((void));
+extern const char * ZEXPORT zlib_zlibVersion OF((void));
/* The application can compare zlibVersion and ZLIB_VERSION for consistency.
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 void * __zlib_panic_workspace OF((void));
+extern void * __zlib_panic_workspace OF((void));
/*
BIG FAT WARNING:
The only valid user of this function is a panic handler. This will
@@ -181,7 +181,7 @@
*/


-ZEXTERN int ZEXPORT zlib_deflate_workspacesize OF((void));
+extern int ZEXPORT zlib_deflate_workspacesize OF((void));
/*
Returns the number of bytes that needs to be allocated for a per-
stream workspace. A pointer to this number of bytes should be
@@ -189,7 +189,7 @@
*/

/*
-ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level));
+extern int ZEXPORT deflateInit OF((z_streamp strm, int level));

Initializes the internal stream state for compression. The fields
zalloc, zfree and opaque must be initialized before by the caller.
@@ -211,7 +211,7 @@
*/


-ZEXTERN int ZEXPORT zlib_deflate OF((z_streamp strm, int flush));
+extern int ZEXPORT zlib_deflate OF((z_streamp strm, int flush));
/*
deflate compresses as much data as possible, and stops when the input
buffer becomes empty or the output buffer becomes full. It may introduce some
@@ -289,7 +289,7 @@
*/


-ZEXTERN int ZEXPORT zlib_deflateEnd OF((z_streamp strm));
+extern int ZEXPORT zlib_deflateEnd OF((z_streamp strm));
/*
All dynamically allocated data structures for this stream are freed.
This function discards any unprocessed input and does not flush any
@@ -303,7 +303,7 @@
*/


-ZEXTERN int ZEXPORT zlib_inflate_workspacesize OF((void));
+extern int ZEXPORT zlib_inflate_workspacesize OF((void));
/*
Returns the number of bytes that needs to be allocated for a per-
stream workspace. A pointer to this number of bytes should be
@@ -311,7 +311,7 @@
*/

/*
-ZEXTERN int ZEXPORT zlib_inflateInit OF((z_streamp strm));
+extern int ZEXPORT zlib_inflateInit OF((z_streamp strm));

Initializes the internal stream state for decompression. The fields
next_in, avail_in, and workspace must be initialized before by
@@ -331,7 +331,7 @@
*/


-ZEXTERN int ZEXPORT zlib_inflate OF((z_streamp strm, int flush));
+extern int ZEXPORT zlib_inflate OF((z_streamp strm, int flush));
/*
inflate decompresses as much data as possible, and stops when the input
buffer becomes empty or the output buffer becomes full. It may some
@@ -400,7 +400,7 @@
*/


-ZEXTERN int ZEXPORT zlib_inflateEnd OF((z_streamp strm));
+extern int ZEXPORT zlib_inflateEnd OF((z_streamp strm));
/*
All dynamically allocated data structures for this stream are freed.
This function discards any unprocessed input and does not flush any
@@ -418,7 +418,7 @@
*/

/*
-ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm,
+extern int ZEXPORT deflateInit2 OF((z_streamp strm,
int level,
int method,
int windowBits,
@@ -461,7 +461,7 @@
not perform any compression: this will be done by deflate().
*/

-ZEXTERN int ZEXPORT zlib_deflateSetDictionary OF((z_streamp strm,
+extern int ZEXPORT zlib_deflateSetDictionary OF((z_streamp strm,
const Byte *dictionary,
uInt dictLength));
/*
@@ -497,7 +497,7 @@
perform any compression: this will be done by deflate().
*/

-ZEXTERN int ZEXPORT zlib_deflateCopy OF((z_streamp dest,
+extern int ZEXPORT zlib_deflateCopy OF((z_streamp dest,
z_streamp source));
/*
Sets the destination stream as a complete copy of the source stream.
@@ -515,7 +515,7 @@
destination.
*/

-ZEXTERN int ZEXPORT zlib_deflateReset OF((z_streamp strm));
+extern int ZEXPORT zlib_deflateReset OF((z_streamp strm));
/*
This function is equivalent to deflateEnd followed by deflateInit,
but does not free and reallocate all the internal compression state.
@@ -526,7 +526,7 @@
stream state was inconsistent (such as zalloc or state being NULL).
*/

-ZEXTERN int ZEXPORT zlib_deflateParams OF((z_streamp strm,
+extern int ZEXPORT zlib_deflateParams OF((z_streamp strm,
int level,
int strategy));
/*
@@ -548,7 +548,7 @@
*/

/*
-ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm,
+extern int ZEXPORT inflateInit2 OF((z_streamp strm,
int windowBits));

This is another version of inflateInit with an extra parameter. The
@@ -570,7 +570,7 @@
modified, but next_out and avail_out are unchanged.)
*/

-ZEXTERN int ZEXPORT zlib_inflateSetDictionary OF((z_streamp strm,
+extern int ZEXPORT zlib_inflateSetDictionary OF((z_streamp strm,
const Byte *dictionary,
uInt dictLength));
/*
@@ -589,7 +589,7 @@
inflate().
*/

-ZEXTERN int ZEXPORT zlib_inflateSync OF((z_streamp strm));
+extern int ZEXPORT zlib_inflateSync OF((z_streamp strm));
/*
Skips invalid compressed data until a full flush point (see above the
description of deflate with Z_FULL_FLUSH) can be found, or until all
@@ -604,7 +604,7 @@
until success or end of the input data.
*/

-ZEXTERN int ZEXPORT zlib_inflateReset OF((z_streamp strm));
+extern int ZEXPORT zlib_inflateReset OF((z_streamp strm));
/*
This function is equivalent to inflateEnd followed by inflateInit,
but does not free and reallocate all the internal decompression state.
@@ -628,15 +628,15 @@
/* deflateInit and inflateInit are macros to allow checking the zlib version
* and the compiler's view of z_stream:
*/
-ZEXTERN int ZEXPORT zlib_deflateInit_ OF((z_streamp strm, int level,
+extern int ZEXPORT zlib_deflateInit_ OF((z_streamp strm, int level,
const char *version, int stream_size));
-ZEXTERN int ZEXPORT zlib_inflateInit_ OF((z_streamp strm,
+extern int ZEXPORT zlib_inflateInit_ OF((z_streamp strm,
const char *version, int stream_size));
-ZEXTERN int ZEXPORT zlib_deflateInit2_ OF((z_streamp strm, int level, int method,
+extern int ZEXPORT zlib_deflateInit2_ OF((z_streamp strm, int level, int method,
int windowBits, int memLevel,
int strategy, const char *version,
int stream_size));
-ZEXTERN int ZEXPORT zlib_inflateInit2_ OF((z_streamp strm, int windowBits,
+extern int ZEXPORT zlib_inflateInit2_ OF((z_streamp strm, int windowBits,
const char *version, int stream_size));
#define zlib_deflateInit(strm, level) \
zlib_deflateInit_((strm), (level), ZLIB_VERSION, sizeof(z_stream))
@@ -653,9 +653,9 @@
struct internal_state {int dummy;}; /* hack for buggy compilers */
#endif

-ZEXTERN const char * ZEXPORT zlib_zError OF((int err));
-ZEXTERN int ZEXPORT zlib_inflateSyncPoint OF((z_streamp z));
-ZEXTERN const uLong * ZEXPORT zlib_get_crc_table OF((void));
+extern const char * ZEXPORT zlib_zError OF((int err));
+extern int ZEXPORT zlib_inflateSyncPoint OF((z_streamp z));
+extern const uLong * ZEXPORT zlib_get_crc_table OF((void));

#ifdef __cplusplus
}

2003-06-05 20:03:30

by Richard B. Johnson

[permalink] [raw]
Subject: Re: [Patch] 2.5.70-bk9 kick FAR out of the zlib

On Thu, 5 Jun 2003, [iso-8859-1] J?rn Engel wrote:

> A while back:
>
> On Fri, 30 May 2003 14:38:07 -0700, Linus Torvalds wrote:
> > On Fri, 30 May 2003, J?rn Engel wrote:
> > >
> > > How about an all or nothing approach? If you really want to get rid
> > > of K&R, change indentation as well, rip out some of the rather
> > > tasteless macros (ZEXPORT, ZEXPORTVA, ZEXTERN, FAR, ...) and so on.
> >
> > I'd love to, but I suspect we lack the motivation to do so, and there
> > aren't any obvious upsides. Yes, the code is ugly, but it's also fairly
> > stable so people seldom need to look at it.
>
> Today was a lazy day and that is often motivation enough. The patch
> below removes FAR, the typedefs using FAR (Bytef and friends) and the
> function prototypes for zalloc and zfree that should have gone earlier
> already.
>
> Hope you like it.
>
> J?rn

[SNIPPED patch]

But you just removed the portability hooks. The current code worked
in DOS, on Windows, etc., as will as Linux. This means that if some-
body, as unlikely as it may seem, develops a better/quicker
version using M$ Visual C/C++, you can't get a patch. In particular,
FAR is your friend. A simple #define makes it disappear when you
are not using a segmented architecture, but allows the use of
large arrays when you are.

These kinds of things don't make the code 'pure'. It just prevents
future enhancements. Look in the 'C' header files and see all the
macros that disappear under the right conditions. Would you
justify getting rid of __P in those headers? If not, please don't
eliminate FAR.

Cheers,
Dick Johnson
Penguin : Linux version 2.4.20 on an i686 machine (797.90 BogoMips).
Why is the government concerned about the lunatic fringe? Think about it.

2003-06-05 20:05:29

by Jörn Engel

[permalink] [raw]
Subject: [Patch] 2.5.70-bk9 zlib cleanup #3 ZEXPORT

Hi Linus!

Just a simple s/ZEXPORT//.

J?rn

--
It does not matter how slowly you go, so long as you do not stop.
-- Confucius

--- linux-2.5.70-bk9/lib/zlib_inflate/inflate.c~zlib_cleanup_ZEXPORT 2003-06-05 22:12:38.000000000 +0200
+++ linux-2.5.70-bk9/lib/zlib_inflate/inflate.c 2003-06-05 22:13:00.000000000 +0200
@@ -9,13 +9,13 @@
#include "infutil.h"


-int ZEXPORT zlib_inflate_workspacesize(void)
+int zlib_inflate_workspacesize(void)
{
return sizeof(struct inflate_workspace);
}


-int ZEXPORT zlib_inflateReset(
+int zlib_inflateReset(
z_streamp z
)
{
@@ -29,7 +29,7 @@
}


-int ZEXPORT zlib_inflateEnd(
+int zlib_inflateEnd(
z_streamp z
)
{
@@ -43,7 +43,7 @@
}


-int ZEXPORT zlib_inflateInit2_(
+int zlib_inflateInit2_(
z_streamp z,
int w,
const char *version,
@@ -106,7 +106,7 @@
}


-int ZEXPORT zlib_inflateInit_(
+int zlib_inflateInit_(
z_streamp z,
const char *version,
int stream_size
@@ -120,7 +120,7 @@
#define NEEDBYTE {if(z->avail_in==0)goto empty;r=trv;}
#define NEXTBYTE (z->avail_in--,z->total_in++,*z->next_in++)

-int ZEXPORT zlib_inflate(
+int zlib_inflate(
z_streamp z,
int f
)
@@ -253,7 +253,7 @@
}


-int ZEXPORT zlib_inflateSync(
+int zlib_inflateSync(
z_streamp z
)
{
@@ -312,7 +312,7 @@
* decompressing, PPP checks that at the end of input packet, inflate is
* waiting for these length bytes.
*/
-int ZEXPORT zlib_inflateSyncPoint(
+int zlib_inflateSyncPoint(
z_streamp z
)
{
@@ -383,7 +383,7 @@
* will have been updated if need be.
*/

-int ZEXPORT zlib_inflateIncomp(
+int zlib_inflateIncomp(
z_stream *z

)
--- linux-2.5.70-bk9/include/linux/zconf.h~zlib_cleanup_ZEXPORT 2003-06-05 22:12:38.000000000 +0200
+++ linux-2.5.70-bk9/include/linux/zconf.h 2003-06-05 22:13:00.000000000 +0200
@@ -57,13 +57,6 @@
# endif
#endif

-#ifndef ZEXPORT
-# define ZEXPORT
-#endif
-#ifndef ZEXPORTVA
-# define ZEXPORTVA
-#endif
-
typedef unsigned char Byte; /* 8 bits */
typedef unsigned int uInt; /* 16 bits or more */
typedef unsigned long uLong; /* 32 bits or more */
--- linux-2.5.70-bk9/include/linux/zlib.h~zlib_cleanup_ZEXPORT 2003-06-05 22:12:38.000000000 +0200
+++ linux-2.5.70-bk9/include/linux/zlib.h 2003-06-05 22:13:00.000000000 +0200
@@ -162,7 +162,7 @@

/* basic functions */

-extern const char * ZEXPORT zlib_zlibVersion OF((void));
+extern const char * zlib_zlibVersion OF((void));
/* The application can compare zlibVersion and ZLIB_VERSION for consistency.
If the first character differs, the library code actually used is
not compatible with the zlib.h header file used by the application.
@@ -181,7 +181,7 @@
*/


-extern int ZEXPORT zlib_deflate_workspacesize OF((void));
+extern int zlib_deflate_workspacesize OF((void));
/*
Returns the number of bytes that needs to be allocated for a per-
stream workspace. A pointer to this number of bytes should be
@@ -189,7 +189,7 @@
*/

/*
-extern int ZEXPORT deflateInit OF((z_streamp strm, int level));
+extern int deflateInit OF((z_streamp strm, int level));

Initializes the internal stream state for compression. The fields
zalloc, zfree and opaque must be initialized before by the caller.
@@ -211,7 +211,7 @@
*/


-extern int ZEXPORT zlib_deflate OF((z_streamp strm, int flush));
+extern int zlib_deflate OF((z_streamp strm, int flush));
/*
deflate compresses as much data as possible, and stops when the input
buffer becomes empty or the output buffer becomes full. It may introduce some
@@ -289,7 +289,7 @@
*/


-extern int ZEXPORT zlib_deflateEnd OF((z_streamp strm));
+extern int zlib_deflateEnd OF((z_streamp strm));
/*
All dynamically allocated data structures for this stream are freed.
This function discards any unprocessed input and does not flush any
@@ -303,7 +303,7 @@
*/


-extern int ZEXPORT zlib_inflate_workspacesize OF((void));
+extern int zlib_inflate_workspacesize OF((void));
/*
Returns the number of bytes that needs to be allocated for a per-
stream workspace. A pointer to this number of bytes should be
@@ -311,7 +311,7 @@
*/

/*
-extern int ZEXPORT zlib_inflateInit OF((z_streamp strm));
+extern int zlib_inflateInit OF((z_streamp strm));

Initializes the internal stream state for decompression. The fields
next_in, avail_in, and workspace must be initialized before by
@@ -331,7 +331,7 @@
*/


-extern int ZEXPORT zlib_inflate OF((z_streamp strm, int flush));
+extern int zlib_inflate OF((z_streamp strm, int flush));
/*
inflate decompresses as much data as possible, and stops when the input
buffer becomes empty or the output buffer becomes full. It may some
@@ -400,7 +400,7 @@
*/


-extern int ZEXPORT zlib_inflateEnd OF((z_streamp strm));
+extern int zlib_inflateEnd OF((z_streamp strm));
/*
All dynamically allocated data structures for this stream are freed.
This function discards any unprocessed input and does not flush any
@@ -418,7 +418,7 @@
*/

/*
-extern int ZEXPORT deflateInit2 OF((z_streamp strm,
+extern int deflateInit2 OF((z_streamp strm,
int level,
int method,
int windowBits,
@@ -461,7 +461,7 @@
not perform any compression: this will be done by deflate().
*/

-extern int ZEXPORT zlib_deflateSetDictionary OF((z_streamp strm,
+extern int zlib_deflateSetDictionary OF((z_streamp strm,
const Byte *dictionary,
uInt dictLength));
/*
@@ -497,7 +497,7 @@
perform any compression: this will be done by deflate().
*/

-extern int ZEXPORT zlib_deflateCopy OF((z_streamp dest,
+extern int zlib_deflateCopy OF((z_streamp dest,
z_streamp source));
/*
Sets the destination stream as a complete copy of the source stream.
@@ -515,7 +515,7 @@
destination.
*/

-extern int ZEXPORT zlib_deflateReset OF((z_streamp strm));
+extern int zlib_deflateReset OF((z_streamp strm));
/*
This function is equivalent to deflateEnd followed by deflateInit,
but does not free and reallocate all the internal compression state.
@@ -526,7 +526,7 @@
stream state was inconsistent (such as zalloc or state being NULL).
*/

-extern int ZEXPORT zlib_deflateParams OF((z_streamp strm,
+extern int zlib_deflateParams OF((z_streamp strm,
int level,
int strategy));
/*
@@ -548,7 +548,7 @@
*/

/*
-extern int ZEXPORT inflateInit2 OF((z_streamp strm,
+extern int inflateInit2 OF((z_streamp strm,
int windowBits));

This is another version of inflateInit with an extra parameter. The
@@ -570,7 +570,7 @@
modified, but next_out and avail_out are unchanged.)
*/

-extern int ZEXPORT zlib_inflateSetDictionary OF((z_streamp strm,
+extern int zlib_inflateSetDictionary OF((z_streamp strm,
const Byte *dictionary,
uInt dictLength));
/*
@@ -589,7 +589,7 @@
inflate().
*/

-extern int ZEXPORT zlib_inflateSync OF((z_streamp strm));
+extern int zlib_inflateSync OF((z_streamp strm));
/*
Skips invalid compressed data until a full flush point (see above the
description of deflate with Z_FULL_FLUSH) can be found, or until all
@@ -604,7 +604,7 @@
until success or end of the input data.
*/

-extern int ZEXPORT zlib_inflateReset OF((z_streamp strm));
+extern int zlib_inflateReset OF((z_streamp strm));
/*
This function is equivalent to inflateEnd followed by inflateInit,
but does not free and reallocate all the internal decompression state.
@@ -614,7 +614,7 @@
stream state was inconsistent (such as zalloc or state being NULL).
*/

-extern int ZEXPORT zlib_inflateIncomp OF((z_stream *strm));
+extern int zlib_inflateIncomp OF((z_stream *strm));
/*
This function adds the data at next_in (avail_in bytes) to the output
history without performing any output. There must be no pending output,
@@ -628,15 +628,15 @@
/* deflateInit and inflateInit are macros to allow checking the zlib version
* and the compiler's view of z_stream:
*/
-extern int ZEXPORT zlib_deflateInit_ OF((z_streamp strm, int level,
+extern int zlib_deflateInit_ OF((z_streamp strm, int level,
const char *version, int stream_size));
-extern int ZEXPORT zlib_inflateInit_ OF((z_streamp strm,
+extern int zlib_inflateInit_ OF((z_streamp strm,
const char *version, int stream_size));
-extern int ZEXPORT zlib_deflateInit2_ OF((z_streamp strm, int level, int method,
+extern int zlib_deflateInit2_ OF((z_streamp strm, int level, int method,
int windowBits, int memLevel,
int strategy, const char *version,
int stream_size));
-extern int ZEXPORT zlib_inflateInit2_ OF((z_streamp strm, int windowBits,
+extern int zlib_inflateInit2_ OF((z_streamp strm, int windowBits,
const char *version, int stream_size));
#define zlib_deflateInit(strm, level) \
zlib_deflateInit_((strm), (level), ZLIB_VERSION, sizeof(z_stream))
@@ -653,9 +653,9 @@
struct internal_state {int dummy;}; /* hack for buggy compilers */
#endif

-extern const char * ZEXPORT zlib_zError OF((int err));
-extern int ZEXPORT zlib_inflateSyncPoint OF((z_streamp z));
-extern const uLong * ZEXPORT zlib_get_crc_table OF((void));
+extern const char * zlib_zError OF((int err));
+extern int zlib_inflateSyncPoint OF((z_streamp z));
+extern const uLong * zlib_get_crc_table OF((void));

#ifdef __cplusplus
}
--- linux-2.5.70-bk9/include/linux/zutil.h~zlib_cleanup_ZEXPORT 2003-06-05 22:12:38.000000000 +0200
+++ linux-2.5.70-bk9/include/linux/zutil.h 2003-06-05 22:13:00.000000000 +0200
@@ -62,7 +62,7 @@

/* functions */

-typedef uLong (ZEXPORT *check_func) OF((uLong check, const Byte *buf,
+typedef uLong (*check_func) OF((uLong check, const Byte *buf,
uInt len));


--- linux-2.5.70-bk9/lib/zlib_deflate/deflate.c~zlib_cleanup_ZEXPORT 2003-06-05 21:59:09.000000000 +0200
+++ linux-2.5.70-bk9/lib/zlib_deflate/deflate.c 2003-06-05 22:14:09.000000000 +0200
@@ -1255,7 +1255,7 @@
return flush == Z_FINISH ? finish_done : block_done;
}

-extern int ZEXPORT zlib_deflate_workspacesize ()
+extern int zlib_deflate_workspacesize ()
{
return sizeof(deflate_workspace);
}

2003-06-05 20:17:54

by Jörn Engel

[permalink] [raw]
Subject: Re: [Patch] 2.5.70-bk9 kick FAR out of the zlib

Linus should have a firm position already, pruned from CC:.

On Thu, 5 June 2003 16:17:52 -0400, Richard B. Johnson wrote:
> On Thu, 5 Jun 2003, [iso-8859-1] J?rn Engel wrote:
>
> > A while back:
> >
> > On Fri, 30 May 2003 14:38:07 -0700, Linus Torvalds wrote:
> > > On Fri, 30 May 2003, J?rn Engel wrote:
> > > >
> > > > How about an all or nothing approach? If you really want to get rid
> > > > of K&R, change indentation as well, rip out some of the rather
> > > > tasteless macros (ZEXPORT, ZEXPORTVA, ZEXTERN, FAR, ...) and so on.
> > >
> > > I'd love to, but I suspect we lack the motivation to do so, and there
> > > aren't any obvious upsides. Yes, the code is ugly, but it's also fairly
> > > stable so people seldom need to look at it.

Please let the above sink in a moment.

> But you just removed the portability hooks. The current code worked
> in DOS, on Windows, etc., as will as Linux. This means that if some-
> body, as unlikely as it may seem, develops a better/quicker
> version using M$ Visual C/C++, you can't get a patch. In particular,
> FAR is your friend. A simple #define makes it disappear when you
> are not using a segmented architecture, but allows the use of
> large arrays when you are.
>
> These kinds of things don't make the code 'pure'. It just prevents
> future enhancements. Look in the 'C' header files and see all the
> macros that disappear under the right conditions. Would you
> justify getting rid of __P in those headers? If not, please don't
> eliminate FAR.

My words were "all or nothing". Linus was against nothing, so the
answer is all, that simple.

As to your "someone comes up with a better zlib" concern, this has
happened already. An guess what, we ignored it. So unless you come
up with a patch to get the 1.1.4 changes into the kernel and describe
what the two magic bits are all about, I couldn't care less.

J?rn

--
But this is not to say that the main benefit of Linux and other GPL
software is lower-cost. Control is the main benefit--cost is secondary.
-- Bruce Perens

2003-06-05 20:20:19

by Jörn Engel

[permalink] [raw]
Subject: Re: [Patch] 2.5.70-bk9 zlib cleanup #4 z_off_t

Hi Linus!

This nice macro must have been one of the good intentions on the road
to hell. Completely unused. :)

J?rn

--
With a PC, I always felt limited by the software available. On Unix,
I am limited only by my knowledge.
-- Peter J. Schoenster

--- linux-2.5.70-bk9/include/linux/zconf.h~zlib_cleanup_z_off_t 2003-06-05 22:13:00.000000000 +0200
+++ linux-2.5.70-bk9/include/linux/zconf.h 2003-06-05 22:18:36.000000000 +0200
@@ -64,6 +64,5 @@

#include <linux/types.h> /* for off_t */
#include <linux/unistd.h> /* for SEEK_* and off_t */
-#define z_off_t off_t

#endif /* _ZCONF_H */

2003-06-05 20:25:30

by Jörn Engel

[permalink] [raw]
Subject: Re: [Patch] 2.5.70-bk9 zlib cleanup #4 z_off_t

Hi Linus!

Two more unused macros.

J?rn

--
Invincibility is in oneself, vulnerability is in the opponent.
-- Sun Tzu

--- linux-2.5.70-bk9/include/linux/zconf.h~zlib_cleanup_more_intentions 2003-06-05 22:31:59.000000000 +0200
+++ linux-2.5.70-bk9/include/linux/zconf.h 2003-06-05 22:33:34.000000000 +0200
@@ -8,18 +8,6 @@
#ifndef _ZCONF_H
#define _ZCONF_H

-#if defined(__GNUC__) || defined(__386__) || defined(i386)
-# ifndef __32BIT__
-# define __32BIT__
-# endif
-#endif
-
-#if defined(__STDC__) || defined(__cplusplus)
-# ifndef STDC
-# define STDC
-# endif
-#endif
-
/* The memory requirements for deflate are (in bytes):
(1 << (windowBits+2)) + (1 << (memLevel+9))
that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values)

2003-06-05 20:28:51

by Jörn Engel

[permalink] [raw]
Subject: Re: [Patch] 2.5.70-bk9 zlib cleanup #4 z_off_t

Argl! Those were actually use by the compiler. Please ignore/revert.

On Thu, 5 June 2003 22:38:59 +0200, J?rn Engel wrote:
>
> Hi Linus!
>
> Two more unused macros.
>
> J?rn
>
> --
> Invincibility is in oneself, vulnerability is in the opponent.
> -- Sun Tzu
>
> --- linux-2.5.70-bk9/include/linux/zconf.h~zlib_cleanup_more_intentions 2003-06-05 22:31:59.000000000 +0200
> +++ linux-2.5.70-bk9/include/linux/zconf.h 2003-06-05 22:33:34.000000000 +0200
> @@ -8,18 +8,6 @@
> #ifndef _ZCONF_H
> #define _ZCONF_H
>
> -#if defined(__GNUC__) || defined(__386__) || defined(i386)
> -# ifndef __32BIT__
> -# define __32BIT__
> -# endif
> -#endif
> -
> -#if defined(__STDC__) || defined(__cplusplus)
> -# ifndef STDC
> -# define STDC
> -# endif
> -#endif
> -
> /* The memory requirements for deflate are (in bytes):
> (1 << (windowBits+2)) + (1 << (memLevel+9))
> that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values)

2003-06-05 20:36:28

by Jörn Engel

[permalink] [raw]
Subject: [Patch] 2.5.70-bk9 zlib cleanup #5 __32BIT__ and STDC

Hi Linus!

This one is working now. Please apply.

J?rn

--
When you close your hand, you own nothing. When you open it up, you
own the whole world.
-- Li Mu Bai in Tiger & Dragon

--- linux-2.5.70-bk9/include/linux/zconf.h~zlib_cleanup_more_intentions 2003-06-05 22:36:32.000000000 +0200
+++ linux-2.5.70-bk9/include/linux/zconf.h 2003-06-05 22:42:41.000000000 +0200
@@ -8,18 +8,6 @@
#ifndef _ZCONF_H
#define _ZCONF_H

-#if defined(__GNUC__) || defined(__386__) || defined(i386)
-# ifndef __32BIT__
-# define __32BIT__
-# endif
-#endif
-
-#if defined(__STDC__) || defined(__cplusplus)
-# ifndef STDC
-# define STDC
-# endif
-#endif
-
/* The memory requirements for deflate are (in bytes):
(1 << (windowBits+2)) + (1 << (memLevel+9))
that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values)
@@ -49,13 +37,7 @@

/* Type declarations */

-#ifndef OF /* function prototypes */
-# ifdef STDC
# define OF(args) args
-# else
-# define OF(args) ()
-# endif
-#endif

typedef unsigned char Byte; /* 8 bits */
typedef unsigned int uInt; /* 16 bits or more */

2003-06-05 21:04:06

by Jörn Engel

[permalink] [raw]
Subject: [Patch] 2.5.70-bk9 zlib cleanup #6 OF

Hi Linus!

This is the last patch to clean up zconf.h, at least for now. Getting
rid of the remaining typedefs is a bit too much work for me and this
late hour. It will have to wait for another lazy day.

J?rn

--
ticks = jiffies;
while (ticks == jiffies);
ticks = jiffies;
-- /usr/src/linux/init/main.c

--- linux-2.5.70-bk9/lib/zlib_deflate/deftree.c~zlib_cleanup_OF 2003-06-05 21:23:40.000000000 +0200
+++ linux-2.5.70-bk9/lib/zlib_deflate/deftree.c 2003-06-05 22:51:00.000000000 +0200
@@ -132,25 +132,25 @@
* Local (static) routines in this file.
*/

-local void tr_static_init OF((void));
-local void init_block OF((deflate_state *s));
-local void pqdownheap OF((deflate_state *s, ct_data *tree, int k));
-local void gen_bitlen OF((deflate_state *s, tree_desc *desc));
-local void gen_codes OF((ct_data *tree, int max_code, ush *bl_count));
-local void build_tree OF((deflate_state *s, tree_desc *desc));
-local void scan_tree OF((deflate_state *s, ct_data *tree, int max_code));
-local void send_tree OF((deflate_state *s, ct_data *tree, int max_code));
-local int build_bl_tree OF((deflate_state *s));
-local void send_all_trees OF((deflate_state *s, int lcodes, int dcodes,
- int blcodes));
-local void compress_block OF((deflate_state *s, ct_data *ltree,
- ct_data *dtree));
-local void set_data_type OF((deflate_state *s));
-local unsigned bi_reverse OF((unsigned value, int length));
-local void bi_windup OF((deflate_state *s));
-local void bi_flush OF((deflate_state *s));
-local void copy_block OF((deflate_state *s, char *buf, unsigned len,
- int header));
+local void tr_static_init (void);
+local void init_block (deflate_state *s);
+local void pqdownheap (deflate_state *s, ct_data *tree, int k);
+local void gen_bitlen (deflate_state *s, tree_desc *desc);
+local void gen_codes (ct_data *tree, int max_code, ush *bl_count);
+local void build_tree (deflate_state *s, tree_desc *desc);
+local void scan_tree (deflate_state *s, ct_data *tree, int max_code);
+local void send_tree (deflate_state *s, ct_data *tree, int max_code);
+local int build_bl_tree (deflate_state *s);
+local void send_all_trees (deflate_state *s, int lcodes, int dcodes,
+ int blcodes);
+local void compress_block (deflate_state *s, ct_data *ltree,
+ ct_data *dtree);
+local void set_data_type (deflate_state *s);
+local unsigned bi_reverse (unsigned value, int length);
+local void bi_windup (deflate_state *s);
+local void bi_flush (deflate_state *s);
+local void copy_block (deflate_state *s, char *buf, unsigned len,
+ int header);

#ifndef DEBUG_ZLIB
# define send_code(s, c, tree) send_bits(s, tree[c].Code, tree[c].Len)
@@ -174,7 +174,7 @@
* IN assertion: length <= 16 and value fits in length bits.
*/
#ifdef DEBUG_ZLIB
-local void send_bits OF((deflate_state *s, int value, int length));
+local void send_bits (deflate_state *s, int value, int length);

local void send_bits(
deflate_state *s,
--- linux-2.5.70-bk9/lib/zlib_deflate/deflate.c~zlib_cleanup_OF 2003-06-05 22:14:09.000000000 +0200
+++ linux-2.5.70-bk9/lib/zlib_deflate/deflate.c 2003-06-05 22:52:09.000000000 +0200
@@ -63,22 +63,22 @@
finish_done /* finish done, accept no more input or output */
} block_state;

-typedef block_state (*compress_func) OF((deflate_state *s, int flush));
+typedef block_state (*compress_func) (deflate_state *s, int flush);
/* Compression function. Returns the block state after the call. */

-local void fill_window OF((deflate_state *s));
-local block_state deflate_stored OF((deflate_state *s, int flush));
-local block_state deflate_fast OF((deflate_state *s, int flush));
-local block_state deflate_slow OF((deflate_state *s, int flush));
-local void lm_init OF((deflate_state *s));
-local void putShortMSB OF((deflate_state *s, uInt b));
-local void flush_pending OF((z_streamp strm));
-local int read_buf OF((z_streamp strm, Byte *buf, unsigned size));
-local uInt longest_match OF((deflate_state *s, IPos cur_match));
+local void fill_window (deflate_state *s);
+local block_state deflate_stored (deflate_state *s, int flush);
+local block_state deflate_fast (deflate_state *s, int flush);
+local block_state deflate_slow (deflate_state *s, int flush);
+local void lm_init (deflate_state *s);
+local void putShortMSB (deflate_state *s, uInt b);
+local void flush_pending (z_streamp strm);
+local int read_buf (z_streamp strm, Byte *buf, unsigned size);
+local uInt longest_match (deflate_state *s, IPos cur_match);

#ifdef DEBUG_ZLIB
-local void check_match OF((deflate_state *s, IPos start, IPos match,
- int length));
+local void check_match (deflate_state *s, IPos start, IPos match,
+ int length);
#endif

/* ===========================================================================
--- linux-2.5.70-bk9/lib/zlib_inflate/infblock.h~zlib_cleanup_OF 2003-06-05 21:34:33.000000000 +0200
+++ linux-2.5.70-bk9/lib/zlib_inflate/infblock.h 2003-06-05 22:53:35.000000000 +0200
@@ -14,31 +14,31 @@
struct inflate_blocks_state;
typedef struct inflate_blocks_state inflate_blocks_statef;

-extern inflate_blocks_statef * zlib_inflate_blocks_new OF((
+extern inflate_blocks_statef * zlib_inflate_blocks_new (
z_streamp z,
- check_func c, /* check function */
- uInt w)); /* window size */
+ check_func c, /* check function */
+ uInt w); /* window size */

-extern int zlib_inflate_blocks OF((
+extern int zlib_inflate_blocks (
inflate_blocks_statef *,
z_streamp ,
- int)); /* initial return code */
+ int); /* initial return code */

-extern void zlib_inflate_blocks_reset OF((
+extern void zlib_inflate_blocks_reset (
inflate_blocks_statef *,
z_streamp ,
- uLong *)); /* check value on output */
+ uLong *); /* check value on output */

-extern int zlib_inflate_blocks_free OF((
+extern int zlib_inflate_blocks_free (
inflate_blocks_statef *,
- z_streamp));
+ z_streamp);

-extern void zlib_inflate_set_dictionary OF((
+extern void zlib_inflate_set_dictionary (
inflate_blocks_statef *s,
- const Byte *d, /* dictionary */
- uInt n)); /* dictionary length */
+ const Byte *d, /* dictionary */
+ uInt n); /* dictionary length */

-extern int zlib_inflate_blocks_sync_point OF((
- inflate_blocks_statef *s));
+extern int zlib_inflate_blocks_sync_point (
+ inflate_blocks_statef *s);

#endif /* _INFBLOCK_H */
--- linux-2.5.70-bk9/lib/zlib_deflate/defutil.h~zlib_cleanup_OF 2003-06-05 21:22:04.000000000 +0200
+++ linux-2.5.70-bk9/lib/zlib_deflate/defutil.h 2003-06-05 22:54:15.000000000 +0200
@@ -264,14 +264,14 @@
*/

/* in trees.c */
-void zlib_tr_init OF((deflate_state *s));
-int zlib_tr_tally OF((deflate_state *s, unsigned dist, unsigned lc));
-ulg zlib_tr_flush_block OF((deflate_state *s, char *buf, ulg stored_len,
- int eof));
-void zlib_tr_align OF((deflate_state *s));
-void zlib_tr_stored_block OF((deflate_state *s, char *buf, ulg stored_len,
- int eof));
-void zlib_tr_stored_type_only OF((deflate_state *));
+void zlib_tr_init (deflate_state *s);
+int zlib_tr_tally (deflate_state *s, unsigned dist, unsigned lc);
+ulg zlib_tr_flush_block (deflate_state *s, char *buf, ulg stored_len,
+ int eof);
+void zlib_tr_align (deflate_state *s);
+void zlib_tr_stored_block (deflate_state *s, char *buf, ulg stored_len,
+ int eof);
+void zlib_tr_stored_type_only (deflate_state *);


/* ===========================================================================
--- linux-2.5.70-bk9/include/linux/zlib.h~zlib_cleanup_OF 2003-06-05 22:13:00.000000000 +0200
+++ linux-2.5.70-bk9/include/linux/zlib.h 2003-06-05 22:57:17.000000000 +0200
@@ -162,14 +162,14 @@

/* basic functions */

-extern const char * zlib_zlibVersion OF((void));
+extern const char * zlib_zlibVersion (void);
/* The application can compare zlibVersion and ZLIB_VERSION for consistency.
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.
*/

-extern void * __zlib_panic_workspace OF((void));
+extern void * __zlib_panic_workspace (void);
/*
BIG FAT WARNING:
The only valid user of this function is a panic handler. This will
@@ -181,7 +181,7 @@
*/


-extern int zlib_deflate_workspacesize OF((void));
+extern int zlib_deflate_workspacesize (void);
/*
Returns the number of bytes that needs to be allocated for a per-
stream workspace. A pointer to this number of bytes should be
@@ -189,7 +189,7 @@
*/

/*
-extern int deflateInit OF((z_streamp strm, int level));
+extern int deflateInit (z_streamp strm, int level);

Initializes the internal stream state for compression. The fields
zalloc, zfree and opaque must be initialized before by the caller.
@@ -211,7 +211,7 @@
*/


-extern int zlib_deflate OF((z_streamp strm, int flush));
+extern int zlib_deflate (z_streamp strm, int flush);
/*
deflate compresses as much data as possible, and stops when the input
buffer becomes empty or the output buffer becomes full. It may introduce some
@@ -289,7 +289,7 @@
*/


-extern int zlib_deflateEnd OF((z_streamp strm));
+extern int zlib_deflateEnd (z_streamp strm);
/*
All dynamically allocated data structures for this stream are freed.
This function discards any unprocessed input and does not flush any
@@ -303,7 +303,7 @@
*/


-extern int zlib_inflate_workspacesize OF((void));
+extern int zlib_inflate_workspacesize (void);
/*
Returns the number of bytes that needs to be allocated for a per-
stream workspace. A pointer to this number of bytes should be
@@ -311,7 +311,7 @@
*/

/*
-extern int zlib_inflateInit OF((z_streamp strm));
+extern int zlib_inflateInit (z_streamp strm);

Initializes the internal stream state for decompression. The fields
next_in, avail_in, and workspace must be initialized before by
@@ -331,7 +331,7 @@
*/


-extern int zlib_inflate OF((z_streamp strm, int flush));
+extern int zlib_inflate (z_streamp strm, int flush);
/*
inflate decompresses as much data as possible, and stops when the input
buffer becomes empty or the output buffer becomes full. It may some
@@ -400,7 +400,7 @@
*/


-extern int zlib_inflateEnd OF((z_streamp strm));
+extern int zlib_inflateEnd (z_streamp strm);
/*
All dynamically allocated data structures for this stream are freed.
This function discards any unprocessed input and does not flush any
@@ -418,12 +418,12 @@
*/

/*
-extern int deflateInit2 OF((z_streamp strm,
+extern int deflateInit2 (z_streamp strm,
int level,
int method,
int windowBits,
int memLevel,
- int strategy));
+ int strategy);

This is another version of deflateInit with more compression options. The
fields next_in, zalloc, zfree and opaque must be initialized before by
@@ -461,9 +461,9 @@
not perform any compression: this will be done by deflate().
*/

-extern int zlib_deflateSetDictionary OF((z_streamp strm,
+extern int zlib_deflateSetDictionary (z_streamp strm,
const Byte *dictionary,
- uInt dictLength));
+ uInt dictLength);
/*
Initializes the compression dictionary from the given byte sequence
without producing any compressed output. This function must be called
@@ -497,8 +497,7 @@
perform any compression: this will be done by deflate().
*/

-extern int zlib_deflateCopy OF((z_streamp dest,
- z_streamp source));
+extern int zlib_deflateCopy (z_streamp dest, z_streamp source);
/*
Sets the destination stream as a complete copy of the source stream.

@@ -515,7 +514,7 @@
destination.
*/

-extern int zlib_deflateReset OF((z_streamp strm));
+extern int zlib_deflateReset (z_streamp strm);
/*
This function is equivalent to deflateEnd followed by deflateInit,
but does not free and reallocate all the internal compression state.
@@ -526,9 +525,7 @@
stream state was inconsistent (such as zalloc or state being NULL).
*/

-extern int zlib_deflateParams OF((z_streamp strm,
- int level,
- int strategy));
+extern int zlib_deflateParams (z_streamp strm, int level, int strategy);
/*
Dynamically update the compression level and compression strategy. The
interpretation of level and strategy is as in deflateInit2. This can be
@@ -548,8 +545,7 @@
*/

/*
-extern int inflateInit2 OF((z_streamp strm,
- int windowBits));
+extern int inflateInit2 (z_streamp strm, int windowBits);

This is another version of inflateInit with an extra parameter. The
fields next_in, avail_in, zalloc, zfree and opaque must be initialized
@@ -570,9 +566,9 @@
modified, but next_out and avail_out are unchanged.)
*/

-extern int zlib_inflateSetDictionary OF((z_streamp strm,
+extern int zlib_inflateSetDictionary (z_streamp strm,
const Byte *dictionary,
- uInt dictLength));
+ uInt dictLength);
/*
Initializes the decompression dictionary from the given uncompressed byte
sequence. This function must be called immediately after a call of inflate
@@ -589,7 +585,7 @@
inflate().
*/

-extern int zlib_inflateSync OF((z_streamp strm));
+extern int zlib_inflateSync (z_streamp strm);
/*
Skips invalid compressed data until a full flush point (see above the
description of deflate with Z_FULL_FLUSH) can be found, or until all
@@ -604,7 +600,7 @@
until success or end of the input data.
*/

-extern int zlib_inflateReset OF((z_streamp strm));
+extern int zlib_inflateReset (z_streamp strm);
/*
This function is equivalent to inflateEnd followed by inflateInit,
but does not free and reallocate all the internal decompression state.
@@ -614,7 +610,7 @@
stream state was inconsistent (such as zalloc or state being NULL).
*/

-extern int zlib_inflateIncomp OF((z_stream *strm));
+extern int zlib_inflateIncomp (z_stream *strm);
/*
This function adds the data at next_in (avail_in bytes) to the output
history without performing any output. There must be no pending output,
@@ -628,16 +624,16 @@
/* deflateInit and inflateInit are macros to allow checking the zlib version
* and the compiler's view of z_stream:
*/
-extern int zlib_deflateInit_ OF((z_streamp strm, int level,
- const char *version, int stream_size));
-extern int zlib_inflateInit_ OF((z_streamp strm,
- const char *version, int stream_size));
-extern int zlib_deflateInit2_ OF((z_streamp strm, int level, int method,
+extern int zlib_deflateInit_ (z_streamp strm, int level,
+ const char *version, int stream_size);
+extern int zlib_inflateInit_ (z_streamp strm,
+ const char *version, int stream_size);
+extern int zlib_deflateInit2_ (z_streamp strm, int level, int method,
int windowBits, int memLevel,
int strategy, const char *version,
- int stream_size));
-extern int zlib_inflateInit2_ OF((z_streamp strm, int windowBits,
- const char *version, int stream_size));
+ int stream_size);
+extern int zlib_inflateInit2_ (z_streamp strm, int windowBits,
+ const char *version, int stream_size);
#define zlib_deflateInit(strm, level) \
zlib_deflateInit_((strm), (level), ZLIB_VERSION, sizeof(z_stream))
#define zlib_inflateInit(strm) \
@@ -653,9 +649,9 @@
struct internal_state {int dummy;}; /* hack for buggy compilers */
#endif

-extern const char * zlib_zError OF((int err));
-extern int zlib_inflateSyncPoint OF((z_streamp z));
-extern const uLong * zlib_get_crc_table OF((void));
+extern const char * zlib_zError (int err);
+extern int zlib_inflateSyncPoint (z_streamp z);
+extern const uLong * zlib_get_crc_table (void);

#ifdef __cplusplus
}
--- linux-2.5.70-bk9/lib/zlib_inflate/infcodes.h~zlib_cleanup_OF 2003-06-05 21:34:12.000000000 +0200
+++ linux-2.5.70-bk9/lib/zlib_inflate/infcodes.h 2003-06-05 22:57:48.000000000 +0200
@@ -16,18 +16,18 @@
struct inflate_codes_state;
typedef struct inflate_codes_state inflate_codes_statef;

-extern inflate_codes_statef *zlib_inflate_codes_new OF((
+extern inflate_codes_statef *zlib_inflate_codes_new (
uInt, uInt,
inflate_huft *, inflate_huft *,
- z_streamp ));
+ z_streamp );

-extern int zlib_inflate_codes OF((
+extern int zlib_inflate_codes (
inflate_blocks_statef *,
z_streamp ,
- int));
+ int);

-extern void zlib_inflate_codes_free OF((
+extern void zlib_inflate_codes_free (
inflate_codes_statef *,
- z_streamp ));
+ z_streamp );

#endif /* _INFCODES_H */
--- linux-2.5.70-bk9/lib/zlib_inflate/inftrees.h~zlib_cleanup_OF 2003-06-05 21:34:42.000000000 +0200
+++ linux-2.5.70-bk9/lib/zlib_inflate/inftrees.h 2003-06-05 22:58:38.000000000 +0200
@@ -35,14 +35,14 @@
value below is more than safe. */
#define MANY 1440

-extern int zlib_inflate_trees_bits OF((
+extern int zlib_inflate_trees_bits (
uInt *, /* 19 code lengths */
uInt *, /* bits tree desired/actual depth */
inflate_huft **, /* bits tree result */
inflate_huft *, /* space for trees */
- z_streamp)); /* for messages */
+ z_streamp); /* for messages */

-extern int zlib_inflate_trees_dynamic OF((
+extern int zlib_inflate_trees_dynamic (
uInt, /* number of literal/length codes */
uInt, /* number of distance codes */
uInt *, /* that many (total) code lengths */
@@ -51,13 +51,13 @@
inflate_huft **, /* literal/length tree result */
inflate_huft **, /* distance tree result */
inflate_huft *, /* space for trees */
- z_streamp)); /* for messages */
+ z_streamp); /* for messages */

-extern int zlib_inflate_trees_fixed OF((
+extern int zlib_inflate_trees_fixed (
uInt *, /* literal desired/actual bit depth */
uInt *, /* distance desired/actual bit depth */
inflate_huft **, /* literal/length tree result */
inflate_huft **, /* distance tree result */
- z_streamp)); /* for memory allocation */
+ z_streamp); /* for memory allocation */

#endif /* _INFTREES_H */
--- linux-2.5.70-bk9/lib/zlib_inflate/inftrees.c~zlib_cleanup_OF 2003-06-05 21:26:36.000000000 +0200
+++ linux-2.5.70-bk9/lib/zlib_inflate/inftrees.c 2003-06-05 22:59:09.000000000 +0200
@@ -22,7 +22,7 @@
#define bits word.what.Bits


-local int huft_build OF((
+local int huft_build (
uInt *, /* code lengths in bits */
uInt, /* number of codes */
uInt, /* number of "simple" codes */
@@ -32,7 +32,7 @@
uInt *, /* maximum lookup bits (returns actual) */
inflate_huft *, /* space for trees */
uInt *, /* hufts used in space */
- uInt * )); /* space for values */
+ uInt * ); /* space for values */

/* Tables for deflate from PKZIP's appnote.txt. */
local const uInt cplens[31] = { /* Copy lengths for literal codes 257..285 */
--- linux-2.5.70-bk9/lib/zlib_inflate/infutil.h~zlib_cleanup_OF 2003-06-05 21:27:33.000000000 +0200
+++ linux-2.5.70-bk9/lib/zlib_inflate/infutil.h 2003-06-05 22:59:45.000000000 +0200
@@ -92,10 +92,10 @@
extern uInt zlib_inflate_mask[17];

/* copy as much as possible from the sliding window to the output area */
-extern int zlib_inflate_flush OF((
+extern int zlib_inflate_flush (
inflate_blocks_statef *,
z_streamp ,
- int));
+ int);

/* inflate private state */
typedef enum {
--- linux-2.5.70-bk9/lib/zlib_inflate/inffast.h~zlib_cleanup_OF 2003-04-07 19:30:43.000000000 +0200
+++ linux-2.5.70-bk9/lib/zlib_inflate/inffast.h 2003-06-05 23:00:05.000000000 +0200
@@ -8,10 +8,10 @@
subject to change. Applications should only use zlib.h.
*/

-extern int zlib_inflate_fast OF((
+extern int zlib_inflate_fast (
uInt,
uInt,
inflate_huft *,
inflate_huft *,
inflate_blocks_statef *,
- z_streamp ));
+ z_streamp );
--- linux-2.5.70-bk9/include/linux/zutil.h~zlib_cleanup_OF 2003-06-05 22:13:00.000000000 +0200
+++ linux-2.5.70-bk9/include/linux/zutil.h 2003-06-05 23:01:00.000000000 +0200
@@ -62,8 +62,8 @@

/* functions */

-typedef uLong (*check_func) OF((uLong check, const Byte *buf,
- uInt len));
+typedef uLong (*check_func) (uLong check, const Byte *buf,
+ uInt len);


/* checksum functions */
--- linux-2.5.70-bk9/include/linux/zconf.h~zlib_cleanup_OF 2003-06-05 22:42:41.000000000 +0200
+++ linux-2.5.70-bk9/include/linux/zconf.h 2003-06-05 23:02:44.000000000 +0200
@@ -37,14 +37,9 @@

/* Type declarations */

-# define OF(args) args
-
typedef unsigned char Byte; /* 8 bits */
typedef unsigned int uInt; /* 16 bits or more */
typedef unsigned long uLong; /* 32 bits or more */
typedef void *voidp;

-#include <linux/types.h> /* for off_t */
-#include <linux/unistd.h> /* for SEEK_* and off_t */
-
#endif /* _ZCONF_H */

2003-06-06 14:35:40

by Nicholas Wourms

[permalink] [raw]
Subject: Re: [Patch] 2.5.70-bk9 kick FAR out of the zlib

J?rn Engel wrote:
> My words were "all or nothing". Linus was against nothing, so the
> answer is all, that simple.
>
> As to your "someone comes up with a better zlib" concern, this has
> happened already. An guess what, we ignored it. So unless you come
> up with a patch to get the 1.1.4 changes into the kernel and describe
> what the two magic bits are all about, I couldn't care less.

1.1.4 would be a waste of time at this point. Better to wait for the
upcoming 1.2.x release, which promises improved performance (esp. on
x86) and better compression...

Cheers,
Nicholas