"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "pbzip2.cpp" between
pbzip2-1.1.12.tar.gz and pbzip2-1.1.13.tar.gz

About: PBZIP2 is a parallel implementation of the bzip2 block-sorting file compressor that uses pthreads.

pbzip2.cpp  (pbzip2-1.1.12):pbzip2.cpp  (pbzip2-1.1.13)
skipping to change at line 46 skipping to change at line 46
// //
// GLOBALS // GLOBALS
// //
static int producerDone = 0; static int producerDone = 0;
static int terminateFlag = 0; // Abnormal premature termination static int terminateFlag = 0; // Abnormal premature termination
static int finishedFlag = 0; // Main thread work finished (about to exit) static int finishedFlag = 0; // Main thread work finished (about to exit)
static int unfinishedWorkCleaned = 0; static int unfinishedWorkCleaned = 0;
static int numCPU = 2; static int numCPU = 2;
static int IgnoreTrailingGarbageFlag = 0; // ingnore trailing garbage on decompr ess flag static int IgnoreTrailingGarbageFlag = 0; // ingnore trailing garbage on decompr ess flag
static int QUEUESIZE = 2;
static int SIG_HANDLER_QUIT_SIGNAL = SIGUSR1; // signal used to stop SignalHandl erThread static int SIG_HANDLER_QUIT_SIGNAL = SIGUSR1; // signal used to stop SignalHandl erThread
#ifdef USE_STACKSIZE_CUSTOMIZATION #ifdef USE_STACKSIZE_CUSTOMIZATION
static int ChildThreadStackSize = 0; // -1 - don't modify stacksize; 0 - use min imum; > 0 - use specified static int ChildThreadStackSize = 0; // -1 - don't modify stacksize; 0 - use min imum; > 0 - use specified
#ifndef PTHREAD_STACK_MIN #ifndef PTHREAD_STACK_MIN
#define PTHREAD_STACK_MIN 4096 #define PTHREAD_STACK_MIN 4096
#endif #endif
#endif // USE_STACKSIZE_CUSTOMIZATION #endif // USE_STACKSIZE_CUSTOMIZATION
static unsigned char Bz2HeaderZero[] = { static unsigned char Bz2HeaderZero[] = {
0x42, 0x5A, 0x68, 0x39, 0x17, 0x72, 0x45, 0x38, 0x50, 0x90, 0x00, 0x00, 0 x00, 0x00 }; 0x42, 0x5A, 0x68, 0x39, 0x17, 0x72, 0x45, 0x38, 0x50, 0x90, 0x00, 0x00, 0 x00, 0x00 };
static OFF_T InFileSize; static OFF_T InFileSize;
static OFF_T InBytesProduced = 0;
static int NumBlocks = 0; static int NumBlocks = 0;
static int NumBlocksEstimated = 0; static int NumBlocksEstimated = 0;
static int NumBufferedBlocks = 0; static int NumBufferedBlocks = 0;
static size_t NumBufferedTailBlocks = 0; static size_t NumBufferedTailBlocks = 0;
static size_t NumBufferedBlocksMax = 0; static size_t NumBufferedBlocksMax = 0;
static int NextBlockToWrite; static int NextBlockToWrite;
static int LastGoodBlock; // set only to terminate write prematurely (ignoring g arbage) static int LastGoodBlock; // set only to terminate write prematurely (ignoring g arbage)
static int MinErrorBlock; // lowest so far block number which has errors (on dec ompress; could be trailing garbage) static int MinErrorBlock; // lowest so far block number which has errors (on dec ompress; could be trailing garbage)
static size_t OutBufferPosToWrite; // = 0; // position in output buffer static size_t OutBufferPosToWrite; // = 0; // position in output buffer
static int Verbosity = 0; static int Verbosity = 0;
skipping to change at line 1197 skipping to change at line 1195
} }
/* /*
********************************************************* *********************************************************
Function works in single pass. It's Splitting long Function works in single pass. It's Splitting long
streams into sequences of multiple segments. streams into sequences of multiple segments.
*/ */
int producer_decompress(int hInfile, OFF_T fileSize, queue *fifo) int producer_decompress(int hInfile, OFF_T fileSize, queue *fifo)
{ {
safe_mutex_lock(&ProgressIndicatorsMutex); safe_mutex_lock(&ProgressIndicatorsMutex);
InBytesProduced = 0;
NumBlocks = 0; NumBlocks = 0;
safe_mutex_unlock(&ProgressIndicatorsMutex); safe_mutex_unlock(&ProgressIndicatorsMutex);
pbzip2::BZ2StreamScanner bz2StreamScanner(hInfile); pbzip2::BZ2StreamScanner bz2StreamScanner(hInfile);
// keep going until all the blocks are processed // keep going until all the blocks are processed
outBuff * fileData = bz2StreamScanner.getNextStream(); outBuff * fileData = bz2StreamScanner.getNextStream();
while (!bz2StreamScanner.failed() && (fileData->bufSize > 0)) while (!bz2StreamScanner.failed() && (fileData->bufSize > 0))
{ {
#ifdef PBZIP_DEBUG #ifdef PBZIP_DEBUG
skipping to change at line 1257 skipping to change at line 1254
} }
#ifdef PBZIP_DEBUG #ifdef PBZIP_DEBUG
fprintf(stderr, "producer: Buffer: %p Size: %"PRIuMAX" Block: %d\n", fileData->buf, fprintf(stderr, "producer: Buffer: %p Size: %"PRIuMAX" Block: %d\n", fileData->buf,
(uintmax_t)fileData->bufSize, NumBlocks); (uintmax_t)fileData->bufSize, NumBlocks);
#endif #endif
fifo->add(fileData); fifo->add(fileData);
safe_cond_signal (fifo->notEmpty); safe_cond_signal (fifo->notEmpty);
safe_mutex_lock(&ProgressIndicatorsMutex); safe_mutex_lock(&ProgressIndicatorsMutex);
InBytesProduced += fileData->bufSize;
NumBlocks = fileData->blockNumber + 1; NumBlocks = fileData->blockNumber + 1;
safe_mutex_unlock(&ProgressIndicatorsMutex); safe_mutex_unlock(&ProgressIndicatorsMutex);
safe_mutex_unlock(fifo->mut); safe_mutex_unlock(fifo->mut);
fileData = bz2StreamScanner.getNextStream(); fileData = bz2StreamScanner.getNextStream();
} // for } // for
close(hInfile); close(hInfile);
skipping to change at line 2083 skipping to change at line 2079
close(hOutfile); close(hOutfile);
if (QuietMode != 1) if (QuietMode != 1)
{ {
fprintf(stderr, " Output Size: %"PRIuMAX" bytes\n", (uintmax_t )CompressedSize); fprintf(stderr, " Output Size: %"PRIuMAX" bytes\n", (uintmax_t )CompressedSize);
} }
syncSetProducerDone(1); // Not really needed for direct version syncSetProducerDone(1); // Not really needed for direct version
return 0; return 0;
} }
void close_streams(FILE *out, FILE *in)
{
if (out != NULL) {
fflush(out);
}
if (in != NULL && in != stdin) {
fclose(in);
}
if (out != NULL && out != stdout) {
fclose(out);
}
}
/* /*
********************************************************* *********************************************************
*/ */
int directdecompress(const char *InFilename, const char *OutFilename) int directdecompress(const char *InFilename, const char *OutFilename)
{ {
FILE *stream = NULL; FILE *stream = NULL;
FILE *zStream = NULL; FILE *zStream = NULL;
BZFILE* bzf = NULL; BZFILE* bzf = NULL;
unsigned char obuf[5000]; unsigned char obuf[5000];
unsigned char unused[BZ_MAX_UNUSED]; unsigned char unused[BZ_MAX_UNUSED];
skipping to change at line 2125 skipping to change at line 2136
{ {
#ifdef WIN32 #ifdef WIN32
setmode(fileno(stdin), O_BINARY); setmode(fileno(stdin), O_BINARY);
#endif #endif
zStream = stdin; zStream = stdin;
} }
// check file stream for errors // check file stream for errors
if (ferror(zStream)) if (ferror(zStream))
{ {
if (zStream != stdin) close_streams(stream, zStream);
fclose(zStream);
handle_error(EF_EXIT, -1, handle_error(EF_EXIT, -1,
"pbzip2: *ERROR: Problem with input stream of fil e [%s]! Aborting...\n", InFilename); "pbzip2: *ERROR: Problem with input stream of fil e [%s]! Aborting...\n", InFilename);
return -1; return -1;
} }
// see if we are outputting to stdout // see if we are outputting to stdout
if (OutputStdOut == 0) if (OutputStdOut == 0)
{ {
stream = safe_fopen_output(OutFilename, "wb"); stream = safe_fopen_output(OutFilename, "wb");
if (stream == NULL) if (stream == NULL)
skipping to change at line 2155 skipping to change at line 2164
{ {
#ifdef WIN32 #ifdef WIN32
setmode(fileno(stdout), O_BINARY); setmode(fileno(stdout), O_BINARY);
#endif #endif
stream = stdout; stream = stdout;
} }
// check file stream for errors // check file stream for errors
if (ferror(stream)) if (ferror(stream))
{ {
if (stream != stdout) close_streams(stream, zStream);
fclose(stream);
handle_error(EF_EXIT, -1, handle_error(EF_EXIT, -1,
"pbzip2: *ERROR: Problem with output stream of fi le [%s]! Aborting...\n", InFilename); "pbzip2: *ERROR: Problem with output stream of fi le [%s]! Aborting...\n", InFilename);
return -1; return -1;
} }
// loop until end of file // loop until end of file
while(true) while(true)
{ {
if (syncGetTerminateFlag() != 0) if (syncGetTerminateFlag() != 0)
{ {
fprintf (stderr, "directdecompress: terminating1 - termin ateFlag set\n"); fprintf (stderr, "directdecompress: terminating1 - termin ateFlag set\n");
if (zStream != stdin) close_streams(stream, zStream);
fclose(zStream);
if (stream != stdout)
fclose(stream);
return -1; return -1;
} }
bzf = BZ2_bzReadOpen(&bzerr, zStream, Verbosity, 0, unused, nUnus ed); bzf = BZ2_bzReadOpen(&bzerr, zStream, Verbosity, 0, unused, nUnus ed);
if (bzf == NULL || bzerr != BZ_OK) if (bzf == NULL || bzerr != BZ_OK)
{ {
ret = testBZ2ErrorHandling(bzerr, bzf, streamNo); ret = testBZ2ErrorHandling(bzerr, bzf, streamNo);
if (zStream != stdin) close_streams(stream, zStream);
fclose(zStream);
if (stream != stdout)
fclose(stream);
if (ret != 0) if (ret != 0)
{ {
syncSetTerminateFlag(1); syncSetTerminateFlag(1);
} }
return ret; return ret;
} }
streamNo++; streamNo++;
while (bzerr == BZ_OK) while (bzerr == BZ_OK)
{ {
if (syncGetTerminateFlag() != 0) if (syncGetTerminateFlag() != 0)
{ {
fprintf (stderr, "directdecompress: terminating2 - terminateFlag set\n"); fprintf (stderr, "directdecompress: terminating2 - terminateFlag set\n");
if (zStream != stdin) close_streams(stream, zStream);
fclose(zStream);
if (stream != stdout)
fclose(stream);
return -1; return -1;
} }
nread = BZ2_bzRead(&bzerr, bzf, obuf, sizeof(obuf)); nread = BZ2_bzRead(&bzerr, bzf, obuf, sizeof(obuf));
if (bzerr == BZ_DATA_ERROR_MAGIC) if (bzerr == BZ_DATA_ERROR_MAGIC)
{ {
// try alternate way of reading data // try alternate way of reading data
if (ForceOverwrite == 1) if (ForceOverwrite == 1)
{ {
rewind(zStream); rewind(zStream);
skipping to change at line 2225 skipping to change at line 2223
{ {
int c = fgetc(zStream); int c = fgetc(zStream);
if (c == EOF) if (c == EOF)
break; break;
ungetc(c,zStream); ungetc(c,zStream);
nread = fread(obuf, sizeof(unsign ed char), sizeof(obuf), zStream ); nread = fread(obuf, sizeof(unsign ed char), sizeof(obuf), zStream );
if (ferror(zStream)) if (ferror(zStream))
{ {
ret = testBZ2ErrorHandlin g(bzerr, bzf, streamNo); ret = testBZ2ErrorHandlin g(bzerr, bzf, streamNo);
if (zStream != stdin) close_streams(stream, zSt
fclose(zStream); ream);
if (stream != stdout)
fclose(stream);
if (ret != 0) if (ret != 0)
{ {
syncSetTerminateF lag(1); syncSetTerminateF lag(1);
} }
return ret; return ret;
} }
if (nread > 0) if (nread > 0)
(void) fwrite (obuf, size of(unsigned char), nread, stream); (void) fwrite (obuf, size of(unsigned char), nread, stream);
if (ferror(stream)) if (ferror(stream))
{ {
ret = testBZ2ErrorHandlin g(bzerr, bzf, streamNo); ret = testBZ2ErrorHandlin g(bzerr, bzf, streamNo);
if (zStream != stdin) close_streams(stream, zSt
fclose(zStream); ream);
if (stream != stdout)
fclose(stream);
if (ret != 0) if (ret != 0)
{ {
syncSetTerminateF lag(1); syncSetTerminateF lag(1);
} }
return ret; return ret;
} }
} }
goto closeok; goto closeok;
} }
} }
if ((bzerr == BZ_OK || bzerr == BZ_STREAM_END) && nread > 0) if ((bzerr == BZ_OK || bzerr == BZ_STREAM_END) && nread > 0)
(void) fwrite(obuf, sizeof(unsigned char), nread, stream ); (void) fwrite(obuf, sizeof(unsigned char), nread, stream );
if (ferror(stream)) if (ferror(stream))
{ {
ret = testBZ2ErrorHandling(bzerr, bzf, streamNo); ret = testBZ2ErrorHandling(bzerr, bzf, streamNo);
if (zStream != stdin) close_streams(stream, zStream);
fclose(zStream);
if (stream != stdout)
fclose(stream);
if (ret != 0) if (ret != 0)
{ {
syncSetTerminateFlag(1); syncSetTerminateFlag(1);
} }
return ret; return ret;
} }
} }
if (bzerr != BZ_STREAM_END) if (bzerr != BZ_STREAM_END)
{ {
ret = testBZ2ErrorHandling(bzerr, bzf, streamNo); ret = testBZ2ErrorHandling(bzerr, bzf, streamNo);
if (zStream != stdin) close_streams(stream, zStream);
fclose(zStream);
if (stream != stdout)
fclose(stream);
if (ret != 0) if (ret != 0)
{ {
syncSetTerminateFlag(1); syncSetTerminateFlag(1);
} }
return ret; return ret;
} }
BZ2_bzReadGetUnused(&bzerr, bzf, (void**)(&unusedTmp), &nUnused); BZ2_bzReadGetUnused(&bzerr, bzf, (void**)(&unusedTmp), &nUnused);
if (bzerr != BZ_OK) if (bzerr != BZ_OK)
skipping to change at line 2416 skipping to change at line 2402
int ret = 0; int ret = 0;
// int pret = -1; // int pret = -1;
// We will now totally ignore the fileSize and read the data as it // We will now totally ignore the fileSize and read the data as it
// comes in. Aside from allowing us to process arbitrary streams, it's // comes in. Aside from allowing us to process arbitrary streams, it's
// also the *right thing to do* in unix environments where data may // also the *right thing to do* in unix environments where data may
// be appended to the file as it's processed (e.g. log files). // be appended to the file as it's processed (e.g. log files).
safe_mutex_lock(&ProgressIndicatorsMutex); safe_mutex_lock(&ProgressIndicatorsMutex);
NumBlocks = 0; NumBlocks = 0;
InBytesProduced = 0;
safe_mutex_unlock(&ProgressIndicatorsMutex); safe_mutex_unlock(&ProgressIndicatorsMutex);
// keep going until all the file is processed // keep going until all the file is processed
while (1) while (1)
{ {
if (syncGetTerminateFlag() != 0) if (syncGetTerminateFlag() != 0)
{ {
close(hInfile); close(hInfile);
return -1; return -1;
} }
skipping to change at line 2510 skipping to change at line 2495
close(hInfile); close(hInfile);
handle_error(EF_EXIT, -1, "pbzip2: *ERROR: Could not allo cate memory (queueElement)! Aborting...\n"); handle_error(EF_EXIT, -1, "pbzip2: *ERROR: Could not allo cate memory (queueElement)! Aborting...\n");
return -1; return -1;
} }
fifo->add(queueElement); fifo->add(queueElement);
safe_cond_signal(fifo->notEmpty); safe_cond_signal(fifo->notEmpty);
safe_mutex_lock(&ProgressIndicatorsMutex); safe_mutex_lock(&ProgressIndicatorsMutex);
++NumBlocks; ++NumBlocks;
InBytesProduced += inSize;
safe_mutex_unlock(&ProgressIndicatorsMutex); safe_mutex_unlock(&ProgressIndicatorsMutex);
safe_mutex_unlock(fifo->mut); safe_mutex_unlock(fifo->mut);
} // while } // while
close(hInfile); close(hInfile);
syncSetProducerDone(1); syncSetProducerDone(1);
safe_mutex_lock(fifo->mut); safe_mutex_lock(fifo->mut);
safe_cond_broadcast(fifo->notEmpty); // just in case safe_cond_broadcast(fifo->notEmpty); // just in case
skipping to change at line 2692 skipping to change at line 2676
ProducerDoneMutex = NULL; ProducerDoneMutex = NULL;
} }
} }
/* /*
********************************************************* *********************************************************
*/ */
queue *queueInit(int queueSize) queue *queueInit(int queueSize)
{ {
queue *q; queue *q;
QUEUESIZE = queueSize;
q = new(std::nothrow) queue; q = new(std::nothrow) queue;
if (q == NULL) if (q == NULL)
return NULL; return NULL;
q->qData = new(std::nothrow) queue::ElementTypePtr[queueSize]; q->qData = new(std::nothrow) queue::ElementTypePtr[queueSize];
if (q->qData == NULL) if (q->qData == NULL)
return NULL; return NULL;
skipping to change at line 3221 skipping to change at line 3204
ncpu = 1; ncpu = 1;
return ncpu; return ncpu;
} }
/* /*
********************************************************* *********************************************************
*/ */
void banner() void banner()
{ {
fprintf(stderr, "Parallel BZIP2 v1.1.12 [Dec 21, 2014]\n"); fprintf(stderr, "Parallel BZIP2 v1.1.13 [Dec 18, 2015]\n");
fprintf(stderr, "By: Jeff Gilchrist [http://compression.ca]\n"); fprintf(stderr, "By: Jeff Gilchrist [http://compression.ca]\n");
fprintf(stderr, "Major contributions: Yavor Nikolov [http://javornikolov. wordpress.com]\n"); fprintf(stderr, "Major contributions: Yavor Nikolov [http://javornikolov. wordpress.com]\n");
fprintf(stderr, "Uses libbzip2 by Julian Seward\n"); fprintf(stderr, "Uses libbzip2 by Julian Seward\n");
return; return;
} }
/* /*
********************************************************* *********************************************************
*/ */
skipping to change at line 3295 skipping to change at line 3278
/* /*
********************************************************* *********************************************************
*/ */
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
queue *fifo; queue *fifo;
pthread_t output; pthread_t output;
char **FileList = NULL; char **FileList = NULL;
char *InFilename = NULL; char *InFilename = NULL;
bool hasInFile = false;
char *progName = NULL; char *progName = NULL;
char *progNamePos = NULL; char *progNamePos = NULL;
char bz2Header[] = {"BZh91AY&SY"}; // using 900k block size char bz2Header[] = {"BZh91AY&SY"}; // using 900k block size
std::string outFilename; // [2048]; std::string outFilename; // [2048];
char cmdLineTemp[2048]; char cmdLineTemp[2048];
unsigned char tmpBuff[50]; unsigned char tmpBuff[50];
char stdinFile[2] = {"-"}; char stdinFile[2] = {"-"};
struct timeval tvStartTime; struct timeval tvStartTime;
struct timeval tvStopTime; struct timeval tvStopTime;
#ifndef WIN32 #ifndef WIN32
skipping to change at line 3867 skipping to change at line 3851
producerDone = 0; producerDone = 0;
InFileSize = 0; InFileSize = 0;
NumBlocks = 0; NumBlocks = 0;
switchedMtToSt = false; switchedMtToSt = false;
int errLevelCurrentFile = 0; int errLevelCurrentFile = 0;
ErrorContext::getInstance()->reset(); ErrorContext::getInstance()->reset();
// set input filename // set input filename
InFilename = FileList[fileLoop]; InFilename = FileList[fileLoop];
hasInFile = (strcmp(InFilename, "-") != 0);
// test file for errors if requested // test file for errors if requested
if (testFile != 0) if (testFile != 0)
{ {
if (QuietMode != 1) if (QuietMode != 1)
{ {
fprintf(stderr, " File #: %d of %d\n", fileL oop+1, FileListCount); fprintf(stderr, " File #: %d of %d\n", fileL oop+1, FileListCount);
if (strcmp(InFilename, "-") != 0) if (hasInFile)
fprintf(stderr, " Testing: %s\n", InF ilename); fprintf(stderr, " Testing: %s\n", InF ilename);
else else
fprintf(stderr, " Testing: <stdin>\n" ); fprintf(stderr, " Testing: <stdin>\n" );
} }
ret = testCompressedData(InFilename); ret = testCompressedData(InFilename);
if (ret > 0) if (ret > 0)
return ret; return ret;
else if (ret == 0) else if (ret == 0)
{ {
if (QuietMode != 1) if (QuietMode != 1)
skipping to change at line 3897 skipping to change at line 3882
else else
errLevel = 2; errLevel = 2;
if (QuietMode != 1) if (QuietMode != 1)
fprintf(stderr, "-------------------------------- -----------\n"); fprintf(stderr, "-------------------------------- -----------\n");
continue; continue;
} }
// set ouput filename // set ouput filename
outFilename = std::string(FileList[fileLoop]); outFilename = std::string(FileList[fileLoop]);
if ((decompress == 1) && (strcmp(InFilename, "-") != 0)) if ((decompress == 1) && hasInFile)
{ {
// check if input file is a valid .bz2 compressed file // check if input file is a valid .bz2 compressed file
hInfile = open(InFilename, O_RDONLY | O_BINARY); hInfile = open(InFilename, O_RDONLY | O_BINARY);
// check to see if file exists before processing // check to see if file exists before processing
if (hInfile == -1) if (hInfile == -1)
{ {
ErrorContext::printErrnoMsg(stderr, errno); ErrorContext::printErrnoMsg(stderr, errno);
fprintf(stderr, "pbzip2: *ERROR: File [%s] NOT fo und! Skipping...\n", InFilename); fprintf(stderr, "pbzip2: *ERROR: File [%s] NOT fo und! Skipping...\n", InFilename);
fprintf(stderr, "-------------------------------- -----------\n"); fprintf(stderr, "-------------------------------- -----------\n");
errLevel = 1; errLevel = 1;
skipping to change at line 3997 skipping to change at line 3982
} }
outFilename += bz2Tail; outFilename += bz2Tail;
} }
// setup signal handling filenames // setup signal handling filenames
safe_mutex_lock(&ErrorHandlerMutex); safe_mutex_lock(&ErrorHandlerMutex);
sigInFilename = InFilename; sigInFilename = InFilename;
sigOutFilename = outFilename.c_str(); sigOutFilename = outFilename.c_str();
safe_mutex_unlock(&ErrorHandlerMutex); safe_mutex_unlock(&ErrorHandlerMutex);
if (strcmp(InFilename, "-") != 0) if (hasInFile)
{ {
struct stat statbuf; struct stat statbuf;
// read file for compression // read file for compression
hInfile = open(InFilename, O_RDONLY | O_BINARY); hInfile = open(InFilename, O_RDONLY | O_BINARY);
// check to see if file exists before processing // check to see if file exists before processing
if (hInfile == -1) if (hInfile == -1)
{ {
fprintf(stderr, "pbzip2: *ERROR: File [%s] NOT fo und! Skipping...\n", InFilename); fprintf(stderr, "pbzip2: *ERROR: File [%s] NOT fo und! Skipping...\n", InFilename);
fprintf(stderr, "-------------------------------- -----------\n"); fprintf(stderr, "-------------------------------- -----------\n");
errLevel = 1; errLevel = 1;
skipping to change at line 4113 skipping to change at line 4098
fprintf(stderr, " File #: %d of %d\n", fileLoop+1 , FileListCount); fprintf(stderr, " File #: %d of %d\n", fileLoop+1 , FileListCount);
fprintf(stderr, " Input Name: %s\n", hInfile != STDIN _FILENO ? InFilename : "<stdin>"); fprintf(stderr, " Input Name: %s\n", hInfile != STDIN _FILENO ? InFilename : "<stdin>");
if (OutputStdOut == 0) if (OutputStdOut == 0)
fprintf(stderr, " Output Name: %s\n\n", outFil ename.c_str()); fprintf(stderr, " Output Name: %s\n\n", outFil ename.c_str());
else else
fprintf(stderr, " Output Name: <stdout>\n\n"); fprintf(stderr, " Output Name: <stdout>\n\n");
if (decompress == 1) if (decompress == 1)
fprintf(stderr, " BWT Block Size: %c00k\n", BWTbl ockSizeChar); fprintf(stderr, " BWT Block Size: %c00k\n", BWTbl ockSizeChar);
if (strcmp(InFilename, "-") != 0) if (hasInFile)
fprintf(stderr, " Input Size: %"PRIuMAX" byte s\n", (uintmax_t)InFileSize); fprintf(stderr, " Input Size: %"PRIuMAX" byte s\n", (uintmax_t)InFileSize);
} }
if (decompress == 1) if (decompress == 1)
{ {
numBlocks = 0; numBlocks = 0;
// Do not use threads if we only have 1 CPU or small file s // Do not use threads if we only have 1 CPU or small file s
if ((numCPU == 1) || (InFileSize < 1000000)) if ((numCPU == 1) || (InFileSize < 1000000))
noThreads = 1; noThreads = 1;
else else
noThreads = 0; noThreads = 0;
// Enable threads method for uncompressing from stdin // Enable threads method for uncompressing from stdin
if ((numCPU > 1) && (strcmp(InFilename, "-") == 0)) if ((numCPU > 1) && !hasInFile)
noThreads = 0; noThreads = 0;
} // if (decompress == 1) } // if (decompress == 1)
else else
{ {
if (InFileSize > 0) if (InFileSize > 0)
{ {
// calculate the # of blocks of data // calculate the # of blocks of data
numBlocks = (InFileSize + blockSize - 1) / blockS ize; numBlocks = (InFileSize + blockSize - 1) / blockS ize;
// Do not use threads for small files where we on ly have 1 block to process // Do not use threads for small files where we on ly have 1 block to process
// or if we only have 1 CPU // or if we only have 1 CPU
 End of changes. 25 change blocks. 
47 lines changed or deleted 34 lines changed or added

Home  |  About  |  All  |  Newest  |  Fossies Dox  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTPS