Skip to content

Commit

Permalink
libsepol: add ebitmap iterator wrapper with startnode
Browse files Browse the repository at this point in the history
Similar like ebitmap_for_each_bit() iterates over all bits of an ebitmap
add ebitmap_for_each_bit_starting() iterating over all bits starting
from a specific node and bit, which can be from an outer iteration.

Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
---
v2:
   * use _after suffix
   * reorder parameters
  • Loading branch information
cgzones committed Jun 29, 2022
1 parent 56a1ac8 commit 69d5f92
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions libsepol/include/sepol/policydb/ebitmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,13 @@ static inline int ebitmap_node_get_bit(const ebitmap_node_t * n, unsigned int bi
#define ebitmap_for_each_positive_bit(e, n, bit) \
ebitmap_for_each_bit(e, n, bit) if (ebitmap_node_get_bit(n, bit)) \

#define ebitmap_for_each_bit_after(e, n, bit, startnode, startbit) \
n = startnode; \
for (bit = ebitmap_next(&n, startbit); bit < ebitmap_length(e); bit = ebitmap_next(&n, bit)) \

#define ebitmap_for_each_positive_bit_after(e, n, bit, startnode, startbit) \
ebitmap_for_each_bit_after(e, n, bit, startnode, startbit) if (ebitmap_node_get_bit(n, bit)) \

extern int ebitmap_cmp(const ebitmap_t * e1, const ebitmap_t * e2);
extern int ebitmap_or(ebitmap_t * dst, const ebitmap_t * e1, const ebitmap_t * e2);
extern int ebitmap_union(ebitmap_t * dst, const ebitmap_t * e1);
Expand Down

0 comments on commit 69d5f92

Please sign in to comment.