datagencli uses mem.h
This commit is contained in:
@@ -59,7 +59,6 @@
|
|||||||
typedef BYTE litDistribTable[LTSIZE];
|
typedef BYTE litDistribTable[LTSIZE];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*-*******************************************************
|
/*-*******************************************************
|
||||||
* Local Functions
|
* Local Functions
|
||||||
*********************************************************/
|
*********************************************************/
|
||||||
|
|||||||
+18
-62
@@ -24,39 +24,17 @@
|
|||||||
- Public forum : https://groups.google.com/forum/#!forum/lz4c
|
- Public forum : https://groups.google.com/forum/#!forum/lz4c
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**************************************
|
/*-************************************
|
||||||
* Includes
|
* Includes
|
||||||
**************************************/
|
**************************************/
|
||||||
#include <stdio.h> /* fprintf, stderr */
|
#include <stdio.h> /* fprintf, stderr */
|
||||||
|
#include "mem.h"
|
||||||
#include "datagen.h" /* RDG_generate */
|
#include "datagen.h" /* RDG_generate */
|
||||||
|
|
||||||
|
|
||||||
/**************************************
|
/*-************************************
|
||||||
* Basic Types
|
|
||||||
**************************************/
|
|
||||||
#if defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */
|
|
||||||
# include <stdint.h>
|
|
||||||
typedef uint8_t BYTE;
|
|
||||||
typedef uint16_t U16;
|
|
||||||
typedef uint32_t U32;
|
|
||||||
typedef int32_t S32;
|
|
||||||
typedef uint64_t U64;
|
|
||||||
#else
|
|
||||||
typedef unsigned char BYTE;
|
|
||||||
typedef unsigned short U16;
|
|
||||||
typedef unsigned int U32;
|
|
||||||
typedef signed int S32;
|
|
||||||
typedef unsigned long long U64;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/**************************************
|
|
||||||
* Constants
|
* Constants
|
||||||
**************************************/
|
**************************************/
|
||||||
#ifndef ZSTD_VERSION
|
|
||||||
# define ZSTD_VERSION "r1"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define KB *(1 <<10)
|
#define KB *(1 <<10)
|
||||||
#define MB *(1 <<20)
|
#define MB *(1 <<20)
|
||||||
#define GB *(1U<<30)
|
#define GB *(1U<<30)
|
||||||
@@ -66,7 +44,7 @@
|
|||||||
#define COMPRESSIBILITY_DEFAULT 50
|
#define COMPRESSIBILITY_DEFAULT 50
|
||||||
|
|
||||||
|
|
||||||
/**************************************
|
/*-************************************
|
||||||
* Macros
|
* Macros
|
||||||
**************************************/
|
**************************************/
|
||||||
#define DISPLAY(...) fprintf(stderr, __VA_ARGS__)
|
#define DISPLAY(...) fprintf(stderr, __VA_ARGS__)
|
||||||
@@ -74,10 +52,10 @@
|
|||||||
static unsigned displayLevel = 2;
|
static unsigned displayLevel = 2;
|
||||||
|
|
||||||
|
|
||||||
/*********************************************************
|
/*-*******************************************************
|
||||||
* Command line
|
* Command line
|
||||||
*********************************************************/
|
*********************************************************/
|
||||||
static int usage(char* programName)
|
static int usage(const char* programName)
|
||||||
{
|
{
|
||||||
DISPLAY( "Compressible data generator\n");
|
DISPLAY( "Compressible data generator\n");
|
||||||
DISPLAY( "Usage :\n");
|
DISPLAY( "Usage :\n");
|
||||||
@@ -92,29 +70,26 @@ static int usage(char* programName)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, const char** argv)
|
||||||
{
|
{
|
||||||
int argNb;
|
int argNb;
|
||||||
double proba = (double)COMPRESSIBILITY_DEFAULT / 100;
|
double proba = (double)COMPRESSIBILITY_DEFAULT / 100;
|
||||||
double litProba = 0.0;
|
double litProba = 0.0;
|
||||||
U64 size = SIZE_DEFAULT;
|
U64 size = SIZE_DEFAULT;
|
||||||
U32 seed = SEED_DEFAULT;
|
U32 seed = SEED_DEFAULT;
|
||||||
char* programName;
|
const char* programName;
|
||||||
|
|
||||||
/* Check command line */
|
/* Check command line */
|
||||||
programName = argv[0];
|
programName = argv[0];
|
||||||
for(argNb=1; argNb<argc; argNb++)
|
for(argNb=1; argNb<argc; argNb++) {
|
||||||
{
|
const char* argument = argv[argNb];
|
||||||
char* argument = argv[argNb];
|
|
||||||
|
|
||||||
if(!argument) continue; /* Protection if argument empty */
|
if(!argument) continue; /* Protection if argument empty */
|
||||||
|
|
||||||
/* Handle commands. Aggregated commands are allowed */
|
/* Handle commands. Aggregated commands are allowed */
|
||||||
if (*argument=='-')
|
if (*argument=='-') {
|
||||||
{
|
|
||||||
argument++;
|
argument++;
|
||||||
while (*argument!=0)
|
while (*argument!=0) {
|
||||||
{
|
|
||||||
switch(*argument)
|
switch(*argument)
|
||||||
{
|
{
|
||||||
case 'h':
|
case 'h':
|
||||||
@@ -123,11 +98,7 @@ int main(int argc, char** argv)
|
|||||||
argument++;
|
argument++;
|
||||||
size=0;
|
size=0;
|
||||||
while ((*argument>='0') && (*argument<='9'))
|
while ((*argument>='0') && (*argument<='9'))
|
||||||
{
|
size *= 10, size += *argument++ - '0';
|
||||||
size *= 10;
|
|
||||||
size += *argument - '0';
|
|
||||||
argument++;
|
|
||||||
}
|
|
||||||
if (*argument=='K') { size <<= 10; argument++; }
|
if (*argument=='K') { size <<= 10; argument++; }
|
||||||
if (*argument=='M') { size <<= 20; argument++; }
|
if (*argument=='M') { size <<= 20; argument++; }
|
||||||
if (*argument=='G') { size <<= 30; argument++; }
|
if (*argument=='G') { size <<= 30; argument++; }
|
||||||
@@ -137,21 +108,13 @@ int main(int argc, char** argv)
|
|||||||
argument++;
|
argument++;
|
||||||
seed=0;
|
seed=0;
|
||||||
while ((*argument>='0') && (*argument<='9'))
|
while ((*argument>='0') && (*argument<='9'))
|
||||||
{
|
seed *= 10, seed += *argument++ - '0';
|
||||||
seed *= 10;
|
|
||||||
seed += *argument - '0';
|
|
||||||
argument++;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case 'P':
|
case 'P':
|
||||||
argument++;
|
argument++;
|
||||||
proba=0.0;
|
proba=0.0;
|
||||||
while ((*argument>='0') && (*argument<='9'))
|
while ((*argument>='0') && (*argument<='9'))
|
||||||
{
|
proba *= 10, proba += *argument++ - '0';
|
||||||
proba *= 10;
|
|
||||||
proba += *argument - '0';
|
|
||||||
argument++;
|
|
||||||
}
|
|
||||||
if (proba>100.) proba=100.;
|
if (proba>100.) proba=100.;
|
||||||
proba /= 100.;
|
proba /= 100.;
|
||||||
break;
|
break;
|
||||||
@@ -159,11 +122,7 @@ int main(int argc, char** argv)
|
|||||||
argument++;
|
argument++;
|
||||||
litProba=0.;
|
litProba=0.;
|
||||||
while ((*argument>='0') && (*argument<='9'))
|
while ((*argument>='0') && (*argument<='9'))
|
||||||
{
|
litProba *= 10, litProba += *argument++ - '0';
|
||||||
litProba *= 10;
|
|
||||||
litProba += *argument - '0';
|
|
||||||
argument++;
|
|
||||||
}
|
|
||||||
if (litProba>100.) litProba=100.;
|
if (litProba>100.) litProba=100.;
|
||||||
litProba /= 100.;
|
litProba /= 100.;
|
||||||
break;
|
break;
|
||||||
@@ -174,12 +133,9 @@ int main(int argc, char** argv)
|
|||||||
default:
|
default:
|
||||||
return usage(programName);
|
return usage(programName);
|
||||||
}
|
}
|
||||||
}
|
} } } /* for(argNb=1; argNb<argc; argNb++) */
|
||||||
|
|
||||||
}
|
DISPLAYLEVEL(4, "Data Generator \n");
|
||||||
}
|
|
||||||
|
|
||||||
DISPLAYLEVEL(4, "Data Generator %s \n", ZSTD_VERSION);
|
|
||||||
DISPLAYLEVEL(3, "Seed = %u \n", seed);
|
DISPLAYLEVEL(3, "Seed = %u \n", seed);
|
||||||
if (proba!=COMPRESSIBILITY_DEFAULT) DISPLAYLEVEL(3, "Compressibility : %i%%\n", (U32)(proba*100));
|
if (proba!=COMPRESSIBILITY_DEFAULT) DISPLAYLEVEL(3, "Compressibility : %i%%\n", (U32)(proba*100));
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user