diff options
Diffstat (limited to 'programs')
-rw-r--r-- | programs/bench.c | 5 | ||||
-rw-r--r-- | programs/bench.h | 5 | ||||
-rw-r--r-- | programs/lz4cli.c | 45 | ||||
-rw-r--r-- | programs/lz4io.c | 6 |
4 files changed, 17 insertions, 44 deletions
diff --git a/programs/bench.c b/programs/bench.c index 3031725..6db1628 100644 --- a/programs/bench.c +++ b/programs/bench.c @@ -75,11 +75,6 @@ static int LZ4_compress_local(const char* src, char* dst, int size, int clevel) # define S_ISREG(x) (((x) & S_IFMT) == S_IFREG) #endif -// GCC does not support _rotl outside of Windows -#if !defined(_WIN32) -# define _rotl(x,r) ((x << r) | (x >> (32 - r))) -#endif - //************************************** // Basic Types diff --git a/programs/bench.h b/programs/bench.h index 7e59e52..d42df68 100644 --- a/programs/bench.h +++ b/programs/bench.h @@ -17,8 +17,8 @@ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. You can contact the author at : - - LZ4 homepage : http://fastcompression.blogspot.com/p/lz4.html - LZ4 source repository : http://code.google.com/p/lz4/ + - LZ4 public forum : https://group.google.com/forum/#!forum/lz4c */ #pragma once @@ -27,9 +27,10 @@ extern "C" { #endif +/* Main function */ int BMK_benchFile(char** fileNamesTable, int nbFiles, int cLevel); -// Parameters +/* Set Parameters */ void BMK_SetBlocksize(int bsize); void BMK_SetNbIterations(int nbLoops); void BMK_SetPause(void); diff --git a/programs/lz4cli.c b/programs/lz4cli.c index 351de80..6f62095 100644 --- a/programs/lz4cli.c +++ b/programs/lz4cli.c @@ -1,6 +1,7 @@ /* - LZ4cli.c - LZ4 Command Line Interface + LZ4cli - LZ4 Command Line Interface Copyright (C) Yann Collet 2011-2014 + GPL v2 License This program is free software; you can redistribute it and/or modify @@ -55,13 +56,9 @@ // Includes //**************************** #include <stdio.h> // fprintf, fopen, fread, _fileno, stdin, stdout -#include <stdlib.h> // malloc +#include <stdlib.h> // exit, calloc, free #include <string.h> // strcmp, strlen -#include <time.h> // clock -#include "lz4.h" -#include "lz4hc.h" -#include "xxhash.h" -#include "bench.h" +#include "bench.h" // BMK_benchFile, BMK_SetNbIterations, BMK_SetBlocksize, BMK_SetPause #include "lz4io.h" @@ -83,30 +80,10 @@ #endif -//************************************** -// Compiler-specific functions -//************************************** -#define GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__) - -#if defined(_MSC_VER) // Visual Studio -# define swap32 _byteswap_ulong -#elif (GCC_VERSION >= 403) || defined(__clang__) -# define swap32 __builtin_bswap32 -#else - static inline unsigned int swap32(unsigned int x) - { - return ((x << 24) & 0xff000000 ) | - ((x << 8) & 0x00ff0000 ) | - ((x >> 8) & 0x0000ff00 ) | - ((x >> 24) & 0x000000ff ); - } -#endif - - //**************************** // Constants //**************************** -#define COMPRESSOR_NAME "LZ4 Compression CLI" +#define COMPRESSOR_NAME "LZ4 command line interface" #ifndef LZ4_VERSION # define LZ4_VERSION "r125" #endif @@ -125,15 +102,15 @@ //************************************** // Macros //************************************** -#define DISPLAY(...) fprintf(stderr, __VA_ARGS__) -#define DISPLAYLEVEL(l, ...) if (displayLevel>=l) { DISPLAY(__VA_ARGS__); } +#define DISPLAY(...) fprintf(stderr, __VA_ARGS__) +#define DISPLAYLEVEL(l, ...) if (displayLevel>=l) { DISPLAY(__VA_ARGS__); } +static unsigned displayLevel = 2; // 0 : no display // 1: errors // 2 : + result + interaction + warnings ; // 3 : + progression; // 4 : + information //************************************** -// Local Parameters +// Local Variables //************************************** static char* programName; -static int displayLevel = 2; // 0 : no display // 1: errors // 2 : + result + interaction + warnings ; // 3 : + progression; // 4 : + information //************************************** @@ -196,7 +173,7 @@ int usage_advanced(void) DISPLAY( " -l : compress using Legacy format (Linux kernel compression)\n"); DISPLAY( " -B# : Block size [4-7](default : 7)\n"); DISPLAY( " -BD : Block dependency (improve compression ratio)\n"); - DISPLAY( " -BX : enable block checksum (default:disabled)\n"); + //DISPLAY( " -BX : enable block checksum (default:disabled)\n"); // Option currently inactive DISPLAY( " -Sx : disable stream checksum (default:enabled)\n"); DISPLAY( "Benchmark arguments :\n"); DISPLAY( " -b : benchmark file(s)\n"); @@ -508,7 +485,7 @@ int main(int argc, char** argv) { if (legacy_format) { - DISPLAYLEVEL(3, "! Generating compressed LZ4 using Legacy format (deprecated !) ! \n"); + DISPLAYLEVEL(3, "! Generating compressed LZ4 using Legacy format (deprecated) ! \n"); LZ4IO_compressFilename_Legacy(input_filename, output_filename, cLevel); } else diff --git a/programs/lz4io.c b/programs/lz4io.c index a9c3c97..a886ac7 100644 --- a/programs/lz4io.c +++ b/programs/lz4io.c @@ -134,6 +134,7 @@ static int blockIndependence = 1; static const int minBlockSizeID = 4; static const int maxBlockSizeID = 7; + //************************************** // Exceptions //************************************** @@ -208,9 +209,8 @@ int LZ4IO_setNotificationLevel(int level) static unsigned LZ4IO_GetMilliSpan(clock_t nPrevious) { -#define CLOCKS_PER_MSEC (CLOCKS_PER_SEC/1000) clock_t nCurrent = clock(); - unsigned nSpan = (unsigned)((nCurrent - nPrevious) / CLOCKS_PER_MSEC); + unsigned nSpan = (unsigned)(((nCurrent - nPrevious) * 1000) / CLOCKS_PER_SEC); return nSpan; } @@ -481,7 +481,6 @@ static unsigned long long decodeLegacyStream(FILE* finput, FILE* foutput) unsigned long long filesize = 0; char* in_buff; char* out_buff; - unsigned int blockSize; // Allocate Memory in_buff = (char*)malloc(LZ4_compressBound(LEGACY_BLOCKSIZE)); @@ -493,6 +492,7 @@ static unsigned long long decodeLegacyStream(FILE* finput, FILE* foutput) { int decodeSize; size_t sizeCheck; + unsigned int blockSize; // Block Size sizeCheck = fread(in_buff, 1, 4, finput); |