Coverage Report

Created: 2026-10-28 06:38

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