[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Bitsets
From: |
Paul Eggert |
Subject: |
Re: Bitsets |
Date: |
17 Jun 2003 13:32:39 -0700 |
User-agent: |
Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 |
Thanks for all the bitset work. Here are some minor patches I made to
your 2003-06-08 edition of libbitset to get it to work well with
Bison. When Bison builds pedantically it objects to some K&Risms, so
most of the changes simply switch to C89 (which libbitset already
assumes). I haven't systematically gone through and removed all
K&Risms, only the stuff that GCC complained about.
2003-06-17 Paul Eggert <address@hidden>
* lib/bbitset.h: Do not include config.h; that's the includer's job.
Do not include <sys/types.h>; shouldn't be needed on a C89 host.
Instead, include <stddef.h>, for size_t.
* lib/bitset.h (bitset_compatible_p): Indent as per GNU standard.
Don't use 'index' in comments, as it's a builtin fn on some hosts.
* lib/bitset_stats.c: Include gettext.h unconditionally, as
per recent gettext manual's suggestion.
* lib/ebitset.c (ebitset_resize, ebitset_unused_clear):
Use prototypes, not old-style definitions.
* lib/lbitset.c (lbitset_unused_clear): Likewise.
* lib/vbitset.c (vbitset_resize, vbitset_ones, vbitset_zero,
vbitset_empty_p, vbitset_copy1, vbitset_not, vbitset_equal_p,
vbitset_subset_p, vbitset_disjoint_p, vbitset_and, vbitset_and_cmp,
vbitset_andn, vbitset_andn_cmp, vbitset_or, vbitset_or_cmp,
vbitset_xor, vbitset_xor_cmp, vbitset_and_or, vbitset_and_or_cmp,
vbitset_andn_or, vbitset_andn_or_cmp, vbitset_or_and,
vbitset_or_and_cmp, vbitset_copy): Likewise.
(vbitset_copy): Now static, not extern.
diff -pru libbitset/bbitset.h gnu/bison/lib/bbitset.h
--- libbitset/bbitset.h Thu Jun 5 03:33:45 2003
+++ gnu/bison/lib/bbitset.h Tue Jun 17 11:22:01 2003
@@ -19,12 +19,11 @@ Foundation, Inc., 59 Temple Place - Suit
#ifndef _BBITSET_H
#define _BBITSET_H
-#include "config.h"
#include "libiberty.h"
#include <stdbool.h>
#include <limits.h>
-#include <sys/types.h>
+#include <stddef.h>
/* Currently we support five flavours of bitsets:
BITSET_ARRAY: Array of bits (fixed size, fast for dense bitsets).
diff -pru libbitset/bitset.h gnu/bison/lib/bitset.h
--- libbitset/bitset.h Sat Jun 7 16:28:20 2003
+++ gnu/bison/lib/bitset.h Tue Jun 17 00:21:59 2003
@@ -286,8 +286,7 @@ extern void bitset_resize PARAMS ((bitse
BITSET_LIST_REVERSE_ (BSET, LIST, NUM, NEXT)
/* Return true if both bitsets are of the same type and size. */
-extern bool
-bitset_compatible_p (bitset bset1, bitset bset2);
+extern bool bitset_compatible_p (bitset bset1, bitset bset2);
/* Find next set bit from the given bit index. */
extern bitset_bindex bitset_next PARAMS ((bitset, bitset_bindex));
@@ -311,12 +310,12 @@ extern void bitset_dump PARAMS ((FILE *,
to the index of each set bit. For example, the following will print
the bits set in a bitset:
- bitset_bindex index;
+ bitset_bindex i;
bitset_iterator iter;
- BITSET_FOR_EACH (iter, src, index, 0)
+ BITSET_FOR_EACH (iter, src, i, 0)
{
- printf ("%ld ", index);
+ printf ("%lu ", (unsigned long int) i);
};
*/
#define BITSET_FOR_EACH(ITER, BSET, INDEX, MIN)
\
@@ -330,15 +329,15 @@ extern void bitset_dump PARAMS ((FILE *,
/* Loop over all elements of BSET, in reverse order starting with
- MIN, setting INDEX to the index of each set bit. For example, the
+ MIN, setting INDEX to the index of each set bit. For example, the
following will print the bits set in a bitset in reverse order:
- bitset_bindex index;
+ bitset_bindex i;
bitset_iterator iter;
- BITSET_FOR_EACH_REVERSE (iter, src, index, 0)
+ BITSET_FOR_EACH_REVERSE (iter, src, i, 0)
{
- printf ("%ld ", index);
+ printf ("%lu ", (unsigned long int) i);
};
*/
#define BITSET_FOR_EACH_REVERSE(ITER, BSET, INDEX, MIN)
\
diff -pru libbitset/bitset_stats.c gnu/bison/lib/bitset_stats.c
--- libbitset/bitset_stats.c Mon Jun 2 03:19:35 2003
+++ gnu/bison/lib/bitset_stats.c Tue Jun 17 00:22:58 2003
@@ -1,5 +1,5 @@
/* Bitset statistics.
- Copyright (C) 2002 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2003 Free Software Foundation, Inc.
Contributed by Michael Hayes (address@hidden).
This program is free software; you can redistribute it and/or modify
@@ -39,12 +39,8 @@
#include <string.h>
#include <stdio.h>
-#ifdef HAVE_GETTEXT_H
#include "gettext.h"
#define _(Msgid) gettext (Msgid)
-#else
-#define _(Msgid) Msgid
-#endif
/* Configuration macros. */
#define BITSET_STATS_FILE "bitset.dat"
diff -pru libbitset/ebitset.c gnu/bison/lib/ebitset.c
--- libbitset/ebitset.c Fri Jun 6 17:31:33 2003
+++ gnu/bison/lib/ebitset.c Tue Jun 17 00:23:46 2003
@@ -121,9 +121,7 @@ static ebitset_elt *ebitset_free_list; /
static bitset_bindex
-ebitset_resize (src, n_bits)
- bitset src;
- bitset_bindex n_bits;
+ebitset_resize (bitset src, bitset_bindex n_bits)
{
bitset_windex oldsize;
bitset_windex newsize;
@@ -838,8 +836,7 @@ ebitset_list (bitset bset, bitset_bindex
/* Ensure that any unused bits within the last element are clear. */
static inline void
-ebitset_unused_clear (dst)
- bitset dst;
+ebitset_unused_clear (bitset dst)
{
unsigned int last_bit;
bitset_bindex n_bits;
diff -pru libbitset/lbitset.c gnu/bison/lib/lbitset.c
--- libbitset/lbitset.c Fri Jun 6 17:31:37 2003
+++ gnu/bison/lib/lbitset.c Tue Jun 17 00:24:40 2003
@@ -883,8 +883,7 @@ lbitset_empty_p (bitset dst)
/* Ensure that any unused bits within the last element are clear. */
static inline void
-lbitset_unused_clear (dst)
- bitset dst;
+lbitset_unused_clear (bitset dst)
{
unsigned int last_bit;
bitset_bindex n_bits;
diff -pru libbitset/vbitset.c gnu/bison/lib/vbitset.c
--- libbitset/vbitset.c Mon Jun 2 04:54:30 2003
+++ gnu/bison/lib/vbitset.c Tue Jun 17 01:16:33 2003
@@ -55,9 +55,7 @@ static bitset_bindex vbitset_list_revers
#define max(a, b) ((a) > (b) ? (a) : (b))
static bitset_bindex
-vbitset_resize (src, n_bits)
- bitset src;
- bitset_bindex n_bits;
+vbitset_resize (bitset src, bitset_bindex n_bits)
{
bitset_windex oldsize;
bitset_windex newsize;
@@ -343,8 +341,7 @@ vbitset_unused_clear (dst)
static void
-vbitset_ones (dst)
- bitset dst;
+vbitset_ones (bitset dst)
{
bitset_word *dstp = VBITSET_WORDS (dst);
unsigned int bytes;
@@ -357,8 +354,7 @@ vbitset_ones (dst)
static void
-vbitset_zero (dst)
- bitset dst;
+vbitset_zero (bitset dst)
{
bitset_word *dstp = VBITSET_WORDS (dst);
unsigned int bytes;
@@ -370,8 +366,7 @@ vbitset_zero (dst)
static bool
-vbitset_empty_p (dst)
- bitset dst;
+vbitset_empty_p (bitset dst)
{
unsigned int i;
bitset_word *dstp = VBITSET_WORDS (dst);
@@ -385,9 +380,7 @@ vbitset_empty_p (dst)
static void
-vbitset_copy1 (dst, src)
- bitset dst;
- bitset src;
+vbitset_copy1 (bitset dst, bitset src)
{
bitset_word *srcp;
bitset_word *dstp;
@@ -412,9 +405,7 @@ vbitset_copy1 (dst, src)
static void
-vbitset_not (dst, src)
- bitset dst;
- bitset src;
+vbitset_not (bitset dst, bitset src)
{
unsigned int i;
bitset_word *srcp;
@@ -439,9 +430,7 @@ vbitset_not (dst, src)
static bool
-vbitset_equal_p (dst, src)
- bitset dst;
- bitset src;
+vbitset_equal_p (bitset dst, bitset src)
{
unsigned int i;
bitset_word *srcp = VBITSET_WORDS (src);
@@ -471,9 +460,7 @@ vbitset_equal_p (dst, src)
static bool
-vbitset_subset_p (dst, src)
- bitset dst;
- bitset src;
+vbitset_subset_p (bitset dst, bitset src)
{
unsigned int i;
bitset_word *srcp = VBITSET_WORDS (src);
@@ -497,9 +484,7 @@ vbitset_subset_p (dst, src)
static bool
-vbitset_disjoint_p (dst, src)
- bitset dst;
- bitset src;
+vbitset_disjoint_p (bitset dst, bitset src)
{
unsigned int i;
bitset_word *srcp = VBITSET_WORDS (src);
@@ -516,10 +501,7 @@ vbitset_disjoint_p (dst, src)
static void
-vbitset_and (dst, src1, src2)
- bitset dst;
- bitset src1;
- bitset src2;
+vbitset_and (bitset dst, bitset src1, bitset src2)
{
unsigned int i;
bitset_word *src1p;
@@ -546,10 +528,7 @@ vbitset_and (dst, src1, src2)
static bool
-vbitset_and_cmp (dst, src1, src2)
- bitset dst;
- bitset src1;
- bitset src2;
+vbitset_and_cmp (bitset dst, bitset src1, bitset src2)
{
unsigned int i;
int changed = 0;
@@ -602,10 +581,7 @@ vbitset_and_cmp (dst, src1, src2)
static void
-vbitset_andn (dst, src1, src2)
- bitset dst;
- bitset src1;
- bitset src2;
+vbitset_andn (bitset dst, bitset src1, bitset src2)
{
unsigned int i;
bitset_word *src1p;
@@ -645,10 +621,7 @@ vbitset_andn (dst, src1, src2)
static bool
-vbitset_andn_cmp (dst, src1, src2)
- bitset dst;
- bitset src1;
- bitset src2;
+vbitset_andn_cmp (bitset dst, bitset src1, bitset src2)
{
unsigned int i;
int changed = 0;
@@ -713,10 +686,7 @@ vbitset_andn_cmp (dst, src1, src2)
static void
-vbitset_or (dst, src1, src2)
- bitset dst;
- bitset src1;
- bitset src2;
+vbitset_or (bitset dst, bitset src1, bitset src2)
{
unsigned int i;
bitset_word *src1p;
@@ -752,10 +722,7 @@ vbitset_or (dst, src1, src2)
static bool
-vbitset_or_cmp (dst, src1, src2)
- bitset dst;
- bitset src1;
- bitset src2;
+vbitset_or_cmp (bitset dst, bitset src1, bitset src2)
{
unsigned int i;
int changed = 0;
@@ -810,10 +777,7 @@ vbitset_or_cmp (dst, src1, src2)
static void
-vbitset_xor (dst, src1, src2)
- bitset dst;
- bitset src1;
- bitset src2;
+vbitset_xor (bitset dst, bitset src1, bitset src2)
{
unsigned int i;
bitset_word *src1p;
@@ -849,10 +813,7 @@ vbitset_xor (dst, src1, src2)
static bool
-vbitset_xor_cmp (dst, src1, src2)
- bitset dst;
- bitset src1;
- bitset src2;
+vbitset_xor_cmp (bitset dst, bitset src1, bitset src2)
{
unsigned int i;
int changed = 0;
@@ -910,11 +871,7 @@ vbitset_xor_cmp (dst, src1, src2)
bitsets. */
static void
-vbitset_and_or (dst, src1, src2, src3)
- bitset dst;
- bitset src1;
- bitset src2;
- bitset src3;
+vbitset_and_or (bitset dst, bitset src1, bitset src2, bitset src3)
{
unsigned int i;
bitset_word *src1p;
@@ -944,11 +901,7 @@ vbitset_and_or (dst, src1, src2, src3)
static bool
-vbitset_and_or_cmp (dst, src1, src2, src3)
- bitset dst;
- bitset src1;
- bitset src2;
- bitset src3;
+vbitset_and_or_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
{
unsigned int i;
int changed = 0;
@@ -985,11 +938,7 @@ vbitset_and_or_cmp (dst, src1, src2, src
static void
-vbitset_andn_or (dst, src1, src2, src3)
- bitset dst;
- bitset src1;
- bitset src2;
- bitset src3;
+vbitset_andn_or (bitset dst, bitset src1, bitset src2, bitset src3)
{
unsigned int i;
bitset_word *src1p;
@@ -1019,11 +968,7 @@ vbitset_andn_or (dst, src1, src2, src3)
static bool
-vbitset_andn_or_cmp (dst, src1, src2, src3)
- bitset dst;
- bitset src1;
- bitset src2;
- bitset src3;
+vbitset_andn_or_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
{
unsigned int i;
int changed = 0;
@@ -1060,11 +1005,7 @@ vbitset_andn_or_cmp (dst, src1, src2, sr
static void
-vbitset_or_and (dst, src1, src2, src3)
- bitset dst;
- bitset src1;
- bitset src2;
- bitset src3;
+vbitset_or_and (bitset dst, bitset src1, bitset src2, bitset src3)
{
unsigned int i;
bitset_word *src1p;
@@ -1094,11 +1035,7 @@ vbitset_or_and (dst, src1, src2, src3)
static bool
-vbitset_or_and_cmp (dst, src1, src2, src3)
- bitset dst;
- bitset src1;
- bitset src2;
- bitset src3;
+vbitset_or_and_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
{
unsigned int i;
int changed = 0;
@@ -1134,10 +1071,8 @@ vbitset_or_and_cmp (dst, src1, src2, src
}
-void
-vbitset_copy (dst, src)
- bitset dst;
- bitset src;
+static void
+vbitset_copy (bitset dst, bitset src)
{
if (BITSET_COMPATIBLE_ (dst, src))
vbitset_copy1 (dst, src);
Re: Bitsets, Zack Weinberg, 2003/06/10
Re: Bitsets, Michael Hayes, 2003/06/11
Re: Bitsets,
Paul Eggert <=