|
FD.io VPP
v21.10.1-2-g0a485f517
Vector Packet Processing
|
Go to the documentation of this file.
38 #ifndef included_clib_bitops_h
39 #define included_clib_bitops_h
49 return __builtin_popcountll (x);
51 return __builtin_popcount (x);
55 const uword c1 = 0x5555555555555555;
56 const uword c2 = 0x3333333333333333;
57 const uword c3 = 0x0f0f0f0f0f0f0f0f;
59 const uword c1 = 0x55555555;
60 const uword c2 = 0x33333333;
61 const uword c3 = 0x0f0f0f0f;
65 x = x - ((x >> (
uword) 1) & c1);
68 x = (x & c2) + ((x >> (
uword) 2) & c2);
71 x = (x + (x >> (
uword) 4)) & c3;
74 x = x + (x >> (
uword) 8);
75 x = x + (x >> (
uword) 16);
77 x = x + (x >> (
uword) 32);
108 m ^= m << (
uword) 32;
110 cm->masks[1 +
i] = n = (m << 1) & zm;
113 zm = zm ^ q ^ (q >> (1 <<
i));
122 r = x &
cm->masks[0];
123 q =
r &
cm->masks[1];
125 q =
r &
cm->masks[2];
127 q =
r &
cm->masks[3];
129 q =
r &
cm->masks[4];
131 q =
r &
cm->masks[5];
134 q =
r &
cm->masks[6];
135 r ^= q ^ (q >> (
uword) 32);
144 return (x <<
i) | (x >> (
BITS (
i) -
i));
150 return (x >>
i) | (x << (
BITS (
i) -
i));
158 uword smallest, ripple, ones;
160 ripple = x + smallest;
163 return ripple | ones;
166 #define foreach_set_bit(var,mask,body) \
168 uword _foreach_set_bit_m_##var = (mask); \
169 uword _foreach_set_bit_f_##var; \
170 while (_foreach_set_bit_m_##var != 0) \
172 _foreach_set_bit_f_##var = first_set (_foreach_set_bit_m_##var); \
173 _foreach_set_bit_m_##var ^= _foreach_set_bit_f_##var; \
174 (var) = min_log2 (_foreach_set_bit_f_##var); \
175 do { body; } while (0); \
static uword compress_bits(compress_main_t *cm, uword x)
static uword rotate_right(uword x, uword i)
vnet_hw_if_output_node_runtime_t * r
static void compress_init(compress_main_t *cm, uword mask)
vnet_feature_config_main_t * cm
static uword count_set_bits(uword x)
static uword log2_first_set(uword x)
static uword next_with_same_number_of_set_bits(uword x)
static uword rotate_left(uword x, uword i)