Since the FreeBSD local modifications are mostly trivial (consisting

primarily of pointless $FreeBSD$ tags), sync most files in HEAD with
those in the ZLIB branch.  This minimizes the differences between
HEAD and ZLIB and should simplify future imports.

After this, there are only three files with local modifications
(gzio.c, minigzip.c, and zconf.h) and two non-vendor files
(Makefile, zopen.c).  The rest exactly match the vendor distribution.

PR:		i386/76294
MFC after:	2 weeks
This commit is contained in:
kientzle 2005-05-11 03:47:48 +00:00
parent 3f1dd047fb
commit 2f1311730e
15 changed files with 90 additions and 77 deletions

View File

@ -3,8 +3,7 @@
* For conditions of distribution and use, see copyright notice in zlib.h
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
/* @(#) $Id$ */
#define ZLIB_INTERNAL
#include "zlib.h"

View File

@ -3,8 +3,7 @@
* For conditions of distribution and use, see copyright notice in zlib.h
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
/* @(#) $Id$ */
#define ZLIB_INTERNAL
#include "zlib.h"

View File

@ -9,8 +9,15 @@
* of two increase in speed on a Power PC G4 (PPC7455) using gcc -O3.
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
/* @(#) $Id$ */
/*
Note on the use of DYNAMIC_CRC_TABLE: there is no mutex or semaphore
protection on the static variables used to control the first-use generation
of the crc tables. Therefore, if you #define DYNAMIC_CRC_TABLE, you should
first call get_crc_table() to initialize the tables before allowing more than
one thread to use crc32().
*/
#ifdef MAKECRCH
# include <stdio.h>
@ -59,7 +66,7 @@ __FBSDID("$FreeBSD$");
#ifdef DYNAMIC_CRC_TABLE
local int crc_table_empty = 1;
local volatile int crc_table_empty = 1;
local unsigned long FAR crc_table[TBLS][256];
local void make_crc_table OF((void));
#ifdef MAKECRCH
@ -96,38 +103,51 @@ local void make_crc_table()
{
unsigned long c;
int n, k;
unsigned long poly; /* polynomial exclusive-or pattern */
unsigned long poly; /* polynomial exclusive-or pattern */
/* terms of polynomial defining this crc (except x^32): */
static volatile int first = 1; /* flag to limit concurrent making */
static const unsigned char p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26};
/* make exclusive-or pattern from polynomial (0xedb88320UL) */
poly = 0UL;
for (n = 0; n < sizeof(p)/sizeof(unsigned char); n++)
poly |= 1UL << (31 - p[n]);
/* See if another task is already doing this (not thread-safe, but better
than nothing -- significantly reduces duration of vulnerability in
case the advice about DYNAMIC_CRC_TABLE is ignored) */
if (first) {
first = 0;
/* generate a crc for every 8-bit value */
for (n = 0; n < 256; n++) {
c = (unsigned long)n;
for (k = 0; k < 8; k++)
c = c & 1 ? poly ^ (c >> 1) : c >> 1;
crc_table[0][n] = c;
}
/* make exclusive-or pattern from polynomial (0xedb88320UL) */
poly = 0UL;
for (n = 0; n < sizeof(p)/sizeof(unsigned char); n++)
poly |= 1UL << (31 - p[n]);
/* generate a crc for every 8-bit value */
for (n = 0; n < 256; n++) {
c = (unsigned long)n;
for (k = 0; k < 8; k++)
c = c & 1 ? poly ^ (c >> 1) : c >> 1;
crc_table[0][n] = c;
}
#ifdef BYFOUR
/* generate crc for each value followed by one, two, and three zeros, and
then the byte reversal of those as well as the first table */
for (n = 0; n < 256; n++) {
c = crc_table[0][n];
crc_table[4][n] = REV(c);
for (k = 1; k < 4; k++) {
c = crc_table[0][c & 0xff] ^ (c >> 8);
crc_table[k][n] = c;
crc_table[k + 4][n] = REV(c);
/* generate crc for each value followed by one, two, and three zeros,
and then the byte reversal of those as well as the first table */
for (n = 0; n < 256; n++) {
c = crc_table[0][n];
crc_table[4][n] = REV(c);
for (k = 1; k < 4; k++) {
c = crc_table[0][c & 0xff] ^ (c >> 8);
crc_table[k][n] = c;
crc_table[k + 4][n] = REV(c);
}
}
}
#endif /* BYFOUR */
crc_table_empty = 0;
crc_table_empty = 0;
}
else { /* not first */
/* wait for the other guy to finish (not efficient, but rare) */
while (crc_table_empty)
;
}
#ifdef MAKECRCH
/* write out CRC tables to crc32.h */
@ -181,9 +201,10 @@ local void write_table(out, table)
const unsigned long FAR * ZEXPORT get_crc_table()
{
#ifdef DYNAMIC_CRC_TABLE
if (crc_table_empty) make_crc_table();
if (crc_table_empty)
make_crc_table();
#endif /* DYNAMIC_CRC_TABLE */
return (const unsigned long FAR *)crc_table;
return (const unsigned long FAR *)crc_table;
}
/* ========================================================================= */

View File

@ -1,11 +1,8 @@
/* deflate.c -- compress data using the deflation algorithm
* Copyright (C) 1995-2003 Jean-loup Gailly.
* Copyright (C) 1995-2004 Jean-loup Gailly.
* For conditions of distribution and use, see copyright notice in zlib.h
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
/*
* ALGORITHM
*
@ -50,12 +47,12 @@ __FBSDID("$FreeBSD$");
*
*/
/* @(#) $FreeBSD$ */
/* @(#) $Id$ */
#include "deflate.h"
const char deflate_copyright[] =
" deflate 1.2.1 Copyright 1995-2003 Jean-loup Gailly ";
" deflate 1.2.2 Copyright 1995-2004 Jean-loup Gailly ";
/*
If you use the zlib library in a product, an acknowledgment is welcome
in the documentation of your product. If for some reason you cannot

View File

@ -8,7 +8,7 @@
subject to change. Applications should only use zlib.h.
*/
/* @(#) $FreeBSD$ */
/* @(#) $Id$ */
#ifndef DEFLATE_H
#define DEFLATE_H
@ -95,7 +95,6 @@ typedef struct internal_state {
Bytef *pending_out; /* next pending byte to output to the stream */
int pending; /* nb of bytes in the pending buffer */
int wrap; /* bit 0 true for zlib, bit 1 true for gzip */
Byte data_type; /* UNKNOWN, BINARY or ASCII */
Byte method; /* STORED (for zip only) or DEFLATED */
int last_flush; /* value of flush param for previous deflate call */

View File

@ -3,8 +3,7 @@
* For conditions of distribution and use, see copyright notice in zlib.h
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
/* @(#) $Id$ */
#include <stdio.h>
#include "zlib.h"

View File

@ -434,8 +434,8 @@ void FAR *out_desc;
}
}
if (state->mode == BAD)
break;
/* handle error breaks in while */
if (state->mode == BAD) break;
/* build code tables */
state->next = state->codes;

View File

@ -1,11 +1,8 @@
/* inffast.c -- fast decoding
* Copyright (C) 1995-2003 Mark Adler
* Copyright (C) 1995-2004 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include "zutil.h"
#include "inftrees.h"
#include "inflate.h"
@ -22,7 +19,7 @@ __FBSDID("$FreeBSD$");
- none
No measurable difference:
- Pentium III (Anderson)
- 68060 (Nikl)
- M68060 (Nikl)
*/
#ifdef POSTINC
# define OFF 0

View File

@ -80,9 +80,6 @@
* The history for versions after 1.2.0 are in ChangeLog in zlib distribution.
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include "zutil.h"
#include "inftrees.h"
#include "inflate.h"
@ -112,6 +109,7 @@ z_streamp strm;
state = (struct inflate_state FAR *)strm->state;
strm->total_in = strm->total_out = state->total = 0;
strm->msg = Z_NULL;
strm->adler = 1; /* to support ill-conceived Java test suite */
state->mode = HEAD;
state->last = 0;
state->havedict = 0;
@ -864,8 +862,8 @@ int flush;
}
}
if (state->mode == BAD)
break;
/* handle error breaks in while */
if (state->mode == BAD) break;
/* build code tables */
state->next = state->codes;

View File

@ -1,18 +1,15 @@
/* inftrees.c -- generate Huffman trees for efficient decoding
* Copyright (C) 1995-2003 Mark Adler
* Copyright (C) 1995-2004 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include "zutil.h"
#include "inftrees.h"
#define MAXBITS 15
const char inflate_copyright[] =
" inflate 1.2.1 Copyright 1995-2003 Mark Adler ";
" inflate 1.2.2 Copyright 1995-2004 Mark Adler ";
/*
If you use the zlib library in a product, an acknowledgment is welcome
in the documentation of your product. If for some reason you cannot
@ -65,7 +62,7 @@ unsigned short FAR *work;
35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0};
static const unsigned short lext[31] = { /* Length codes 257..285 extra */
16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,
19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 76, 66};
19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 199, 198};
static const unsigned short dbase[32] = { /* Distance codes 0..29 base */
1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
@ -117,7 +114,15 @@ unsigned short FAR *work;
for (max = MAXBITS; max >= 1; max--)
if (count[max] != 0) break;
if (root > max) root = max;
if (max == 0) return -1; /* no codes! */
if (max == 0) { /* no symbols to code at all */
this.op = (unsigned char)64; /* invalid code marker */
this.bits = (unsigned char)1;
this.val = (unsigned short)0;
*(*table)++ = this; /* make a table to force an error */
*(*table)++ = this;
*bits = 1;
return 0; /* no symbols, but wait for decoding to report error */
}
for (min = 1; min <= MAXBITS; min++)
if (count[min] != 0) break;
if (root < min) root = min;
@ -298,7 +303,6 @@ unsigned short FAR *work;
drop = 0;
len = root;
next = *table;
curr = root;
this.bits = (unsigned char)len;
}

View File

@ -29,8 +29,7 @@
* Addison-Wesley, 1983. ISBN 0-201-06672-6.
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
/* @(#) $Id$ */
/* #define GEN_TREES_H */
@ -932,7 +931,7 @@ void _tr_flush_block(s, buf, stored_len, eof)
if (s->level > 0) {
/* Check if the file is ascii or binary */
if (s->data_type == Z_UNKNOWN) set_data_type(s);
if (s->strm->data_type == Z_UNKNOWN) set_data_type(s);
/* Construct the literal and distance trees */
build_tree(s, (tree_desc *)(&(s->l_desc)));
@ -1132,7 +1131,7 @@ local void set_data_type(s)
while (n < 7) bin_freq += s->dyn_ltree[n++].Freq;
while (n < 128) ascii_freq += s->dyn_ltree[n++].Freq;
while (n < LITERALS) bin_freq += s->dyn_ltree[n++].Freq;
s->data_type = (Byte)(bin_freq > (ascii_freq >> 2) ? Z_BINARY : Z_ASCII);
s->strm->data_type = bin_freq > (ascii_freq >> 2) ? Z_BINARY : Z_ASCII;
}
/* ===========================================================================

View File

@ -3,8 +3,7 @@
* For conditions of distribution and use, see copyright notice in zlib.h
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
/* @(#) $Id$ */
#define ZLIB_INTERNAL
#include "zlib.h"

View File

@ -1,6 +1,4 @@
.\" $FreeBSD$
.\"
.TH ZLIB 3 "17 November 2003"
.TH ZLIB 3 "3 October 2004"
.SH NAME
zlib \- compression/decompression library
.SH SYNOPSIS
@ -135,8 +133,8 @@ before asking for help.
Send questions and/or comments to zlib@gzip.org,
or (for the Windows DLL version) to Gilles Vollant (info@winimage.com).
.SH AUTHORS
Version 1.2.1
Copyright (C) 1995-2003 Jean-loup Gailly (jloup@gzip.org)
Version 1.2.2
Copyright (C) 1995-2004 Jean-loup Gailly (jloup@gzip.org)
and Mark Adler (madler@alumni.caltech.edu).
.LP
This software is provided "as-is,"

View File

@ -3,8 +3,7 @@
* For conditions of distribution and use, see copyright notice in zlib.h
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
/* @(#) $Id$ */
#include "zutil.h"

View File

@ -8,7 +8,7 @@
subject to change. Applications should only use zlib.h.
*/
/* @(#) $FreeBSD$ */
/* @(#) $Id$ */
#ifndef ZUTIL_H
#define ZUTIL_H
@ -189,9 +189,14 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
# define NO_vsnprintf
# endif
#endif
#ifdef VMS
# define NO_vsnprintf
#endif
#ifdef HAVE_STRERROR
extern char *strerror OF((int));
# ifndef VMS
extern char *strerror OF((int));
# endif
# define zstrerror(errnum) strerror(errnum)
#else
# define zstrerror(errnum) ""