refactor timefn
The timer storage type is no longer dependent on OS. This will make it possible to re-enable posix precise timers since the timer storage type will no longer be sensible to #include order. See #3168 for details of pbs of previous interface. Suggestion by @terrelln
This commit is contained in:
+16
-11
@@ -25,21 +25,13 @@
|
||||
#include "zdict.h"
|
||||
|
||||
/* Direct access to internal compression functions is required */
|
||||
#include "zstd_compress.c" /* ZSTD_resetSeqStore, ZSTD_storeSeq, *_TO_OFFBASE, HIST_countFast_wksp, HIST_isError */
|
||||
#include "compress/zstd_compress.c" /* ZSTD_resetSeqStore, ZSTD_storeSeq, *_TO_OFFBASE, HIST_countFast_wksp, HIST_isError */
|
||||
|
||||
#define XXH_STATIC_LINKING_ONLY
|
||||
#include "xxhash.h" /* XXH64 */
|
||||
|
||||
#ifndef MIN
|
||||
#define MIN(a, b) ((a) < (b) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
#ifndef MAX_PATH
|
||||
#ifdef PATH_MAX
|
||||
#define MAX_PATH PATH_MAX
|
||||
#else
|
||||
#define MAX_PATH 256
|
||||
#endif
|
||||
#if !(defined (__cplusplus) || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */))
|
||||
# define inline /* disable */
|
||||
#endif
|
||||
|
||||
/*-************************************
|
||||
@@ -71,6 +63,7 @@ static UTIL_time_t g_displayClock = UTIL_TIME_INITIALIZER;
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
|
||||
/*-*******************************************************
|
||||
* Random function
|
||||
*********************************************************/
|
||||
@@ -176,6 +169,14 @@ const char* BLOCK_TYPES[] = {"raw", "rle", "compressed"};
|
||||
#define MIN_SEQ_LEN (3)
|
||||
#define MAX_NB_SEQ ((ZSTD_BLOCKSIZE_MAX + MIN_SEQ_LEN - 1) / MIN_SEQ_LEN)
|
||||
|
||||
#ifndef MAX_PATH
|
||||
#ifdef PATH_MAX
|
||||
#define MAX_PATH PATH_MAX
|
||||
#else
|
||||
#define MAX_PATH 256
|
||||
#endif
|
||||
#endif
|
||||
|
||||
BYTE CONTENT_BUFFER[MAX_DECOMPRESSED_SIZE];
|
||||
BYTE FRAME_BUFFER[MAX_DECOMPRESSED_SIZE * 2];
|
||||
BYTE LITERAL_BUFFER[ZSTD_BLOCKSIZE_MAX];
|
||||
@@ -241,6 +242,10 @@ typedef enum {
|
||||
gt_block, /* generate compressed blocks without block/frame headers */
|
||||
} genType_e;
|
||||
|
||||
#ifndef MIN
|
||||
#define MIN(a, b) ((a) < (b) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
/*-*******************************************************
|
||||
* Global variables (set from command line)
|
||||
*********************************************************/
|
||||
|
||||
@@ -32,4 +32,4 @@ size_t zstreamExternalMatchFinder(
|
||||
size_t windowSize
|
||||
);
|
||||
|
||||
#endif // EXTERNAL_MATCHFINDER
|
||||
#endif /* EXTERNAL_MATCHFINDER */
|
||||
|
||||
+11
-11
@@ -476,7 +476,7 @@ static void test_compressBound(unsigned tnb)
|
||||
CHECK_EQ(ZSTD_compressBound(w), ZSTD_COMPRESSBOUND(w));
|
||||
} }
|
||||
|
||||
// Ensure error if srcSize too big
|
||||
/* Ensure error if srcSize too big */
|
||||
{ size_t const w = ZSTD_MAX_INPUT_SIZE + 1;
|
||||
CHECK(ZSTD_isError(ZSTD_compressBound(w))); /* must fail */
|
||||
CHECK_EQ(ZSTD_COMPRESSBOUND(w), 0);
|
||||
@@ -489,7 +489,7 @@ static void test_decompressBound(unsigned tnb)
|
||||
{
|
||||
DISPLAYLEVEL(3, "test%3u : decompressBound : ", tnb);
|
||||
|
||||
// Simple compression, with size : should provide size;
|
||||
/* Simple compression, with size : should provide size; */
|
||||
{ const char example[] = "abcd";
|
||||
char cBuffer[ZSTD_COMPRESSBOUND(sizeof(example))];
|
||||
size_t const cSize = ZSTD_compress(cBuffer, sizeof(cBuffer), example, sizeof(example), 0);
|
||||
@@ -497,7 +497,7 @@ static void test_decompressBound(unsigned tnb)
|
||||
CHECK_EQ(ZSTD_decompressBound(cBuffer, cSize), (unsigned long long)sizeof(example));
|
||||
}
|
||||
|
||||
// Simple small compression without size : should provide 1 block size
|
||||
/* Simple small compression without size : should provide 1 block size */
|
||||
{ char cBuffer[ZSTD_COMPRESSBOUND(0)];
|
||||
ZSTD_outBuffer out = { cBuffer, sizeof(cBuffer), 0 };
|
||||
ZSTD_inBuffer in = { NULL, 0, 0 };
|
||||
@@ -510,14 +510,14 @@ static void test_decompressBound(unsigned tnb)
|
||||
ZSTD_freeCCtx(cctx);
|
||||
}
|
||||
|
||||
// Attempt to overflow 32-bit intermediate multiplication result
|
||||
// This requires dBound >= 4 GB, aka 2^32.
|
||||
// This requires 2^32 / 2^17 = 2^15 blocks
|
||||
// => create 2^15 blocks (can be empty, or just 1 byte).
|
||||
/* Attempt to overflow 32-bit intermediate multiplication result
|
||||
* This requires dBound >= 4 GB, aka 2^32.
|
||||
* This requires 2^32 / 2^17 = 2^15 blocks
|
||||
* => create 2^15 blocks (can be empty, or just 1 byte). */
|
||||
{ const char input[] = "a";
|
||||
size_t const nbBlocks = (1 << 15) + 1;
|
||||
size_t blockNb;
|
||||
size_t const outCapacity = 1 << 18; // large margin
|
||||
size_t const outCapacity = 1 << 18; /* large margin */
|
||||
char* const outBuffer = malloc (outCapacity);
|
||||
ZSTD_outBuffer out = { outBuffer, outCapacity, 0 };
|
||||
ZSTD_CCtx* const cctx = ZSTD_createCCtx();
|
||||
@@ -3535,7 +3535,7 @@ static int basicUnitTests(U32 const seed, double compressibility)
|
||||
|
||||
DISPLAYLEVEL(3, "test%3i : testing bitwise intrinsics PR#3045: ", testNb++);
|
||||
{
|
||||
U32 seed_copy = seed; // need non-const seed to avoid compiler warning for FUZ_rand(&seed)
|
||||
U32 seed_copy = seed; /* need non-const seed to avoid compiler warning for FUZ_rand(&seed) */
|
||||
U32 rand32 = FUZ_rand(&seed_copy);
|
||||
U64 rand64 = ((U64)FUZ_rand(&seed_copy) << 32) | FUZ_rand(&seed_copy);
|
||||
U32 lowbit_only_32 = 1;
|
||||
@@ -3543,8 +3543,8 @@ static int basicUnitTests(U32 const seed, double compressibility)
|
||||
U32 highbit_only_32 = (U32)1 << 31;
|
||||
U64 highbit_only_64 = (U64)1 << 63;
|
||||
U32 i;
|
||||
if (rand32 == 0) rand32 = 1; // CLZ and CTZ are undefined on 0
|
||||
if (rand64 == 0) rand64 = 1; // CLZ and CTZ are undefined on 0
|
||||
if (rand32 == 0) rand32 = 1; /* CLZ and CTZ are undefined on 0 */
|
||||
if (rand64 == 0) rand64 = 1; /* CLZ and CTZ are undefined on 0 */
|
||||
|
||||
/* Test ZSTD_countTrailingZeros32 */
|
||||
CHECK_EQ(ZSTD_countTrailingZeros32(lowbit_only_32), 0u);
|
||||
|
||||
Reference in New Issue
Block a user