DPDK 25.03.0-rc0
rte_bitset.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2023 Ericsson AB
3 */
4
5#ifndef _RTE_BITSET_H_
6#define _RTE_BITSET_H_
7
33#include <limits.h>
34#include <stdbool.h>
35#include <stddef.h>
36#include <stdint.h>
37
38#include <rte_bitops.h>
40#include <rte_common.h>
41#include <rte_compat.h>
42#include <rte_debug.h>
43#include <rte_memcpy.h>
44
45#ifdef __cplusplus
46extern "C" {
47#endif
48
53#define RTE_BITSET_WORD_SIZE (sizeof(uint64_t))
54
59#define RTE_BITSET_WORD_BITS (RTE_BITSET_WORD_SIZE * CHAR_BIT)
60
64#define RTE_BITSET_NUM_WORDS(size) \
65 ((size + RTE_BITSET_WORD_BITS - 1) / RTE_BITSET_WORD_BITS)
66
71#define RTE_BITSET_SIZE(size) \
72 ((size_t)(RTE_BITSET_NUM_WORDS(size) * RTE_BITSET_WORD_SIZE))
73
74#define __RTE_BITSET_WORD_IDX(bit_num) ((bit_num) / RTE_BITSET_WORD_BITS)
75#define __RTE_BITSET_BIT_OFFSET(bit_num) ((bit_num) % RTE_BITSET_WORD_BITS)
76#define __RTE_BITSET_UNUSED(size) \
77 ((RTE_BITSET_NUM_WORDS(size) * RTE_BITSET_WORD_BITS) - (size))
78#define __RTE_BITSET_USED_MASK(size) \
79 (UINT64_MAX >> __RTE_BITSET_UNUSED(size))
80
81#define __RTE_BITSET_DELEGATE_N(fun, bitset, bit_num, ...) \
82 fun(&(bitset)[__RTE_BITSET_WORD_IDX(bit_num)], __RTE_BITSET_BIT_OFFSET(bit_num), \
83 __VA_ARGS__)
84
85/* MSVC doesn't have ##__VA_ARGS__, so argument-less -> special case */
86#define __RTE_BITSET_DELEGATE(fun, bitset, bit_num) \
87 fun(&(bitset)[__RTE_BITSET_WORD_IDX(bit_num)], __RTE_BITSET_BIT_OFFSET(bit_num))
88
104#define RTE_BITSET_DECLARE(name, size) \
105 uint64_t name[RTE_BITSET_NUM_WORDS(size)]
106
107#define __RTE_BITSET_FOREACH_LEFT(var, size, start_bit, len) \
108 ((len) - 1 - ((var) >= (start_bit) ? (var) - (start_bit) : (size) - (start_bit) + (var)))
109
110#define __RTE_BITSET_FOREACH(var, bitset, size, start_bit, len, flags) \
111 for ((var) = __rte_bitset_find(bitset, size, start_bit, len, flags); \
112 (var) != -1; \
113 (var) = __RTE_BITSET_FOREACH_LEFT(var, size, start_bit, len) > 0 ? \
114 __rte_bitset_find(bitset, size, ((var) + 1) % (size), \
115 __RTE_BITSET_FOREACH_LEFT(var, size, start_bit, len), flags) : -1)
116
135#define RTE_BITSET_FOREACH_SET(var, bitset, size) \
136 __RTE_BITSET_FOREACH(var, bitset, size, 0, size, 0)
137
155#define RTE_BITSET_FOREACH_CLEAR(var, bitset, size) \
156 __RTE_BITSET_FOREACH(var, bitset, size, 0, size, __RTE_BITSET_FIND_FLAG_FIND_CLEAR)
157
181#define RTE_BITSET_FOREACH_SET_RANGE(var, bitset, size, start_bit, len) \
182 __RTE_BITSET_FOREACH(var, bitset, size, start_bit, len, 0)
183
207#define RTE_BITSET_FOREACH_CLEAR_RANGE(var, bitset, size, start_bit, len) \
208 __RTE_BITSET_FOREACH(var, bitset, size, start_bit, len, __RTE_BITSET_FIND_FLAG_FIND_CLEAR)
209
210#define RTE_BITSET_FOREACH_SET_WRAP(var, bitset, size, start_bit, len) \
211 __RTE_BITSET_FOREACH(var, bitset, size, start_bit, len, __RTE_BITSET_FIND_FLAG_WRAP)
212
213#define RTE_BITSET_FOREACH_CLEAR_WRAP(var, bitset, size, start_bit, len) \
214 __RTE_BITSET_FOREACH(var, bitset, size, start_bit, len, \
215 __RTE_BITSET_FIND_FLAG_WRAP | __RTE_BITSET_FIND_FLAG_FIND_CLEAR)
216
234__rte_experimental
235static inline void
236rte_bitset_init(uint64_t *bitset, size_t size)
237{
238 memset(bitset, 0, RTE_BITSET_SIZE(size));
239}
240
254__rte_experimental
255static inline bool
256rte_bitset_test(const uint64_t *bitset, size_t bit_num)
257{
258#ifdef ALLOW_EXPERIMENTAL_API
259 return __RTE_BITSET_DELEGATE(rte_bit_test, bitset, bit_num);
260#else
261 RTE_SET_USED(bitset);
262 RTE_SET_USED(bit_num);
263 RTE_VERIFY(false);
264#endif
265}
266
282__rte_experimental
283static inline void
284rte_bitset_set(uint64_t *bitset, size_t bit_num)
285{
286#ifdef ALLOW_EXPERIMENTAL_API
287 __RTE_BITSET_DELEGATE(rte_bit_set, bitset, bit_num);
288#else
289 RTE_SET_USED(bitset);
290 RTE_SET_USED(bit_num);
291 RTE_VERIFY(false);
292#endif
293}
294
310__rte_experimental
311static inline void
312rte_bitset_clear(uint64_t *bitset, size_t bit_num)
313{
314#ifdef ALLOW_EXPERIMENTAL_API
315 __RTE_BITSET_DELEGATE(rte_bit_clear, bitset, bit_num);
316#else
317 RTE_SET_USED(bitset);
318 RTE_SET_USED(bit_num);
319 RTE_VERIFY(false);
320#endif
321}
322
340__rte_experimental
341static inline void
342rte_bitset_assign(uint64_t *bitset, size_t bit_num, bool bit_value)
343{
344#ifdef ALLOW_EXPERIMENTAL_API
345 __RTE_BITSET_DELEGATE_N(rte_bit_assign, bitset, bit_num, bit_value);
346#else
347 RTE_SET_USED(bitset);
348 RTE_SET_USED(bit_num);
349 RTE_SET_USED(bit_value);
350 RTE_VERIFY(false);
351#endif
352}
353
369__rte_experimental
370static inline void
371rte_bitset_flip(uint64_t *bitset, size_t bit_num)
372{
373#ifdef ALLOW_EXPERIMENTAL_API
374 __RTE_BITSET_DELEGATE(rte_bit_flip, bitset, bit_num);
375#else
376 RTE_SET_USED(bitset);
377 RTE_SET_USED(bit_num);
378 RTE_VERIFY(false);
379#endif
380}
381
400__rte_experimental
401static inline bool
402rte_bitset_atomic_test(const uint64_t *bitset, size_t bit_num, int memory_order)
403{
404#ifdef ALLOW_EXPERIMENTAL_API
405 return __RTE_BITSET_DELEGATE_N(rte_bit_atomic_test, bitset, bit_num, memory_order);
406#else
407 RTE_SET_USED(bitset);
408 RTE_SET_USED(bit_num);
409 RTE_SET_USED(memory_order);
410 RTE_VERIFY(false);
411#endif
412}
413
436__rte_experimental
437static inline void
438rte_bitset_atomic_set(uint64_t *bitset, size_t bit_num, int memory_order)
439{
440#ifdef ALLOW_EXPERIMENTAL_API
441 __RTE_BITSET_DELEGATE_N(rte_bit_atomic_set, bitset, bit_num, memory_order);
442#else
443 RTE_SET_USED(bitset);
444 RTE_SET_USED(bit_num);
445 RTE_SET_USED(memory_order);
446 RTE_VERIFY(false);
447#endif
448}
449
472__rte_experimental
473static inline void
474rte_bitset_atomic_clear(uint64_t *bitset, size_t bit_num, int memory_order)
475{
476#ifdef ALLOW_EXPERIMENTAL_API
477 __RTE_BITSET_DELEGATE_N(rte_bit_atomic_clear, bitset, bit_num, memory_order);
478#else
479 RTE_SET_USED(bitset);
480 RTE_SET_USED(bit_num);
481 RTE_SET_USED(memory_order);
482 RTE_VERIFY(false);
483#endif
484}
485
510__rte_experimental
511static inline void
512rte_bitset_atomic_assign(uint64_t *bitset, size_t bit_num, bool bit_value, int memory_order)
513{
514#ifdef ALLOW_EXPERIMENTAL_API
515 __RTE_BITSET_DELEGATE_N(rte_bit_atomic_assign, bitset, bit_num, bit_value, memory_order);
516#else
517 RTE_SET_USED(bitset);
518 RTE_SET_USED(bit_num);
519 RTE_SET_USED(bit_value);
520 RTE_SET_USED(memory_order);
521 RTE_VERIFY(false);
522#endif
523}
524
547__rte_experimental
548static inline void
549rte_bitset_atomic_flip(uint64_t *bitset, size_t bit_num, int memory_order)
550{
551#ifdef ALLOW_EXPERIMENTAL_API
552 __RTE_BITSET_DELEGATE_N(rte_bit_atomic_flip, bitset, bit_num, memory_order);
553#else
554 RTE_SET_USED(bitset);
555 RTE_SET_USED(bit_num);
556 RTE_SET_USED(memory_order);
557 RTE_VERIFY(false);
558#endif
559}
560
572__rte_experimental
573static inline void
574rte_bitset_set_all(uint64_t *bitset, size_t size)
575{
576 memset(bitset, 0xFF, RTE_BITSET_SIZE(size));
577}
578
590__rte_experimental
591static inline void
592rte_bitset_clear_all(uint64_t *bitset, size_t size)
593{
594#ifdef ALLOW_EXPERIMENTAL_API
595 rte_bitset_init(bitset, size);
596#else
597 RTE_SET_USED(bitset);
598 RTE_SET_USED(size);
599 RTE_VERIFY(false);
600#endif
601}
602
616__rte_experimental
617static inline size_t
618rte_bitset_count_set(const uint64_t *bitset, size_t size)
619{
620 size_t i;
621 size_t total = 0;
622
623 /*
624 * Unused bits in a rte_bitset are always '0', and thus are
625 * not included in this count.
626 */
627 for (i = 0; i < RTE_BITSET_NUM_WORDS(size) - 1; i++)
628 total += rte_popcount64(bitset[i]);
629
630 total += rte_popcount64(bitset[i] & __RTE_BITSET_USED_MASK(size));
631
632 return total;
633}
634
648__rte_experimental
649static inline size_t
650rte_bitset_count_clear(const uint64_t *bitset, size_t size)
651{
652#ifdef ALLOW_EXPERIMENTAL_API
653 return size - rte_bitset_count_set(bitset, size);
654#else
655 RTE_SET_USED(bitset);
656 RTE_SET_USED(size);
657 RTE_VERIFY(false);
658#endif
659}
660
661#define __RTE_BITSET_FIND_FLAG_FIND_CLEAR (1U << 0)
662#define __RTE_BITSET_FIND_FLAG_WRAP (1U << 1)
663
664__rte_experimental
665static inline ssize_t
666__rte_bitset_find_nowrap(const uint64_t *bitset, size_t __rte_unused size, size_t start_bit,
667 size_t len, bool find_clear)
668{
669 size_t word_idx;
670 size_t offset;
671 size_t end_bit = start_bit + len;
672
673 RTE_ASSERT(end_bit <= size);
674
675 if (unlikely(len == 0))
676 return -1;
677
678 word_idx = __RTE_BITSET_WORD_IDX(start_bit);
679 offset = __RTE_BITSET_BIT_OFFSET(start_bit);
680
681 while (word_idx <= __RTE_BITSET_WORD_IDX(end_bit - 1)) {
682 uint64_t word;
683
684 word = bitset[word_idx];
685 if (find_clear)
686 word = ~word;
687
688 word >>= offset;
689
690 if (word != 0) {
691 size_t ffs = start_bit + rte_bsf64(word);
692
693 /*
694 * Check if set bit were among the last,
695 * unused bits, in the last word.
696 */
697 if (unlikely(ffs >= end_bit))
698 return -1;
699
700 return ffs;
701 }
702
703 start_bit += (RTE_BITSET_WORD_BITS - offset);
704 word_idx++;
705 offset = 0;
706 }
707
708 return -1;
709
710}
711
712__rte_experimental
713static inline ssize_t
714__rte_bitset_find(const uint64_t *bitset, size_t size, size_t start_bit, size_t len,
715 unsigned int flags)
716{
717#ifdef ALLOW_EXPERIMENTAL_API
718 bool find_clear = flags & __RTE_BITSET_FIND_FLAG_FIND_CLEAR;
719 bool may_wrap = flags & __RTE_BITSET_FIND_FLAG_WRAP;
720 bool does_wrap = (start_bit + len) > size;
721 ssize_t rc;
722
723 RTE_ASSERT(len <= size);
724 if (!may_wrap)
725 RTE_ASSERT(!does_wrap);
726
727 if (may_wrap && does_wrap) {
728 size_t len0 = size - start_bit;
729 size_t len1 = len - len0;
730
731 rc = __rte_bitset_find_nowrap(bitset, size, start_bit, len0, find_clear);
732 if (rc < 0)
733 rc = __rte_bitset_find_nowrap(bitset, size, 0, len1, find_clear);
734 } else
735 rc = __rte_bitset_find_nowrap(bitset, size, start_bit, len, find_clear);
736
737 return rc;
738#else
739 RTE_SET_USED(bitset);
740 RTE_SET_USED(size);
741 RTE_SET_USED(start_bit);
742 RTE_SET_USED(len);
743 RTE_SET_USED(flags);
744 RTE_VERIFY(false);
745#endif
746}
747
765__rte_experimental
766static inline ssize_t
767rte_bitset_find_first_set(const uint64_t *bitset, size_t size)
768{
769#ifdef ALLOW_EXPERIMENTAL_API
770 return __rte_bitset_find(bitset, size, 0, size, 0);
771#else
772 RTE_SET_USED(bitset);
773 RTE_SET_USED(size);
774 RTE_VERIFY(false);
775#endif
776}
777
801__rte_experimental
802static inline ssize_t
803rte_bitset_find_set(const uint64_t *bitset, size_t size, size_t start_bit, size_t len)
804{
805#ifdef ALLOW_EXPERIMENTAL_API
806 return __rte_bitset_find(bitset, size, start_bit, len, 0);
807#else
808 RTE_SET_USED(bitset);
809 RTE_SET_USED(size);
810 RTE_SET_USED(start_bit);
811 RTE_SET_USED(len);
812 RTE_VERIFY(false);
813#endif
814}
815
840__rte_experimental
841static inline ssize_t
842rte_bitset_find_set_wrap(const uint64_t *bitset, size_t size, size_t start_bit, size_t len)
843{
844#ifdef ALLOW_EXPERIMENTAL_API
845 return __rte_bitset_find(bitset, size, start_bit, len, __RTE_BITSET_FIND_FLAG_WRAP);
846#else
847 RTE_SET_USED(bitset);
848 RTE_SET_USED(size);
849 RTE_SET_USED(start_bit);
850 RTE_SET_USED(len);
851 RTE_VERIFY(false);
852#endif
853}
854
872__rte_experimental
873static inline ssize_t
874rte_bitset_find_first_clear(const uint64_t *bitset, size_t size)
875{
876#ifdef ALLOW_EXPERIMENTAL_API
877 return __rte_bitset_find(bitset, size, 0, size, __RTE_BITSET_FIND_FLAG_FIND_CLEAR);
878#else
879 RTE_SET_USED(bitset);
880 RTE_SET_USED(size);
881 RTE_VERIFY(false);
882#endif
883}
884
908__rte_experimental
909static inline ssize_t
910rte_bitset_find_clear(const uint64_t *bitset, size_t size, size_t start_bit, size_t len)
911{
912#ifdef ALLOW_EXPERIMENTAL_API
913 return __rte_bitset_find(bitset, size, start_bit, len, __RTE_BITSET_FIND_FLAG_FIND_CLEAR);
914#else
915 RTE_SET_USED(bitset);
916 RTE_SET_USED(size);
917 RTE_SET_USED(start_bit);
918 RTE_SET_USED(len);
919 RTE_VERIFY(false);
920#endif
921}
922
947__rte_experimental
948static inline ssize_t
949rte_bitset_find_clear_wrap(const uint64_t *bitset, size_t size, size_t start_bit, size_t len)
950{
951#ifdef ALLOW_EXPERIMENTAL_API
952 return __rte_bitset_find(bitset, size, start_bit, len,
953 __RTE_BITSET_FIND_FLAG_FIND_CLEAR | __RTE_BITSET_FIND_FLAG_WRAP);
954#else
955 RTE_SET_USED(bitset);
956 RTE_SET_USED(size);
957 RTE_SET_USED(start_bit);
958 RTE_SET_USED(len);
959 RTE_VERIFY(false);
960#endif
961}
962
980__rte_experimental
981static inline void
982rte_bitset_copy(uint64_t *__rte_restrict dst_bitset, const uint64_t *__rte_restrict src_bitset,
983 size_t size)
984{
985 rte_memcpy(dst_bitset, src_bitset, RTE_BITSET_SIZE(size));
986}
987
1007__rte_experimental
1008static inline void
1009rte_bitset_or(uint64_t *dst_bitset, const uint64_t *src_bitset0, const uint64_t *src_bitset1,
1010 size_t size)
1011{
1012 size_t i;
1013
1014 for (i = 0; i < RTE_BITSET_NUM_WORDS(size); i++)
1015 dst_bitset[i] = src_bitset0[i] | src_bitset1[i];
1016}
1017
1037__rte_experimental
1038static inline void
1039rte_bitset_and(uint64_t *dst_bitset, const uint64_t *src_bitset0, const uint64_t *src_bitset1,
1040 size_t size)
1041{
1042 size_t i;
1043
1044 for (i = 0; i < RTE_BITSET_NUM_WORDS(size); i++)
1045 dst_bitset[i] = src_bitset0[i] & src_bitset1[i];
1046}
1047
1067__rte_experimental
1068static inline void
1069rte_bitset_xor(uint64_t *dst_bitset, const uint64_t *src_bitset0, const uint64_t *src_bitset1,
1070 size_t size)
1071{
1072 size_t i;
1073
1074 for (i = 0; i < RTE_BITSET_NUM_WORDS(size); i++)
1075 dst_bitset[i] = src_bitset0[i] ^ src_bitset1[i];
1076}
1077
1094__rte_experimental
1095static inline void
1096rte_bitset_complement(uint64_t *dst_bitset, const uint64_t *src_bitset, size_t size)
1097{
1098 size_t i;
1099
1100 for (i = 0; i < RTE_BITSET_NUM_WORDS(size); i++)
1101 dst_bitset[i] = ~src_bitset[i];
1102}
1103
1122__rte_experimental
1123static inline void
1124rte_bitset_shift_left(uint64_t *dst_bitset, const uint64_t *src_bitset, size_t size,
1125 size_t shift_bits)
1126{
1127 const int src_word_offset = shift_bits / RTE_BITSET_WORD_BITS;
1128 const int src_bit_offset = shift_bits % RTE_BITSET_WORD_BITS;
1129 unsigned int dst_idx;
1130
1131 for (dst_idx = 0; dst_idx < RTE_BITSET_NUM_WORDS(size); dst_idx++) {
1132 int src_high_idx = dst_idx - src_word_offset;
1133 uint64_t low_bits = 0;
1134 uint64_t high_bits = 0;
1135
1136 if (src_high_idx >= 0) {
1137 int src_low_idx = src_high_idx - 1;
1138
1139 high_bits = src_bitset[src_high_idx] << src_bit_offset;
1140
1141 if (src_bit_offset > 0 && src_low_idx >= 0)
1142 low_bits = src_bitset[src_low_idx] >>
1143 (RTE_BITSET_WORD_BITS - src_bit_offset);
1144 }
1145 dst_bitset[dst_idx] = low_bits | high_bits;
1146 }
1147}
1148
1167__rte_experimental
1168static inline void
1169rte_bitset_shift_right(uint64_t *dst_bitset, const uint64_t *src_bitset, size_t size,
1170 size_t shift_bits)
1171{
1172 const int num_words = RTE_BITSET_NUM_WORDS(size);
1173 const uint64_t used_mask = __RTE_BITSET_USED_MASK(size);
1174 const int src_word_offset = shift_bits / RTE_BITSET_WORD_BITS;
1175 const int src_bit_offset = shift_bits % RTE_BITSET_WORD_BITS;
1176 int dst_idx;
1177
1178 for (dst_idx = 0; dst_idx < num_words; dst_idx++) {
1179 int src_low_idx = src_word_offset + dst_idx;
1180 int src_high_idx = src_low_idx + 1;
1181 uint64_t src_low_word_bits = 0;
1182 uint64_t src_high_word_bits = 0;
1183
1184 if (src_low_idx < num_words) {
1185 src_low_word_bits = src_bitset[src_low_idx];
1186
1187 if (src_low_idx == (num_words - 1))
1188 src_low_word_bits &= used_mask;
1189
1190 src_low_word_bits >>= src_bit_offset;
1191
1192 if (src_bit_offset > 0 && src_high_idx < num_words) {
1193 src_high_word_bits = src_bitset[src_high_idx];
1194
1195 if (src_high_idx == (num_words - 1))
1196 src_high_word_bits &= used_mask;
1197
1198 src_high_word_bits <<= (RTE_BITSET_WORD_BITS - src_bit_offset);
1199 }
1200 }
1201 dst_bitset[dst_idx] = src_low_word_bits | src_high_word_bits;
1202 }
1203}
1204
1220__rte_experimental
1221static inline bool
1222rte_bitset_equal(const uint64_t *bitset_a, const uint64_t *bitset_b, size_t size)
1223{
1224 size_t i;
1225 uint64_t last_a, last_b;
1226
1227 for (i = 0; i < RTE_BITSET_NUM_WORDS(size) - 1; i++)
1228 if (bitset_a[i] != bitset_b[i])
1229 return false;
1230
1231 last_a = bitset_a[i] << __RTE_BITSET_UNUSED(size);
1232 last_b = bitset_b[i] << __RTE_BITSET_UNUSED(size);
1233
1234 return last_a == last_b;
1235}
1236
1262__rte_experimental
1263ssize_t
1264rte_bitset_to_str(const uint64_t *bitset, size_t size, char *buf, size_t capacity);
1265
1266#ifdef __cplusplus
1267}
1268#endif
1269
1270#endif /* _RTE_BITSET_H_ */
#define rte_bit_atomic_assign(addr, nr, value, memory_order)
Definition: rte_bitops.h:347
#define rte_bit_flip(addr, nr)
Definition: rte_bitops.h:239
#define rte_bit_set(addr, nr)
Definition: rte_bitops.h:160
#define rte_bit_atomic_flip(addr, nr, memory_order)
Definition: rte_bitops.h:373
static uint32_t rte_bsf64(uint64_t v)
Definition: rte_bitops.h:1147
#define rte_bit_assign(addr, nr, value)
Definition: rte_bitops.h:213
#define rte_bit_test(addr, nr)
Definition: rte_bitops.h:130
static unsigned int rte_popcount64(uint64_t v)
Definition: rte_bitops.h:1042
#define rte_bit_atomic_set(addr, nr, memory_order)
Definition: rte_bitops.h:295
#define rte_bit_clear(addr, nr)
Definition: rte_bitops.h:186
#define rte_bit_atomic_clear(addr, nr, memory_order)
Definition: rte_bitops.h:320
#define rte_bit_atomic_test(addr, nr, memory_order)
Definition: rte_bitops.h:266
#define RTE_BITSET_WORD_BITS
Definition: rte_bitset.h:59
static __rte_experimental ssize_t rte_bitset_find_clear_wrap(const uint64_t *bitset, size_t size, size_t start_bit, size_t len)
Definition: rte_bitset.h:949
static __rte_experimental void rte_bitset_or(uint64_t *dst_bitset, const uint64_t *src_bitset0, const uint64_t *src_bitset1, size_t size)
Definition: rte_bitset.h:1009
static __rte_experimental size_t rte_bitset_count_set(const uint64_t *bitset, size_t size)
Definition: rte_bitset.h:618
static __rte_experimental ssize_t rte_bitset_find_first_set(const uint64_t *bitset, size_t size)
Definition: rte_bitset.h:767
static __rte_experimental void rte_bitset_assign(uint64_t *bitset, size_t bit_num, bool bit_value)
Definition: rte_bitset.h:342
static __rte_experimental void rte_bitset_copy(uint64_t *__rte_restrict dst_bitset, const uint64_t *__rte_restrict src_bitset, size_t size)
Definition: rte_bitset.h:982
static __rte_experimental ssize_t rte_bitset_find_first_clear(const uint64_t *bitset, size_t size)
Definition: rte_bitset.h:874
static __rte_experimental void rte_bitset_and(uint64_t *dst_bitset, const uint64_t *src_bitset0, const uint64_t *src_bitset1, size_t size)
Definition: rte_bitset.h:1039
static __rte_experimental void rte_bitset_xor(uint64_t *dst_bitset, const uint64_t *src_bitset0, const uint64_t *src_bitset1, size_t size)
Definition: rte_bitset.h:1069
static __rte_experimental bool rte_bitset_atomic_test(const uint64_t *bitset, size_t bit_num, int memory_order)
Definition: rte_bitset.h:402
static __rte_experimental void rte_bitset_shift_right(uint64_t *dst_bitset, const uint64_t *src_bitset, size_t size, size_t shift_bits)
Definition: rte_bitset.h:1169
static __rte_experimental ssize_t rte_bitset_find_set_wrap(const uint64_t *bitset, size_t size, size_t start_bit, size_t len)
Definition: rte_bitset.h:842
static __rte_experimental void rte_bitset_set_all(uint64_t *bitset, size_t size)
Definition: rte_bitset.h:574
static __rte_experimental void rte_bitset_init(uint64_t *bitset, size_t size)
Definition: rte_bitset.h:236
static __rte_experimental void rte_bitset_complement(uint64_t *dst_bitset, const uint64_t *src_bitset, size_t size)
Definition: rte_bitset.h:1096
static __rte_experimental bool rte_bitset_equal(const uint64_t *bitset_a, const uint64_t *bitset_b, size_t size)
Definition: rte_bitset.h:1222
static __rte_experimental void rte_bitset_atomic_flip(uint64_t *bitset, size_t bit_num, int memory_order)
Definition: rte_bitset.h:549
static __rte_experimental void rte_bitset_shift_left(uint64_t *dst_bitset, const uint64_t *src_bitset, size_t size, size_t shift_bits)
Definition: rte_bitset.h:1124
static __rte_experimental void rte_bitset_atomic_set(uint64_t *bitset, size_t bit_num, int memory_order)
Definition: rte_bitset.h:438
static __rte_experimental void rte_bitset_flip(uint64_t *bitset, size_t bit_num)
Definition: rte_bitset.h:371
static __rte_experimental void rte_bitset_clear(uint64_t *bitset, size_t bit_num)
Definition: rte_bitset.h:312
static __rte_experimental bool rte_bitset_test(const uint64_t *bitset, size_t bit_num)
Definition: rte_bitset.h:256
static __rte_experimental void rte_bitset_clear_all(uint64_t *bitset, size_t size)
Definition: rte_bitset.h:592
static __rte_experimental void rte_bitset_atomic_assign(uint64_t *bitset, size_t bit_num, bool bit_value, int memory_order)
Definition: rte_bitset.h:512
static __rte_experimental size_t rte_bitset_count_clear(const uint64_t *bitset, size_t size)
Definition: rte_bitset.h:650
static __rte_experimental void rte_bitset_set(uint64_t *bitset, size_t bit_num)
Definition: rte_bitset.h:284
static __rte_experimental void rte_bitset_atomic_clear(uint64_t *bitset, size_t bit_num, int memory_order)
Definition: rte_bitset.h:474
static __rte_experimental ssize_t rte_bitset_find_clear(const uint64_t *bitset, size_t size, size_t start_bit, size_t len)
Definition: rte_bitset.h:910
#define RTE_BITSET_NUM_WORDS(size)
Definition: rte_bitset.h:64
#define RTE_BITSET_SIZE(size)
Definition: rte_bitset.h:71
static __rte_experimental ssize_t rte_bitset_find_set(const uint64_t *bitset, size_t size, size_t start_bit, size_t len)
Definition: rte_bitset.h:803
__rte_experimental ssize_t rte_bitset_to_str(const uint64_t *bitset, size_t size, char *buf, size_t capacity)
#define unlikely(x)
#define RTE_SET_USED(x)
Definition: rte_common.h:187
#define __rte_unused
Definition: rte_common.h:171
#define __rte_restrict
Definition: rte_common.h:178
static void * rte_memcpy(void *dst, const void *src, size_t n)