Lines Matching refs:val

52 static inline int clz32(uint32_t val)  in clz32()  argument
55 if (val) in clz32()
56 return __builtin_clz(val); in clz32()
62 if (!(val & 0xFFFF0000U)) { in clz32()
64 val <<= 16; in clz32()
66 if (!(val & 0xFF000000U)) { in clz32()
68 val <<= 8; in clz32()
70 if (!(val & 0xF0000000U)) { in clz32()
72 val <<= 4; in clz32()
74 if (!(val & 0xC0000000U)) { in clz32()
76 val <<= 2; in clz32()
78 if (!(val & 0x80000000U)) { in clz32()
80 val <<= 1; in clz32()
82 if (!(val & 0x80000000U)) { in clz32()
89 static inline int clo32(uint32_t val) in clo32() argument
91 return clz32(~val); in clo32()
94 static inline int clz64(uint64_t val) in clz64() argument
97 if (val) in clz64()
98 return __builtin_clzll(val); in clz64()
104 if (!(val >> 32)) { in clz64()
107 val >>= 32; in clz64()
110 return cnt + clz32(val); in clz64()
114 static inline int clo64(uint64_t val) in clo64() argument
116 return clz64(~val); in clo64()
119 static inline int ctz32(uint32_t val) in ctz32() argument
122 if (val) in ctz32()
123 return __builtin_ctz(val); in ctz32()
130 if (!(val & 0x0000FFFFUL)) { in ctz32()
132 val >>= 16; in ctz32()
134 if (!(val & 0x000000FFUL)) { in ctz32()
136 val >>= 8; in ctz32()
138 if (!(val & 0x0000000FUL)) { in ctz32()
140 val >>= 4; in ctz32()
142 if (!(val & 0x00000003UL)) { in ctz32()
144 val >>= 2; in ctz32()
146 if (!(val & 0x00000001UL)) { in ctz32()
148 val >>= 1; in ctz32()
150 if (!(val & 0x00000001UL)) { in ctz32()
158 static inline int cto32(uint32_t val) in cto32() argument
160 return ctz32(~val); in cto32()
163 static inline int ctz64(uint64_t val) in ctz64() argument
166 if (val) in ctz64()
167 return __builtin_ctzll(val); in ctz64()
174 if (!((uint32_t)val)) { in ctz64()
176 val >>= 32; in ctz64()
179 return cnt + ctz32(val); in ctz64()
183 static inline int cto64(uint64_t val) in cto64() argument
185 return ctz64(~val); in cto64()
188 static inline int ctpop8(uint8_t val) in ctpop8() argument
190 val = (val & 0x55) + ((val >> 1) & 0x55); in ctpop8()
191 val = (val & 0x33) + ((val >> 2) & 0x33); in ctpop8()
192 val = (val & 0x0f) + ((val >> 4) & 0x0f); in ctpop8()
194 return val; in ctpop8()
197 static inline int ctpop16(uint16_t val) in ctpop16() argument
199 val = (val & 0x5555) + ((val >> 1) & 0x5555); in ctpop16()
200 val = (val & 0x3333) + ((val >> 2) & 0x3333); in ctpop16()
201 val = (val & 0x0f0f) + ((val >> 4) & 0x0f0f); in ctpop16()
202 val = (val & 0x00ff) + ((val >> 8) & 0x00ff); in ctpop16()
204 return val; in ctpop16()
207 static inline int ctpop32(uint32_t val) in ctpop32() argument
210 return __builtin_popcount(val); in ctpop32()
212 val = (val & 0x55555555) + ((val >> 1) & 0x55555555); in ctpop32()
213 val = (val & 0x33333333) + ((val >> 2) & 0x33333333); in ctpop32()
214 val = (val & 0x0f0f0f0f) + ((val >> 4) & 0x0f0f0f0f); in ctpop32()
215 val = (val & 0x00ff00ff) + ((val >> 8) & 0x00ff00ff); in ctpop32()
216 val = (val & 0x0000ffff) + ((val >> 16) & 0x0000ffff); in ctpop32()
218 return val; in ctpop32()
222 static inline int ctpop64(uint64_t val) in ctpop64() argument
225 return __builtin_popcountll(val); in ctpop64()
227 val = (val & 0x5555555555555555ULL) + ((val >> 1) & 0x5555555555555555ULL); in ctpop64()
228 val = (val & 0x3333333333333333ULL) + ((val >> 2) & 0x3333333333333333ULL); in ctpop64()
229 val = (val & 0x0f0f0f0f0f0f0f0fULL) + ((val >> 4) & 0x0f0f0f0f0f0f0f0fULL); in ctpop64()
230 val = (val & 0x00ff00ff00ff00ffULL) + ((val >> 8) & 0x00ff00ff00ff00ffULL); in ctpop64()
231 val = (val & 0x0000ffff0000ffffULL) + ((val >> 16) & 0x0000ffff0000ffffULL); in ctpop64()
232 val = (val & 0x00000000ffffffffULL) + ((val >> 32) & 0x00000000ffffffffULL); in ctpop64()
234 return val; in ctpop64()