This commit is contained in:
Paul Eggert
2003-06-02 11:54:30 +00:00
parent 598c90ee77
commit 964db18ed6

View File

@@ -1,10 +1,10 @@
/* Variable array bitsets.
Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
Copyright (C) 2002, 2003 Free Software Foundation, Inc.
Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz).
This program is free software: you can redistribute it and/or modify
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
@@ -13,12 +13,15 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <config.h>
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "vbitset.h"
#include <stdlib.h>
#include <string.h>
@@ -30,28 +33,31 @@
has the same size.
*/
static void vbitset_unused_clear (bitset);
static void vbitset_unused_clear PARAMS ((bitset));
static void vbitset_set (bitset, bitset_bindex);
static void vbitset_reset (bitset, bitset_bindex);
static bool vbitset_test (bitset, bitset_bindex);
static bitset_bindex vbitset_list (bitset, bitset_bindex *,
bitset_bindex, bitset_bindex *);
static bitset_bindex vbitset_list_reverse (bitset, bitset_bindex *,
bitset_bindex, bitset_bindex *);
static void vbitset_set PARAMS ((bitset, bitset_bindex));
static void vbitset_reset PARAMS ((bitset, bitset_bindex));
static bool vbitset_test PARAMS ((bitset, bitset_bindex));
static bitset_bindex vbitset_list PARAMS ((bitset, bitset_bindex *,
bitset_bindex,
bitset_bindex *));
static bitset_bindex vbitset_list_reverse PARAMS ((bitset, bitset_bindex *,
bitset_bindex,
bitset_bindex *));
#define VBITSET_N_WORDS(N) (((N) + BITSET_WORD_BITS - 1) / BITSET_WORD_BITS)
#define VBITSET_WORDS(X) ((X)->b.cdata)
#define VBITSET_SIZE(X) ((X)->b.csize)
#define VBITSET_ASIZE(X) ((X)->v.size)
#undef min
#undef max
#define min(a, b) ((a) > (b) ? (b) : (a))
#define max(a, b) ((a) > (b) ? (a) : (b))
static bitset_bindex
vbitset_resize (bitset src, bitset_bindex n_bits)
vbitset_resize (src, n_bits)
bitset src;
bitset_bindex n_bits;
{
bitset_windex oldsize;
bitset_windex newsize;
@@ -337,7 +343,8 @@ vbitset_unused_clear (dst)
static void
vbitset_ones (bitset dst)
vbitset_ones (dst)
bitset dst;
{
bitset_word *dstp = VBITSET_WORDS (dst);
unsigned int bytes;
@@ -350,7 +357,8 @@ vbitset_ones (bitset dst)
static void
vbitset_zero (bitset dst)
vbitset_zero (dst)
bitset dst;
{
bitset_word *dstp = VBITSET_WORDS (dst);
unsigned int bytes;
@@ -362,7 +370,8 @@ vbitset_zero (bitset dst)
static bool
vbitset_empty_p (bitset dst)
vbitset_empty_p (dst)
bitset dst;
{
unsigned int i;
bitset_word *dstp = VBITSET_WORDS (dst);
@@ -376,7 +385,9 @@ vbitset_empty_p (bitset dst)
static void
vbitset_copy1 (bitset dst, bitset src)
vbitset_copy1 (dst, src)
bitset dst;
bitset src;
{
bitset_word *srcp;
bitset_word *dstp;
@@ -401,7 +412,9 @@ vbitset_copy1 (bitset dst, bitset src)
static void
vbitset_not (bitset dst, bitset src)
vbitset_not (dst, src)
bitset dst;
bitset src;
{
unsigned int i;
bitset_word *srcp;
@@ -426,7 +439,9 @@ vbitset_not (bitset dst, bitset src)
static bool
vbitset_equal_p (bitset dst, bitset src)
vbitset_equal_p (dst, src)
bitset dst;
bitset src;
{
unsigned int i;
bitset_word *srcp = VBITSET_WORDS (src);
@@ -456,7 +471,9 @@ vbitset_equal_p (bitset dst, bitset src)
static bool
vbitset_subset_p (bitset dst, bitset src)
vbitset_subset_p (dst, src)
bitset dst;
bitset src;
{
unsigned int i;
bitset_word *srcp = VBITSET_WORDS (src);
@@ -480,7 +497,9 @@ vbitset_subset_p (bitset dst, bitset src)
static bool
vbitset_disjoint_p (bitset dst, bitset src)
vbitset_disjoint_p (dst, src)
bitset dst;
bitset src;
{
unsigned int i;
bitset_word *srcp = VBITSET_WORDS (src);
@@ -497,7 +516,10 @@ vbitset_disjoint_p (bitset dst, bitset src)
static void
vbitset_and (bitset dst, bitset src1, bitset src2)
vbitset_and (dst, src1, src2)
bitset dst;
bitset src1;
bitset src2;
{
unsigned int i;
bitset_word *src1p;
@@ -524,7 +546,10 @@ vbitset_and (bitset dst, bitset src1, bitset src2)
static bool
vbitset_and_cmp (bitset dst, bitset src1, bitset src2)
vbitset_and_cmp (dst, src1, src2)
bitset dst;
bitset src1;
bitset src2;
{
unsigned int i;
int changed = 0;
@@ -577,7 +602,10 @@ vbitset_and_cmp (bitset dst, bitset src1, bitset src2)
static void
vbitset_andn (bitset dst, bitset src1, bitset src2)
vbitset_andn (dst, src1, src2)
bitset dst;
bitset src1;
bitset src2;
{
unsigned int i;
bitset_word *src1p;
@@ -617,7 +645,10 @@ vbitset_andn (bitset dst, bitset src1, bitset src2)
static bool
vbitset_andn_cmp (bitset dst, bitset src1, bitset src2)
vbitset_andn_cmp (dst, src1, src2)
bitset dst;
bitset src1;
bitset src2;
{
unsigned int i;
int changed = 0;
@@ -682,7 +713,10 @@ vbitset_andn_cmp (bitset dst, bitset src1, bitset src2)
static void
vbitset_or (bitset dst, bitset src1, bitset src2)
vbitset_or (dst, src1, src2)
bitset dst;
bitset src1;
bitset src2;
{
unsigned int i;
bitset_word *src1p;
@@ -718,7 +752,10 @@ vbitset_or (bitset dst, bitset src1, bitset src2)
static bool
vbitset_or_cmp (bitset dst, bitset src1, bitset src2)
vbitset_or_cmp (dst, src1, src2)
bitset dst;
bitset src1;
bitset src2;
{
unsigned int i;
int changed = 0;
@@ -773,7 +810,10 @@ vbitset_or_cmp (bitset dst, bitset src1, bitset src2)
static void
vbitset_xor (bitset dst, bitset src1, bitset src2)
vbitset_xor (dst, src1, src2)
bitset dst;
bitset src1;
bitset src2;
{
unsigned int i;
bitset_word *src1p;
@@ -809,7 +849,10 @@ vbitset_xor (bitset dst, bitset src1, bitset src2)
static bool
vbitset_xor_cmp (bitset dst, bitset src1, bitset src2)
vbitset_xor_cmp (dst, src1, src2)
bitset dst;
bitset src1;
bitset src2;
{
unsigned int i;
int changed = 0;
@@ -867,7 +910,11 @@ vbitset_xor_cmp (bitset dst, bitset src1, bitset src2)
bitsets. */
static void
vbitset_and_or (bitset dst, bitset src1, bitset src2, bitset src3)
vbitset_and_or (dst, src1, src2, src3)
bitset dst;
bitset src1;
bitset src2;
bitset src3;
{
unsigned int i;
bitset_word *src1p;
@@ -897,7 +944,11 @@ vbitset_and_or (bitset dst, bitset src1, bitset src2, bitset src3)
static bool
vbitset_and_or_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
vbitset_and_or_cmp (dst, src1, src2, src3)
bitset dst;
bitset src1;
bitset src2;
bitset src3;
{
unsigned int i;
int changed = 0;
@@ -934,7 +985,11 @@ vbitset_and_or_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
static void
vbitset_andn_or (bitset dst, bitset src1, bitset src2, bitset src3)
vbitset_andn_or (dst, src1, src2, src3)
bitset dst;
bitset src1;
bitset src2;
bitset src3;
{
unsigned int i;
bitset_word *src1p;
@@ -964,7 +1019,11 @@ vbitset_andn_or (bitset dst, bitset src1, bitset src2, bitset src3)
static bool
vbitset_andn_or_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
vbitset_andn_or_cmp (dst, src1, src2, src3)
bitset dst;
bitset src1;
bitset src2;
bitset src3;
{
unsigned int i;
int changed = 0;
@@ -1001,7 +1060,11 @@ vbitset_andn_or_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
static void
vbitset_or_and (bitset dst, bitset src1, bitset src2, bitset src3)
vbitset_or_and (dst, src1, src2, src3)
bitset dst;
bitset src1;
bitset src2;
bitset src3;
{
unsigned int i;
bitset_word *src1p;
@@ -1031,7 +1094,11 @@ vbitset_or_and (bitset dst, bitset src1, bitset src2, bitset src3)
static bool
vbitset_or_and_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
vbitset_or_and_cmp (dst, src1, src2, src3)
bitset dst;
bitset src1;
bitset src2;
bitset src3;
{
unsigned int i;
int changed = 0;
@@ -1067,8 +1134,10 @@ vbitset_or_and_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
}
static void
vbitset_copy (bitset dst, bitset src)
void
vbitset_copy (dst, src)
bitset dst;
bitset src;
{
if (BITSET_COMPATIBLE_ (dst, src))
vbitset_copy1 (dst, src);