11#ifndef ZSTD_CCOMMON_H_MODULE
12#define ZSTD_CCOMMON_H_MODULE
27#define ZSTD_STATIC_LINKING_ONLY
29#define FSE_STATIC_LINKING_ONLY
32#ifndef XXH_STATIC_LINKING_ONLY
33# define XXH_STATIC_LINKING_ONLY
42#if defined (__cplusplus)
47#define ZSTD_STATIC_ASSERT(c) DEBUG_STATIC_ASSERT(c)
48#define ZSTD_isError ERR_isError
49#define FSE_isError ERR_isError
50#define HUF_isError ERR_isError
58#define MIN(a,b) ((a)<(b) ? (a) : (b))
59#define MAX(a,b) ((a)>(b) ? (a) : (b))
60#define BOUNDED(min,val,max) (MAX(min,MIN(val,max)))
66#define ZSTD_OPT_NUM (1<<12)
82#define ZSTD_WINDOWLOG_ABSOLUTEMIN 10
83static UNUSED_ATTR const size_t ZSTD_fcs_fieldSize[4] = { 0, 2, 4, 8 };
84static UNUSED_ATTR const size_t ZSTD_did_fieldSize[4] = { 0, 1, 2, 4 };
86#define ZSTD_FRAMEIDSIZE 4
88#define ZSTD_BLOCKHEADERSIZE 3
92#define ZSTD_FRAMECHECKSUMSIZE 4
94#define MIN_SEQUENCES_SIZE 1
95#define MIN_CBLOCK_SIZE (1 + 1 )
96#define MIN_LITERALS_FOR_4_STREAMS 6
100#define LONGNBSEQ 0x7F00
106#define MaxLit ((1<<Litbits) - 1)
109#define DefaultMaxOff 28
111#define MaxSeq MAX(MaxLL, MaxML)
115#define MaxFSELog MAX(MAX(MLFSELog, LLFSELog), OffFSELog)
119#define ZSTD_MAX_HUF_HEADER_SIZE 128
121#define ZSTD_MAX_FSE_HEADERS_SIZE (((MaxML + 1) * MLFSELog + (MaxLL + 1) * LLFSELog + (MaxOff + 1) * OffFSELog + 7) / 8)
124 0, 0, 0, 0, 0, 0, 0, 0,
125 0, 0, 0, 0, 0, 0, 0, 0,
126 1, 1, 1, 1, 2, 2, 3, 3,
127 4, 6, 7, 8, 9,10,11,12,
131 4, 3, 2, 2, 2, 2, 2, 2,
132 2, 2, 2, 2, 2, 1, 1, 1,
133 2, 2, 2, 2, 2, 2, 2, 2,
134 2, 3, 2, 1, 1, 1, 1, 1,
137#define LL_DEFAULTNORMLOG 6
141 0, 0, 0, 0, 0, 0, 0, 0,
142 0, 0, 0, 0, 0, 0, 0, 0,
143 0, 0, 0, 0, 0, 0, 0, 0,
144 0, 0, 0, 0, 0, 0, 0, 0,
145 1, 1, 1, 1, 2, 2, 3, 3,
146 4, 4, 5, 7, 8, 9,10,11,
150 1, 4, 3, 2, 2, 2, 2, 2,
151 2, 1, 1, 1, 1, 1, 1, 1,
152 1, 1, 1, 1, 1, 1, 1, 1,
153 1, 1, 1, 1, 1, 1, 1, 1,
154 1, 1, 1, 1, 1, 1, 1, 1,
155 1, 1, 1, 1, 1, 1,-1,-1,
158#define ML_DEFAULTNORMLOG 6
162 1, 1, 1, 1, 1, 1, 2, 2,
163 2, 1, 1, 1, 1, 1, 1, 1,
164 1, 1, 1, 1, 1, 1, 1, 1,
167#define OF_DEFAULTNORMLOG 5
174static void ZSTD_copy8(
void* dst,
const void* src) {
175#if defined(ZSTD_ARCH_ARM_NEON)
181#define COPY8(d,s) do { ZSTD_copy8(d,s); d+=8; s+=8; } while (0)
187static void ZSTD_copy16(
void* dst,
const void* src) {
188#if defined(ZSTD_ARCH_ARM_NEON)
190#elif defined(ZSTD_ARCH_X86_SSE2)
191 _mm_storeu_si128((__m128i*)dst, _mm_loadu_si128((
const __m128i*)src));
192#elif defined(__clang__)
201#define COPY16(d,s) do { ZSTD_copy16(d,s); d+=16; s+=16; } while (0)
203#define WILDCOPY_OVERLENGTH 32
204#define WILDCOPY_VECLEN 16
222 ptrdiff_t diff = (
BYTE*)dst - (
const BYTE*)src;
225 BYTE*
const oend = op + length;
241 if (16 >= length)
return;
254 size_t const length =
MIN(dstCapacity, srcSize);
262#define ZSTD_WORKSPACETOOLARGE_FACTOR 3
269#define ZSTD_WORKSPACETOOLARGE_MAXDURATION 128
377 const void* src,
size_t srcSize);
385 return ZSTD_cpuid_bmi1(cpuid) && ZSTD_cpuid_bmi2(cpuid);
388#if defined (__cplusplus)
#define FORCE_INLINE_ATTR
MEM_STATIC ZSTD_cpuid_t ZSTD_cpuid(void)
#define assert(condition)
unsigned long long decompressedBound
ZSTD_longLengthType_e longLengthType
#define ZSTD_memmove(d, s, l)
#define ZSTD_memcpy(d, s, l)
int ZSTD_seqToCodes(const seqStore_t *seqStorePtr)
#define ZSTD_BLOCKHEADERSIZE
MEM_STATIC int ZSTD_cpuSupportsBmi2(void)
#define OF_DEFAULTNORMLOG
MEM_STATIC size_t ZSTD_limitCopy(void *dst, size_t dstCapacity, const void *src, size_t srcSize)
#define ML_DEFAULTNORMLOG
size_t ZSTD_decodeSeqHeaders(ZSTD_DCtx *dctx, int *nbSeqPtr, const void *src, size_t srcSize)
MEM_STATIC FORCE_INLINE_ATTR void ZSTD_wildcopy(void *dst, const void *src, ptrdiff_t length, ZSTD_overlap_e const ovtype)
#define LL_DEFAULTNORMLOG
void ZSTD_invalidateRepCodes(ZSTD_CCtx *cctx)
const seqStore_t * ZSTD_getSeqStore(const ZSTD_CCtx *ctx)
size_t ZSTD_getcBlockSize(const void *src, size_t srcSize, blockProperties_t *bpPtr)
@ ZSTD_overlap_src_before_dst
MEM_STATIC ZSTD_sequenceLength ZSTD_getSequenceLength(seqStore_t const *seqStore, seqDef const *seq)