MCPcopy Create free account
hub / github.com/F-Stack/f-stack / BIT_highbit32

Function BIT_highbit32

freebsd/contrib/zstd/lib/common/bitstream.h:140–169  ·  view source on GitHub ↗

-************************************************************** * Internal functions ****************************************************************/

Source from the content-addressed store, hash-verified

138* Internal functions
139****************************************************************/
140MEM_STATIC unsigned BIT_highbit32 (U32 val)
141{
142 assert(val != 0);
143 {
144# if defined(_MSC_VER) /* Visual */
145# if STATIC_BMI2 == 1
146 return _lzcnt_u32(val) ^ 31;
147# else
148 unsigned long r = 0;
149 return _BitScanReverse(&r, val) ? (unsigned)r : 0;
150# endif
151# elif defined(__GNUC__) && (__GNUC__ >= 3) /* Use GCC Intrinsic */
152 return __builtin_clz (val) ^ 31;
153# elif defined(__ICCARM__) /* IAR Intrinsic */
154 return 31 - __CLZ(val);
155# else /* Software version */
156 static const unsigned DeBruijnClz[32] = { 0, 9, 1, 10, 13, 21, 2, 29,
157 11, 14, 16, 18, 22, 25, 3, 30,
158 8, 12, 20, 28, 15, 17, 24, 7,
159 19, 27, 23, 6, 26, 5, 4, 31 };
160 U32 v = val;
161 v |= v >> 1;
162 v |= v >> 2;
163 v |= v >> 4;
164 v |= v >> 8;
165 v |= v >> 16;
166 return DeBruijnClz[ (U32) (v * 0x07C4ACDDU) >> 27];
167# endif
168 }
169}
170
171/*===== Local Constants =====*/
172static const unsigned BIT_mask[] = {

Callers 9

FSE_readNCount_bodyFunction · 0.70
HUF_readStats_bodyFunction · 0.70
BIT_initDStreamFunction · 0.70
FSE_buildDTable_internalFunction · 0.70
HUF_setMaxHeightFunction · 0.50
HUF_sortFunction · 0.50
FSE_buildCTable_wkspFunction · 0.50
FSE_minTableLogFunction · 0.50

Calls

no outgoing calls

Tested by

no test coverage detected