Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
pigz version 2.1.6
  • Loading branch information
madler committed Jan 25, 2010
1 parent 0d895c8 commit 92d565c
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 22 deletions.
7 changes: 6 additions & 1 deletion Makefile
@@ -1,4 +1,4 @@
CFLAGS=-O2
CFLAGS=-O3

pigz: pigz.o yarn.o
cc -o pigz pigz.o yarn.o -lpthread -lz
Expand Down Expand Up @@ -38,5 +38,10 @@ tests: dev test
./pigzn -kf pigz.c ; ./pigz -t pigz.c.gz
rm -f pigz.c.gz

docs: pigz.pdf

pigz.pdf: pigz.1
groff -mandoc -f H -T ps pigz.1 | ps2pdf - pigz.pdf

clean:
rm -f *.o pigz unpigz pigzn pigzt pigz.c.gz pigz.c.zz pigz.c.zip
2 changes: 1 addition & 1 deletion README
@@ -1,4 +1,4 @@
pigz 2.1.5 (20 Jul 2009) by Mark Adler
pigz 2.1.6 (17 Jan 2010) by Mark Adler

pigz, which stands for Parallel Implementation of GZip, is a fully functional
replacement for gzip that exploits multiple processors and multiple cores to
Expand Down
5 changes: 3 additions & 2 deletions pigz.1
Expand Up @@ -61,7 +61,8 @@ five byte overhead to the output for each input chunk.
.PP
The default input block size is 128K, but can be changed with the
.B -b
option. The number of compress threads is set by default to 4,
option. The number of compress threads is set by default to the number
of online processors,
which can be changed using the
.B -p
option. Specifying
Expand Down Expand Up @@ -183,4 +184,4 @@ This software is provided 'as-is', without any express or implied
warranty. In no event will the author be held liable for any damages
arising from the use of this software.
.PP
Copyright (C) 2007, 2008, 2009 Mark Adler <madler@alumni.caltech.edu>
Copyright (C) 2007, 2008, 2009, 2010 Mark Adler <madler@alumni.caltech.edu>
60 changes: 42 additions & 18 deletions pigz.c
@@ -1,6 +1,6 @@
/* pigz.c -- parallel implementation of gzip
* Copyright (C) 2007, 2008, 2009 Mark Adler
* Version 2.1.5 20 Jul 2009 Mark Adler
* Copyright (C) 2007, 2008, 2009, 2010 Mark Adler
* Version 2.1.6 17 Jan 2010 Mark Adler
*/

/*
Expand Down Expand Up @@ -100,9 +100,15 @@
Fix --suffix short option to be -S to match gzip [Bloch]
Decompress if executable named "unpigz" [Amundsen]
Add a little bit of testing to Makefile
2.1.6 17 Jan 2010 Added pigz.spec to distribution for RPM systems [Brown]
Avoid some compiler warnings
Process symbolic links if piping to stdout [Hoffstätte]
Decompress if executable named "gunzip" [Hoffstätte]
Allow ".tgz" suffix [Chernookiy]
Fix adler32 comparison on .zz files
*/

#define VERSION "pigz 2.1.5\n"
#define VERSION "pigz 2.1.6\n"

/* To-do:
- add --rsyncable (or -R) [use my own algorithm, set min/max block size]
Expand Down Expand Up @@ -264,6 +270,7 @@

#include "zlib.h" /* deflateInit2(), deflateReset(), deflate(), */
/* deflateEnd(), deflateSetDictionary(), crc32(),
inflateBackInit(), inflateBack(), inflateBackEnd(),
Z_DEFAULT_COMPRESSION, Z_DEFAULT_STRATEGY,
Z_DEFLATED, Z_NO_FLUSH, Z_NULL, Z_OK,
Z_SYNC_FLUSH, z_stream */
Expand Down Expand Up @@ -1035,6 +1042,8 @@ local void compress_thread(void *dummy)
size_t len; /* remaining bytes to compress/check */
z_stream strm; /* deflate stream */

(void)dummy;

/* initialize the deflate stream for this thread */
strm.zfree = Z_NULL;
strm.zalloc = Z_NULL;
Expand Down Expand Up @@ -1157,6 +1166,8 @@ local void write_thread(void *dummy)
unsigned long clen; /* total compressed size (overflow ok) */
unsigned long check; /* check value of uncompressed data */

(void)dummy;

/* build and write header */
Trace(("-- write thread running"));
head = put_header();
Expand Down Expand Up @@ -1418,6 +1429,8 @@ local void load_read(void *dummy)
{
size_t len;

(void)dummy;

Trace(("-- launched decompress read thread"));
do {
possess(load_state);
Expand Down Expand Up @@ -1726,7 +1739,7 @@ local int get_header(int save)
if (in_left == 0 && load() == 0)
return -3;
end = memchr(in_next, 0, in_left);
copy = end == NULL ? in_left : (end - in_next) + 1;
copy = end == NULL ? in_left : (size_t)(end - in_next) + 1;
if (have + copy > size) {
while (have + copy > (size <<= 1))
;
Expand Down Expand Up @@ -1770,7 +1783,8 @@ local size_t compressed_suffix(char *nm)
if (len > 4) {
nm += len - 4;
len = 4;
if (strcmp(nm, ".zip") == 0 || strcmp(nm, ".ZIP") == 0)
if (strcmp(nm, ".zip") == 0 || strcmp(nm, ".ZIP") == 0 ||
strcmp(nm, ".tgz") == 0)
return 4;
}
if (len > 3) {
Expand All @@ -1796,7 +1810,7 @@ local size_t compressed_suffix(char *nm)
/* print gzip or lzw file information */
local void show_info(int method, unsigned long check, off_t len, int cont)
{
int max; /* maximum name length for current verbosity */
size_t max; /* maximum name length for current verbosity */
size_t n; /* name length without suffix */
time_t now; /* for getting current year */
char mod[26]; /* modification time in text */
Expand Down Expand Up @@ -1991,6 +2005,7 @@ local void list_info(void)
/* call-back input function for inflateBack() */
local unsigned inb(void *desc, unsigned char **buf)
{
(void)desc;
load();
*buf = in_next;
return in_left;
Expand All @@ -2014,6 +2029,8 @@ local void outb_write(void *dummy)
{
size_t len;

(void)dummy;

Trace(("-- launched decompress write thread"));
do {
possess(outb_write_more);
Expand All @@ -2032,6 +2049,8 @@ local void outb_check(void *dummy)
{
size_t len;

(void)dummy;

Trace(("-- launched decompress check thread"));
do {
possess(outb_check_more);
Expand All @@ -2054,6 +2073,8 @@ local int outb(void *desc, unsigned char *buf, unsigned len)
#ifndef NOTHREAD
static thread *wr, *ch;

(void)desc;

if (procs > 1) {
/* if first time, initialize state and launch threads */
if (outb_write_more == NULL) {
Expand Down Expand Up @@ -2165,7 +2186,7 @@ local void infchk(void)
/* if second length doesn't match, try 64-bit lengths */
if (zip_ulen != (out_tot & LOW32)) {
zip_ulen = GET4();
GET4();
(void)GET4();
}
if (in_eof)
bail("corrupted zip entry -- missing trailer: ", in);
Expand All @@ -2175,8 +2196,8 @@ local void infchk(void)
check = zip_crc;
}
else if (form == 1) { /* zlib (big-endian) trailer */
check = GET() << 24;
check += GET() << 16;
check = (unsigned long)(GET()) << 24;
check += (unsigned long)(GET()) << 16;
check += GET() << 8;
check += GET();
if (in_eof)
Expand Down Expand Up @@ -2244,7 +2265,7 @@ unsigned char match[65280 + 2]; /* buffer for reversed match */
local void unlzw(void)
{
int got; /* byte just read by GET() */
int chunk; /* bytes left in current chunk */
unsigned chunk; /* bytes left in current chunk */
int left; /* bits left in rem */
unsigned rem; /* unused bits from input */
int bits; /* current bits per code */
Expand Down Expand Up @@ -2498,7 +2519,7 @@ local void process(char *path)
in);
return;
}
if ((st.st_mode & S_IFMT) == S_IFLNK && !force) {
if ((st.st_mode & S_IFMT) == S_IFLNK && !force && !pipeout) {
if (verbosity > 0)
fprintf(stderr, "%s is a symbolic link -- skipping\n", in);
return;
Expand Down Expand Up @@ -2553,8 +2574,8 @@ local void process(char *path)

/* run process() for each entry in the directory */
cut = base = in + strlen(in);
if (base > in && base[-1] != '/') {
if (base - in >= sizeof(in))
if (base > in && base[-1] != (unsigned char)'/') {
if ((size_t)(base - in) >= sizeof(in))
bail("path too long", in);
*base++ = '/';
}
Expand Down Expand Up @@ -2802,7 +2823,7 @@ local void help(void)

if (verbosity == 0)
return;
for (n = 0; n < sizeof(helptext) / sizeof(char *); n++)
for (n = 0; n < (int)(sizeof(helptext) / sizeof(char *)); n++)
fprintf(stderr, "%s\n", helptext[n]);
fflush(stderr);
exit(0);
Expand Down Expand Up @@ -2944,7 +2965,8 @@ local int option(char *arg)
case 'K': form = 2; sufx = ".zip"; break;
case 'L':
fputs(VERSION, stderr);
fputs("Copyright (C) 2007, 2008, 2009 Mark Adler\n", stderr);
fputs("Copyright (C) 2007, 2008, 2009, 2010 Mark Adler\n",
stderr);
fputs("Subject to the terms of the zlib license.\n",
stderr);
fputs("No warranty is provided or implied.\n", stderr);
Expand Down Expand Up @@ -3002,7 +3024,7 @@ local int option(char *arg)
procs = (int)n; /* # processes */
if (procs < 1)
bail("invalid number of processes: ", arg);
if (procs != n || ((procs << 1) + 2) < 1)
if ((size_t)procs != n || ((procs << 1) + 2) < 1)
bail("too many processes: ", arg);
#ifdef NOTHREAD
if (procs > 1)
Expand All @@ -3023,6 +3045,7 @@ local int option(char *arg)
/* catch termination signal */
local void cut_short(int sig)
{
(void)sig;
Trace(("termination by user"));
if (outd != -1 && out != NULL)
unlink(out);
Expand Down Expand Up @@ -3075,9 +3098,10 @@ int main(int argc, char **argv)
if (argc < 2 && isatty(1))
help();

/* decompress if named "unpigz" */
/* decompress if named "unpigz" or "gunzip" */
p = strrchr(argv[0], '/');
if (strcmp(p == NULL ? argv[0] : p + 1, "unpigz") == 0)
p = p == NULL ? argv[0] : p + 1;
if (strcmp(p, "unpigz") == 0 || strcmp(p, "gunzip") == 0)
decode = 1, headis = 0;

/* process command-line arguments */
Expand Down
Binary file modified pigz.pdf
Binary file not shown.
Binary file added pigz.ps
Binary file not shown.
26 changes: 26 additions & 0 deletions pigz.spec
@@ -0,0 +1,26 @@
Summary: pigz is a parallel implementation of gzip which utilizes multiple cores
Name: pigz
Version: 2.1.6
Release: 1
Source0: %{name}-%{version}.tar.gz
License: GPL
Group: Applications/Tools
Packager: Duncan Brown <duncan@duncanbrown.org>
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
URL: http://www.zlib.net/pigz

%description
pigz, which stands for parallel implementation of gzip, is a fully functional replacement for gzip that exploits multiple processors and multiple cores to the hilt when compressing data. pigz was written by Mark Adler, and uses the zlib and pthread libraries.

%clean
rm -rf $RPM_BUILD_ROOT
%prep
mkdir -p $RPM_BUILD_ROOT
%setup -q
%build
make
mkdir -p ${RPM_BUILD_ROOT}/usr/bin
mv pigz ${RPM_BUILD_ROOT}/usr/bin
%files
%defattr(-,root,root)
/usr/bin/pigz

0 comments on commit 92d565c

Please sign in to comment.