Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
lz4.c File Reference
#include <stdlib.h>
#include <string.h>
#include "lz4.h"
#include <stdint.h>

Go to the source code of this file.

Classes

struct  _U16_S
 
struct  _U32_S
 
struct  _U64_S
 
struct  refTables
 

Macros

#define MEMORY_USAGE   14
 
#define LZ4_ARCH64   0
 
#define restrict
 
#define GCC_VERSION   (__GNUC__ * 100 + __GNUC_MINOR__)
 
#define lz4_bswap16(x)   ((unsigned short int) ((((x) >> 8) & 0xffu) | (((x) & 0xffu) << 8)))
 
#define expect(expr, value)   (expr)
 
#define likely(expr)   expect((expr) != 0, 1)
 
#define unlikely(expr)   expect((expr) != 0, 0)
 
#define BYTE   uint8_t
 
#define U16   uint16_t
 
#define U32   uint32_t
 
#define S32   int32_t
 
#define U64   uint64_t
 
#define S64   int64_t
 
#define A64(x)   (((U64_S *)(x))->v)
 
#define A32(x)   (((U32_S *)(x))->v)
 
#define A16(x)   (((U16_S *)(x))->v)
 
#define MINMATCH   4
 
#define HASH_LOG   (MEMORY_USAGE-2)
 
#define HASHTABLESIZE   (1 << HASH_LOG)
 
#define HASH_MASK   (HASHTABLESIZE - 1)
 
#define NOTCOMPRESSIBLE_DETECTIONLEVEL   6
 
#define SKIPSTRENGTH   (NOTCOMPRESSIBLE_DETECTIONLEVEL>2?NOTCOMPRESSIBLE_DETECTIONLEVEL:2)
 
#define STACKLIMIT   13
 
#define HEAPMODE   (HASH_LOG>STACKLIMIT)
 
#define COPYLENGTH   8
 
#define LASTLITERALS   5
 
#define MFLIMIT   (COPYLENGTH+MINMATCH)
 
#define MINLENGTH   (MFLIMIT+1)
 
#define MAXD_LOG   16
 
#define MAX_DISTANCE   ((1 << MAXD_LOG) - 1)
 
#define ML_BITS   4
 
#define ML_MASK   ((1U<<ML_BITS)-1)
 
#define RUN_BITS   (8-ML_BITS)
 
#define RUN_MASK   ((1U<<RUN_BITS)-1)
 
#define STEPSIZE   4
 
#define UARCH   U32
 
#define AARCH   A32
 
#define LZ4_COPYSTEP(s, d)   A32(d) = A32(s); d+=4; s+=4;
 
#define LZ4_COPYPACKET(s, d)   LZ4_COPYSTEP(s,d); LZ4_COPYSTEP(s,d);
 
#define LZ4_SECURECOPY   LZ4_WILDCOPY
 
#define HTYPE   const BYTE*
 
#define INITBASE(base)   const int base = 0
 
#define LZ4_READ_LITTLEENDIAN_16(d, s, p)   { d = (s) - A16(p); }
 
#define LZ4_WRITE_LITTLEENDIAN_16(p, v)   { A16(p) = v; p+=2; }
 
#define LZ4_HASH_FUNCTION(i)   (((i) * 2654435761U) >> ((MINMATCH*8)-HASH_LOG))
 
#define LZ4_HASH_VALUE(p)   LZ4_HASH_FUNCTION(A32(p))
 
#define LZ4_WILDCOPY(s, d, e)   do { LZ4_COPYPACKET(s,d) } while (d<e);
 
#define LZ4_BLINDCOPY(s, d, l)   { BYTE* e=(d)+l; LZ4_WILDCOPY(s,d,e); d=e; }
 
#define matchlimit   (iend - LASTLITERALS)
 
#define LZ4_64KLIMIT   ((1<<16) + (MFLIMIT-1))
 
#define HASHLOG64K   (HASH_LOG+1)
 
#define HASH64KTABLESIZE   (1U<<HASHLOG64K)
 
#define LZ4_HASH64K_FUNCTION(i)   (((i) * 2654435761U) >> ((MINMATCH*8)-HASHLOG64K))
 
#define LZ4_HASH64K_VALUE(p)   LZ4_HASH64K_FUNCTION(A32(p))
 
#define matchlimit   (iend - LASTLITERALS)
 

Typedefs

typedef struct _U16_S U16_S
 
typedef struct _U32_S U32_S
 
typedef struct _U64_S U64_S
 

Functions

static int LZ4_NbCommonBytes (register U32 val)
 
static int LZ4_compressCtx (void **ctx, const char *source, char *dest, int inputSize, int maxOutputSize)
 
static int LZ4_compress64kCtx (void **ctx, const char *source, char *dest, int isize, int maxOutputSize)
 
 CORE_EXPORT (int)
 

Macro Definition Documentation

#define A16 (   x)    (((U16_S *)(x))->v)

Definition at line 176 of file lz4.c.

Referenced by LZ4_compress64kCtx(), and LZ4_compressCtx().

#define A32 (   x)    (((U32_S *)(x))->v)

Definition at line 175 of file lz4.c.

Referenced by LZ4_compress64kCtx(), and LZ4_compressCtx().

#define A64 (   x)    (((U64_S *)(x))->v)

Definition at line 174 of file lz4.c.

#define AARCH   A32

Definition at line 221 of file lz4.c.

Referenced by LZ4_compress64kCtx(), and LZ4_compressCtx().

#define BYTE   uint8_t

Definition at line 154 of file lz4.c.

Referenced by LZ4_compress64kCtx(), and LZ4_compressCtx().

#define COPYLENGTH   8

Definition at line 192 of file lz4.c.

#define expect (   expr,
  value 
)    (expr)

Definition at line 127 of file lz4.c.

#define GCC_VERSION   (__GNUC__ * 100 + __GNUC_MINOR__)

Definition at line 104 of file lz4.c.

#define HASH64KTABLESIZE   (1U<<HASHLOG64K)

Definition at line 568 of file lz4.c.

Referenced by LZ4_compress64kCtx().

#define HASH_LOG   (MEMORY_USAGE-2)

Definition at line 184 of file lz4.c.

#define HASH_MASK   (HASHTABLESIZE - 1)

Definition at line 186 of file lz4.c.

#define HASHLOG64K   (HASH_LOG+1)

Definition at line 567 of file lz4.c.

#define HASHTABLESIZE   (1 << HASH_LOG)

Definition at line 185 of file lz4.c.

Referenced by LZ4_compressCtx().

#define HEAPMODE   (HASH_LOG>STACKLIMIT)

Definition at line 191 of file lz4.c.

#define HTYPE   const BYTE*

Definition at line 225 of file lz4.c.

Referenced by LZ4_compressCtx().

#define INITBASE (   base)    const int base = 0

Definition at line 226 of file lz4.c.

Referenced by LZ4_compressCtx().

#define LASTLITERALS   5

Definition at line 193 of file lz4.c.

Referenced by LZ4_compress64kCtx(), and LZ4_compressCtx().

#define likely (   expr)    expect((expr) != 0, 1)

Definition at line 130 of file lz4.c.

Referenced by LZ4_compressCtx().

#define LZ4_64KLIMIT   ((1<<16) + (MFLIMIT-1))

Definition at line 566 of file lz4.c.

Referenced by CORE_EXPORT().

#define LZ4_ARCH64   0

Definition at line 60 of file lz4.c.

Referenced by LZ4_compress64kCtx(), and LZ4_compressCtx().

#define LZ4_BLINDCOPY (   s,
  d,
 
)    { BYTE* e=(d)+l; LZ4_WILDCOPY(s,d,e); d=e; }

Definition at line 251 of file lz4.c.

Referenced by LZ4_compress64kCtx(), and LZ4_compressCtx().

#define lz4_bswap16 (   x)    ((unsigned short int) ((((x) >> 8) & 0xffu) | (((x) & 0xffu) << 8)))

Definition at line 121 of file lz4.c.

#define LZ4_COPYPACKET (   s,
 
)    LZ4_COPYSTEP(s,d); LZ4_COPYSTEP(s,d);

Definition at line 223 of file lz4.c.

#define LZ4_COPYSTEP (   s,
 
)    A32(d) = A32(s); d+=4; s+=4;

Definition at line 222 of file lz4.c.

#define LZ4_HASH64K_FUNCTION (   i)    (((i) * 2654435761U) >> ((MINMATCH*8)-HASHLOG64K))

Definition at line 569 of file lz4.c.

#define LZ4_HASH64K_VALUE (   p)    LZ4_HASH64K_FUNCTION(A32(p))

Definition at line 570 of file lz4.c.

Referenced by LZ4_compress64kCtx().

#define LZ4_HASH_FUNCTION (   i)    (((i) * 2654435761U) >> ((MINMATCH*8)-HASH_LOG))

Definition at line 248 of file lz4.c.

#define LZ4_HASH_VALUE (   p)    LZ4_HASH_FUNCTION(A32(p))

Definition at line 249 of file lz4.c.

Referenced by LZ4_compressCtx().

#define LZ4_READ_LITTLEENDIAN_16 (   d,
  s,
 
)    { d = (s) - A16(p); }

Definition at line 233 of file lz4.c.

#define LZ4_SECURECOPY   LZ4_WILDCOPY

Definition at line 224 of file lz4.c.

#define LZ4_WILDCOPY (   s,
  d,
 
)    do { LZ4_COPYPACKET(s,d) } while (d<e);

Definition at line 250 of file lz4.c.

#define LZ4_WRITE_LITTLEENDIAN_16 (   p,
 
)    { A16(p) = v; p+=2; }

Definition at line 234 of file lz4.c.

Referenced by LZ4_compress64kCtx(), and LZ4_compressCtx().

#define matchlimit   (iend - LASTLITERALS)
#define matchlimit   (iend - LASTLITERALS)
#define MAX_DISTANCE   ((1 << MAXD_LOG) - 1)

Definition at line 198 of file lz4.c.

Referenced by LZ4_compressCtx().

#define MAXD_LOG   16

Definition at line 197 of file lz4.c.

#define MEMORY_USAGE   14

Definition at line 43 of file lz4.c.

#define MFLIMIT   (COPYLENGTH+MINMATCH)

Definition at line 194 of file lz4.c.

Referenced by LZ4_compress64kCtx(), and LZ4_compressCtx().

#define MINLENGTH   (MFLIMIT+1)

Definition at line 195 of file lz4.c.

Referenced by LZ4_compress64kCtx(), and LZ4_compressCtx().

#define MINMATCH   4

Definition at line 182 of file lz4.c.

Referenced by LZ4_compress64kCtx(), and LZ4_compressCtx().

#define ML_BITS   4

Definition at line 200 of file lz4.c.

Referenced by LZ4_compress64kCtx(), and LZ4_compressCtx().

#define ML_MASK   ((1U<<ML_BITS)-1)

Definition at line 201 of file lz4.c.

Referenced by LZ4_compress64kCtx(), and LZ4_compressCtx().

#define NOTCOMPRESSIBLE_DETECTIONLEVEL   6

Definition at line 188 of file lz4.c.

#define restrict

Definition at line 101 of file lz4.c.

#define RUN_BITS   (8-ML_BITS)

Definition at line 202 of file lz4.c.

#define RUN_MASK   ((1U<<RUN_BITS)-1)

Definition at line 203 of file lz4.c.

Referenced by LZ4_compress64kCtx(), and LZ4_compressCtx().

#define S32   int32_t

Definition at line 157 of file lz4.c.

Referenced by LZ4_NbCommonBytes().

#define S64   int64_t

Definition at line 159 of file lz4.c.

#define SKIPSTRENGTH   (NOTCOMPRESSIBLE_DETECTIONLEVEL>2?NOTCOMPRESSIBLE_DETECTIONLEVEL:2)

Definition at line 189 of file lz4.c.

Referenced by LZ4_compress64kCtx(), and LZ4_compressCtx().

#define STACKLIMIT   13

Definition at line 190 of file lz4.c.

#define STEPSIZE   4

Definition at line 219 of file lz4.c.

Referenced by LZ4_compress64kCtx(), and LZ4_compressCtx().

#define U16   uint16_t

Definition at line 155 of file lz4.c.

Referenced by LZ4_compress64kCtx(), and LZ4_compressCtx().

#define U32   uint32_t

Definition at line 156 of file lz4.c.

Referenced by LZ4_compress64kCtx(), LZ4_compressCtx(), and LZ4_NbCommonBytes().

#define U64   uint64_t

Definition at line 158 of file lz4.c.

#define UARCH   U32

Definition at line 220 of file lz4.c.

Referenced by LZ4_compress64kCtx(), and LZ4_compressCtx().

#define unlikely (   expr)    expect((expr) != 0, 0)

Definition at line 131 of file lz4.c.

Referenced by LZ4_compress64kCtx(), and LZ4_compressCtx().

Typedef Documentation

typedef struct _U16_S U16_S
typedef struct _U32_S U32_S
typedef struct _U64_S U64_S

Function Documentation

CORE_EXPORT ( int  )

Definition at line 774 of file lz4.c.

References LZ4_64KLIMIT, LZ4_compress64kCtx(), and LZ4_compressCtx().

static int LZ4_compress64kCtx ( void **  ctx,
const char *  source,
char *  dest,
int  isize,
int  maxOutputSize 
)
static
static int LZ4_compressCtx ( void **  ctx,
const char *  source,
char *  dest,
int  inputSize,
int  maxOutputSize 
)
static
static int LZ4_NbCommonBytes ( register U32  val)
static

Definition at line 298 of file lz4.c.

References S32, and U32.

Referenced by LZ4_compress64kCtx(), and LZ4_compressCtx().