[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 2/7] bitset: style: sort header
From: |
Akim Demaille |
Subject: |
[PATCH 2/7] bitset: style: sort header |
Date: |
Sun, 29 Nov 2020 17:42:16 +0100 |
* lib/bitset/base.h (bitset_ffs): Rename as...
(bitset_ffs_): this.
(bitset_ffs_, BITSET_FOR_EACH_BIT): Move to better places.
---
ChangeLog | 7 +++++++
lib/bitset/base.h | 31 +++++++++++++++----------------
2 files changed, 22 insertions(+), 16 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 67576a51f..7f83f5e1d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2020-11-29 Akim Demaille <akim@lrde.epita.fr>
+
+ bitset: style: sort header
+ * lib/bitset/base.h (bitset_ffs): Rename as...
+ (bitset_ffs_): this.
+ (bitset_ffs_, BITSET_FOR_EACH_BIT): Move to better places.
+
2020-11-29 Akim Demaille <akim@lrde.epita.fr>
bitset: tests: check BITSET_FOR_EACH_REVERSE
diff --git a/lib/bitset/base.h b/lib/bitset/base.h
index 50569a0fc..a124b0df4 100644
--- a/lib/bitset/base.h
+++ b/lib/bitset/base.h
@@ -53,14 +53,6 @@ extern const char * const bitset_type_names[];
typedef unsigned long bitset_word;
#define BITSET_WORD_BITS ((unsigned) (CHAR_BIT * sizeof (bitset_word)))
-/* Iterate over each set bit of WORD.
- Each iteration sets POS to the 0-based index of the next set bit in WORD.
- Repeatedly resets bits in WORD in place until it's null. */
-#define BITSET_FOR_EACH_BIT(Pos, Word) \
- for (int Pos = bitset_ffs (Word); \
- 0 <= Pos; \
- Word ^= 1UL << Pos, Pos = bitset_ffs (Word))
-
/* Bit index. In theory we might need a type wider than size_t, but
in practice we lose at most a factor of CHAR_BIT by going with
size_t, and that is good enough. If this type is changed to be
@@ -69,14 +61,6 @@ typedef unsigned long bitset_word;
The bit and word index types must be unsigned. */
typedef size_t bitset_bindex;
-/* First first set bit in WORD.
- Indexes start at 0, return -1 if WORD is null. */
-static inline
-int bitset_ffs (bitset_word word)
-{
- return ffsl ((long) word) - 1;
-}
-
/* Word index. */
typedef size_t bitset_windex;
@@ -294,6 +278,13 @@ if (!BITSET_COMPATIBLE_ (DST, SRC1) || !BITSET_COMPATIBLE_
(DST, SRC2) \
#define BITSET_LIST_REVERSE_(BSET, LIST, NUM, NEXT) \
(BSET)->b.vtable->list_reverse (BSET, LIST, NUM, NEXT)
+/* Iterate left to right over each set bit of WORD.
+ Each iteration sets POS to the 0-based index of the next set bit in WORD.
+ Repeatedly resets bits in WORD in place until it's null. */
+#define BITSET_FOR_EACH_BIT(Pos, Word) \
+ for (int Pos = bitset_ffs_ (Word); \
+ 0 <= Pos; \
+ Word ^= 1UL << Pos, Pos = bitset_ffs_ (Word))
/* Private functions for bitset implementations. */
@@ -317,4 +308,12 @@ void bitset_or_and_ (bitset, bitset, bitset, bitset);
bool bitset_or_and_cmp_ (bitset, bitset, bitset, bitset);
+/* First set bit in WORD.
+ Indexes start at 0, return -1 if WORD is null. */
+static inline
+int bitset_ffs_ (bitset_word word)
+{
+ return ffsl ((long) word) - 1;
+}
+
#endif /* _BBITSET_H */
--
2.29.2
- [PATCH 0/7] bitset: use integrer_length in reverse iterations, Akim Demaille, 2020/11/29
- [PATCH 1/7] bitset: tests: check BITSET_FOR_EACH_REVERSE, Akim Demaille, 2020/11/29
- [PATCH 2/7] bitset: style: sort header,
Akim Demaille <=
- [PATCH 3/7] bitset: style: use consistent names, Akim Demaille, 2020/11/29
- [PATCH 4/7] bitset: use integrer_length in array implementation, Akim Demaille, 2020/11/29
- [PATCH 5/7] bitset: use integrer_length in vector implementation, Akim Demaille, 2020/11/29
- [PATCH 6/7] bitset: use integrer_length in list implementation, Akim Demaille, 2020/11/29
- [PATCH 7/7] bitset: use integrer_length in table implementation, Akim Demaille, 2020/11/29