Skip to content

Commit 83d0c76

Browse files
committed
added several compilation flags
1 parent bd1964a commit 83d0c76

File tree

7 files changed

+33
-24
lines changed

7 files changed

+33
-24
lines changed

examples/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ clean:
4646
simple_compression simple_decompression \
4747
dictionary_compression dictionary_decompression \
4848
streaming_compression streaming_decompression \
49-
multiple_streaming_compression
49+
multiple_streaming_compression
5050
@echo Cleaning completed
5151

5252
test: all

lib/Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ CPPFLAGS+= -I. -I./common -DXXH_NAMESPACE=ZSTD_
2424
CFLAGS ?= -O3
2525
DEBUGFLAGS = -Wall -Wextra -Wcast-qual -Wcast-align -Wshadow \
2626
-Wstrict-aliasing=1 -Wswitch-enum -Wdeclaration-after-statement \
27-
-Wstrict-prototypes -Wundef -Wpointer-arith -Wformat-security
27+
-Wstrict-prototypes -Wundef -Wpointer-arith -Wformat-security \
28+
-Wvla -Wformat=2 -Winit-self -Wfloat-equal -Wwrite-strings \
29+
-Wbad-function-cast -Wredundant-decls
2830
CFLAGS += $(DEBUGFLAGS) $(MOREFLAGS)
2931
FLAGS = $(CPPFLAGS) $(CFLAGS)
3032

programs/Makefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ CPPFLAGS+= -I$(ZSTDDIR) -I$(ZSTDDIR)/common -I$(ZSTDDIR)/compress \
4343
CFLAGS ?= -O3
4444
DEBUGFLAGS = -Wall -Wextra -Wcast-qual -Wcast-align -Wshadow \
4545
-Wstrict-aliasing=1 -Wswitch-enum -Wdeclaration-after-statement \
46-
-Wstrict-prototypes -Wundef -Wpointer-arith -Wformat-security
46+
-Wstrict-prototypes -Wundef -Wpointer-arith -Wformat-security \
47+
-Wvla -Wformat=2 -Winit-self -Wfloat-equal -Wwrite-strings \
48+
-Wbad-function-cast -Wredundant-decls
4749
CFLAGS += $(DEBUGFLAGS) $(MOREFLAGS)
4850
FLAGS = $(CPPFLAGS) $(CFLAGS) $(LDFLAGS)
4951

@@ -56,7 +58,7 @@ ZDICT_FILES := $(ZSTDDIR)/dictBuilder/*.c
5658
ZSTDDECOMP_O = $(ZSTDDIR)/decompress/zstd_decompress.o
5759

5860
ZSTD_LEGACY_SUPPORT ?= 4
59-
ZSTDLEGACY_FILES:=
61+
ZSTDLEGACY_FILES :=
6062
ifneq ($(ZSTD_LEGACY_SUPPORT), 0)
6163
ifeq ($(shell test $(ZSTD_LEGACY_SUPPORT) -lt 8; echo $$?), 0)
6264
ZSTDLEGACY_FILES += $(shell ls $(ZSTDDIR)/legacy/*.c | grep 'v0[$(ZSTD_LEGACY_SUPPORT)-7]')

tests/Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ CPPFLAGS+= -I$(ZSTDDIR) -I$(ZSTDDIR)/common -I$(ZSTDDIR)/compress \
3333
CFLAGS ?= -O3
3434
CFLAGS += -Wall -Wextra -Wcast-qual -Wcast-align -Wshadow \
3535
-Wstrict-aliasing=1 -Wswitch-enum -Wdeclaration-after-statement \
36-
-Wstrict-prototypes -Wundef -Wformat-security
36+
-Wstrict-prototypes -Wundef -Wformat-security \
37+
-Wvla -Wformat=2 -Winit-self -Wfloat-equal -Wwrite-strings \
38+
-Wbad-function-cast -Wredundant-decls
3739
CFLAGS += $(MOREFLAGS)
3840
FLAGS = $(CPPFLAGS) $(CFLAGS) $(LDFLAGS)
3941

tests/datagencli.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,16 @@ static int usage(const char* programName)
4848
DISPLAY( "Arguments :\n");
4949
DISPLAY( " -g# : generate # data (default:%i)\n", SIZE_DEFAULT);
5050
DISPLAY( " -s# : Select seed (default:%i)\n", SEED_DEFAULT);
51-
DISPLAY( " -P# : Select compressibility in %% (default:%i%%)\n", COMPRESSIBILITY_DEFAULT);
51+
DISPLAY( " -P# : Select compressibility in %% (default:%i%%)\n",
52+
COMPRESSIBILITY_DEFAULT);
5253
DISPLAY( " -h : display help and exit\n");
5354
return 0;
5455
}
5556

5657

5758
int main(int argc, const char** argv)
5859
{
59-
double proba = (double)COMPRESSIBILITY_DEFAULT / 100;
60+
unsigned probaU32 = COMPRESSIBILITY_DEFAULT;
6061
double litProba = 0.0;
6162
U64 size = SIZE_DEFAULT;
6263
U32 seed = SEED_DEFAULT;
@@ -94,11 +95,10 @@ int main(int argc, const char** argv)
9495
break;
9596
case 'P':
9697
argument++;
97-
proba=0.0;
98+
probaU32=0.0;
9899
while ((*argument>='0') && (*argument<='9'))
99-
proba *= 10, proba += *argument++ - '0';
100-
if (proba>100.) proba=100.;
101-
proba /= 100.;
100+
probaU32 *= 10, probaU32 += *argument++ - '0';
101+
if (probaU32>100.) probaU32=100.;
102102
break;
103103
case 'L': /* hidden argument : Literal distribution probability */
104104
argument++;
@@ -117,11 +117,12 @@ int main(int argc, const char** argv)
117117
}
118118
} } } /* for(argNb=1; argNb<argc; argNb++) */
119119

120-
DISPLAYLEVEL(4, "Data Generator \n");
120+
DISPLAYLEVEL(4, "Compressible data Generator \n");
121+
if (probaU32!=COMPRESSIBILITY_DEFAULT)
122+
DISPLAYLEVEL(3, "Compressibility : %i%%\n", probaU32);
121123
DISPLAYLEVEL(3, "Seed = %u \n", seed);
122-
if (proba!=COMPRESSIBILITY_DEFAULT) DISPLAYLEVEL(3, "Compressibility : %i%%\n", (U32)(proba*100));
123124

124-
RDG_genStdout(size, proba, litProba, seed);
125+
RDG_genStdout(size, (double)probaU32/100, litProba, seed);
125126
DISPLAYLEVEL(1, "\n");
126127

127128
return 0;

tests/fullbench.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -363,9 +363,8 @@ static size_t benchMem(const void* src, size_t srcSize, U32 benchNb)
363363
for (loopNb = 1; loopNb <= g_nbIterations; loopNb++) {
364364
clock_t const timeLoop = TIMELOOP_S * CLOCKS_PER_SEC;
365365
clock_t clockStart;
366-
U32 nbRounds;
367366
size_t benchResult=0;
368-
double averageTime;
367+
U32 nbRounds;
369368

370369
clockStart = clock();
371370
while (clock() == clockStart);
@@ -374,10 +373,11 @@ static size_t benchMem(const void* src, size_t srcSize, U32 benchNb)
374373
benchResult = benchFunction(dstBuff, dstBuffSize, buff2, src, srcSize);
375374
if (ZSTD_isError(benchResult)) { DISPLAY("ERROR ! %s() => %s !! \n", benchName, ZSTD_getErrorName(benchResult)); exit(1); }
376375
}
377-
averageTime = (((double)BMK_clockSpan(clockStart)) / CLOCKS_PER_SEC) / nbRounds;
378-
if (averageTime < bestTime) bestTime = averageTime;
379-
DISPLAY("%2i- %-30.30s : %7.1f MB/s (%9u)\r", loopNb, benchName, (double)srcSize / (1 MB) / bestTime, (U32)benchResult);
380-
} }
376+
{ clock_t const clockTotal = BMK_clockSpan(clockStart);
377+
double const averageTime = (double)clockTotal / CLOCKS_PER_SEC / nbRounds;
378+
if (averageTime < bestTime) bestTime = averageTime;
379+
DISPLAY("%2i- %-30.30s : %7.1f MB/s (%9u)\r", loopNb, benchName, (double)srcSize / (1 MB) / bestTime, (U32)benchResult);
380+
} } }
381381
DISPLAY("%2u\n", benchNb);
382382

383383
_cleanOut:

tests/paramgrill.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
#define GB *(1ULL<<30)
3939

4040
#define NBLOOPS 2
41-
#define TIMELOOP (2 * CLOCKS_PER_SEC)
41+
#define TIMELOOP (2 * CLOCKS_PER_SEC)
4242

4343
#define NB_LEVELS_TRACKED 30
4444

@@ -47,7 +47,7 @@ static const size_t maxMemory = (sizeof(size_t)==4) ? (2 GB - 64 MB) : (size_t
4747
#define COMPRESSIBILITY_DEFAULT 0.50
4848
static const size_t sampleSize = 10000000;
4949

50-
static const U32 g_grillDuration_s = 60000; /* about 16 hours */
50+
static const double g_grillDuration_s = 90000; /* about 24 hours */
5151
static const clock_t g_maxParamTime = 15 * CLOCKS_PER_SEC;
5252
static const clock_t g_maxVariationTime = 60 * CLOCKS_PER_SEC;
5353
static const int g_maxNbVariations = 64;
@@ -87,9 +87,11 @@ void BMK_SetNbIterations(int nbLoops)
8787
* Private functions
8888
*********************************************************/
8989

90-
static clock_t BMK_clockSpan(clock_t cStart) { return clock() - cStart; } /* works even if overflow ; max span ~ 30 mn */
90+
/* works even if overflow ; max span ~ 30 mn */
91+
static clock_t BMK_clockSpan(clock_t cStart) { return clock() - cStart; }
9192

92-
static U32 BMK_timeSpan(time_t tStart) { return (U32)difftime(time(NULL), tStart); } /* accuracy in seconds only, span can be multiple years */
93+
/* accuracy in seconds only, span can be multiple years */
94+
static double BMK_timeSpan(time_t tStart) { return difftime(time(NULL), tStart); }
9395

9496

9597
static size_t BMK_findMaxMem(U64 requiredMem)

0 commit comments

Comments
 (0)