CMSIS2000  0.0.7
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
lz4.c File Reference
#include <stdlib.h>
#include <string.h>
#include "lz4.h"
#include <stdint.h>
Include dependency graph for lz4.c:

Go to the source code of this file.

Data Structures

struct  _U16_S
struct  _U32_S
struct  _U64_S
struct  refTables

Macros

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

Typedefs

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

Functions

int LZ4_compress (const char *source, char *dest, int isize)
static int LZ4_compress64kCtx (void **ctx, const char *source, char *dest, int isize, int maxOutputSize)
int LZ4_compress_limitedOutput (const char *source, char *dest, int isize, int maxOutputSize)
static int LZ4_compressCtx (void **ctx, const char *source, char *dest, int isize, int maxOutputSize)
static int LZ4_NbCommonBytes (register U32 val)
int LZ4_uncompress (const char *source, char *dest, int osize)
int LZ4_uncompress_unknownOutputSize (const char *source, char *dest, int isize, int maxOutputSize)

Macro Definition Documentation

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

Definition at line 171 of file lz4.c.

Referenced by LZ4_compress64kCtx(), and LZ4_compressCtx().

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

Definition at line 169 of file lz4.c.

#define AARCH   A32

Definition at line 222 of file lz4.c.

Referenced by LZ4_compress64kCtx(), and LZ4_compressCtx().

#define BYTE   uint8_t

Definition at line 150 of file lz4.c.

#define COPYLENGTH   8

Definition at line 193 of file lz4.c.

Referenced by LZ4_uncompress(), and LZ4_uncompress_unknownOutputSize().

#define expect (   expr,
  value 
)    (expr)

Definition at line 124 of file lz4.c.

#define GCC_VERSION   (__GNUC__ * 100 + __GNUC_MINOR__)

Definition at line 102 of file lz4.c.

#define HASH64KTABLESIZE   (1U<<HASHLOG64K)

Definition at line 514 of file lz4.c.

Referenced by LZ4_compress64kCtx().

#define HASH_LOG   (MEMORY_USAGE-2)

Definition at line 179 of file lz4.c.

#define HASH_MASK   (HASHTABLESIZE - 1)

Definition at line 181 of file lz4.c.

#define HASHLOG64K   (HASH_LOG+1)

Definition at line 513 of file lz4.c.

#define HASHTABLESIZE   (1 << HASH_LOG)

Definition at line 180 of file lz4.c.

Referenced by LZ4_compressCtx().

#define HEAPMODE   (HASH_LOG>STACKLIMIT)

Definition at line 192 of file lz4.c.

#define HTYPE   const BYTE*

Definition at line 226 of file lz4.c.

Referenced by LZ4_compressCtx().

#define INITBASE (   base)    const int base = 0

Definition at line 227 of file lz4.c.

Referenced by LZ4_compressCtx().

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

Definition at line 127 of file lz4.c.

Referenced by LZ4_compressCtx(), and LZ4_uncompress_unknownOutputSize().

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

Definition at line 512 of file lz4.c.

Referenced by LZ4_compress_limitedOutput().

#define LZ4_ARCH64   0

Definition at line 59 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 254 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 118 of file lz4.c.

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

Definition at line 224 of file lz4.c.

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

Definition at line 223 of file lz4.c.

Referenced by LZ4_uncompress(), and LZ4_uncompress_unknownOutputSize().

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

Definition at line 515 of file lz4.c.

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

Definition at line 516 of file lz4.c.

Referenced by LZ4_compress64kCtx().

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

Definition at line 251 of file lz4.c.

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

Definition at line 252 of file lz4.c.

Referenced by LZ4_compressCtx().

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

Definition at line 234 of file lz4.c.

Referenced by LZ4_uncompress(), and LZ4_uncompress_unknownOutputSize().

#define LZ4_SECURECOPY   LZ4_WILDCOPY

Definition at line 225 of file lz4.c.

Referenced by LZ4_uncompress(), and LZ4_uncompress_unknownOutputSize().

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

Definition at line 253 of file lz4.c.

Referenced by LZ4_uncompress(), and LZ4_uncompress_unknownOutputSize().

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

Definition at line 235 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 199 of file lz4.c.

Referenced by LZ4_compressCtx().

#define MAXD_LOG   16

Definition at line 198 of file lz4.c.

#define MEMORY_USAGE   14

Definition at line 42 of file lz4.c.

#define MFLIMIT   (COPYLENGTH+MINMATCH)

Definition at line 195 of file lz4.c.

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

#define MINLENGTH   (MFLIMIT+1)

Definition at line 196 of file lz4.c.

Referenced by LZ4_compress64kCtx(), and LZ4_compressCtx().

#define MINMATCH   4

Definition at line 177 of file lz4.c.

Referenced by LZ4_compress64kCtx(), and LZ4_compressCtx().

#define ML_BITS   4
#define ML_MASK   ((1U<<ML_BITS)-1)
#define NOTCOMPRESSIBLE_DETECTIONLEVEL   6

Definition at line 189 of file lz4.c.

#define restrict

Definition at line 99 of file lz4.c.

Referenced by LZ4_uncompress(), and LZ4_uncompress_unknownOutputSize().

#define RUN_BITS   (8-ML_BITS)

Definition at line 203 of file lz4.c.

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

Definition at line 153 of file lz4.c.

Referenced by LZ4_NbCommonBytes().

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

Definition at line 190 of file lz4.c.

Referenced by LZ4_compress64kCtx(), and LZ4_compressCtx().

#define STACKLIMIT   13

Definition at line 191 of file lz4.c.

#define STEPSIZE   4
#define U16   uint16_t

Definition at line 151 of file lz4.c.

Referenced by LZ4_compress64kCtx(), and LZ4_compressCtx().

#define U32   uint32_t

Definition at line 152 of file lz4.c.

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

#define U64   uint64_t

Definition at line 154 of file lz4.c.

#define UARCH   U32

Definition at line 221 of file lz4.c.

Referenced by LZ4_compress64kCtx(), and LZ4_compressCtx().

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

Typedef Documentation

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

Function Documentation

int LZ4_compress ( const char *  source,
char *  dest,
int  isize 
)

Definition at line 695 of file lz4.c.

References LZ4_compress_limitedOutput(), and LZ4_compressBound().

Referenced by compress_file().

Here is the call graph for this function:

Here is the caller graph for this function:

static int LZ4_compress64kCtx ( void **  ctx,
const char *  source,
char *  dest,
int  isize,
int  maxOutputSize 
)
inlinestatic

Definition at line 517 of file lz4.c.

References A16, A32, AARCH, BYTE, HASH64KTABLESIZE, refTables::hashTable, LASTLITERALS, LZ4_ARCH64, LZ4_BLINDCOPY, LZ4_HASH64K_VALUE, LZ4_NbCommonBytes(), LZ4_WRITE_LITTLEENDIAN_16, matchlimit, MFLIMIT, MINLENGTH, MINMATCH, ML_BITS, ML_MASK, NULL, RUN_MASK, SKIPSTRENGTH, STEPSIZE, U16, U32, UARCH, and unlikely.

Referenced by LZ4_compress_limitedOutput().

Here is the call graph for this function:

Here is the caller graph for this function:

int LZ4_compress_limitedOutput ( const char *  source,
char *  dest,
int  isize,
int  maxOutputSize 
)

Definition at line 675 of file lz4.c.

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

Referenced by LZ4_compress(), and main().

Here is the call graph for this function:

Here is the caller graph for this function:

static int LZ4_compressCtx ( void **  ctx,
const char *  source,
char *  dest,
int  isize,
int  maxOutputSize 
)
inlinestatic

Definition at line 337 of file lz4.c.

References A16, A32, AARCH, BYTE, refTables::hashTable, HASHTABLESIZE, HTYPE, INITBASE, LASTLITERALS, likely, LZ4_ARCH64, LZ4_BLINDCOPY, LZ4_HASH_VALUE, LZ4_NbCommonBytes(), LZ4_WRITE_LITTLEENDIAN_16, matchlimit, MAX_DISTANCE, MFLIMIT, MINLENGTH, MINMATCH, ML_BITS, ML_MASK, NULL, RUN_MASK, SKIPSTRENGTH, STEPSIZE, U16, U32, UARCH, and unlikely.

Referenced by LZ4_compress_limitedOutput().

Here is the call graph for this function:

Here is the caller graph for this function:

static int LZ4_NbCommonBytes ( register U32  val)
inlinestatic

Definition at line 294 of file lz4.c.

References S32, and U32.

Referenced by LZ4_compress64kCtx(), and LZ4_compressCtx().

Here is the caller graph for this function:

int LZ4_uncompress ( const char *  source,
char *  dest,
int  osize 
)

Definition at line 715 of file lz4.c.

References A32, COPYLENGTH, LASTLITERALS, LZ4_COPYSTEP, LZ4_READ_LITTLEENDIAN_16, LZ4_SECURECOPY, LZ4_WILDCOPY, ML_BITS, ML_MASK, restrict, RUN_MASK, STEPSIZE, and unlikely.

Referenced by BMK_benchFile(), FUZ_SecurityTest(), and main().

Here is the caller graph for this function:

int LZ4_uncompress_unknownOutputSize ( const char *  source,
char *  dest,
int  isize,
int  maxOutputSize 
)

Definition at line 802 of file lz4.c.

References A32, COPYLENGTH, LASTLITERALS, likely, LZ4_COPYSTEP, LZ4_READ_LITTLEENDIAN_16, LZ4_SECURECOPY, LZ4_WILDCOPY, MFLIMIT, ML_BITS, ML_MASK, restrict, RUN_MASK, STEPSIZE, and unlikely.

Referenced by decode_file(), and main().

Here is the caller graph for this function: