1
0
mirror of https://github.com/facebook/zstd.git synced 2025-07-29 11:21:22 +03:00

Updated FSE

Added clang and g++ tests
This commit is contained in:
Yann Collet
2015-06-18 07:43:16 -08:00
parent bbfa7d77c9
commit 213089c078
11 changed files with 99 additions and 61 deletions

View File

@ -75,7 +75,7 @@
* Local Functions
*********************************************************/
#define RDG_rotl32(x,r) ((x << r) | (x >> (32 - r)))
static unsigned int RDG_rand(U32* src)
static U32 RDG_rand(U32* src)
{
U32 rand32 = *src;
rand32 *= PRIME1;
@ -88,20 +88,21 @@ static unsigned int RDG_rand(U32* src)
#define LTSIZE 8192
#define LTMASK (LTSIZE-1)
static void* RDG_createLiteralDistrib(double ld)
static void* RDG_createLiteralDistrib(const double ld)
{
BYTE* lt = malloc(LTSIZE);
BYTE* lt = (BYTE*)malloc(LTSIZE);
U32 i = 0;
BYTE character = '0';
BYTE firstChar = '(';
BYTE lastChar = '}';
if (ld==0.0)
if (ld<=0.02)
{
character = 0;
firstChar = 0;
lastChar =255;
lastChar = 254;
character = firstChar;
}
if (ld==0.0) lastChar = 255;
while (i<LTSIZE)
{
U32 weight = (U32)((double)(LTSIZE - i) * ld) + 1;
@ -117,7 +118,7 @@ static void* RDG_createLiteralDistrib(double ld)
static char RDG_genChar(U32* seed, const void* ltctx)
{
const BYTE* lt = ltctx;
const BYTE* lt = (const BYTE*)ltctx;
U32 id = RDG_rand(seed) & LTMASK;
return lt[id];
}