Project Alice
Loading...
Searching...
No Matches
zstd_internal.h File Reference
#include "compiler.h"
#include "cpu.h"
#include "mem.h"
#include "debug.h"
#include "error_private.h"
#include "../zstd.h"
#include "fse.h"
#include "huf.h"
#include "xxhash.h"
#include "zstd_trace.h"
Include dependency graph for zstd_internal.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  seqDef_s
 
struct  seqStore_t
 
struct  ZSTD_sequenceLength
 
struct  ZSTD_frameSizeInfo
 
struct  blockProperties_t
 

Macros

#define ZSTD_STATIC_LINKING_ONLY
 
#define FSE_STATIC_LINKING_ONLY
 
#define XXH_STATIC_LINKING_ONLY   /* XXH64_state_t */
 
#define ZSTD_STATIC_ASSERT(c)   DEBUG_STATIC_ASSERT(c)
 
#define ZSTD_isError   ERR_isError /* for inlining */
 
#define FSE_isError   ERR_isError
 
#define HUF_isError   ERR_isError
 
#define MIN(a, b)   ((a)<(b) ? (a) : (b))
 
#define MAX(a, b)   ((a)>(b) ? (a) : (b))
 
#define BOUNDED(min, val, max)   (MAX(min,MIN(val,max)))
 
#define ZSTD_OPT_NUM   (1<<12)
 
#define ZSTD_REP_NUM   3 /* number of repcodes */
 
#define KB   *(1 <<10)
 
#define MB   *(1 <<20)
 
#define GB   *(1U<<30)
 
#define BIT7   128
 
#define BIT6   64
 
#define BIT5   32
 
#define BIT4   16
 
#define BIT1   2
 
#define BIT0   1
 
#define ZSTD_WINDOWLOG_ABSOLUTEMIN   10
 
#define ZSTD_FRAMEIDSIZE   4 /* magic number size */
 
#define ZSTD_BLOCKHEADERSIZE   3 /* C standard doesn't allow `static const` variable to be init using another `static const` variable */
 
#define ZSTD_FRAMECHECKSUMSIZE   4
 
#define MIN_SEQUENCES_SIZE   1 /* nbSeq==0 */
 
#define MIN_CBLOCK_SIZE   (1 /*litCSize*/ + 1 /* RLE or RAW */) /* for a non-null block */
 
#define MIN_LITERALS_FOR_4_STREAMS   6
 
#define LONGNBSEQ   0x7F00
 
#define MINMATCH   3
 
#define Litbits   8
 
#define LitHufLog   11
 
#define MaxLit   ((1<<Litbits) - 1)
 
#define MaxML   52
 
#define MaxLL   35
 
#define DefaultMaxOff   28
 
#define MaxOff   31
 
#define MaxSeq   MAX(MaxLL, MaxML) /* Assumption : MaxOff < MaxLL,MaxML */
 
#define MLFSELog   9
 
#define LLFSELog   9
 
#define OffFSELog   8
 
#define MaxFSELog   MAX(MAX(MLFSELog, LLFSELog), OffFSELog)
 
#define MaxMLBits   16
 
#define MaxLLBits   16
 
#define ZSTD_MAX_HUF_HEADER_SIZE   128 /* header + <= 127 byte tree description */
 
#define ZSTD_MAX_FSE_HEADERS_SIZE   (((MaxML + 1) * MLFSELog + (MaxLL + 1) * LLFSELog + (MaxOff + 1) * OffFSELog + 7) / 8)
 
#define LL_DEFAULTNORMLOG   6 /* for static allocation */
 
#define ML_DEFAULTNORMLOG   6 /* for static allocation */
 
#define OF_DEFAULTNORMLOG   5 /* for static allocation */
 
#define COPY8(d, s)   do { ZSTD_copy8(d,s); d+=8; s+=8; } while (0)
 
#define COPY16(d, s)   do { ZSTD_copy16(d,s); d+=16; s+=16; } while (0)
 
#define WILDCOPY_OVERLENGTH   32
 
#define WILDCOPY_VECLEN   16
 
#define ZSTD_WORKSPACETOOLARGE_FACTOR   3
 
#define ZSTD_WORKSPACETOOLARGE_MAXDURATION   128
 

Typedefs

typedef struct seqDef_s seqDef
 

Enumerations

enum  blockType_e { bt_raw , bt_rle , bt_compressed , bt_reserved }
 
enum  symbolEncodingType_e { set_basic , set_rle , set_compressed , set_repeat }
 
enum  ZSTD_overlap_e { ZSTD_no_overlap , ZSTD_overlap_src_before_dst }
 
enum  ZSTD_bufferMode_e { ZSTD_bm_buffered = 0 , ZSTD_bm_stable = 1 }
 
enum  ZSTD_longLengthType_e { ZSTD_llt_none = 0 , ZSTD_llt_literalLength = 1 , ZSTD_llt_matchLength = 2 }
 

Functions

MEM_STATIC FORCE_INLINE_ATTR void ZSTD_wildcopy (void *dst, const void *src, ptrdiff_t length, ZSTD_overlap_e const ovtype)
 
MEM_STATIC size_t ZSTD_limitCopy (void *dst, size_t dstCapacity, const void *src, size_t srcSize)
 
MEM_STATIC ZSTD_sequenceLength ZSTD_getSequenceLength (seqStore_t const *seqStore, seqDef const *seq)
 
const seqStore_tZSTD_getSeqStore (const ZSTD_CCtx *ctx)
 
int ZSTD_seqToCodes (const seqStore_t *seqStorePtr)
 
void ZSTD_invalidateRepCodes (ZSTD_CCtx *cctx)
 
size_t ZSTD_getcBlockSize (const void *src, size_t srcSize, blockProperties_t *bpPtr)
 
size_t ZSTD_decodeSeqHeaders (ZSTD_DCtx *dctx, int *nbSeqPtr, const void *src, size_t srcSize)
 
MEM_STATIC int ZSTD_cpuSupportsBmi2 (void)
 

Macro Definition Documentation

◆ BIT0

#define BIT0   1

Definition at line 80 of file zstd_internal.h.

◆ BIT1

#define BIT1   2

Definition at line 79 of file zstd_internal.h.

◆ BIT4

#define BIT4   16

Definition at line 78 of file zstd_internal.h.

◆ BIT5

#define BIT5   32

Definition at line 77 of file zstd_internal.h.

◆ BIT6

#define BIT6   64

Definition at line 76 of file zstd_internal.h.

◆ BIT7

#define BIT7   128

Definition at line 75 of file zstd_internal.h.

◆ BOUNDED

#define BOUNDED (   min,
  val,
  max 
)    (MAX(min,MIN(val,max)))

Definition at line 60 of file zstd_internal.h.

◆ COPY16

#define COPY16 (   d,
 
)    do { ZSTD_copy16(d,s); d+=16; s+=16; } while (0)

Definition at line 201 of file zstd_internal.h.

◆ COPY8

#define COPY8 (   d,
 
)    do { ZSTD_copy8(d,s); d+=8; s+=8; } while (0)

Definition at line 181 of file zstd_internal.h.

◆ DefaultMaxOff

#define DefaultMaxOff   28

Definition at line 109 of file zstd_internal.h.

◆ FSE_isError

#define FSE_isError   ERR_isError

Definition at line 49 of file zstd_internal.h.

◆ FSE_STATIC_LINKING_ONLY

#define FSE_STATIC_LINKING_ONLY

Definition at line 29 of file zstd_internal.h.

◆ GB

#define GB   *(1U<<30)

Definition at line 73 of file zstd_internal.h.

◆ HUF_isError

#define HUF_isError   ERR_isError

Definition at line 50 of file zstd_internal.h.

◆ KB

#define KB   *(1 <<10)

Definition at line 71 of file zstd_internal.h.

◆ Litbits

#define Litbits   8

Definition at line 104 of file zstd_internal.h.

◆ LitHufLog

#define LitHufLog   11

Definition at line 105 of file zstd_internal.h.

◆ LL_DEFAULTNORMLOG

#define LL_DEFAULTNORMLOG   6 /* for static allocation */

Definition at line 137 of file zstd_internal.h.

◆ LLFSELog

#define LLFSELog   9

Definition at line 113 of file zstd_internal.h.

◆ LONGNBSEQ

#define LONGNBSEQ   0x7F00

Definition at line 100 of file zstd_internal.h.

◆ MAX

#define MAX (   a,
 
)    ((a)>(b) ? (a) : (b))

Definition at line 59 of file zstd_internal.h.

◆ MaxFSELog

#define MaxFSELog   MAX(MAX(MLFSELog, LLFSELog), OffFSELog)

Definition at line 115 of file zstd_internal.h.

◆ MaxLit

#define MaxLit   ((1<<Litbits) - 1)

Definition at line 106 of file zstd_internal.h.

◆ MaxLL

#define MaxLL   35

Definition at line 108 of file zstd_internal.h.

◆ MaxLLBits

#define MaxLLBits   16

Definition at line 117 of file zstd_internal.h.

◆ MaxML

#define MaxML   52

Definition at line 107 of file zstd_internal.h.

◆ MaxMLBits

#define MaxMLBits   16

Definition at line 116 of file zstd_internal.h.

◆ MaxOff

#define MaxOff   31

Definition at line 110 of file zstd_internal.h.

◆ MaxSeq

#define MaxSeq   MAX(MaxLL, MaxML) /* Assumption : MaxOff < MaxLL,MaxML */

Definition at line 111 of file zstd_internal.h.

◆ MB

#define MB   *(1 <<20)

Definition at line 72 of file zstd_internal.h.

◆ MIN

#define MIN (   a,
 
)    ((a)<(b) ? (a) : (b))

Definition at line 58 of file zstd_internal.h.

◆ MIN_CBLOCK_SIZE

#define MIN_CBLOCK_SIZE   (1 /*litCSize*/ + 1 /* RLE or RAW */) /* for a non-null block */

Definition at line 95 of file zstd_internal.h.

◆ MIN_LITERALS_FOR_4_STREAMS

#define MIN_LITERALS_FOR_4_STREAMS   6

Definition at line 96 of file zstd_internal.h.

◆ MIN_SEQUENCES_SIZE

#define MIN_SEQUENCES_SIZE   1 /* nbSeq==0 */

Definition at line 94 of file zstd_internal.h.

◆ MINMATCH

#define MINMATCH   3

Definition at line 102 of file zstd_internal.h.

◆ ML_DEFAULTNORMLOG

#define ML_DEFAULTNORMLOG   6 /* for static allocation */

Definition at line 158 of file zstd_internal.h.

◆ MLFSELog

#define MLFSELog   9

Definition at line 112 of file zstd_internal.h.

◆ OF_DEFAULTNORMLOG

#define OF_DEFAULTNORMLOG   5 /* for static allocation */

Definition at line 167 of file zstd_internal.h.

◆ OffFSELog

#define OffFSELog   8

Definition at line 114 of file zstd_internal.h.

◆ WILDCOPY_OVERLENGTH

#define WILDCOPY_OVERLENGTH   32

Definition at line 203 of file zstd_internal.h.

◆ WILDCOPY_VECLEN

#define WILDCOPY_VECLEN   16

Definition at line 204 of file zstd_internal.h.

◆ XXH_STATIC_LINKING_ONLY

#define XXH_STATIC_LINKING_ONLY   /* XXH64_state_t */

Definition at line 33 of file zstd_internal.h.

◆ ZSTD_BLOCKHEADERSIZE

#define ZSTD_BLOCKHEADERSIZE   3 /* C standard doesn't allow `static const` variable to be init using another `static const` variable */

Definition at line 88 of file zstd_internal.h.

◆ ZSTD_FRAMECHECKSUMSIZE

#define ZSTD_FRAMECHECKSUMSIZE   4

Definition at line 92 of file zstd_internal.h.

◆ ZSTD_FRAMEIDSIZE

#define ZSTD_FRAMEIDSIZE   4 /* magic number size */

Definition at line 86 of file zstd_internal.h.

◆ ZSTD_isError

#define ZSTD_isError   ERR_isError /* for inlining */

Definition at line 48 of file zstd_internal.h.

◆ ZSTD_MAX_FSE_HEADERS_SIZE

#define ZSTD_MAX_FSE_HEADERS_SIZE   (((MaxML + 1) * MLFSELog + (MaxLL + 1) * LLFSELog + (MaxOff + 1) * OffFSELog + 7) / 8)

Definition at line 121 of file zstd_internal.h.

◆ ZSTD_MAX_HUF_HEADER_SIZE

#define ZSTD_MAX_HUF_HEADER_SIZE   128 /* header + <= 127 byte tree description */

Definition at line 119 of file zstd_internal.h.

◆ ZSTD_OPT_NUM

#define ZSTD_OPT_NUM   (1<<12)

Definition at line 66 of file zstd_internal.h.

◆ ZSTD_REP_NUM

#define ZSTD_REP_NUM   3 /* number of repcodes */

Definition at line 68 of file zstd_internal.h.

◆ ZSTD_STATIC_ASSERT

#define ZSTD_STATIC_ASSERT (   c)    DEBUG_STATIC_ASSERT(c)

Definition at line 47 of file zstd_internal.h.

◆ ZSTD_STATIC_LINKING_ONLY

#define ZSTD_STATIC_LINKING_ONLY

Definition at line 27 of file zstd_internal.h.

◆ ZSTD_WINDOWLOG_ABSOLUTEMIN

#define ZSTD_WINDOWLOG_ABSOLUTEMIN   10

Definition at line 82 of file zstd_internal.h.

◆ ZSTD_WORKSPACETOOLARGE_FACTOR

#define ZSTD_WORKSPACETOOLARGE_FACTOR   3

Definition at line 262 of file zstd_internal.h.

◆ ZSTD_WORKSPACETOOLARGE_MAXDURATION

#define ZSTD_WORKSPACETOOLARGE_MAXDURATION   128

Definition at line 269 of file zstd_internal.h.

Typedef Documentation

◆ seqDef

typedef struct seqDef_s seqDef

Enumeration Type Documentation

◆ blockType_e

Enumerator
bt_raw 
bt_rle 
bt_compressed 
bt_reserved 

Definition at line 90 of file zstd_internal.h.

◆ symbolEncodingType_e

Enumerator
set_basic 
set_rle 
set_compressed 
set_repeat 

Definition at line 98 of file zstd_internal.h.

◆ ZSTD_bufferMode_e

Enumerator
ZSTD_bm_buffered 
ZSTD_bm_stable 

Definition at line 272 of file zstd_internal.h.

◆ ZSTD_longLengthType_e

Enumerator
ZSTD_llt_none 
ZSTD_llt_literalLength 
ZSTD_llt_matchLength 

Definition at line 288 of file zstd_internal.h.

◆ ZSTD_overlap_e

Enumerator
ZSTD_no_overlap 
ZSTD_overlap_src_before_dst 

Definition at line 206 of file zstd_internal.h.

Function Documentation

◆ ZSTD_cpuSupportsBmi2()

MEM_STATIC int ZSTD_cpuSupportsBmi2 ( void  )
Returns
true iff the CPU supports dynamic BMI2 dispatch.

Definition at line 382 of file zstd_internal.h.

Here is the call graph for this function:

◆ ZSTD_decodeSeqHeaders()

size_t ZSTD_decodeSeqHeaders ( ZSTD_DCtx dctx,
int *  nbSeqPtr,
const void *  src,
size_t  srcSize 
)

ZSTD_decodeSeqHeaders() : decode sequence header from src

Definition at line 695 of file zstd_decompress_block.c.

◆ ZSTD_getcBlockSize()

size_t ZSTD_getcBlockSize ( const void *  src,
size_t  srcSize,
blockProperties_t bpPtr 
)

ZSTD_getcBlockSize() : Provides the size of compressed block from block header src

Definition at line 63 of file zstd_decompress_block.c.

Here is the call graph for this function:

◆ ZSTD_getSeqStore()

const seqStore_t * ZSTD_getSeqStore ( const ZSTD_CCtx ctx)

Definition at line 220 of file zstd_compress.c.

◆ ZSTD_getSequenceLength()

MEM_STATIC ZSTD_sequenceLength ZSTD_getSequenceLength ( seqStore_t const *  seqStore,
seqDef const *  seq 
)

Returns the ZSTD_sequenceLength for the given sequences. It handles the decoding of long sequences indicated by longLengthPos and longLengthType, and adds MINMATCH back to matchLength.

Definition at line 322 of file zstd_internal.h.

◆ ZSTD_invalidateRepCodes()

void ZSTD_invalidateRepCodes ( ZSTD_CCtx cctx)

Definition at line 2275 of file zstd_compress.c.

Here is the call graph for this function:

◆ ZSTD_limitCopy()

MEM_STATIC size_t ZSTD_limitCopy ( void *  dst,
size_t  dstCapacity,
const void *  src,
size_t  srcSize 
)

Definition at line 252 of file zstd_internal.h.

◆ ZSTD_seqToCodes()

int ZSTD_seqToCodes ( const seqStore_t seqStorePtr)

Definition at line 2681 of file zstd_compress.c.

Here is the call graph for this function:

◆ ZSTD_wildcopy()

MEM_STATIC FORCE_INLINE_ATTR void ZSTD_wildcopy ( void *  dst,
const void *  src,
ptrdiff_t  length,
ZSTD_overlap_e const  ovtype 
)

ZSTD_wildcopy() : Custom version of ZSTD_memcpy(), can over read/write up to WILDCOPY_OVERLENGTH bytes (if length==0)

Parameters
ovtypecontrols the overlap detection
  • ZSTD_no_overlap: The source and destination are guaranteed to be at least WILDCOPY_VECLEN bytes apart.
  • ZSTD_overlap_src_before_dst: The src and dst may overlap, but they MUST be at least 8 bytes apart. The src buffer must be before the dst buffer.

Definition at line 220 of file zstd_internal.h.