Coverage Report

Created: 2026-03-12 07:14

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/zstd/lib/common/bitstream.h
Line
Count
Source
1
/* ******************************************************************
2
 * bitstream
3
 * Part of FSE library
4
 * Copyright (c) Meta Platforms, Inc. and affiliates.
5
 *
6
 * You can contact the author at :
7
 * - Source repository : https://github.com/Cyan4973/FiniteStateEntropy
8
 *
9
 * This source code is licensed under both the BSD-style license (found in the
10
 * LICENSE file in the root directory of this source tree) and the GPLv2 (found
11
 * in the COPYING file in the root directory of this source tree).
12
 * You may select, at your option, one of the above-listed licenses.
13
****************************************************************** */
14
#ifndef BITSTREAM_H_MODULE
15
#define BITSTREAM_H_MODULE
16
17
/*
18
*  This API consists of small unitary functions, which must be inlined for best performance.
19
*  Since link-time-optimization is not available for all compilers,
20
*  these functions are defined into a .h to be included.
21
*/
22
23
/*-****************************************
24
*  Dependencies
25
******************************************/
26
#include "mem.h"            /* unaligned access routines */
27
#include "compiler.h"       /* UNLIKELY() */
28
#include "debug.h"          /* assert(), DEBUGLOG(), RAWLOG() */
29
#include "error_private.h"  /* error codes and messages */
30
#include "bits.h"           /* ZSTD_highbit32 */
31
32
/*=========================================
33
*  Target specific
34
=========================================*/
35
#ifndef ZSTD_NO_INTRINSICS
36
#  if (defined(__BMI__) || defined(__BMI2__)) && defined(__GNUC__)
37
#    include <immintrin.h>   /* support for bextr (experimental)/bzhi */
38
#  elif defined(__ICCARM__)
39
#    include <intrinsics.h>
40
#  endif
41
#endif
42
43
0
#define STREAM_ACCUMULATOR_MIN_32  25
44
0
#define STREAM_ACCUMULATOR_MIN_64  57
45
0
#define STREAM_ACCUMULATOR_MIN    ((U32)(MEM_32bits() ? STREAM_ACCUMULATOR_MIN_32 : STREAM_ACCUMULATOR_MIN_64))
46
47
48
/*-******************************************
49
*  bitStream encoding API (write forward)
50
********************************************/
51
typedef size_t BitContainerType;
52
/* bitStream can mix input from multiple sources.
53
 * A critical property of these streams is that they encode and decode in **reverse** direction.
54
 * So the first bit sequence you add will be the last to be read, like a LIFO stack.
55
 */
56
typedef struct {
57
    BitContainerType bitContainer;
58
    unsigned bitPos;
59
    char*  startPtr;
60
    char*  ptr;
61
    char*  endPtr;
62
} BIT_CStream_t;
63
64
MEM_STATIC size_t BIT_initCStream(BIT_CStream_t* bitC, void* dstBuffer, size_t dstCapacity);
65
MEM_STATIC void   BIT_addBits(BIT_CStream_t* bitC, BitContainerType value, unsigned nbBits);
66
MEM_STATIC void   BIT_flushBits(BIT_CStream_t* bitC);
67
MEM_STATIC size_t BIT_closeCStream(BIT_CStream_t* bitC);
68
69
/* Start with initCStream, providing the size of buffer to write into.
70
*  bitStream will never write outside of this buffer.
71
*  `dstCapacity` must be >= sizeof(bitD->bitContainer), otherwise @return will be an error code.
72
*
73
*  bits are first added to a local register.
74
*  Local register is BitContainerType, 64-bits on 64-bits systems, or 32-bits on 32-bits systems.
75
*  Writing data into memory is an explicit operation, performed by the flushBits function.
76
*  Hence keep track how many bits are potentially stored into local register to avoid register overflow.
77
*  After a flushBits, a maximum of 7 bits might still be stored into local register.
78
*
79
*  Avoid storing elements of more than 24 bits if you want compatibility with 32-bits bitstream readers.
80
*
81
*  Last operation is to close the bitStream.
82
*  The function returns the final size of CStream in bytes.
83
*  If data couldn't fit into `dstBuffer`, it will return a 0 ( == not storable)
84
*/
85
86
87
/*-********************************************
88
*  bitStream decoding API (read backward)
89
**********************************************/
90
typedef struct {
91
    BitContainerType bitContainer;
92
    unsigned bitsConsumed;
93
    const char* ptr;
94
    const char* start;
95
    const char* limitPtr;
96
} BIT_DStream_t;
97
98
typedef enum { BIT_DStream_unfinished = 0,  /* fully refilled */
99
               BIT_DStream_endOfBuffer = 1, /* still some bits left in bitstream */
100
               BIT_DStream_completed = 2,   /* bitstream entirely consumed, bit-exact */
101
               BIT_DStream_overflow = 3     /* user requested more bits than present in bitstream */
102
    } BIT_DStream_status;  /* result of BIT_reloadDStream() */
103
104
MEM_STATIC size_t   BIT_initDStream(BIT_DStream_t* bitD, const void* srcBuffer, size_t srcSize);
105
FORCE_INLINE_TEMPLATE BitContainerType BIT_readBits(BIT_DStream_t* bitD, unsigned nbBits);
106
FORCE_INLINE_TEMPLATE BIT_DStream_status BIT_reloadDStream(BIT_DStream_t* bitD);
107
MEM_STATIC unsigned BIT_endOfDStream(const BIT_DStream_t* bitD);
108
109
110
/* Start by invoking BIT_initDStream().
111
*  A chunk of the bitStream is then stored into a local register.
112
*  Local register size is 64-bits on 64-bits systems, 32-bits on 32-bits systems (BitContainerType).
113
*  You can then retrieve bitFields stored into the local register, **in reverse order**.
114
*  Local register is explicitly reloaded from memory by the BIT_reloadDStream() method.
115
*  A reload guarantee a minimum of ((8*sizeof(bitD->bitContainer))-7) bits when its result is BIT_DStream_unfinished.
116
*  Otherwise, it can be less than that, so proceed accordingly.
117
*  Checking if DStream has reached its end can be performed with BIT_endOfDStream().
118
*/
119
120
121
/*-****************************************
122
*  unsafe API
123
******************************************/
124
MEM_STATIC void BIT_addBitsFast(BIT_CStream_t* bitC, BitContainerType value, unsigned nbBits);
125
/* faster, but works only if value is "clean", meaning all high bits above nbBits are 0 */
126
127
MEM_STATIC void BIT_flushBitsFast(BIT_CStream_t* bitC);
128
/* unsafe version; does not check buffer overflow */
129
130
MEM_STATIC size_t BIT_readBitsFast(BIT_DStream_t* bitD, unsigned nbBits);
131
/* faster, but works only if nbBits >= 1 */
132
133
/*=====    Local Constants   =====*/
134
static const unsigned BIT_mask[] = {
135
    0,          1,         3,         7,         0xF,       0x1F,
136
    0x3F,       0x7F,      0xFF,      0x1FF,     0x3FF,     0x7FF,
137
    0xFFF,      0x1FFF,    0x3FFF,    0x7FFF,    0xFFFF,    0x1FFFF,
138
    0x3FFFF,    0x7FFFF,   0xFFFFF,   0x1FFFFF,  0x3FFFFF,  0x7FFFFF,
139
    0xFFFFFF,   0x1FFFFFF, 0x3FFFFFF, 0x7FFFFFF, 0xFFFFFFF, 0x1FFFFFFF,
140
    0x3FFFFFFF, 0x7FFFFFFF}; /* up to 31 bits */
141
#define BIT_MASK_SIZE (sizeof(BIT_mask) / sizeof(BIT_mask[0]))
142
143
/*-**************************************************************
144
*  bitStream encoding
145
****************************************************************/
146
/*! BIT_initCStream() :
147
 *  `dstCapacity` must be > sizeof(size_t)
148
 *  @return : 0 if success,
149
 *            otherwise an error code (can be tested using ERR_isError()) */
150
MEM_STATIC size_t BIT_initCStream(BIT_CStream_t* bitC,
151
                                  void* startPtr, size_t dstCapacity)
152
0
{
153
0
    bitC->bitContainer = 0;
154
0
    bitC->bitPos = 0;
155
0
    bitC->startPtr = (char*)startPtr;
156
0
    bitC->ptr = bitC->startPtr;
157
0
    bitC->endPtr = bitC->startPtr + dstCapacity - sizeof(bitC->bitContainer);
158
0
    if (dstCapacity <= sizeof(bitC->bitContainer)) return ERROR(dstSize_tooSmall);
159
0
    return 0;
160
0
}
Unexecuted instantiation: zstd_common.c:BIT_initCStream
Unexecuted instantiation: zstd_compress.c:BIT_initCStream
Unexecuted instantiation: zstd_compress_literals.c:BIT_initCStream
Unexecuted instantiation: zstd_compress_sequences.c:BIT_initCStream
Unexecuted instantiation: zstd_compress_superblock.c:BIT_initCStream
Unexecuted instantiation: zstd_double_fast.c:BIT_initCStream
Unexecuted instantiation: zstd_fast.c:BIT_initCStream
Unexecuted instantiation: zstd_lazy.c:BIT_initCStream
Unexecuted instantiation: zstd_ldm.c:BIT_initCStream
Unexecuted instantiation: zstd_opt.c:BIT_initCStream
Unexecuted instantiation: zstd_preSplit.c:BIT_initCStream
Unexecuted instantiation: zstdmt_compress.c:BIT_initCStream
Unexecuted instantiation: zstd_decompress.c:BIT_initCStream
Unexecuted instantiation: zstd_decompress_block.c:BIT_initCStream
Unexecuted instantiation: entropy_common.c:BIT_initCStream
Unexecuted instantiation: fse_decompress.c:BIT_initCStream
Unexecuted instantiation: fse_compress.c:BIT_initCStream
Unexecuted instantiation: huf_compress.c:BIT_initCStream
Unexecuted instantiation: huf_decompress.c:BIT_initCStream
Unexecuted instantiation: zstd_ddict.c:BIT_initCStream
161
162
FORCE_INLINE_TEMPLATE BitContainerType BIT_getLowerBits(BitContainerType bitContainer, U32 const nbBits)
163
0
{
164
#if STATIC_BMI2 && !defined(ZSTD_NO_INTRINSICS)
165
#  if (defined(__x86_64__) || defined(_M_X64)) && !defined(__ILP32__)
166
    return _bzhi_u64(bitContainer, nbBits);
167
#  else
168
    DEBUG_STATIC_ASSERT(sizeof(bitContainer) == sizeof(U32));
169
    return _bzhi_u32(bitContainer, nbBits);
170
#  endif
171
#else
172
0
    assert(nbBits < BIT_MASK_SIZE);
173
0
    return bitContainer & BIT_mask[nbBits];
174
0
#endif
175
0
}
Unexecuted instantiation: zstd_common.c:BIT_getLowerBits
Unexecuted instantiation: zstd_compress.c:BIT_getLowerBits
Unexecuted instantiation: zstd_compress_literals.c:BIT_getLowerBits
Unexecuted instantiation: zstd_compress_sequences.c:BIT_getLowerBits
Unexecuted instantiation: zstd_compress_superblock.c:BIT_getLowerBits
Unexecuted instantiation: zstd_double_fast.c:BIT_getLowerBits
Unexecuted instantiation: zstd_fast.c:BIT_getLowerBits
Unexecuted instantiation: zstd_lazy.c:BIT_getLowerBits
Unexecuted instantiation: zstd_ldm.c:BIT_getLowerBits
Unexecuted instantiation: zstd_opt.c:BIT_getLowerBits
Unexecuted instantiation: zstd_preSplit.c:BIT_getLowerBits
Unexecuted instantiation: zstdmt_compress.c:BIT_getLowerBits
Unexecuted instantiation: zstd_decompress.c:BIT_getLowerBits
Unexecuted instantiation: zstd_decompress_block.c:BIT_getLowerBits
Unexecuted instantiation: entropy_common.c:BIT_getLowerBits
Unexecuted instantiation: fse_decompress.c:BIT_getLowerBits
Unexecuted instantiation: fse_compress.c:BIT_getLowerBits
Unexecuted instantiation: huf_compress.c:BIT_getLowerBits
Unexecuted instantiation: huf_decompress.c:BIT_getLowerBits
Unexecuted instantiation: zstd_ddict.c:BIT_getLowerBits
176
177
/*! BIT_addBits() :
178
 *  can add up to 31 bits into `bitC`.
179
 *  Note : does not check for register overflow ! */
180
MEM_STATIC void BIT_addBits(BIT_CStream_t* bitC,
181
                            BitContainerType value, unsigned nbBits)
182
0
{
183
0
    DEBUG_STATIC_ASSERT(BIT_MASK_SIZE == 32);
184
0
    assert(nbBits < BIT_MASK_SIZE);
185
0
    assert(nbBits + bitC->bitPos < sizeof(bitC->bitContainer) * 8);
186
0
    bitC->bitContainer |= BIT_getLowerBits(value, nbBits) << bitC->bitPos;
187
0
    bitC->bitPos += nbBits;
188
0
}
Unexecuted instantiation: zstd_common.c:BIT_addBits
Unexecuted instantiation: zstd_compress.c:BIT_addBits
Unexecuted instantiation: zstd_compress_literals.c:BIT_addBits
Unexecuted instantiation: zstd_compress_sequences.c:BIT_addBits
Unexecuted instantiation: zstd_compress_superblock.c:BIT_addBits
Unexecuted instantiation: zstd_double_fast.c:BIT_addBits
Unexecuted instantiation: zstd_fast.c:BIT_addBits
Unexecuted instantiation: zstd_lazy.c:BIT_addBits
Unexecuted instantiation: zstd_ldm.c:BIT_addBits
Unexecuted instantiation: zstd_opt.c:BIT_addBits
Unexecuted instantiation: zstd_preSplit.c:BIT_addBits
Unexecuted instantiation: zstdmt_compress.c:BIT_addBits
Unexecuted instantiation: zstd_decompress.c:BIT_addBits
Unexecuted instantiation: zstd_decompress_block.c:BIT_addBits
Unexecuted instantiation: entropy_common.c:BIT_addBits
Unexecuted instantiation: fse_decompress.c:BIT_addBits
Unexecuted instantiation: fse_compress.c:BIT_addBits
Unexecuted instantiation: huf_compress.c:BIT_addBits
Unexecuted instantiation: huf_decompress.c:BIT_addBits
Unexecuted instantiation: zstd_ddict.c:BIT_addBits
189
190
/*! BIT_addBitsFast() :
191
 *  works only if `value` is _clean_,
192
 *  meaning all high bits above nbBits are 0 */
193
MEM_STATIC void BIT_addBitsFast(BIT_CStream_t* bitC,
194
                                BitContainerType value, unsigned nbBits)
195
0
{
196
0
    assert((value>>nbBits) == 0);
197
0
    assert(nbBits + bitC->bitPos < sizeof(bitC->bitContainer) * 8);
198
0
    bitC->bitContainer |= value << bitC->bitPos;
199
0
    bitC->bitPos += nbBits;
200
0
}
Unexecuted instantiation: zstd_common.c:BIT_addBitsFast
Unexecuted instantiation: zstd_compress.c:BIT_addBitsFast
Unexecuted instantiation: zstd_compress_literals.c:BIT_addBitsFast
Unexecuted instantiation: zstd_compress_sequences.c:BIT_addBitsFast
Unexecuted instantiation: zstd_compress_superblock.c:BIT_addBitsFast
Unexecuted instantiation: zstd_double_fast.c:BIT_addBitsFast
Unexecuted instantiation: zstd_fast.c:BIT_addBitsFast
Unexecuted instantiation: zstd_lazy.c:BIT_addBitsFast
Unexecuted instantiation: zstd_ldm.c:BIT_addBitsFast
Unexecuted instantiation: zstd_opt.c:BIT_addBitsFast
Unexecuted instantiation: zstd_preSplit.c:BIT_addBitsFast
Unexecuted instantiation: zstdmt_compress.c:BIT_addBitsFast
Unexecuted instantiation: zstd_decompress.c:BIT_addBitsFast
Unexecuted instantiation: zstd_decompress_block.c:BIT_addBitsFast
Unexecuted instantiation: entropy_common.c:BIT_addBitsFast
Unexecuted instantiation: fse_decompress.c:BIT_addBitsFast
Unexecuted instantiation: fse_compress.c:BIT_addBitsFast
Unexecuted instantiation: huf_compress.c:BIT_addBitsFast
Unexecuted instantiation: huf_decompress.c:BIT_addBitsFast
Unexecuted instantiation: zstd_ddict.c:BIT_addBitsFast
201
202
/*! BIT_flushBitsFast() :
203
 *  assumption : bitContainer has not overflowed
204
 *  unsafe version; does not check buffer overflow */
205
MEM_STATIC void BIT_flushBitsFast(BIT_CStream_t* bitC)
206
0
{
207
0
    size_t const nbBytes = bitC->bitPos >> 3;
208
0
    assert(bitC->bitPos < sizeof(bitC->bitContainer) * 8);
209
0
    assert(bitC->ptr <= bitC->endPtr);
210
0
    MEM_writeLEST(bitC->ptr, bitC->bitContainer);
211
0
    bitC->ptr += nbBytes;
212
0
    bitC->bitPos &= 7;
213
0
    bitC->bitContainer >>= nbBytes*8;
214
0
}
Unexecuted instantiation: zstd_common.c:BIT_flushBitsFast
Unexecuted instantiation: zstd_compress.c:BIT_flushBitsFast
Unexecuted instantiation: zstd_compress_literals.c:BIT_flushBitsFast
Unexecuted instantiation: zstd_compress_sequences.c:BIT_flushBitsFast
Unexecuted instantiation: zstd_compress_superblock.c:BIT_flushBitsFast
Unexecuted instantiation: zstd_double_fast.c:BIT_flushBitsFast
Unexecuted instantiation: zstd_fast.c:BIT_flushBitsFast
Unexecuted instantiation: zstd_lazy.c:BIT_flushBitsFast
Unexecuted instantiation: zstd_ldm.c:BIT_flushBitsFast
Unexecuted instantiation: zstd_opt.c:BIT_flushBitsFast
Unexecuted instantiation: zstd_preSplit.c:BIT_flushBitsFast
Unexecuted instantiation: zstdmt_compress.c:BIT_flushBitsFast
Unexecuted instantiation: zstd_decompress.c:BIT_flushBitsFast
Unexecuted instantiation: zstd_decompress_block.c:BIT_flushBitsFast
Unexecuted instantiation: entropy_common.c:BIT_flushBitsFast
Unexecuted instantiation: fse_decompress.c:BIT_flushBitsFast
Unexecuted instantiation: fse_compress.c:BIT_flushBitsFast
Unexecuted instantiation: huf_compress.c:BIT_flushBitsFast
Unexecuted instantiation: huf_decompress.c:BIT_flushBitsFast
Unexecuted instantiation: zstd_ddict.c:BIT_flushBitsFast
215
216
/*! BIT_flushBits() :
217
 *  assumption : bitContainer has not overflowed
218
 *  safe version; check for buffer overflow, and prevents it.
219
 *  note : does not signal buffer overflow.
220
 *  overflow will be revealed later on using BIT_closeCStream() */
221
MEM_STATIC void BIT_flushBits(BIT_CStream_t* bitC)
222
0
{
223
0
    size_t const nbBytes = bitC->bitPos >> 3;
224
0
    assert(bitC->bitPos < sizeof(bitC->bitContainer) * 8);
225
0
    assert(bitC->ptr <= bitC->endPtr);
226
0
    MEM_writeLEST(bitC->ptr, bitC->bitContainer);
227
0
    bitC->ptr += nbBytes;
228
0
    if (bitC->ptr > bitC->endPtr) bitC->ptr = bitC->endPtr;
229
0
    bitC->bitPos &= 7;
230
0
    bitC->bitContainer >>= nbBytes*8;
231
0
}
Unexecuted instantiation: zstd_common.c:BIT_flushBits
Unexecuted instantiation: zstd_compress.c:BIT_flushBits
Unexecuted instantiation: zstd_compress_literals.c:BIT_flushBits
Unexecuted instantiation: zstd_compress_sequences.c:BIT_flushBits
Unexecuted instantiation: zstd_compress_superblock.c:BIT_flushBits
Unexecuted instantiation: zstd_double_fast.c:BIT_flushBits
Unexecuted instantiation: zstd_fast.c:BIT_flushBits
Unexecuted instantiation: zstd_lazy.c:BIT_flushBits
Unexecuted instantiation: zstd_ldm.c:BIT_flushBits
Unexecuted instantiation: zstd_opt.c:BIT_flushBits
Unexecuted instantiation: zstd_preSplit.c:BIT_flushBits
Unexecuted instantiation: zstdmt_compress.c:BIT_flushBits
Unexecuted instantiation: zstd_decompress.c:BIT_flushBits
Unexecuted instantiation: zstd_decompress_block.c:BIT_flushBits
Unexecuted instantiation: entropy_common.c:BIT_flushBits
Unexecuted instantiation: fse_decompress.c:BIT_flushBits
Unexecuted instantiation: fse_compress.c:BIT_flushBits
Unexecuted instantiation: huf_compress.c:BIT_flushBits
Unexecuted instantiation: huf_decompress.c:BIT_flushBits
Unexecuted instantiation: zstd_ddict.c:BIT_flushBits
232
233
/*! BIT_closeCStream() :
234
 *  @return : size of CStream, in bytes,
235
 *            or 0 if it could not fit into dstBuffer */
236
MEM_STATIC size_t BIT_closeCStream(BIT_CStream_t* bitC)
237
0
{
238
0
    BIT_addBitsFast(bitC, 1, 1);   /* endMark */
239
0
    BIT_flushBits(bitC);
240
0
    if (bitC->ptr >= bitC->endPtr) return 0; /* overflow detected */
241
0
    return (size_t)(bitC->ptr - bitC->startPtr) + (bitC->bitPos > 0);
242
0
}
Unexecuted instantiation: zstd_common.c:BIT_closeCStream
Unexecuted instantiation: zstd_compress.c:BIT_closeCStream
Unexecuted instantiation: zstd_compress_literals.c:BIT_closeCStream
Unexecuted instantiation: zstd_compress_sequences.c:BIT_closeCStream
Unexecuted instantiation: zstd_compress_superblock.c:BIT_closeCStream
Unexecuted instantiation: zstd_double_fast.c:BIT_closeCStream
Unexecuted instantiation: zstd_fast.c:BIT_closeCStream
Unexecuted instantiation: zstd_lazy.c:BIT_closeCStream
Unexecuted instantiation: zstd_ldm.c:BIT_closeCStream
Unexecuted instantiation: zstd_opt.c:BIT_closeCStream
Unexecuted instantiation: zstd_preSplit.c:BIT_closeCStream
Unexecuted instantiation: zstdmt_compress.c:BIT_closeCStream
Unexecuted instantiation: zstd_decompress.c:BIT_closeCStream
Unexecuted instantiation: zstd_decompress_block.c:BIT_closeCStream
Unexecuted instantiation: entropy_common.c:BIT_closeCStream
Unexecuted instantiation: fse_decompress.c:BIT_closeCStream
Unexecuted instantiation: fse_compress.c:BIT_closeCStream
Unexecuted instantiation: huf_compress.c:BIT_closeCStream
Unexecuted instantiation: huf_decompress.c:BIT_closeCStream
Unexecuted instantiation: zstd_ddict.c:BIT_closeCStream
243
244
245
/*-********************************************************
246
*  bitStream decoding
247
**********************************************************/
248
/*! BIT_initDStream() :
249
 *  Initialize a BIT_DStream_t.
250
 * `bitD` : a pointer to an already allocated BIT_DStream_t structure.
251
 * `srcSize` must be the *exact* size of the bitStream, in bytes.
252
 * @return : size of stream (== srcSize), or an errorCode if a problem is detected
253
 */
254
MEM_STATIC size_t BIT_initDStream(BIT_DStream_t* bitD, const void* srcBuffer, size_t srcSize)
255
11.6k
{
256
11.6k
    if (srcSize < 1) { ZSTD_memset(bitD, 0, sizeof(*bitD)); return ERROR(srcSize_wrong); }
257
258
11.5k
    bitD->start = (const char*)srcBuffer;
259
11.5k
    bitD->limitPtr = bitD->start + sizeof(bitD->bitContainer);
260
261
11.5k
    if (srcSize >=  sizeof(bitD->bitContainer)) {  /* normal case */
262
8.63k
        bitD->ptr   = (const char*)srcBuffer + srcSize - sizeof(bitD->bitContainer);
263
8.63k
        bitD->bitContainer = MEM_readLEST(bitD->ptr);
264
8.63k
        { BYTE const lastByte = ((const BYTE*)srcBuffer)[srcSize-1];
265
8.63k
          bitD->bitsConsumed = lastByte ? 8 - ZSTD_highbit32(lastByte) : 0;  /* ensures bitsConsumed is always set */
266
8.63k
          if (lastByte == 0) return ERROR(GENERIC); /* endMark not present */ }
267
8.63k
    } else {
268
2.88k
        bitD->ptr   = bitD->start;
269
2.88k
        bitD->bitContainer = *(const BYTE*)(bitD->start);
270
2.88k
        switch(srcSize)
271
2.88k
        {
272
394
        case 7: bitD->bitContainer += (BitContainerType)(((const BYTE*)(srcBuffer))[6]) << (sizeof(bitD->bitContainer)*8 - 16);
273
394
                ZSTD_FALLTHROUGH;
274
275
684
        case 6: bitD->bitContainer += (BitContainerType)(((const BYTE*)(srcBuffer))[5]) << (sizeof(bitD->bitContainer)*8 - 24);
276
684
                ZSTD_FALLTHROUGH;
277
278
992
        case 5: bitD->bitContainer += (BitContainerType)(((const BYTE*)(srcBuffer))[4]) << (sizeof(bitD->bitContainer)*8 - 32);
279
992
                ZSTD_FALLTHROUGH;
280
281
1.38k
        case 4: bitD->bitContainer += (BitContainerType)(((const BYTE*)(srcBuffer))[3]) << 24;
282
1.38k
                ZSTD_FALLTHROUGH;
283
284
2.04k
        case 3: bitD->bitContainer += (BitContainerType)(((const BYTE*)(srcBuffer))[2]) << 16;
285
2.04k
                ZSTD_FALLTHROUGH;
286
287
2.49k
        case 2: bitD->bitContainer += (BitContainerType)(((const BYTE*)(srcBuffer))[1]) <<  8;
288
2.49k
                ZSTD_FALLTHROUGH;
289
290
2.88k
        default: break;
291
2.88k
        }
292
2.88k
        {   BYTE const lastByte = ((const BYTE*)srcBuffer)[srcSize-1];
293
2.88k
            bitD->bitsConsumed = lastByte ? 8 - ZSTD_highbit32(lastByte) : 0;
294
2.88k
            if (lastByte == 0) return ERROR(corruption_detected);  /* endMark not present */
295
2.88k
        }
296
2.72k
        bitD->bitsConsumed += (U32)(sizeof(bitD->bitContainer) - srcSize)*8;
297
2.72k
    }
298
299
11.0k
    return srcSize;
300
11.5k
}
Unexecuted instantiation: zstd_common.c:BIT_initDStream
Unexecuted instantiation: zstd_compress.c:BIT_initDStream
Unexecuted instantiation: zstd_compress_literals.c:BIT_initDStream
Unexecuted instantiation: zstd_compress_sequences.c:BIT_initDStream
Unexecuted instantiation: zstd_compress_superblock.c:BIT_initDStream
Unexecuted instantiation: zstd_double_fast.c:BIT_initDStream
Unexecuted instantiation: zstd_fast.c:BIT_initDStream
Unexecuted instantiation: zstd_lazy.c:BIT_initDStream
Unexecuted instantiation: zstd_ldm.c:BIT_initDStream
Unexecuted instantiation: zstd_opt.c:BIT_initDStream
Unexecuted instantiation: zstd_preSplit.c:BIT_initDStream
Unexecuted instantiation: zstdmt_compress.c:BIT_initDStream
Unexecuted instantiation: zstd_decompress.c:BIT_initDStream
zstd_decompress_block.c:BIT_initDStream
Line
Count
Source
255
4.31k
{
256
4.31k
    if (srcSize < 1) { ZSTD_memset(bitD, 0, sizeof(*bitD)); return ERROR(srcSize_wrong); }
257
258
4.25k
    bitD->start = (const char*)srcBuffer;
259
4.25k
    bitD->limitPtr = bitD->start + sizeof(bitD->bitContainer);
260
261
4.25k
    if (srcSize >=  sizeof(bitD->bitContainer)) {  /* normal case */
262
3.36k
        bitD->ptr   = (const char*)srcBuffer + srcSize - sizeof(bitD->bitContainer);
263
3.36k
        bitD->bitContainer = MEM_readLEST(bitD->ptr);
264
3.36k
        { BYTE const lastByte = ((const BYTE*)srcBuffer)[srcSize-1];
265
3.36k
          bitD->bitsConsumed = lastByte ? 8 - ZSTD_highbit32(lastByte) : 0;  /* ensures bitsConsumed is always set */
266
3.36k
          if (lastByte == 0) return ERROR(GENERIC); /* endMark not present */ }
267
3.36k
    } else {
268
893
        bitD->ptr   = bitD->start;
269
893
        bitD->bitContainer = *(const BYTE*)(bitD->start);
270
893
        switch(srcSize)
271
893
        {
272
115
        case 7: bitD->bitContainer += (BitContainerType)(((const BYTE*)(srcBuffer))[6]) << (sizeof(bitD->bitContainer)*8 - 16);
273
115
                ZSTD_FALLTHROUGH;
274
275
234
        case 6: bitD->bitContainer += (BitContainerType)(((const BYTE*)(srcBuffer))[5]) << (sizeof(bitD->bitContainer)*8 - 24);
276
234
                ZSTD_FALLTHROUGH;
277
278
345
        case 5: bitD->bitContainer += (BitContainerType)(((const BYTE*)(srcBuffer))[4]) << (sizeof(bitD->bitContainer)*8 - 32);
279
345
                ZSTD_FALLTHROUGH;
280
281
450
        case 4: bitD->bitContainer += (BitContainerType)(((const BYTE*)(srcBuffer))[3]) << 24;
282
450
                ZSTD_FALLTHROUGH;
283
284
661
        case 3: bitD->bitContainer += (BitContainerType)(((const BYTE*)(srcBuffer))[2]) << 16;
285
661
                ZSTD_FALLTHROUGH;
286
287
786
        case 2: bitD->bitContainer += (BitContainerType)(((const BYTE*)(srcBuffer))[1]) <<  8;
288
786
                ZSTD_FALLTHROUGH;
289
290
893
        default: break;
291
893
        }
292
893
        {   BYTE const lastByte = ((const BYTE*)srcBuffer)[srcSize-1];
293
893
            bitD->bitsConsumed = lastByte ? 8 - ZSTD_highbit32(lastByte) : 0;
294
893
            if (lastByte == 0) return ERROR(corruption_detected);  /* endMark not present */
295
893
        }
296
861
        bitD->bitsConsumed += (U32)(sizeof(bitD->bitContainer) - srcSize)*8;
297
861
    }
298
299
4.03k
    return srcSize;
300
4.25k
}
Unexecuted instantiation: entropy_common.c:BIT_initDStream
fse_decompress.c:BIT_initDStream
Line
Count
Source
255
3.58k
{
256
3.58k
    if (srcSize < 1) { ZSTD_memset(bitD, 0, sizeof(*bitD)); return ERROR(srcSize_wrong); }
257
258
3.56k
    bitD->start = (const char*)srcBuffer;
259
3.56k
    bitD->limitPtr = bitD->start + sizeof(bitD->bitContainer);
260
261
3.56k
    if (srcSize >=  sizeof(bitD->bitContainer)) {  /* normal case */
262
3.14k
        bitD->ptr   = (const char*)srcBuffer + srcSize - sizeof(bitD->bitContainer);
263
3.14k
        bitD->bitContainer = MEM_readLEST(bitD->ptr);
264
3.14k
        { BYTE const lastByte = ((const BYTE*)srcBuffer)[srcSize-1];
265
3.14k
          bitD->bitsConsumed = lastByte ? 8 - ZSTD_highbit32(lastByte) : 0;  /* ensures bitsConsumed is always set */
266
3.14k
          if (lastByte == 0) return ERROR(GENERIC); /* endMark not present */ }
267
3.14k
    } else {
268
426
        bitD->ptr   = bitD->start;
269
426
        bitD->bitContainer = *(const BYTE*)(bitD->start);
270
426
        switch(srcSize)
271
426
        {
272
38
        case 7: bitD->bitContainer += (BitContainerType)(((const BYTE*)(srcBuffer))[6]) << (sizeof(bitD->bitContainer)*8 - 16);
273
38
                ZSTD_FALLTHROUGH;
274
275
98
        case 6: bitD->bitContainer += (BitContainerType)(((const BYTE*)(srcBuffer))[5]) << (sizeof(bitD->bitContainer)*8 - 24);
276
98
                ZSTD_FALLTHROUGH;
277
278
136
        case 5: bitD->bitContainer += (BitContainerType)(((const BYTE*)(srcBuffer))[4]) << (sizeof(bitD->bitContainer)*8 - 32);
279
136
                ZSTD_FALLTHROUGH;
280
281
178
        case 4: bitD->bitContainer += (BitContainerType)(((const BYTE*)(srcBuffer))[3]) << 24;
282
178
                ZSTD_FALLTHROUGH;
283
284
294
        case 3: bitD->bitContainer += (BitContainerType)(((const BYTE*)(srcBuffer))[2]) << 16;
285
294
                ZSTD_FALLTHROUGH;
286
287
392
        case 2: bitD->bitContainer += (BitContainerType)(((const BYTE*)(srcBuffer))[1]) <<  8;
288
392
                ZSTD_FALLTHROUGH;
289
290
426
        default: break;
291
426
        }
292
426
        {   BYTE const lastByte = ((const BYTE*)srcBuffer)[srcSize-1];
293
426
            bitD->bitsConsumed = lastByte ? 8 - ZSTD_highbit32(lastByte) : 0;
294
426
            if (lastByte == 0) return ERROR(corruption_detected);  /* endMark not present */
295
426
        }
296
378
        bitD->bitsConsumed += (U32)(sizeof(bitD->bitContainer) - srcSize)*8;
297
378
    }
298
299
3.43k
    return srcSize;
300
3.56k
}
Unexecuted instantiation: fse_compress.c:BIT_initDStream
Unexecuted instantiation: huf_compress.c:BIT_initDStream
huf_decompress.c:BIT_initDStream
Line
Count
Source
255
3.78k
{
256
3.78k
    if (srcSize < 1) { ZSTD_memset(bitD, 0, sizeof(*bitD)); return ERROR(srcSize_wrong); }
257
258
3.69k
    bitD->start = (const char*)srcBuffer;
259
3.69k
    bitD->limitPtr = bitD->start + sizeof(bitD->bitContainer);
260
261
3.69k
    if (srcSize >=  sizeof(bitD->bitContainer)) {  /* normal case */
262
2.12k
        bitD->ptr   = (const char*)srcBuffer + srcSize - sizeof(bitD->bitContainer);
263
2.12k
        bitD->bitContainer = MEM_readLEST(bitD->ptr);
264
2.12k
        { BYTE const lastByte = ((const BYTE*)srcBuffer)[srcSize-1];
265
2.12k
          bitD->bitsConsumed = lastByte ? 8 - ZSTD_highbit32(lastByte) : 0;  /* ensures bitsConsumed is always set */
266
2.12k
          if (lastByte == 0) return ERROR(GENERIC); /* endMark not present */ }
267
2.12k
    } else {
268
1.56k
        bitD->ptr   = bitD->start;
269
1.56k
        bitD->bitContainer = *(const BYTE*)(bitD->start);
270
1.56k
        switch(srcSize)
271
1.56k
        {
272
241
        case 7: bitD->bitContainer += (BitContainerType)(((const BYTE*)(srcBuffer))[6]) << (sizeof(bitD->bitContainer)*8 - 16);
273
241
                ZSTD_FALLTHROUGH;
274
275
352
        case 6: bitD->bitContainer += (BitContainerType)(((const BYTE*)(srcBuffer))[5]) << (sizeof(bitD->bitContainer)*8 - 24);
276
352
                ZSTD_FALLTHROUGH;
277
278
511
        case 5: bitD->bitContainer += (BitContainerType)(((const BYTE*)(srcBuffer))[4]) << (sizeof(bitD->bitContainer)*8 - 32);
279
511
                ZSTD_FALLTHROUGH;
280
281
752
        case 4: bitD->bitContainer += (BitContainerType)(((const BYTE*)(srcBuffer))[3]) << 24;
282
752
                ZSTD_FALLTHROUGH;
283
284
1.09k
        case 3: bitD->bitContainer += (BitContainerType)(((const BYTE*)(srcBuffer))[2]) << 16;
285
1.09k
                ZSTD_FALLTHROUGH;
286
287
1.31k
        case 2: bitD->bitContainer += (BitContainerType)(((const BYTE*)(srcBuffer))[1]) <<  8;
288
1.31k
                ZSTD_FALLTHROUGH;
289
290
1.56k
        default: break;
291
1.56k
        }
292
1.56k
        {   BYTE const lastByte = ((const BYTE*)srcBuffer)[srcSize-1];
293
1.56k
            bitD->bitsConsumed = lastByte ? 8 - ZSTD_highbit32(lastByte) : 0;
294
1.56k
            if (lastByte == 0) return ERROR(corruption_detected);  /* endMark not present */
295
1.56k
        }
296
1.48k
        bitD->bitsConsumed += (U32)(sizeof(bitD->bitContainer) - srcSize)*8;
297
1.48k
    }
298
299
3.54k
    return srcSize;
300
3.69k
}
Unexecuted instantiation: zstd_ddict.c:BIT_initDStream
301
302
FORCE_INLINE_TEMPLATE BitContainerType BIT_getUpperBits(BitContainerType bitContainer, U32 const start)
303
0
{
304
0
    return bitContainer >> start;
305
0
}
Unexecuted instantiation: zstd_common.c:BIT_getUpperBits
Unexecuted instantiation: zstd_compress.c:BIT_getUpperBits
Unexecuted instantiation: zstd_compress_literals.c:BIT_getUpperBits
Unexecuted instantiation: zstd_compress_sequences.c:BIT_getUpperBits
Unexecuted instantiation: zstd_compress_superblock.c:BIT_getUpperBits
Unexecuted instantiation: zstd_double_fast.c:BIT_getUpperBits
Unexecuted instantiation: zstd_fast.c:BIT_getUpperBits
Unexecuted instantiation: zstd_lazy.c:BIT_getUpperBits
Unexecuted instantiation: zstd_ldm.c:BIT_getUpperBits
Unexecuted instantiation: zstd_opt.c:BIT_getUpperBits
Unexecuted instantiation: zstd_preSplit.c:BIT_getUpperBits
Unexecuted instantiation: zstdmt_compress.c:BIT_getUpperBits
Unexecuted instantiation: zstd_decompress.c:BIT_getUpperBits
Unexecuted instantiation: zstd_decompress_block.c:BIT_getUpperBits
Unexecuted instantiation: entropy_common.c:BIT_getUpperBits
Unexecuted instantiation: fse_decompress.c:BIT_getUpperBits
Unexecuted instantiation: fse_compress.c:BIT_getUpperBits
Unexecuted instantiation: huf_compress.c:BIT_getUpperBits
Unexecuted instantiation: huf_decompress.c:BIT_getUpperBits
Unexecuted instantiation: zstd_ddict.c:BIT_getUpperBits
306
307
FORCE_INLINE_TEMPLATE BitContainerType BIT_getMiddleBits(BitContainerType bitContainer, U32 const start, U32 const nbBits)
308
35.0M
{
309
35.0M
    U32 const regMask = sizeof(bitContainer)*8 - 1;
310
    /* if start > regMask, bitstream is corrupted, and result is undefined */
311
35.0M
    assert(nbBits < BIT_MASK_SIZE);
312
    /* x86 transform & ((1 << nbBits) - 1) to bzhi instruction, it is better
313
     * than accessing memory. When bmi2 instruction is not present, we consider
314
     * such cpus old (pre-Haswell, 2013) and their performance is not of that
315
     * importance.
316
     */
317
35.0M
#if defined(__x86_64__) || defined(_M_X64)
318
35.0M
    return (bitContainer >> (start & regMask)) & ((((U64)1) << nbBits) - 1);
319
#else
320
    return (bitContainer >> (start & regMask)) & BIT_mask[nbBits];
321
#endif
322
35.0M
}
Unexecuted instantiation: zstd_common.c:BIT_getMiddleBits
Unexecuted instantiation: zstd_compress.c:BIT_getMiddleBits
Unexecuted instantiation: zstd_compress_literals.c:BIT_getMiddleBits
Unexecuted instantiation: zstd_compress_sequences.c:BIT_getMiddleBits
Unexecuted instantiation: zstd_compress_superblock.c:BIT_getMiddleBits
Unexecuted instantiation: zstd_double_fast.c:BIT_getMiddleBits
Unexecuted instantiation: zstd_fast.c:BIT_getMiddleBits
Unexecuted instantiation: zstd_lazy.c:BIT_getMiddleBits
Unexecuted instantiation: zstd_ldm.c:BIT_getMiddleBits
Unexecuted instantiation: zstd_opt.c:BIT_getMiddleBits
Unexecuted instantiation: zstd_preSplit.c:BIT_getMiddleBits
Unexecuted instantiation: zstdmt_compress.c:BIT_getMiddleBits
Unexecuted instantiation: zstd_decompress.c:BIT_getMiddleBits
zstd_decompress_block.c:BIT_getMiddleBits
Line
Count
Source
308
34.7M
{
309
34.7M
    U32 const regMask = sizeof(bitContainer)*8 - 1;
310
    /* if start > regMask, bitstream is corrupted, and result is undefined */
311
34.7M
    assert(nbBits < BIT_MASK_SIZE);
312
    /* x86 transform & ((1 << nbBits) - 1) to bzhi instruction, it is better
313
     * than accessing memory. When bmi2 instruction is not present, we consider
314
     * such cpus old (pre-Haswell, 2013) and their performance is not of that
315
     * importance.
316
     */
317
34.7M
#if defined(__x86_64__) || defined(_M_X64)
318
34.7M
    return (bitContainer >> (start & regMask)) & ((((U64)1) << nbBits) - 1);
319
#else
320
    return (bitContainer >> (start & regMask)) & BIT_mask[nbBits];
321
#endif
322
34.7M
}
Unexecuted instantiation: entropy_common.c:BIT_getMiddleBits
fse_decompress.c:BIT_getMiddleBits
Line
Count
Source
308
273k
{
309
273k
    U32 const regMask = sizeof(bitContainer)*8 - 1;
310
    /* if start > regMask, bitstream is corrupted, and result is undefined */
311
273k
    assert(nbBits < BIT_MASK_SIZE);
312
    /* x86 transform & ((1 << nbBits) - 1) to bzhi instruction, it is better
313
     * than accessing memory. When bmi2 instruction is not present, we consider
314
     * such cpus old (pre-Haswell, 2013) and their performance is not of that
315
     * importance.
316
     */
317
273k
#if defined(__x86_64__) || defined(_M_X64)
318
273k
    return (bitContainer >> (start & regMask)) & ((((U64)1) << nbBits) - 1);
319
#else
320
    return (bitContainer >> (start & regMask)) & BIT_mask[nbBits];
321
#endif
322
273k
}
Unexecuted instantiation: fse_compress.c:BIT_getMiddleBits
Unexecuted instantiation: huf_compress.c:BIT_getMiddleBits
Unexecuted instantiation: huf_decompress.c:BIT_getMiddleBits
Unexecuted instantiation: zstd_ddict.c:BIT_getMiddleBits
323
324
/*! BIT_lookBits() :
325
 *  Provides next n bits from local register.
326
 *  local register is not modified.
327
 *  On 32-bits, maxNbBits==24.
328
 *  On 64-bits, maxNbBits==56.
329
 * @return : value extracted */
330
FORCE_INLINE_TEMPLATE BitContainerType BIT_lookBits(const BIT_DStream_t*  bitD, U32 nbBits)
331
35.0M
{
332
    /* arbitrate between double-shift and shift+mask */
333
35.0M
#if 1
334
    /* if bitD->bitsConsumed + nbBits > sizeof(bitD->bitContainer)*8,
335
     * bitstream is likely corrupted, and result is undefined */
336
35.0M
    return BIT_getMiddleBits(bitD->bitContainer, (sizeof(bitD->bitContainer)*8) - bitD->bitsConsumed - nbBits, nbBits);
337
#else
338
    /* this code path is slower on my os-x laptop */
339
    U32 const regMask = sizeof(bitD->bitContainer)*8 - 1;
340
    return ((bitD->bitContainer << (bitD->bitsConsumed & regMask)) >> 1) >> ((regMask-nbBits) & regMask);
341
#endif
342
35.0M
}
Unexecuted instantiation: zstd_common.c:BIT_lookBits
Unexecuted instantiation: zstd_compress.c:BIT_lookBits
Unexecuted instantiation: zstd_compress_literals.c:BIT_lookBits
Unexecuted instantiation: zstd_compress_sequences.c:BIT_lookBits
Unexecuted instantiation: zstd_compress_superblock.c:BIT_lookBits
Unexecuted instantiation: zstd_double_fast.c:BIT_lookBits
Unexecuted instantiation: zstd_fast.c:BIT_lookBits
Unexecuted instantiation: zstd_lazy.c:BIT_lookBits
Unexecuted instantiation: zstd_ldm.c:BIT_lookBits
Unexecuted instantiation: zstd_opt.c:BIT_lookBits
Unexecuted instantiation: zstd_preSplit.c:BIT_lookBits
Unexecuted instantiation: zstdmt_compress.c:BIT_lookBits
Unexecuted instantiation: zstd_decompress.c:BIT_lookBits
zstd_decompress_block.c:BIT_lookBits
Line
Count
Source
331
34.7M
{
332
    /* arbitrate between double-shift and shift+mask */
333
34.7M
#if 1
334
    /* if bitD->bitsConsumed + nbBits > sizeof(bitD->bitContainer)*8,
335
     * bitstream is likely corrupted, and result is undefined */
336
34.7M
    return BIT_getMiddleBits(bitD->bitContainer, (sizeof(bitD->bitContainer)*8) - bitD->bitsConsumed - nbBits, nbBits);
337
#else
338
    /* this code path is slower on my os-x laptop */
339
    U32 const regMask = sizeof(bitD->bitContainer)*8 - 1;
340
    return ((bitD->bitContainer << (bitD->bitsConsumed & regMask)) >> 1) >> ((regMask-nbBits) & regMask);
341
#endif
342
34.7M
}
Unexecuted instantiation: entropy_common.c:BIT_lookBits
fse_decompress.c:BIT_lookBits
Line
Count
Source
331
273k
{
332
    /* arbitrate between double-shift and shift+mask */
333
273k
#if 1
334
    /* if bitD->bitsConsumed + nbBits > sizeof(bitD->bitContainer)*8,
335
     * bitstream is likely corrupted, and result is undefined */
336
273k
    return BIT_getMiddleBits(bitD->bitContainer, (sizeof(bitD->bitContainer)*8) - bitD->bitsConsumed - nbBits, nbBits);
337
#else
338
    /* this code path is slower on my os-x laptop */
339
    U32 const regMask = sizeof(bitD->bitContainer)*8 - 1;
340
    return ((bitD->bitContainer << (bitD->bitsConsumed & regMask)) >> 1) >> ((regMask-nbBits) & regMask);
341
#endif
342
273k
}
Unexecuted instantiation: fse_compress.c:BIT_lookBits
Unexecuted instantiation: huf_compress.c:BIT_lookBits
Unexecuted instantiation: huf_decompress.c:BIT_lookBits
Unexecuted instantiation: zstd_ddict.c:BIT_lookBits
343
344
/*! BIT_lookBitsFast() :
345
 *  unsafe version; only works if nbBits >= 1 */
346
MEM_STATIC BitContainerType BIT_lookBitsFast(const BIT_DStream_t* bitD, U32 nbBits)
347
11.6M
{
348
11.6M
    U32 const regMask = sizeof(bitD->bitContainer)*8 - 1;
349
11.6M
    assert(nbBits >= 1);
350
11.6M
    return (bitD->bitContainer << (bitD->bitsConsumed & regMask)) >> (((regMask+1)-nbBits) & regMask);
351
11.6M
}
Unexecuted instantiation: zstd_common.c:BIT_lookBitsFast
Unexecuted instantiation: zstd_compress.c:BIT_lookBitsFast
Unexecuted instantiation: zstd_compress_literals.c:BIT_lookBitsFast
Unexecuted instantiation: zstd_compress_sequences.c:BIT_lookBitsFast
Unexecuted instantiation: zstd_compress_superblock.c:BIT_lookBitsFast
Unexecuted instantiation: zstd_double_fast.c:BIT_lookBitsFast
Unexecuted instantiation: zstd_fast.c:BIT_lookBitsFast
Unexecuted instantiation: zstd_lazy.c:BIT_lookBitsFast
Unexecuted instantiation: zstd_ldm.c:BIT_lookBitsFast
Unexecuted instantiation: zstd_opt.c:BIT_lookBitsFast
Unexecuted instantiation: zstd_preSplit.c:BIT_lookBitsFast
Unexecuted instantiation: zstdmt_compress.c:BIT_lookBitsFast
Unexecuted instantiation: zstd_decompress.c:BIT_lookBitsFast
zstd_decompress_block.c:BIT_lookBitsFast
Line
Count
Source
347
7.61M
{
348
7.61M
    U32 const regMask = sizeof(bitD->bitContainer)*8 - 1;
349
7.61M
    assert(nbBits >= 1);
350
7.61M
    return (bitD->bitContainer << (bitD->bitsConsumed & regMask)) >> (((regMask+1)-nbBits) & regMask);
351
7.61M
}
Unexecuted instantiation: entropy_common.c:BIT_lookBitsFast
fse_decompress.c:BIT_lookBitsFast
Line
Count
Source
347
32.8k
{
348
32.8k
    U32 const regMask = sizeof(bitD->bitContainer)*8 - 1;
349
32.8k
    assert(nbBits >= 1);
350
32.8k
    return (bitD->bitContainer << (bitD->bitsConsumed & regMask)) >> (((regMask+1)-nbBits) & regMask);
351
32.8k
}
Unexecuted instantiation: fse_compress.c:BIT_lookBitsFast
Unexecuted instantiation: huf_compress.c:BIT_lookBitsFast
huf_decompress.c:BIT_lookBitsFast
Line
Count
Source
347
3.98M
{
348
3.98M
    U32 const regMask = sizeof(bitD->bitContainer)*8 - 1;
349
3.98M
    assert(nbBits >= 1);
350
3.98M
    return (bitD->bitContainer << (bitD->bitsConsumed & regMask)) >> (((regMask+1)-nbBits) & regMask);
351
3.98M
}
Unexecuted instantiation: zstd_ddict.c:BIT_lookBitsFast
352
353
FORCE_INLINE_TEMPLATE void BIT_skipBits(BIT_DStream_t* bitD, U32 nbBits)
354
46.6M
{
355
46.6M
    bitD->bitsConsumed += nbBits;
356
46.6M
}
Unexecuted instantiation: zstd_common.c:BIT_skipBits
Unexecuted instantiation: zstd_compress.c:BIT_skipBits
Unexecuted instantiation: zstd_compress_literals.c:BIT_skipBits
Unexecuted instantiation: zstd_compress_sequences.c:BIT_skipBits
Unexecuted instantiation: zstd_compress_superblock.c:BIT_skipBits
Unexecuted instantiation: zstd_double_fast.c:BIT_skipBits
Unexecuted instantiation: zstd_fast.c:BIT_skipBits
Unexecuted instantiation: zstd_lazy.c:BIT_skipBits
Unexecuted instantiation: zstd_ldm.c:BIT_skipBits
Unexecuted instantiation: zstd_opt.c:BIT_skipBits
Unexecuted instantiation: zstd_preSplit.c:BIT_skipBits
Unexecuted instantiation: zstdmt_compress.c:BIT_skipBits
Unexecuted instantiation: zstd_decompress.c:BIT_skipBits
zstd_decompress_block.c:BIT_skipBits
Line
Count
Source
354
42.4M
{
355
42.4M
    bitD->bitsConsumed += nbBits;
356
42.4M
}
Unexecuted instantiation: entropy_common.c:BIT_skipBits
fse_decompress.c:BIT_skipBits
Line
Count
Source
354
306k
{
355
306k
    bitD->bitsConsumed += nbBits;
356
306k
}
Unexecuted instantiation: fse_compress.c:BIT_skipBits
Unexecuted instantiation: huf_compress.c:BIT_skipBits
huf_decompress.c:BIT_skipBits
Line
Count
Source
354
3.98M
{
355
3.98M
    bitD->bitsConsumed += nbBits;
356
3.98M
}
Unexecuted instantiation: zstd_ddict.c:BIT_skipBits
357
358
/*! BIT_readBits() :
359
 *  Read (consume) next n bits from local register and update.
360
 *  Pay attention to not read more than nbBits contained into local register.
361
 * @return : extracted value. */
362
FORCE_INLINE_TEMPLATE BitContainerType BIT_readBits(BIT_DStream_t* bitD, unsigned nbBits)
363
35.0M
{
364
35.0M
    BitContainerType const value = BIT_lookBits(bitD, nbBits);
365
35.0M
    BIT_skipBits(bitD, nbBits);
366
35.0M
    return value;
367
35.0M
}
Unexecuted instantiation: zstd_common.c:BIT_readBits
Unexecuted instantiation: zstd_compress.c:BIT_readBits
Unexecuted instantiation: zstd_compress_literals.c:BIT_readBits
Unexecuted instantiation: zstd_compress_sequences.c:BIT_readBits
Unexecuted instantiation: zstd_compress_superblock.c:BIT_readBits
Unexecuted instantiation: zstd_double_fast.c:BIT_readBits
Unexecuted instantiation: zstd_fast.c:BIT_readBits
Unexecuted instantiation: zstd_lazy.c:BIT_readBits
Unexecuted instantiation: zstd_ldm.c:BIT_readBits
Unexecuted instantiation: zstd_opt.c:BIT_readBits
Unexecuted instantiation: zstd_preSplit.c:BIT_readBits
Unexecuted instantiation: zstdmt_compress.c:BIT_readBits
Unexecuted instantiation: zstd_decompress.c:BIT_readBits
zstd_decompress_block.c:BIT_readBits
Line
Count
Source
363
34.7M
{
364
34.7M
    BitContainerType const value = BIT_lookBits(bitD, nbBits);
365
34.7M
    BIT_skipBits(bitD, nbBits);
366
34.7M
    return value;
367
34.7M
}
Unexecuted instantiation: entropy_common.c:BIT_readBits
fse_decompress.c:BIT_readBits
Line
Count
Source
363
273k
{
364
273k
    BitContainerType const value = BIT_lookBits(bitD, nbBits);
365
273k
    BIT_skipBits(bitD, nbBits);
366
273k
    return value;
367
273k
}
Unexecuted instantiation: fse_compress.c:BIT_readBits
Unexecuted instantiation: huf_compress.c:BIT_readBits
Unexecuted instantiation: huf_decompress.c:BIT_readBits
Unexecuted instantiation: zstd_ddict.c:BIT_readBits
368
369
/*! BIT_readBitsFast() :
370
 *  unsafe version; only works if nbBits >= 1 */
371
MEM_STATIC BitContainerType BIT_readBitsFast(BIT_DStream_t* bitD, unsigned nbBits)
372
7.64M
{
373
7.64M
    BitContainerType const value = BIT_lookBitsFast(bitD, nbBits);
374
7.64M
    assert(nbBits >= 1);
375
7.64M
    BIT_skipBits(bitD, nbBits);
376
7.64M
    return value;
377
7.64M
}
Unexecuted instantiation: zstd_common.c:BIT_readBitsFast
Unexecuted instantiation: zstd_compress.c:BIT_readBitsFast
Unexecuted instantiation: zstd_compress_literals.c:BIT_readBitsFast
Unexecuted instantiation: zstd_compress_sequences.c:BIT_readBitsFast
Unexecuted instantiation: zstd_compress_superblock.c:BIT_readBitsFast
Unexecuted instantiation: zstd_double_fast.c:BIT_readBitsFast
Unexecuted instantiation: zstd_fast.c:BIT_readBitsFast
Unexecuted instantiation: zstd_lazy.c:BIT_readBitsFast
Unexecuted instantiation: zstd_ldm.c:BIT_readBitsFast
Unexecuted instantiation: zstd_opt.c:BIT_readBitsFast
Unexecuted instantiation: zstd_preSplit.c:BIT_readBitsFast
Unexecuted instantiation: zstdmt_compress.c:BIT_readBitsFast
Unexecuted instantiation: zstd_decompress.c:BIT_readBitsFast
zstd_decompress_block.c:BIT_readBitsFast
Line
Count
Source
372
7.61M
{
373
7.61M
    BitContainerType const value = BIT_lookBitsFast(bitD, nbBits);
374
7.61M
    assert(nbBits >= 1);
375
7.61M
    BIT_skipBits(bitD, nbBits);
376
7.61M
    return value;
377
7.61M
}
Unexecuted instantiation: entropy_common.c:BIT_readBitsFast
fse_decompress.c:BIT_readBitsFast
Line
Count
Source
372
32.8k
{
373
32.8k
    BitContainerType const value = BIT_lookBitsFast(bitD, nbBits);
374
32.8k
    assert(nbBits >= 1);
375
32.8k
    BIT_skipBits(bitD, nbBits);
376
32.8k
    return value;
377
32.8k
}
Unexecuted instantiation: fse_compress.c:BIT_readBitsFast
Unexecuted instantiation: huf_compress.c:BIT_readBitsFast
Unexecuted instantiation: huf_decompress.c:BIT_readBitsFast
Unexecuted instantiation: zstd_ddict.c:BIT_readBitsFast
378
379
/*! BIT_reloadDStream_internal() :
380
 *  Simple variant of BIT_reloadDStream(), with two conditions:
381
 *  1. bitstream is valid : bitsConsumed <= sizeof(bitD->bitContainer)*8
382
 *  2. look window is valid after shifted down : bitD->ptr >= bitD->start
383
 */
384
MEM_STATIC BIT_DStream_status BIT_reloadDStream_internal(BIT_DStream_t* bitD)
385
560k
{
386
560k
    assert(bitD->bitsConsumed <= sizeof(bitD->bitContainer)*8);
387
560k
    bitD->ptr -= bitD->bitsConsumed >> 3;
388
560k
    assert(bitD->ptr >= bitD->start);
389
560k
    bitD->bitsConsumed &= 7;
390
560k
    bitD->bitContainer = MEM_readLEST(bitD->ptr);
391
560k
    return BIT_DStream_unfinished;
392
560k
}
Unexecuted instantiation: zstd_common.c:BIT_reloadDStream_internal
Unexecuted instantiation: zstd_compress.c:BIT_reloadDStream_internal
Unexecuted instantiation: zstd_compress_literals.c:BIT_reloadDStream_internal
Unexecuted instantiation: zstd_compress_sequences.c:BIT_reloadDStream_internal
Unexecuted instantiation: zstd_compress_superblock.c:BIT_reloadDStream_internal
Unexecuted instantiation: zstd_double_fast.c:BIT_reloadDStream_internal
Unexecuted instantiation: zstd_fast.c:BIT_reloadDStream_internal
Unexecuted instantiation: zstd_lazy.c:BIT_reloadDStream_internal
Unexecuted instantiation: zstd_ldm.c:BIT_reloadDStream_internal
Unexecuted instantiation: zstd_opt.c:BIT_reloadDStream_internal
Unexecuted instantiation: zstd_preSplit.c:BIT_reloadDStream_internal
Unexecuted instantiation: zstdmt_compress.c:BIT_reloadDStream_internal
Unexecuted instantiation: zstd_decompress.c:BIT_reloadDStream_internal
zstd_decompress_block.c:BIT_reloadDStream_internal
Line
Count
Source
385
429k
{
386
429k
    assert(bitD->bitsConsumed <= sizeof(bitD->bitContainer)*8);
387
429k
    bitD->ptr -= bitD->bitsConsumed >> 3;
388
429k
    assert(bitD->ptr >= bitD->start);
389
429k
    bitD->bitsConsumed &= 7;
390
429k
    bitD->bitContainer = MEM_readLEST(bitD->ptr);
391
429k
    return BIT_DStream_unfinished;
392
429k
}
Unexecuted instantiation: entropy_common.c:BIT_reloadDStream_internal
fse_decompress.c:BIT_reloadDStream_internal
Line
Count
Source
385
6.94k
{
386
6.94k
    assert(bitD->bitsConsumed <= sizeof(bitD->bitContainer)*8);
387
6.94k
    bitD->ptr -= bitD->bitsConsumed >> 3;
388
6.94k
    assert(bitD->ptr >= bitD->start);
389
6.94k
    bitD->bitsConsumed &= 7;
390
6.94k
    bitD->bitContainer = MEM_readLEST(bitD->ptr);
391
6.94k
    return BIT_DStream_unfinished;
392
6.94k
}
Unexecuted instantiation: fse_compress.c:BIT_reloadDStream_internal
Unexecuted instantiation: huf_compress.c:BIT_reloadDStream_internal
huf_decompress.c:BIT_reloadDStream_internal
Line
Count
Source
385
123k
{
386
123k
    assert(bitD->bitsConsumed <= sizeof(bitD->bitContainer)*8);
387
123k
    bitD->ptr -= bitD->bitsConsumed >> 3;
388
123k
    assert(bitD->ptr >= bitD->start);
389
123k
    bitD->bitsConsumed &= 7;
390
123k
    bitD->bitContainer = MEM_readLEST(bitD->ptr);
391
123k
    return BIT_DStream_unfinished;
392
123k
}
Unexecuted instantiation: zstd_ddict.c:BIT_reloadDStream_internal
393
394
/*! BIT_reloadDStreamFast() :
395
 *  Similar to BIT_reloadDStream(), but with two differences:
396
 *  1. bitsConsumed <= sizeof(bitD->bitContainer)*8 must hold!
397
 *  2. Returns BIT_DStream_overflow when bitD->ptr < bitD->limitPtr, at this
398
 *     point you must use BIT_reloadDStream() to reload.
399
 */
400
MEM_STATIC BIT_DStream_status BIT_reloadDStreamFast(BIT_DStream_t* bitD)
401
4.07k
{
402
4.07k
    if (UNLIKELY(bitD->ptr < bitD->limitPtr))
403
1.67k
        return BIT_DStream_overflow;
404
2.40k
    return BIT_reloadDStream_internal(bitD);
405
4.07k
}
Unexecuted instantiation: zstd_common.c:BIT_reloadDStreamFast
Unexecuted instantiation: zstd_compress.c:BIT_reloadDStreamFast
Unexecuted instantiation: zstd_compress_literals.c:BIT_reloadDStreamFast
Unexecuted instantiation: zstd_compress_sequences.c:BIT_reloadDStreamFast
Unexecuted instantiation: zstd_compress_superblock.c:BIT_reloadDStreamFast
Unexecuted instantiation: zstd_double_fast.c:BIT_reloadDStreamFast
Unexecuted instantiation: zstd_fast.c:BIT_reloadDStreamFast
Unexecuted instantiation: zstd_lazy.c:BIT_reloadDStreamFast
Unexecuted instantiation: zstd_ldm.c:BIT_reloadDStreamFast
Unexecuted instantiation: zstd_opt.c:BIT_reloadDStreamFast
Unexecuted instantiation: zstd_preSplit.c:BIT_reloadDStreamFast
Unexecuted instantiation: zstdmt_compress.c:BIT_reloadDStreamFast
Unexecuted instantiation: zstd_decompress.c:BIT_reloadDStreamFast
Unexecuted instantiation: zstd_decompress_block.c:BIT_reloadDStreamFast
Unexecuted instantiation: entropy_common.c:BIT_reloadDStreamFast
Unexecuted instantiation: fse_decompress.c:BIT_reloadDStreamFast
Unexecuted instantiation: fse_compress.c:BIT_reloadDStreamFast
Unexecuted instantiation: huf_compress.c:BIT_reloadDStreamFast
huf_decompress.c:BIT_reloadDStreamFast
Line
Count
Source
401
4.07k
{
402
4.07k
    if (UNLIKELY(bitD->ptr < bitD->limitPtr))
403
1.67k
        return BIT_DStream_overflow;
404
2.40k
    return BIT_reloadDStream_internal(bitD);
405
4.07k
}
Unexecuted instantiation: zstd_ddict.c:BIT_reloadDStreamFast
406
407
/*! BIT_reloadDStream() :
408
 *  Refill `bitD` from buffer previously set in BIT_initDStream() .
409
 *  This function is safe, it guarantees it will not never beyond src buffer.
410
 * @return : status of `BIT_DStream_t` internal register.
411
 *           when status == BIT_DStream_unfinished, internal register is filled with at least 25 or 57 bits */
412
FORCE_INLINE_TEMPLATE BIT_DStream_status BIT_reloadDStream(BIT_DStream_t* bitD)
413
11.9M
{
414
    /* note : once in overflow mode, a bitstream remains in this mode until it's reset */
415
11.9M
    if (UNLIKELY(bitD->bitsConsumed > (sizeof(bitD->bitContainer)*8))) {
416
11.1M
        static const BitContainerType zeroFilled = 0;
417
11.1M
        bitD->ptr = (const char*)&zeroFilled; /* aliasing is allowed for char */
418
        /* overflow detected, erroneous scenario or end of stream: no update */
419
11.1M
        return BIT_DStream_overflow;
420
11.1M
    }
421
422
871k
    assert(bitD->ptr >= bitD->start);
423
424
871k
    if (bitD->ptr >= bitD->limitPtr) {
425
557k
        return BIT_reloadDStream_internal(bitD);
426
557k
    }
427
314k
    if (bitD->ptr == bitD->start) {
428
        /* reached end of bitStream => no update */
429
185k
        if (bitD->bitsConsumed < sizeof(bitD->bitContainer)*8) return BIT_DStream_endOfBuffer;
430
3.64k
        return BIT_DStream_completed;
431
185k
    }
432
    /* start < ptr < limitPtr => cautious update */
433
128k
    {   U32 nbBytes = bitD->bitsConsumed >> 3;
434
128k
        BIT_DStream_status result = BIT_DStream_unfinished;
435
128k
        if (bitD->ptr - nbBytes < bitD->start) {
436
5.28k
            nbBytes = (U32)(bitD->ptr - bitD->start);  /* ptr > start */
437
5.28k
            result = BIT_DStream_endOfBuffer;
438
5.28k
        }
439
128k
        bitD->ptr -= nbBytes;
440
128k
        bitD->bitsConsumed -= nbBytes*8;
441
128k
        bitD->bitContainer = MEM_readLEST(bitD->ptr);   /* reminder : srcSize > sizeof(bitD->bitContainer), otherwise bitD->ptr == bitD->start */
442
128k
        return result;
443
314k
    }
444
314k
}
Unexecuted instantiation: zstd_common.c:BIT_reloadDStream
Unexecuted instantiation: zstd_compress.c:BIT_reloadDStream
Unexecuted instantiation: zstd_compress_literals.c:BIT_reloadDStream
Unexecuted instantiation: zstd_compress_sequences.c:BIT_reloadDStream
Unexecuted instantiation: zstd_compress_superblock.c:BIT_reloadDStream
Unexecuted instantiation: zstd_double_fast.c:BIT_reloadDStream
Unexecuted instantiation: zstd_fast.c:BIT_reloadDStream
Unexecuted instantiation: zstd_lazy.c:BIT_reloadDStream
Unexecuted instantiation: zstd_ldm.c:BIT_reloadDStream
Unexecuted instantiation: zstd_opt.c:BIT_reloadDStream
Unexecuted instantiation: zstd_preSplit.c:BIT_reloadDStream
Unexecuted instantiation: zstdmt_compress.c:BIT_reloadDStream
Unexecuted instantiation: zstd_decompress.c:BIT_reloadDStream
zstd_decompress_block.c:BIT_reloadDStream
Line
Count
Source
413
11.6M
{
414
    /* note : once in overflow mode, a bitstream remains in this mode until it's reset */
415
11.6M
    if (UNLIKELY(bitD->bitsConsumed > (sizeof(bitD->bitContainer)*8))) {
416
11.1M
        static const BitContainerType zeroFilled = 0;
417
11.1M
        bitD->ptr = (const char*)&zeroFilled; /* aliasing is allowed for char */
418
        /* overflow detected, erroneous scenario or end of stream: no update */
419
11.1M
        return BIT_DStream_overflow;
420
11.1M
    }
421
422
507k
    assert(bitD->ptr >= bitD->start);
423
424
507k
    if (bitD->ptr >= bitD->limitPtr) {
425
429k
        return BIT_reloadDStream_internal(bitD);
426
429k
    }
427
77.5k
    if (bitD->ptr == bitD->start) {
428
        /* reached end of bitStream => no update */
429
9.98k
        if (bitD->bitsConsumed < sizeof(bitD->bitContainer)*8) return BIT_DStream_endOfBuffer;
430
188
        return BIT_DStream_completed;
431
9.98k
    }
432
    /* start < ptr < limitPtr => cautious update */
433
67.5k
    {   U32 nbBytes = bitD->bitsConsumed >> 3;
434
67.5k
        BIT_DStream_status result = BIT_DStream_unfinished;
435
67.5k
        if (bitD->ptr - nbBytes < bitD->start) {
436
1.00k
            nbBytes = (U32)(bitD->ptr - bitD->start);  /* ptr > start */
437
1.00k
            result = BIT_DStream_endOfBuffer;
438
1.00k
        }
439
67.5k
        bitD->ptr -= nbBytes;
440
67.5k
        bitD->bitsConsumed -= nbBytes*8;
441
67.5k
        bitD->bitContainer = MEM_readLEST(bitD->ptr);   /* reminder : srcSize > sizeof(bitD->bitContainer), otherwise bitD->ptr == bitD->start */
442
67.5k
        return result;
443
77.5k
    }
444
77.5k
}
Unexecuted instantiation: entropy_common.c:BIT_reloadDStream
fse_decompress.c:BIT_reloadDStream
Line
Count
Source
413
212k
{
414
    /* note : once in overflow mode, a bitstream remains in this mode until it's reset */
415
212k
    if (UNLIKELY(bitD->bitsConsumed > (sizeof(bitD->bitContainer)*8))) {
416
3.42k
        static const BitContainerType zeroFilled = 0;
417
3.42k
        bitD->ptr = (const char*)&zeroFilled; /* aliasing is allowed for char */
418
        /* overflow detected, erroneous scenario or end of stream: no update */
419
3.42k
        return BIT_DStream_overflow;
420
3.42k
    }
421
422
208k
    assert(bitD->ptr >= bitD->start);
423
424
208k
    if (bitD->ptr >= bitD->limitPtr) {
425
6.94k
        return BIT_reloadDStream_internal(bitD);
426
6.94k
    }
427
202k
    if (bitD->ptr == bitD->start) {
428
        /* reached end of bitStream => no update */
429
167k
        if (bitD->bitsConsumed < sizeof(bitD->bitContainer)*8) return BIT_DStream_endOfBuffer;
430
3.38k
        return BIT_DStream_completed;
431
167k
    }
432
    /* start < ptr < limitPtr => cautious update */
433
34.1k
    {   U32 nbBytes = bitD->bitsConsumed >> 3;
434
34.1k
        BIT_DStream_status result = BIT_DStream_unfinished;
435
34.1k
        if (bitD->ptr - nbBytes < bitD->start) {
436
216
            nbBytes = (U32)(bitD->ptr - bitD->start);  /* ptr > start */
437
216
            result = BIT_DStream_endOfBuffer;
438
216
        }
439
34.1k
        bitD->ptr -= nbBytes;
440
34.1k
        bitD->bitsConsumed -= nbBytes*8;
441
34.1k
        bitD->bitContainer = MEM_readLEST(bitD->ptr);   /* reminder : srcSize > sizeof(bitD->bitContainer), otherwise bitD->ptr == bitD->start */
442
34.1k
        return result;
443
202k
    }
444
202k
}
Unexecuted instantiation: fse_compress.c:BIT_reloadDStream
Unexecuted instantiation: huf_compress.c:BIT_reloadDStream
huf_decompress.c:BIT_reloadDStream
Line
Count
Source
413
156k
{
414
    /* note : once in overflow mode, a bitstream remains in this mode until it's reset */
415
156k
    if (UNLIKELY(bitD->bitsConsumed > (sizeof(bitD->bitContainer)*8))) {
416
739
        static const BitContainerType zeroFilled = 0;
417
739
        bitD->ptr = (const char*)&zeroFilled; /* aliasing is allowed for char */
418
        /* overflow detected, erroneous scenario or end of stream: no update */
419
739
        return BIT_DStream_overflow;
420
739
    }
421
422
155k
    assert(bitD->ptr >= bitD->start);
423
424
155k
    if (bitD->ptr >= bitD->limitPtr) {
425
120k
        return BIT_reloadDStream_internal(bitD);
426
120k
    }
427
34.5k
    if (bitD->ptr == bitD->start) {
428
        /* reached end of bitStream => no update */
429
7.96k
        if (bitD->bitsConsumed < sizeof(bitD->bitContainer)*8) return BIT_DStream_endOfBuffer;
430
77
        return BIT_DStream_completed;
431
7.96k
    }
432
    /* start < ptr < limitPtr => cautious update */
433
26.6k
    {   U32 nbBytes = bitD->bitsConsumed >> 3;
434
26.6k
        BIT_DStream_status result = BIT_DStream_unfinished;
435
26.6k
        if (bitD->ptr - nbBytes < bitD->start) {
436
4.06k
            nbBytes = (U32)(bitD->ptr - bitD->start);  /* ptr > start */
437
4.06k
            result = BIT_DStream_endOfBuffer;
438
4.06k
        }
439
26.6k
        bitD->ptr -= nbBytes;
440
26.6k
        bitD->bitsConsumed -= nbBytes*8;
441
26.6k
        bitD->bitContainer = MEM_readLEST(bitD->ptr);   /* reminder : srcSize > sizeof(bitD->bitContainer), otherwise bitD->ptr == bitD->start */
442
26.6k
        return result;
443
34.5k
    }
444
34.5k
}
Unexecuted instantiation: zstd_ddict.c:BIT_reloadDStream
445
446
/*! BIT_endOfDStream() :
447
 * @return : 1 if DStream has _exactly_ reached its end (all bits consumed).
448
 */
449
MEM_STATIC unsigned BIT_endOfDStream(const BIT_DStream_t* DStream)
450
3.70k
{
451
3.70k
    return ((DStream->ptr == DStream->start) && (DStream->bitsConsumed == sizeof(DStream->bitContainer)*8));
452
3.70k
}
Unexecuted instantiation: zstd_common.c:BIT_endOfDStream
Unexecuted instantiation: zstd_compress.c:BIT_endOfDStream
Unexecuted instantiation: zstd_compress_literals.c:BIT_endOfDStream
Unexecuted instantiation: zstd_compress_sequences.c:BIT_endOfDStream
Unexecuted instantiation: zstd_compress_superblock.c:BIT_endOfDStream
Unexecuted instantiation: zstd_double_fast.c:BIT_endOfDStream
Unexecuted instantiation: zstd_fast.c:BIT_endOfDStream
Unexecuted instantiation: zstd_lazy.c:BIT_endOfDStream
Unexecuted instantiation: zstd_ldm.c:BIT_endOfDStream
Unexecuted instantiation: zstd_opt.c:BIT_endOfDStream
Unexecuted instantiation: zstd_preSplit.c:BIT_endOfDStream
Unexecuted instantiation: zstdmt_compress.c:BIT_endOfDStream
Unexecuted instantiation: zstd_decompress.c:BIT_endOfDStream
zstd_decompress_block.c:BIT_endOfDStream
Line
Count
Source
450
379
{
451
379
    return ((DStream->ptr == DStream->start) && (DStream->bitsConsumed == sizeof(DStream->bitContainer)*8));
452
379
}
Unexecuted instantiation: entropy_common.c:BIT_endOfDStream
Unexecuted instantiation: fse_decompress.c:BIT_endOfDStream
Unexecuted instantiation: fse_compress.c:BIT_endOfDStream
Unexecuted instantiation: huf_compress.c:BIT_endOfDStream
huf_decompress.c:BIT_endOfDStream
Line
Count
Source
450
3.32k
{
451
3.32k
    return ((DStream->ptr == DStream->start) && (DStream->bitsConsumed == sizeof(DStream->bitContainer)*8));
452
3.32k
}
Unexecuted instantiation: zstd_ddict.c:BIT_endOfDStream
453
454
#endif /* BITSTREAM_H_MODULE */