11#ifndef ZSTD_CCOMMON_H_MODULE
12#define ZSTD_CCOMMON_H_MODULE
29#define ZSTD_STATIC_LINKING_ONLY
31#define FSE_STATIC_LINKING_ONLY
33#define HUF_STATIC_LINKING_ONLY
35#ifndef XXH_STATIC_LINKING_ONLY
36# define XXH_STATIC_LINKING_ONLY
40#if defined (__cplusplus)
45#define ZSTD_STATIC_ASSERT(c) DEBUG_STATIC_ASSERT(c)
46#define ZSTD_isError ERR_isError
47#define FSE_isError ERR_isError
48#define HUF_isError ERR_isError
56#define MIN(a,b) ((a)<(b) ? (a) : (b))
57#define MAX(a,b) ((a)>(b) ? (a) : (b))
79#define _FORCE_HAS_FORMAT_STRING(...) \
81 _force_has_format_string(__VA_ARGS__); \
91#define RETURN_ERROR_IF(cond, err, ...) \
93 RAWLOG(3, "%s:%d: ERROR!: check %s failed, returning %s", \
94 __FILE__, __LINE__, ZSTD_QUOTE(cond), ZSTD_QUOTE(ERROR(err))); \
95 _FORCE_HAS_FORMAT_STRING(__VA_ARGS__); \
96 RAWLOG(3, ": " __VA_ARGS__); \
106#define RETURN_ERROR(err, ...) \
108 RAWLOG(3, "%s:%d: ERROR!: unconditional check failed, returning %s", \
109 __FILE__, __LINE__, ZSTD_QUOTE(ERROR(err))); \
110 _FORCE_HAS_FORMAT_STRING(__VA_ARGS__); \
111 RAWLOG(3, ": " __VA_ARGS__); \
121#define FORWARD_IF_ERROR(err, ...) \
123 size_t const err_code = (err); \
124 if (ERR_isError(err_code)) { \
125 RAWLOG(3, "%s:%d: ERROR!: forwarding error in %s: %s", \
126 __FILE__, __LINE__, ZSTD_QUOTE(err), ERR_getErrorName(err_code)); \
127 _FORCE_HAS_FORMAT_STRING(__VA_ARGS__); \
128 RAWLOG(3, ": " __VA_ARGS__); \
138#define ZSTD_OPT_NUM (1<<12)
140#define ZSTD_REP_NUM 3
141#define ZSTD_REP_MOVE (ZSTD_REP_NUM-1)
155#define ZSTD_WINDOWLOG_ABSOLUTEMIN 10
159#define ZSTD_FRAMEIDSIZE 4
161#define ZSTD_BLOCKHEADERSIZE 3
165#define ZSTD_FRAMECHECKSUMSIZE 4
167#define MIN_SEQUENCES_SIZE 1
168#define MIN_CBLOCK_SIZE (1 + 1 + MIN_SEQUENCES_SIZE )
173#define LONGNBSEQ 0x7F00
178#define MaxLit ((1<<Litbits) - 1)
181#define DefaultMaxOff 28
183#define MaxSeq MAX(MaxLL, MaxML)
187#define MaxFSELog MAX(MAX(MLFSELog, LLFSELog), OffFSELog)
190 0, 0, 0, 0, 0, 0, 0, 0,
191 1, 1, 1, 1, 2, 2, 3, 3,
192 4, 6, 7, 8, 9,10,11,12,
195 2, 2, 2, 2, 2, 1, 1, 1,
196 2, 2, 2, 2, 2, 2, 2, 2,
197 2, 3, 2, 1, 1, 1, 1, 1,
199#define LL_DEFAULTNORMLOG 6
203 0, 0, 0, 0, 0, 0, 0, 0,
204 0, 0, 0, 0, 0, 0, 0, 0,
205 0, 0, 0, 0, 0, 0, 0, 0,
206 1, 1, 1, 1, 2, 2, 3, 3,
207 4, 4, 5, 7, 8, 9,10,11,
210 2, 1, 1, 1, 1, 1, 1, 1,
211 1, 1, 1, 1, 1, 1, 1, 1,
212 1, 1, 1, 1, 1, 1, 1, 1,
213 1, 1, 1, 1, 1, 1, 1, 1,
214 1, 1, 1, 1, 1, 1,-1,-1,
216#define ML_DEFAULTNORMLOG 6
220 2, 1, 1, 1, 1, 1, 1, 1,
221 1, 1, 1, 1, 1, 1, 1, 1,
223#define OF_DEFAULTNORMLOG 5
238#define COPY8(d,s) { ZSTD_copy8(d,s); d+=8; s+=8; }
246#define COPY16(d,s) { ZSTD_copy16(d,s); d+=16; s+=16; }
248#define WILDCOPY_OVERLENGTH 32
249#define WILDCOPY_VECLEN 16
294 if (
op >= oend)
return;
306 size_t const length =
MIN(dstCapacity, srcSize);
314#define ZSTD_WORKSPACETOOLARGE_FACTOR 3
321#define ZSTD_WORKSPACETOOLARGE_MAXDURATION 128
396# if defined(_MSC_VER)
399# elif defined(__GNUC__) && (__GNUC__ >= 3)
400 return __builtin_clz (
val) ^ 31;
401# elif defined(__ICCARM__)
402 return 31 - __CLZ(
val);
404 static const U32 DeBruijnClz[32] = { 0, 9, 1, 10, 13, 21, 2, 29, 11, 14, 16, 18, 22, 25, 3, 30, 8, 12, 20, 28, 15, 17, 24, 7, 19, 27, 23, 6, 26, 5, 4, 31 };
411 return DeBruijnClz[(
v * 0x07C4ACDDU) >> 27];
440 const void*
src,
size_t srcSize);
443#if defined (__cplusplus)
__kernel_ptrdiff_t ptrdiff_t
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
GLdouble GLdouble GLdouble r
GLuint GLsizei GLsizei * length
unsigned char _BitScanReverse(unsigned long *_Index, unsigned long _Mask)
#define memcpy(s1, s2, n)
static unsigned(__cdecl *hash_bstr)(bstr_t s)
unsigned long long decompressedBound
#define FORCE_INLINE_ATTR
void ZSTD_seqToCodes(const seqStore_t *seqStorePtr)
static const U32 LL_defaultNormLog
static INLINE_KEYWORD UNUSED_ATTR void _force_has_format_string(const char *format,...)
#define ZSTD_BLOCKHEADERSIZE
static const size_t ZSTD_blockHeaderSize
#define OF_DEFAULTNORMLOG
MEM_STATIC U32 ZSTD_highbit32(U32 val)
static const U32 OF_defaultNormLog
static const U32 ML_bits[MaxML+1]
static const size_t ZSTD_did_fieldSize[4]
MEM_STATIC size_t ZSTD_limitCopy(void *dst, size_t dstCapacity, const void *src, size_t srcSize)
static const S16 LL_defaultNorm[MaxLL+1]
#define ML_DEFAULTNORMLOG
size_t ZSTD_decodeSeqHeaders(ZSTD_DCtx *dctx, int *nbSeqPtr, const void *src, size_t srcSize)
static const size_t ZSTD_fcs_fieldSize[4]
void ZSTD_free(void *ptr, ZSTD_customMem customMem)
static void ZSTD_copy16(void *dst, const void *src)
static const U32 repStartValue[ZSTD_REP_NUM]
static const U32 LL_bits[MaxLL+1]
void * ZSTD_malloc(size_t size, ZSTD_customMem customMem)
MEM_STATIC FORCE_INLINE_ATTR void ZSTD_wildcopy(void *dst, const void *src, ptrdiff_t length, ZSTD_overlap_e const ovtype)
static void ZSTD_copy8(void *dst, const void *src)
static const S16 ML_defaultNorm[MaxML+1]
#define LL_DEFAULTNORMLOG
static const U32 ML_defaultNormLog
void ZSTD_invalidateRepCodes(ZSTD_CCtx *cctx)
static const S16 OF_defaultNorm[DefaultMaxOff+1]
const seqStore_t * ZSTD_getSeqStore(const ZSTD_CCtx *ctx)
void * ZSTD_calloc(size_t size, ZSTD_customMem customMem)
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)