bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
* [PATCH 0/5] bitset: use ffs
@ 2020-11-15 13:11 Akim Demaille
  2020-11-15 13:11 ` [PATCH 1/5] bitset: comment changes Akim Demaille
                   ` (4 more replies)
  0 siblings, 5 replies; 14+ messages in thread
From: Akim Demaille @ 2020-11-15 13:11 UTC (permalink / raw
  To: bug-gnulib; +Cc: Akim Demaille

Some time ago, Bruno reported that it was surprising that there are no
occurrences of ffs in the bitset module.  This series introduces the
use of ffs in array-based bitsets.  There are more places where ffs
could be used, but before installing it everywhere, I want to first
make sure that the approach I took is ok.

Originally bitset right-shifting words looking for set
least-significant bits:

    for (bitno = bitoff; word; bitno++)
      {
        if (word & 1)
          list[count++] = bitno;
        word >>= 1;
      }
      
I first tried to reproduce something similar with ffs.  Unfortunately
that led to `word >>= pos + 1`, where pos could be 63, so noop...

Instead, I'm reseting each least-significant bit in word, and the loop
above becomes:

    BITSET_FOR_EACH_BIT (pos, word)
      list[count++] = bitoff + pos;

with

    #define BITSET_FOR_EACH_BIT(Pos, Word)                  \
      for (int Pos = bitset_ffs (Word);                     \
           0 <= Pos;                                        \
           Word ^= 1UL << Pos, Pos = bitset_ffs (Word))

Cheers!

Akim Demaille (5):
  bitset: comment changes
  bitset: making debug traces more useful
  bitset: fix the copy from lbitset to other types
  bitset: more tests
  bitset: use ffsl to accelerate iterations over set bits

 ChangeLog           |  28 ++++++++++++
 lib/bitset.c        |   9 ++--
 lib/bitset.h        |  28 ++++++++----
 lib/bitset/array.c  |  56 +++++++++--------------
 lib/bitset/base.h   |   9 ++++
 lib/bitset/list.c   |  11 ++++-
 modules/bitset      |   1 +
 tests/test-bitset.c | 107 ++++++++++++++++++++++++++++++++++++++++----
 8 files changed, 190 insertions(+), 59 deletions(-)

-- 
2.29.2



^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH 1/5] bitset: comment changes
  2020-11-15 13:11 [PATCH 0/5] bitset: use ffs Akim Demaille
@ 2020-11-15 13:11 ` Akim Demaille
  2020-11-15 13:11 ` [PATCH 2/5] bitset: making debug traces more useful Akim Demaille
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 14+ messages in thread
From: Akim Demaille @ 2020-11-15 13:11 UTC (permalink / raw
  To: bug-gnulib; +Cc: Akim Demaille

* lib/bitset.c: Move some documenting comments to...
* lib/bitset.h: here.
* lib/bitset/array.c: Fix some comments.
---
 ChangeLog          |  7 +++++++
 lib/bitset.c       |  4 ----
 lib/bitset.h       | 20 ++++++++++++--------
 lib/bitset/array.c |  6 +++---
 4 files changed, 22 insertions(+), 15 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 4abbcd385..f25a948eb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2020-11-15  Akim Demaille  <akim@lrde.epita.fr>
+
+	bitset: comment changes
+	* lib/bitset.c: Move some documenting comments to...
+	* lib/bitset.h: here.
+	* lib/bitset/array.c: Fix some comments.
+
 2020-11-14  Paul Eggert  <eggert@cs.ucla.edu>
 
 	careadlinkat: warn better about GCC bug 93644
diff --git a/lib/bitset.c b/lib/bitset.c
index 70752b621..06a47ad64 100644
--- a/lib/bitset.c
+++ b/lib/bitset.c
@@ -207,8 +207,6 @@ bitset_type_name_get (bitset bset)
 }
 
 
-/* Find next bit set in SRC starting from and including BITNO.
-   Return BITSET_BINDEX_MAX if SRC empty.  */
 bitset_bindex
 bitset_next (bitset src, bitset_bindex bitno)
 {
@@ -228,8 +226,6 @@ bitset_compatible_p (bitset bset1, bitset bset2)
 }
 
 
-/* Find previous bit set in SRC starting from and including BITNO.
-   Return BITSET_BINDEX_MAX if SRC empty.  */
 bitset_bindex
 bitset_prev (bitset src, bitset_bindex bitno)
 {
diff --git a/lib/bitset.h b/lib/bitset.h
index a13b8d4d1..172b2c575 100644
--- a/lib/bitset.h
+++ b/lib/bitset.h
@@ -282,17 +282,21 @@ bitset_test (bitset bset, bitset_bindex bitno)
 /* Return true if both bitsets are of the same type and size.  */
 bool bitset_compatible_p (bitset bset1, bitset bset2);
 
-/* Find next set bit from the given bit index.  */
-bitset_bindex bitset_next (bitset, bitset_bindex);
+/* Find next bit set in SRC starting from and including BITNO.
+   Return BITSET_BINDEX_MAX if SRC empty.  */
+bitset_bindex bitset_next (bitset src, bitset_bindex bitno);
 
-/* Find previous set bit from the given bit index.  */
-bitset_bindex bitset_prev (bitset, bitset_bindex);
+/* Find previous bit set in SRC starting from and including BITNO.
+   Return BITSET_BINDEX_MAX if SRC empty.  */
+bitset_bindex bitset_prev (bitset src, bitset_bindex bitno);
 
-/* Find first set bit.  */
-bitset_bindex bitset_first (bitset);
+/* Find first set bit.
+   Return BITSET_BINDEX_MAX if SRC empty.  */
+bitset_bindex bitset_first (bitset src);
 
-/* Find last set bit.  */
-bitset_bindex bitset_last (bitset);
+/* Find last set bit.
+   Return BITSET_BINDEX_MAX if SRC empty.  */
+bitset_bindex bitset_last (bitset src);
 
 /* Return nonzero if this is the only set bit.  */
 bool bitset_only_set_p (bitset, bitset_bindex);
diff --git a/lib/bitset/array.c b/lib/bitset/array.c
index f350b53eb..1db583891 100644
--- a/lib/bitset/array.c
+++ b/lib/bitset/array.c
@@ -42,7 +42,7 @@ abitset_resize (bitset src, bitset_bindex size)
   return size;
 }
 
-/* Find list of up to NUM bits set in BSET starting from and including
+/* Find list of up to NUM bits set in SRC starting from and including
    *NEXT and store in array LIST.  Return with actual number of bits
    found and with *NEXT indicating where search stopped.  */
 static bitset_bindex
@@ -130,7 +130,7 @@ abitset_test (bitset src MAYBE_UNUSED,
 }
 
 
-/* Find list of up to NUM bits set in BSET in reverse order, starting
+/* Find list of up to NUM bits set in SRC in reverse order, starting
    from and including NEXT and store in array LIST.  Return with
    actual number of bits found and with *NEXT indicating where search
    stopped.  */
@@ -182,7 +182,7 @@ abitset_list_reverse (bitset src, bitset_bindex *list,
 }
 
 
-/* Find list of up to NUM bits set in BSET starting from and including
+/* Find list of up to NUM bits set in SRC starting from and including
    *NEXT and store in array LIST.  Return with actual number of bits
    found and with *NEXT indicating where search stopped.  */
 static bitset_bindex
-- 
2.29.2



^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 2/5] bitset: making debug traces more useful
  2020-11-15 13:11 [PATCH 0/5] bitset: use ffs Akim Demaille
  2020-11-15 13:11 ` [PATCH 1/5] bitset: comment changes Akim Demaille
@ 2020-11-15 13:11 ` Akim Demaille
  2020-11-15 16:36   ` Bruno Haible
  2020-11-15 13:11 ` [PATCH 3/5] bitset: fix the copy from lbitset to other types Akim Demaille
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 14+ messages in thread
From: Akim Demaille @ 2020-11-15 13:11 UTC (permalink / raw
  To: bug-gnulib; +Cc: Akim Demaille

* lib/bitset.c (bitset_print): Print the bitset type in verbose node.
---
 ChangeLog    | 3 +++
 lib/bitset.c | 5 +++--
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index f25a948eb..3e3e78ed3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2020-11-15  Akim Demaille  <akim@lrde.epita.fr>
 
+	bitset: making debug traces more useful
+	* lib/bitset.c (bitset_print): Print the bitset type in verbose node.
+
 	bitset: comment changes
 	* lib/bitset.c: Move some documenting comments to...
 	* lib/bitset.h: here.
diff --git a/lib/bitset.c b/lib/bitset.c
index 06a47ad64..26d176e18 100644
--- a/lib/bitset.c
+++ b/lib/bitset.c
@@ -271,7 +271,8 @@ static void
 bitset_print (FILE *file, bitset bset, bool verbose)
 {
   if (verbose)
-    fprintf (file, "n_bits = %lu, set = {",
+    fprintf (file, "%s{n_bits = %lu, set = {",
+             bitset_type_name_get (bset),
              (unsigned long) bitset_size (bset));
 
   unsigned pos = 30;
@@ -290,7 +291,7 @@ bitset_print (FILE *file, bitset bset, bool verbose)
   }
 
   if (verbose)
-    fprintf (file, "}\n");
+    fprintf (file, "}}\n");
 }
 
 
-- 
2.29.2



^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 3/5] bitset: fix the copy from lbitset to other types
  2020-11-15 13:11 [PATCH 0/5] bitset: use ffs Akim Demaille
  2020-11-15 13:11 ` [PATCH 1/5] bitset: comment changes Akim Demaille
  2020-11-15 13:11 ` [PATCH 2/5] bitset: making debug traces more useful Akim Demaille
@ 2020-11-15 13:11 ` Akim Demaille
  2020-11-15 13:11 ` [PATCH 4/5] bitset: more tests Akim Demaille
  2020-11-15 13:11 ` [PATCH 5/5] bitset: use ffsl to accelerate iterations over set bits Akim Demaille
  4 siblings, 0 replies; 14+ messages in thread
From: Akim Demaille @ 2020-11-15 13:11 UTC (permalink / raw
  To: bug-gnulib; +Cc: Akim Demaille

bitset_copy from an lbitset did not check whether the destination has
the same type.  Apply the same strategy as elsewhere.

Without this commit, the following one fails.

* lib/bitset/list.c (lbitset_copy): Rename as...
(lbitset_copy_): this.
(lbitset_copy): New.
Dispatch to heterogeneous/homogeneous copy.
---
 ChangeLog         |  6 ++++++
 lib/bitset/list.c | 11 ++++++++++-
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index 3e3e78ed3..ff21b6631 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2020-11-15  Akim Demaille  <akim@lrde.epita.fr>
 
+	bitset: fix the copy from lbitset to other types
+	* lib/bitset/list.c (lbitset_copy): Rename as...
+	(lbitset_copy_): this.
+	(lbitset_copy): New.
+	Dispatch to heterogeneous/homogeneous copy.
+
 	bitset: making debug traces more useful
 	* lib/bitset.c (bitset_print): Print the bitset type in verbose node.
 
diff --git a/lib/bitset/list.c b/lib/bitset/list.c
index c1f3d9b15..dc00fdc29 100644
--- a/lib/bitset/list.c
+++ b/lib/bitset/list.c
@@ -428,7 +428,7 @@ lbitset_equal_p (bitset dst, bitset src)
 
 /* Copy bits from bitset SRC to bitset DST.  */
 static inline void
-lbitset_copy (bitset dst, bitset src)
+lbitset_copy_ (bitset dst, bitset src)
 {
   if (src == dst)
     return;
@@ -463,6 +463,15 @@ lbitset_copy (bitset dst, bitset src)
 }
 
 
+static void
+lbitset_copy (bitset dst, bitset src)
+{
+  if (BITSET_COMPATIBLE_ (dst, src))
+    lbitset_copy_ (dst, src);
+  else
+    bitset_copy_ (dst, src);
+}
+
 /* Copy bits from bitset SRC to bitset DST.  Return true if
    bitsets different.  */
 static inline bool
-- 
2.29.2



^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 4/5] bitset: more tests
  2020-11-15 13:11 [PATCH 0/5] bitset: use ffs Akim Demaille
                   ` (2 preceding siblings ...)
  2020-11-15 13:11 ` [PATCH 3/5] bitset: fix the copy from lbitset to other types Akim Demaille
@ 2020-11-15 13:11 ` Akim Demaille
  2020-11-15 16:39   ` Bruno Haible
  2020-11-15 13:11 ` [PATCH 5/5] bitset: use ffsl to accelerate iterations over set bits Akim Demaille
  4 siblings, 1 reply; 14+ messages in thread
From: Akim Demaille @ 2020-11-15 13:11 UTC (permalink / raw
  To: bug-gnulib; +Cc: Akim Demaille

These new tests managed to uncover shortcomings in previous versions
of the following commit.

* tests/test-bitset.c (compare): Make it clear that the random values
should not be modified.
Check bitset_first, bitset_last and BITSET_FOR_EACH.
---
 ChangeLog           |   5 +++
 tests/test-bitset.c | 107 ++++++++++++++++++++++++++++++++++++++++----
 2 files changed, 103 insertions(+), 9 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index ff21b6631..713206bcf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2020-11-15  Akim Demaille  <akim@lrde.epita.fr>
 
+	bitset: more tests
+	* tests/test-bitset.c (compare): Make it clear that the random values
+	should not be modified.
+	Check bitset_first, bitset_last and BITSET_FOR_EACH.
+
 	bitset: fix the copy from lbitset to other types
 	* lib/bitset/list.c (lbitset_copy): Rename as...
 	(lbitset_copy_): this.
diff --git a/tests/test-bitset.c b/tests/test-bitset.c
index 02d7cda82..523210dae 100644
--- a/tests/test-bitset.c
+++ b/tests/test-bitset.c
@@ -48,24 +48,28 @@ void compare (enum bitset_attr a, enum bitset_attr b)
 {
   const int nbits = RANDOM (256);
 
-  bitset asrc0 = bitset_create (nbits, a);
+  /* Four read only random initial values of type A.  */
+  const bitset asrc0 = bitset_create (nbits, a);
   bitset_random (asrc0);
-  bitset asrc1 = bitset_create (nbits, a);
+  const bitset asrc1 = bitset_create (nbits, a);
   bitset_random (asrc1);
-  bitset asrc2 = bitset_create (nbits, a);
+  const bitset asrc2 = bitset_create (nbits, a);
   bitset_random (asrc2);
-  bitset asrc3 = bitset_create (nbits, a);
+  const bitset asrc3 = bitset_create (nbits, a);
   bitset_random (asrc3);
-  bitset adst = bitset_create (nbits, a);
 
-  bitset bsrc0 = bitset_create (nbits, b);
+  /* Four read only values of type B, equal to the values of type A. */
+  const bitset bsrc0 = bitset_create (nbits, b);
   bitset_copy (bsrc0, asrc0);
-  bitset bsrc1 = bitset_create (nbits, b);
+  const bitset bsrc1 = bitset_create (nbits, b);
   bitset_copy (bsrc1, asrc1);
-  bitset bsrc2 = bitset_create (nbits, b);
+  const bitset bsrc2 = bitset_create (nbits, b);
   bitset_copy (bsrc2, asrc2);
-  bitset bsrc3 = bitset_create (nbits, b);
+  const bitset bsrc3 = bitset_create (nbits, b);
   bitset_copy (bsrc3, asrc3);
+
+  /* Destinations for each operation.  */
+  bitset adst = bitset_create (nbits, a);
   bitset bdst = bitset_create (nbits, b);
 
   /* not */
@@ -139,6 +143,91 @@ void compare (enum bitset_attr a, enum bitset_attr b)
   bitset_zero (bdst);
   assert_bitset_equal (adst, bdst);
 
+  /* first and last
+
+     Exercise on random values (i == -1), but also on all the
+     single-bit values: it's easy to get the handling of the most
+     significant bit wrong.  */
+  for (int i = -1; i < nbits; ++i)
+    {
+      /* Work on bdst to exercise all the bitset types (adst is
+         BITSET_VARIABLE).  */
+      if (i >= 0)
+        {
+          bitset_zero (bdst);
+          bitset_set (bdst, i);
+        }
+      else
+        {
+          bitset_copy (bdst, bsrc0);
+          debug_bitset (bdst);
+          debug_bitset (bsrc0);
+        }
+      bitset_copy (adst, bdst);
+
+      {
+      bitset_bindex first = bitset_first (adst);
+      ASSERT (first == bitset_first (bdst));
+
+      bitset_bindex last  = bitset_last (adst);
+      ASSERT (last == bitset_last (bdst));
+
+      if (i >= 0)
+        {
+          ASSERT (first == i);
+          ASSERT (last == i);
+        }
+
+      if (first != BITSET_BINDEX_MAX)
+        {
+          ASSERT (last != BITSET_BINDEX_MAX);
+          ASSERT (first <= last);
+          ASSERT (bitset_test (adst, first));
+          ASSERT (bitset_test (adst, last));
+          ASSERT (bitset_test (bdst, first));
+          ASSERT (bitset_test (bdst, last));
+        }
+      else
+        ASSERT (last == BITSET_BINDEX_MAX);
+      }
+
+
+      /* FOR_EACH.
+
+         Iterate over bsrc0 to exercise all the bitset types (asrc0 is
+         BITSET_VARIABLE).  */
+      {
+        bitset_iterator iter;
+        bitset_bindex j;
+        bitset_bindex first = bitset_first (bdst);
+        bitset_bindex last  = bitset_last (bdst);
+        bool seen_first = false;
+        bool seen_last = false;
+        BITSET_FOR_EACH (iter, bdst, j, 0)
+          {
+            ASSERT (first <= j && j <= last);
+            ASSERT (bitset_test (bdst, j));
+            if (j == first)
+              seen_first = true;
+            if (j == last)
+              seen_last = true;
+            if (0 <= i)
+              ASSERT (j == i);
+          }
+        if (first == BITSET_BINDEX_MAX)
+          {
+            ASSERT (!seen_first);
+            ASSERT (!seen_last);
+          }
+        else
+          {
+            ASSERT (seen_first);
+            ASSERT (seen_last);
+          }
+      }
+  }
+
+
   /* resize.
 
      ARRAY bitsets cannot be resized.  */
-- 
2.29.2



^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 5/5] bitset: use ffsl to accelerate iterations over set bits
  2020-11-15 13:11 [PATCH 0/5] bitset: use ffs Akim Demaille
                   ` (3 preceding siblings ...)
  2020-11-15 13:11 ` [PATCH 4/5] bitset: more tests Akim Demaille
@ 2020-11-15 13:11 ` Akim Demaille
  2020-11-15 16:42   ` Bruno Haible
  4 siblings, 1 reply; 14+ messages in thread
From: Akim Demaille @ 2020-11-15 13:11 UTC (permalink / raw
  To: bug-gnulib; +Cc: Akim Demaille

Currently we iterate over words bit by bit.  Instead, we should jump
from set bit to set bit.
Suggested by Bruno Haible.

* modules/bitset: Depend upon ffsl.
* lib/bitset/base.h (bitset_ffs, BITSET_FOR_EACH_BIT): New.
* lib/bitset/array.c (abitset_list): Use BITSET_FOR_EACH_BIT.
---
 ChangeLog          |  6 ++++++
 lib/bitset/array.c | 50 +++++++++++++++++-----------------------------
 lib/bitset/base.h  | 17 ++++++++++++++++
 modules/bitset     |  1 +
 4 files changed, 42 insertions(+), 32 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 713206bcf..d2f104af3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2020-11-15  Akim Demaille  <akim@lrde.epita.fr>
 
+	bitset: use ffsl to accelerate iterations over set bits
+	Suggested by Bruno Haible.
+	* modules/bitset: Depend upon ffsl.
+	* lib/bitset/base.h (bitset_ffs, BITSET_FOR_EACH_BIT): New.
+	* lib/bitset/array.c (abitset_list): Use BITSET_FOR_EACH_BIT.
+
 	bitset: more tests
 	* tests/test-bitset.c (compare): Make it clear that the random values
 	should not be modified.
diff --git a/lib/bitset/array.c b/lib/bitset/array.c
index 1db583891..6c5f7ed34 100644
--- a/lib/bitset/array.c
+++ b/lib/bitset/array.c
@@ -227,18 +227,15 @@ abitset_list (bitset src, bitset_bindex *list,
 
           bitoff = windex * BITSET_WORD_BITS;
           bitset_word word = srcp[windex] >> bitno;
-          for (bitno = bitoff + bitno; word; bitno++)
+          bitno = bitoff + bitno;
+          BITSET_FOR_EACH_BIT (pos, word)
             {
-              if (word & 1)
+              list[count++] = bitno + pos;
+              if (count >= num)
                 {
-                  list[count++] = bitno;
-                  if (count >= num)
-                    {
-                      *next = bitno + 1;
-                      return count;
-                    }
+                  *next = bitno + pos + 1;
+                  return count;
                 }
-              word >>= 1;
             }
           windex++;
         }
@@ -251,31 +248,20 @@ abitset_list (bitset src, bitset_bindex *list,
       if (!word)
         continue;
 
+      /* Is there enough room to avoid checking in each iteration? */
       if ((count + BITSET_WORD_BITS) < num)
-        {
-          for (bitno = bitoff; word; bitno++)
-            {
-              if (word & 1)
-                list[count++] = bitno;
-              word >>= 1;
-            }
-        }
+        BITSET_FOR_EACH_BIT (pos, word)
+          list[count++] = bitoff + pos;
       else
-        {
-          for (bitno = bitoff; word; bitno++)
-            {
-              if (word & 1)
-                {
-                  list[count++] = bitno;
-                  if (count >= num)
-                    {
-                      *next = bitno + 1;
-                      return count;
-                    }
-                }
-              word >>= 1;
-            }
-        }
+        BITSET_FOR_EACH_BIT (pos, word)
+          {
+            list[count++] = bitoff + pos;
+            if (count >= num)
+              {
+                *next = bitoff + pos + 1;
+                return count;
+              }
+          }
     }
 
   *next = bitoff;
diff --git a/lib/bitset/base.h b/lib/bitset/base.h
index 2ae7b2080..50569a0fc 100644
--- a/lib/bitset/base.h
+++ b/lib/bitset/base.h
@@ -24,6 +24,7 @@
 #include <limits.h>
 #include <stdbool.h>
 #include <stddef.h>
+#include <string.h> /* ffsl */
 
 #include "attribute.h"
 #include "xalloc.h"
@@ -52,6 +53,14 @@ 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
@@ -60,6 +69,14 @@ 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;
 
diff --git a/modules/bitset b/modules/bitset
index 21cde24ac..c65471a02 100644
--- a/modules/bitset
+++ b/modules/bitset
@@ -20,6 +20,7 @@ Depends-on:
 attribute
 c99
 fopen-gnu
+fssl
 gettext-h
 obstack
 xalloc
-- 
2.29.2



^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [PATCH 2/5] bitset: making debug traces more useful
  2020-11-15 13:11 ` [PATCH 2/5] bitset: making debug traces more useful Akim Demaille
@ 2020-11-15 16:36   ` Bruno Haible
  0 siblings, 0 replies; 14+ messages in thread
From: Bruno Haible @ 2020-11-15 16:36 UTC (permalink / raw
  To: bug-gnulib; +Cc: Akim Demaille

Akim Demaille wrote:
> * lib/bitset.c (bitset_print): Print the bitset type in verbose node.

Is this a typo? s/node/mode/ ?

Bruno



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 4/5] bitset: more tests
  2020-11-15 13:11 ` [PATCH 4/5] bitset: more tests Akim Demaille
@ 2020-11-15 16:39   ` Bruno Haible
  0 siblings, 0 replies; 14+ messages in thread
From: Bruno Haible @ 2020-11-15 16:39 UTC (permalink / raw
  To: bug-gnulib; +Cc: Akim Demaille

Akim Demaille wrote:
> +      {
> +      bitset_bindex first = bitset_first (adst);
> +      ASSERT (first == bitset_first (bdst));
> 

What's up with the indentation, here (lines 169..191)?

Bruno



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 5/5] bitset: use ffsl to accelerate iterations over set bits
  2020-11-15 13:11 ` [PATCH 5/5] bitset: use ffsl to accelerate iterations over set bits Akim Demaille
@ 2020-11-15 16:42   ` Bruno Haible
  2020-11-15 17:03     ` Akim Demaille
  0 siblings, 1 reply; 14+ messages in thread
From: Bruno Haible @ 2020-11-15 16:42 UTC (permalink / raw
  To: bug-gnulib; +Cc: Akim Demaille

Akim Demaille wrote:
> @@ -20,6 +20,7 @@ Depends-on:
>  attribute
>  c99
>  fopen-gnu
> +fssl

Typo: We don't have a module named 'fssl'.

Bruno



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 5/5] bitset: use ffsl to accelerate iterations over set bits
  2020-11-15 16:42   ` Bruno Haible
@ 2020-11-15 17:03     ` Akim Demaille
  2020-11-15 18:07       ` Bruno Haible
  0 siblings, 1 reply; 14+ messages in thread
From: Akim Demaille @ 2020-11-15 17:03 UTC (permalink / raw
  To: Bruno Haible; +Cc: bug-gnulib

Hi Bruno,

> Le 15 nov. 2020 à 17:42, Bruno Haible <bruno@clisp.org> a écrit :
> 
> Akim Demaille wrote:
>> @@ -20,6 +20,7 @@ Depends-on:
>> attribute
>> c99
>> fopen-gnu
>> +fssl
> 
> Typo: We don't have a module named 'fssl'.

Thanks for catching these errors.  I have fixed them.
Good to install?

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 5/5] bitset: use ffsl to accelerate iterations over set bits
  2020-11-15 17:03     ` Akim Demaille
@ 2020-11-15 18:07       ` Bruno Haible
  2020-11-15 18:14         ` Akim Demaille
  0 siblings, 1 reply; 14+ messages in thread
From: Bruno Haible @ 2020-11-15 18:07 UTC (permalink / raw
  To: Akim Demaille; +Cc: bug-gnulib

Hi Akim,

> Thanks for catching these errors.  I have fixed them.
> Good to install?

Yes, assuming you did a quick check with the unit tests:
  ./gnulib-tool --test --single-configure bitset

Bruno



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 5/5] bitset: use ffsl to accelerate iterations over set bits
  2020-11-15 18:07       ` Bruno Haible
@ 2020-11-15 18:14         ` Akim Demaille
  2020-11-18  3:40           ` Bruno Haible
  0 siblings, 1 reply; 14+ messages in thread
From: Akim Demaille @ 2020-11-15 18:14 UTC (permalink / raw
  To: Bruno Haible; +Cc: bug-gnulib



> Le 15 nov. 2020 à 19:07, Bruno Haible <bruno@clisp.org> a écrit :
> 
> Hi Akim,
> 
>> Thanks for catching these errors.  I have fixed them.
>> Good to install?
> 
> Yes, assuming you did a quick check with the unit tests:
>  ./gnulib-tool --test --single-configure bitset

Yes, I did run the test suite :)

Installed.  Thanks!



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 5/5] bitset: use ffsl to accelerate iterations over set bits
  2020-11-15 18:14         ` Akim Demaille
@ 2020-11-18  3:40           ` Bruno Haible
  2020-11-18  5:56             ` Akim Demaille
  0 siblings, 1 reply; 14+ messages in thread
From: Bruno Haible @ 2020-11-18  3:40 UTC (permalink / raw
  To: Akim Demaille; +Cc: bug-gnulib

[-- Attachment #1: Type: text/plain, Size: 403 bytes --]

Hi Akim,

> > Yes, assuming you did a quick check with the unit tests:
> >  ./gnulib-tool --test --single-configure bitset
> 
> Yes, I did run the test suite :)
> 
> Installed.  Thanks!

A testdir of all of gnulib now shows 1 test failure:
FAIL: test-bitset

This is on a glibc system, x86_64, with gcc 5.4.0.

Is this bug the one that you are fixing in the new patch series, or a different
one?

Bruno

[-- Attachment #2: test-bitset.log --]
[-- Type: text/x-log, Size: 18797 bytes --]

vbitset{n_bits = 103, set = {2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 
99 100 101 102 }}
abitset{n_bits = 103, set = {2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 
99 100 101 102 }}
vbitset{n_bits = 103, set = {0 1 }}
abitset{n_bits = 103, set = {0 1 }}
vbitset{n_bits = 103, set = {0 1 }}
abitset{n_bits = 103, set = {0 1 }}
vbitset{n_bits = 103, set = {}}
abitset{n_bits = 103, set = {}}
vbitset{n_bits = 103, set = {}}
abitset{n_bits = 103, set = {}}
vbitset{n_bits = 103, set = {0 1 }}
abitset{n_bits = 103, set = {0 1 }}
vbitset{n_bits = 103, set = {0 1 }}
abitset{n_bits = 103, set = {0 1 }}
vbitset{n_bits = 103, set = {}}
abitset{n_bits = 103, set = {}}
vbitset{n_bits = 103, set = {}}
abitset{n_bits = 103, set = {}}
vbitset{n_bits = 103, set = {0 1 }}
abitset{n_bits = 103, set = {0 1 }}
vbitset{n_bits = 103, set = {0 1 }}
abitset{n_bits = 103, set = {0 1 }}
vbitset{n_bits = 103, set = {0 1 }}
abitset{n_bits = 103, set = {0 1 }}
vbitset{n_bits = 103, set = {0 1 }}
abitset{n_bits = 103, set = {0 1 }}
vbitset{n_bits = 103, set = {0 1 }}
abitset{n_bits = 103, set = {0 1 }}
vbitset{n_bits = 103, set = {0 1 }}
abitset{n_bits = 103, set = {0 1 }}
vbitset{n_bits = 103, set = {0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 
98 99 100 101 102 }}
abitset{n_bits = 103, set = {0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 
98 99 100 101 102 }}
vbitset{n_bits = 103, set = {}}
abitset{n_bits = 103, set = {}}
abitset{n_bits = 103, set = {0 1 }}
abitset{n_bits = 103, set = {0 1 }}
vbitset{n_bits = 112, set = {2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 
99 100 101 102 103 104 105 106 107 108 109 110 111 }}
vbitset{n_bits = 112, set = {2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 
99 100 101 102 103 104 105 106 107 108 109 110 111 }}
vbitset{n_bits = 112, set = {0 1 }}
vbitset{n_bits = 112, set = {0 1 }}
vbitset{n_bits = 112, set = {0 1 }}
vbitset{n_bits = 112, set = {0 1 }}
vbitset{n_bits = 112, set = {}}
vbitset{n_bits = 112, set = {}}
vbitset{n_bits = 112, set = {}}
vbitset{n_bits = 112, set = {}}
vbitset{n_bits = 112, set = {0 1 }}
vbitset{n_bits = 112, set = {0 1 }}
vbitset{n_bits = 112, set = {0 1 }}
vbitset{n_bits = 112, set = {0 1 }}
vbitset{n_bits = 112, set = {}}
vbitset{n_bits = 112, set = {}}
vbitset{n_bits = 112, set = {}}
vbitset{n_bits = 112, set = {}}
vbitset{n_bits = 112, set = {0 1 }}
vbitset{n_bits = 112, set = {0 1 }}
vbitset{n_bits = 112, set = {0 1 }}
vbitset{n_bits = 112, set = {0 1 }}
vbitset{n_bits = 112, set = {0 1 }}
vbitset{n_bits = 112, set = {0 1 }}
vbitset{n_bits = 112, set = {0 1 }}
vbitset{n_bits = 112, set = {0 1 }}
vbitset{n_bits = 112, set = {0 1 }}
vbitset{n_bits = 112, set = {0 1 }}
vbitset{n_bits = 112, set = {0 1 }}
vbitset{n_bits = 112, set = {0 1 }}
vbitset{n_bits = 112, set = {0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 
98 99 100 101 102 103 104 105 106 107 108 109 110 111 }}
vbitset{n_bits = 112, set = {0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 
98 99 100 101 102 103 104 105 106 107 108 109 110 111 }}
vbitset{n_bits = 112, set = {}}
vbitset{n_bits = 112, set = {}}
vbitset{n_bits = 112, set = {0 1 }}
vbitset{n_bits = 112, set = {0 1 }}
vbitset{n_bits = 118, set = {0 1 }}
vbitset{n_bits = 118, set = {0 1 }}
vbitset{n_bits = 91, set = {2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 }}
vbitset{n_bits = 91, set = {2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 }}
vbitset{n_bits = 91, set = {0 1 }}
vbitset{n_bits = 91, set = {0 1 }}
vbitset{n_bits = 91, set = {0 1 }}
vbitset{n_bits = 91, set = {0 1 }}
vbitset{n_bits = 91, set = {}}
vbitset{n_bits = 91, set = {}}
vbitset{n_bits = 91, set = {}}
vbitset{n_bits = 91, set = {}}
vbitset{n_bits = 91, set = {0 1 }}
vbitset{n_bits = 91, set = {0 1 }}
vbitset{n_bits = 91, set = {0 1 }}
vbitset{n_bits = 91, set = {0 1 }}
vbitset{n_bits = 91, set = {}}
vbitset{n_bits = 91, set = {}}
vbitset{n_bits = 91, set = {}}
vbitset{n_bits = 91, set = {}}
vbitset{n_bits = 91, set = {0 1 }}
vbitset{n_bits = 91, set = {0 1 }}
vbitset{n_bits = 91, set = {0 1 }}
vbitset{n_bits = 91, set = {0 1 }}
vbitset{n_bits = 91, set = {0 1 }}
vbitset{n_bits = 91, set = {0 1 }}
vbitset{n_bits = 91, set = {0 1 }}
vbitset{n_bits = 91, set = {0 1 }}
vbitset{n_bits = 91, set = {0 1 }}
vbitset{n_bits = 91, set = {0 1 }}
vbitset{n_bits = 91, set = {0 1 }}
vbitset{n_bits = 91, set = {0 1 }}
vbitset{n_bits = 91, set = {0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 }}
vbitset{n_bits = 91, set = {0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 }}
vbitset{n_bits = 91, set = {}}
vbitset{n_bits = 91, set = {}}
vbitset{n_bits = 91, set = {0 1 }}
vbitset{n_bits = 91, set = {0 1 }}
vbitset{n_bits = 43, set = {0 1 }}
vbitset{n_bits = 43, set = {0 1 }}
vbitset{n_bits = 239, set = {2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 
171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 
195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 
219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 }}
lbitset{n_bits = 239, set = {2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 
171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 
195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 
219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 }}
vbitset{n_bits = 239, set = {0 1 }}
lbitset{n_bits = 239, set = {0 1 }}
vbitset{n_bits = 239, set = {0 1 }}
lbitset{n_bits = 239, set = {0 1 }}
vbitset{n_bits = 239, set = {}}
lbitset{n_bits = 239, set = {}}
vbitset{n_bits = 239, set = {}}
lbitset{n_bits = 239, set = {}}
vbitset{n_bits = 239, set = {0 1 }}
lbitset{n_bits = 239, set = {0 1 }}
vbitset{n_bits = 239, set = {0 1 }}
lbitset{n_bits = 239, set = {0 1 }}
vbitset{n_bits = 239, set = {}}
lbitset{n_bits = 239, set = {}}
vbitset{n_bits = 239, set = {}}
lbitset{n_bits = 239, set = {}}
vbitset{n_bits = 239, set = {0 1 }}
lbitset{n_bits = 239, set = {0 1 }}
vbitset{n_bits = 239, set = {0 1 }}
lbitset{n_bits = 239, set = {0 1 }}
vbitset{n_bits = 239, set = {0 1 }}
lbitset{n_bits = 239, set = {0 1 }}
vbitset{n_bits = 239, set = {0 1 }}
lbitset{n_bits = 239, set = {0 1 }}
vbitset{n_bits = 239, set = {0 1 }}
lbitset{n_bits = 239, set = {0 1 }}
vbitset{n_bits = 239, set = {0 1 }}
lbitset{n_bits = 239, set = {0 1 }}
vbitset{n_bits = 239, set = {0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 
171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 
195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 
219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 }}
lbitset{n_bits = 239, set = {0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 
171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 
195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 
219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 }}
vbitset{n_bits = 239, set = {}}
lbitset{n_bits = 239, set = {}}
lbitset{n_bits = 239, set = {0 1 }}
lbitset{n_bits = 239, set = {0 1 }}
vbitset{n_bits = 232, set = {0 1 }}
lbitset{n_bits = 232, set = {0 1 }}
vbitset{n_bits = 66, set = {2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 
63 64 65 }}
vbitset{n_bits = 66, set = {2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 
63 64 65 }}
vbitset{n_bits = 66, set = {0 1 }}
vbitset{n_bits = 66, set = {0 1 }}
vbitset{n_bits = 66, set = {0 1 }}
vbitset{n_bits = 66, set = {0 1 }}
vbitset{n_bits = 66, set = {}}
vbitset{n_bits = 66, set = {}}
vbitset{n_bits = 66, set = {}}
vbitset{n_bits = 66, set = {}}
vbitset{n_bits = 66, set = {0 1 }}
vbitset{n_bits = 66, set = {0 1 }}
vbitset{n_bits = 66, set = {0 1 }}
vbitset{n_bits = 66, set = {0 1 }}
vbitset{n_bits = 66, set = {}}
vbitset{n_bits = 66, set = {}}
vbitset{n_bits = 66, set = {}}
vbitset{n_bits = 66, set = {}}
vbitset{n_bits = 66, set = {0 1 }}
vbitset{n_bits = 66, set = {0 1 }}
vbitset{n_bits = 66, set = {0 1 }}
vbitset{n_bits = 66, set = {0 1 }}
vbitset{n_bits = 66, set = {0 1 }}
vbitset{n_bits = 66, set = {0 1 }}
vbitset{n_bits = 66, set = {0 1 }}
vbitset{n_bits = 66, set = {0 1 }}
vbitset{n_bits = 66, set = {0 1 }}
vbitset{n_bits = 66, set = {0 1 }}
vbitset{n_bits = 66, set = {0 1 }}
vbitset{n_bits = 66, set = {0 1 }}
vbitset{n_bits = 66, set = {0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 
62 63 64 65 }}
vbitset{n_bits = 66, set = {0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 
62 63 64 65 }}
vbitset{n_bits = 66, set = {}}
vbitset{n_bits = 66, set = {}}
vbitset{n_bits = 66, set = {0 1 }}
vbitset{n_bits = 66, set = {0 1 }}
vbitset{n_bits = 15, set = {0 1 }}
vbitset{n_bits = 15, set = {0 1 }}
vbitset{n_bits = 229, set = {2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 
171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 
195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 
219 220 221 222 223 224 225 226 227 228 }}
tbitset{n_bits = 229, set = {2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 
171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 
195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 
219 220 221 222 223 224 225 226 227 228 }}
vbitset{n_bits = 229, set = {0 1 }}
tbitset{n_bits = 229, set = {0 1 }}
vbitset{n_bits = 229, set = {0 1 }}
tbitset{n_bits = 229, set = {0 1 }}
vbitset{n_bits = 229, set = {}}
tbitset{n_bits = 229, set = {}}
vbitset{n_bits = 229, set = {}}
tbitset{n_bits = 229, set = {}}
vbitset{n_bits = 229, set = {0 1 }}
tbitset{n_bits = 229, set = {0 1 }}
vbitset{n_bits = 229, set = {0 1 }}
tbitset{n_bits = 229, set = {0 1 }}
vbitset{n_bits = 229, set = {}}
tbitset{n_bits = 229, set = {}}
vbitset{n_bits = 229, set = {}}
tbitset{n_bits = 229, set = {}}
vbitset{n_bits = 229, set = {0 1 }}
tbitset{n_bits = 229, set = {0 1 }}
vbitset{n_bits = 229, set = {0 1 }}
tbitset{n_bits = 229, set = {0 1 }}
vbitset{n_bits = 229, set = {0 1 }}
tbitset{n_bits = 229, set = {0 1 }}
vbitset{n_bits = 229, set = {0 1 }}
tbitset{n_bits = 229, set = {0 1 }}
vbitset{n_bits = 229, set = {0 1 }}
tbitset{n_bits = 229, set = {0 1 }}
vbitset{n_bits = 229, set = {0 1 }}
tbitset{n_bits = 229, set = {0 1 }}
vbitset{n_bits = 229, set = {0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 
171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 
195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 
219 220 221 222 223 224 225 226 227 228 }}
tbitset{n_bits = 229, set = {0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 
171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 
195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 
219 220 221 222 223 224 225 226 227 228 }}
vbitset{n_bits = 229, set = {}}
tbitset{n_bits = 229, set = {}}
tbitset{n_bits = 229, set = {0 1 }}
tbitset{n_bits = 229, set = {0 1 }}
../../gltests/test-bitset.c:171: assertion 'first == bitset_first (bdst)' failed
FAIL test-bitset (exit status: 134)

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 5/5] bitset: use ffsl to accelerate iterations over set bits
  2020-11-18  3:40           ` Bruno Haible
@ 2020-11-18  5:56             ` Akim Demaille
  0 siblings, 0 replies; 14+ messages in thread
From: Akim Demaille @ 2020-11-18  5:56 UTC (permalink / raw
  To: Bruno Haible; +Cc: bug-gnulib

Hi Bruno,

> Le 18 nov. 2020 à 04:40, Bruno Haible <bruno@clisp.org> a écrit :
> 
> Hi Akim,
> 
>>> Yes, assuming you did a quick check with the unit tests:
>>> ./gnulib-tool --test --single-configure bitset
>> 
>> Yes, I did run the test suite :)
>> 
>> Installed.  Thanks!
> 
> A testdir of all of gnulib now shows 1 test failure:

tbitset{n_bits = 229, set = {0 1 }}
../../gltests/test-bitset.c:171: assertion 'first == bitset_first (bdst)' failed

> This is on a glibc system, x86_64, with gcc 5.4.0.
> 
> Is this bug the one that you are fixing in the new patch series, or a different
> one?

Most likely the same one: bitset_first uses bitset_list under the
hood, and it's tbitset_list that I fixed in the other series.

It turns out that on my machine it was not revealed, because when it comes
to tbitset, the random size that was picked is small enough not to fall
into the trap.  That's why I added deterministic tests for "large" bit sets.

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2020-11-18  5:56 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-11-15 13:11 [PATCH 0/5] bitset: use ffs Akim Demaille
2020-11-15 13:11 ` [PATCH 1/5] bitset: comment changes Akim Demaille
2020-11-15 13:11 ` [PATCH 2/5] bitset: making debug traces more useful Akim Demaille
2020-11-15 16:36   ` Bruno Haible
2020-11-15 13:11 ` [PATCH 3/5] bitset: fix the copy from lbitset to other types Akim Demaille
2020-11-15 13:11 ` [PATCH 4/5] bitset: more tests Akim Demaille
2020-11-15 16:39   ` Bruno Haible
2020-11-15 13:11 ` [PATCH 5/5] bitset: use ffsl to accelerate iterations over set bits Akim Demaille
2020-11-15 16:42   ` Bruno Haible
2020-11-15 17:03     ` Akim Demaille
2020-11-15 18:07       ` Bruno Haible
2020-11-15 18:14         ` Akim Demaille
2020-11-18  3:40           ` Bruno Haible
2020-11-18  5:56             ` Akim Demaille

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).