Switch from 'int' to 'bool' where that makes sense.

This commit is contained in:
Paul Eggert
2003-05-24 19:16:02 +00:00
parent 637fa3f83e
commit d08290769c
25 changed files with 376 additions and 295 deletions

View File

@@ -1,5 +1,5 @@
/* Array bitsets.
Copyright (C) 2002 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
@@ -123,14 +123,14 @@ abitset_reset (bitset dst ATTRIBUTE_UNUSED,
/* Test bit BITNO in bitset SRC. */
static int
static bool
abitset_test (bitset src ATTRIBUTE_UNUSED,
bitset_bindex bitno ATTRIBUTE_UNUSED)
{
/* This should never occur for abitsets since we should always
hit the cache. */
abort ();
return 0;
return false;
}
@@ -336,7 +336,7 @@ abitset_zero (bitset dst)
}
static int
static bool
abitset_empty_p (bitset dst)
{
bitset_windex i;
@@ -344,9 +344,9 @@ abitset_empty_p (bitset dst)
for (i = 0; i < dst->b.csize; i++)
if (dstp[i])
return 0;
return false;
return 1;
return true;
}
@@ -377,7 +377,7 @@ abitset_not (bitset dst, bitset src)
}
static int
static bool
abitset_equal_p (bitset dst, bitset src)
{
bitset_windex i;
@@ -387,12 +387,12 @@ abitset_equal_p (bitset dst, bitset src)
for (i = 0; i < size; i++)
if (*srcp++ != *dstp++)
return 0;
return 1;
return false;
return true;
}
static int
static bool
abitset_subset_p (bitset dst, bitset src)
{
bitset_windex i;
@@ -402,12 +402,12 @@ abitset_subset_p (bitset dst, bitset src)
for (i = 0; i < size; i++, dstp++, srcp++)
if (*dstp != (*srcp | *dstp))
return 0;
return 1;
return false;
return true;
}
static int
static bool
abitset_disjoint_p (bitset dst, bitset src)
{
bitset_windex i;
@@ -417,9 +417,9 @@ abitset_disjoint_p (bitset dst, bitset src)
for (i = 0; i < size; i++)
if (*srcp++ & *dstp++)
return 0;
return false;
return 1;
return true;
}
@@ -437,11 +437,11 @@ abitset_and (bitset dst, bitset src1, bitset src2)
}
static int
static bool
abitset_and_cmp (bitset dst, bitset src1, bitset src2)
{
bitset_windex i;
int changed = 0;
bool changed = false;
bitset_word *src1p = ABITSET_WORDS (src1);
bitset_word *src2p = ABITSET_WORDS (src2);
bitset_word *dstp = ABITSET_WORDS (dst);
@@ -453,7 +453,7 @@ abitset_and_cmp (bitset dst, bitset src1, bitset src2)
if (*dstp != tmp)
{
changed = 1;
changed = true;
*dstp = tmp;
}
}
@@ -475,11 +475,11 @@ abitset_andn (bitset dst, bitset src1, bitset src2)
}
static int
static bool
abitset_andn_cmp (bitset dst, bitset src1, bitset src2)
{
bitset_windex i;
int changed = 0;
bool changed = false;
bitset_word *src1p = ABITSET_WORDS (src1);
bitset_word *src2p = ABITSET_WORDS (src2);
bitset_word *dstp = ABITSET_WORDS (dst);
@@ -491,7 +491,7 @@ abitset_andn_cmp (bitset dst, bitset src1, bitset src2)
if (*dstp != tmp)
{
changed = 1;
changed = true;
*dstp = tmp;
}
}
@@ -513,11 +513,11 @@ abitset_or (bitset dst, bitset src1, bitset src2)
}
static int
static bool
abitset_or_cmp (bitset dst, bitset src1, bitset src2)
{
bitset_windex i;
int changed = 0;
bool changed = false;
bitset_word *src1p = ABITSET_WORDS (src1);
bitset_word *src2p = ABITSET_WORDS (src2);
bitset_word *dstp = ABITSET_WORDS (dst);
@@ -529,7 +529,7 @@ abitset_or_cmp (bitset dst, bitset src1, bitset src2)
if (*dstp != tmp)
{
changed = 1;
changed = true;
*dstp = tmp;
}
}
@@ -551,11 +551,11 @@ abitset_xor (bitset dst, bitset src1, bitset src2)
}
static int
static bool
abitset_xor_cmp (bitset dst, bitset src1, bitset src2)
{
bitset_windex i;
int changed = 0;
bool changed = false;
bitset_word *src1p = ABITSET_WORDS (src1);
bitset_word *src2p = ABITSET_WORDS (src2);
bitset_word *dstp = ABITSET_WORDS (dst);
@@ -567,7 +567,7 @@ abitset_xor_cmp (bitset dst, bitset src1, bitset src2)
if (*dstp != tmp)
{
changed = 1;
changed = true;
*dstp = tmp;
}
}
@@ -590,11 +590,11 @@ abitset_and_or (bitset dst, bitset src1, bitset src2, bitset src3)
}
static int
static bool
abitset_and_or_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
{
bitset_windex i;
int changed = 0;
bool changed = false;
bitset_word *src1p = ABITSET_WORDS (src1);
bitset_word *src2p = ABITSET_WORDS (src2);
bitset_word *src3p = ABITSET_WORDS (src3);
@@ -607,7 +607,7 @@ abitset_and_or_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
if (*dstp != tmp)
{
changed = 1;
changed = true;
*dstp = tmp;
}
}
@@ -630,11 +630,11 @@ abitset_andn_or (bitset dst, bitset src1, bitset src2, bitset src3)
}
static int
static bool
abitset_andn_or_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
{
bitset_windex i;
int changed = 0;
bool changed = false;
bitset_word *src1p = ABITSET_WORDS (src1);
bitset_word *src2p = ABITSET_WORDS (src2);
bitset_word *src3p = ABITSET_WORDS (src3);
@@ -647,7 +647,7 @@ abitset_andn_or_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
if (*dstp != tmp)
{
changed = 1;
changed = true;
*dstp = tmp;
}
}
@@ -670,11 +670,11 @@ abitset_or_and (bitset dst, bitset src1, bitset src2, bitset src3)
}
static int
static bool
abitset_or_and_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
{
bitset_windex i;
int changed = 0;
bool changed = false;
bitset_word *src1p = ABITSET_WORDS (src1);
bitset_word *src2p = ABITSET_WORDS (src2);
bitset_word *src3p = ABITSET_WORDS (src3);
@@ -687,7 +687,7 @@ abitset_or_and_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
if (*dstp != tmp)
{
changed = 1;
changed = true;
*dstp = tmp;
}
}

View File

@@ -21,6 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include "libiberty.h"
#include <stdbool.h>
#include <limits.h>
/* Currently we support three flavours of bitsets:
@@ -97,36 +98,36 @@ struct bitset_vtable
{
void (*set) PARAMS ((bitset, bitset_bindex));
void (*reset) PARAMS ((bitset, bitset_bindex));
int (*toggle) PARAMS ((bitset, bitset_bindex));
int (*test) PARAMS ((bitset, bitset_bindex));
bool (*toggle) PARAMS ((bitset, bitset_bindex));
bool (*test) PARAMS ((bitset, bitset_bindex));
bitset_bindex (*size) PARAMS ((bitset));
bitset_bindex (*count) PARAMS ((bitset));
int (*empty_p) PARAMS ((bitset));
bool (*empty_p) PARAMS ((bitset));
void (*ones) PARAMS ((bitset));
void (*zero) PARAMS ((bitset));
void (*copy) PARAMS ((bitset, bitset));
int (*disjoint_p) PARAMS ((bitset, bitset));
int (*equal_p) PARAMS ((bitset, bitset));
bool (*disjoint_p) PARAMS ((bitset, bitset));
bool (*equal_p) PARAMS ((bitset, bitset));
void (*not) PARAMS ((bitset, bitset));
int (*subset_p) PARAMS ((bitset, bitset));
bool (*subset_p) PARAMS ((bitset, bitset));
void (*and) PARAMS ((bitset, bitset, bitset));
int (*and_cmp) PARAMS ((bitset, bitset, bitset));
bool (*and_cmp) PARAMS ((bitset, bitset, bitset));
void (*andn) PARAMS ((bitset, bitset, bitset));
int (*andn_cmp) PARAMS ((bitset, bitset, bitset));
bool (*andn_cmp) PARAMS ((bitset, bitset, bitset));
void (*or) PARAMS ((bitset, bitset, bitset));
int (*or_cmp) PARAMS ((bitset, bitset, bitset));
bool (*or_cmp) PARAMS ((bitset, bitset, bitset));
void (*xor) PARAMS ((bitset, bitset, bitset));
int (*xor_cmp) PARAMS ((bitset, bitset, bitset));
bool (*xor_cmp) PARAMS ((bitset, bitset, bitset));
void (*and_or) PARAMS ((bitset, bitset, bitset, bitset));
int (*and_or_cmp) PARAMS ((bitset, bitset, bitset, bitset));
bool (*and_or_cmp) PARAMS ((bitset, bitset, bitset, bitset));
void (*andn_or) PARAMS ((bitset, bitset, bitset, bitset));
int (*andn_or_cmp) PARAMS ((bitset, bitset, bitset, bitset));
bool (*andn_or_cmp) PARAMS ((bitset, bitset, bitset, bitset));
void (*or_and) PARAMS ((bitset, bitset, bitset, bitset));
int (*or_and_cmp) PARAMS ((bitset, bitset, bitset, bitset));
bool (*or_and_cmp) PARAMS ((bitset, bitset, bitset, bitset));
bitset_bindex (*list) PARAMS ((bitset, bitset_bindex *,
bitset_bindex, bitset_bindex *));
@@ -259,22 +260,22 @@ if (!BITSET_COMPATIBLE_ (DST, SRC1) || !BITSET_COMPATIBLE_ (DST, SRC2) \
/* Private functions for bitset implementations. */
extern int bitset_toggle_ PARAMS ((bitset, bitset_bindex));
extern bool bitset_toggle_ PARAMS ((bitset, bitset_bindex));
extern bitset_bindex bitset_count_ PARAMS ((bitset));
extern int bitset_copy_ PARAMS ((bitset, bitset));
extern bool bitset_copy_ PARAMS ((bitset, bitset));
extern void bitset_and_or_ PARAMS ((bitset, bitset, bitset, bitset));
extern int bitset_and_or_cmp_ PARAMS ((bitset, bitset, bitset, bitset));
extern bool bitset_and_or_cmp_ PARAMS ((bitset, bitset, bitset, bitset));
extern void bitset_andn_or_ PARAMS ((bitset, bitset, bitset, bitset));
extern int bitset_andn_or_cmp_ PARAMS ((bitset, bitset, bitset, bitset));
extern bool bitset_andn_or_cmp_ PARAMS ((bitset, bitset, bitset, bitset));
extern void bitset_or_and_ PARAMS ((bitset, bitset, bitset, bitset));
extern int bitset_or_and_cmp_ PARAMS ((bitset, bitset, bitset, bitset));
extern bool bitset_or_and_cmp_ PARAMS ((bitset, bitset, bitset, bitset));
#endif /* _BBITSET_H */

View File

@@ -1,5 +1,5 @@
/* General bitsets.
Copyright (C) 2002 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
@@ -253,22 +253,22 @@ bitset_last (bitset src)
}
/* Return non-zero if BITNO in SRC is the only set bit. */
int
/* Is BITNO in SRC the only set bit? */
bool
bitset_only_set_p (bitset src, bitset_bindex bitno)
{
bitset_bindex val[2];
bitset_bindex next = 0;
if (bitset_list (src, val, 2, &next) != 1)
return 0;
return false;
return val[0] == bitno;
}
/* Print contents of bitset BSET to FILE. */
static void
bitset_print (FILE *file, bitset bset, int verbose)
bitset_print (FILE *file, bitset bset, bool verbose)
{
unsigned int pos;
bitset_bindex i;
@@ -300,7 +300,7 @@ bitset_print (FILE *file, bitset bset, int verbose)
void
bitset_dump (FILE *file, bitset bset)
{
bitset_print (file, bset, 0);
bitset_print (file, bset, false);
}
@@ -315,8 +315,8 @@ bitset_release_memory (void)
/* Toggle bit BITNO in bitset BSET and return non-zero if not set. */
int
/* Toggle bit BITNO in bitset BSET and the new value of the bit. */
bool
bitset_toggle_ (bitset bset, bitset_bindex bitno)
{
/* This routine is for completeness. It could be optimized if
@@ -324,12 +324,12 @@ bitset_toggle_ (bitset bset, bitset_bindex bitno)
if (bitset_test (bset, bitno))
{
bitset_reset (bset, bitno);
return 0;
return false;
}
else
{
bitset_set (bset, bitno);
return 1;
return true;
}
}
@@ -356,10 +356,10 @@ bitset_count_ (bitset src)
}
/* DST = SRC. Return non-zero if DST != SRC.
/* DST = SRC. Return true if DST != SRC.
This is a fallback for the case where SRC and DST are different
bitset types. */
int
bool
bitset_copy_ (bitset dst, bitset src)
{
bitset_bindex i;
@@ -373,23 +373,23 @@ bitset_copy_ (bitset dst, bitset src)
bitset_set (dst, i);
};
return 1;
return true;
}
/* This is a fallback for implementations that do not support
four operand operations. */
static inline int
static inline bool
bitset_op4_cmp (bitset dst, bitset src1, bitset src2, bitset src3,
enum bitset_ops op)
{
int changed = 0;
int stats_enabled_save;
bool changed = false;
bool stats_enabled_save;
bitset tmp;
/* Create temporary bitset. */
stats_enabled_save = bitset_stats_enabled;
bitset_stats_enabled = 0;
bitset_stats_enabled = false;
tmp = bitset_alloc (0, bitset_type_get (dst));
bitset_stats_enabled = stats_enabled_save;
@@ -429,7 +429,7 @@ bitset_and_or_ (bitset dst, bitset src1, bitset src2, bitset src3)
/* DST = (SRC1 & SRC2) | SRC3. Return non-zero if
DST != (SRC1 & SRC2) | SRC3. */
int
bool
bitset_and_or_cmp_ (bitset dst, bitset src1, bitset src2, bitset src3)
{
return bitset_op4_cmp (dst, src1, src2, src3, BITSET_OP_AND_OR);
@@ -446,7 +446,7 @@ bitset_andn_or_ (bitset dst, bitset src1, bitset src2, bitset src3)
/* DST = (SRC1 & ~SRC2) | SRC3. Return non-zero if
DST != (SRC1 & ~SRC2) | SRC3. */
int
bool
bitset_andn_or_cmp_ (bitset dst, bitset src1, bitset src2, bitset src3)
{
return bitset_op4_cmp (dst, src1, src2, src3, BITSET_OP_ANDN_OR);
@@ -463,7 +463,7 @@ bitset_or_and_ (bitset dst, bitset src1, bitset src2, bitset src3)
/* DST = (SRC1 | SRC2) & SRC3. Return non-zero if
DST != (SRC1 | SRC2) & SRC3. */
int
bool
bitset_or_and_cmp_ (bitset dst, bitset src1, bitset src2, bitset src3)
{
return bitset_op4_cmp (dst, src1, src2, src3, BITSET_OP_OR_AND);
@@ -475,5 +475,5 @@ void
debug_bitset (bitset bset)
{
if (bset)
bitset_print (stderr, bset, 1);
bitset_print (stderr, bset, true);
}

View File

@@ -160,7 +160,7 @@ bitset_reset (bitset bset, bitset_bindex bitno)
/* Test bit BITNO in bitset BSET. */
static inline int
static inline bool
bitset_test (bitset bset, bitset_bindex bitno)
{
bitset_windex windex = bitno / BITSET_WORD_BITS;
@@ -290,7 +290,7 @@ extern bitset_bindex bitset_first PARAMS ((bitset));
extern bitset_bindex bitset_last PARAMS ((bitset));
/* Return nonzero if this is the only set bit. */
extern int bitset_only_set_p PARAMS ((bitset, bitset_bindex));
extern bool bitset_only_set_p PARAMS ((bitset, bitset_bindex));
/* Dump bitset. */
extern void bitset_dump PARAMS ((FILE *, bitset));

View File

@@ -100,7 +100,7 @@ struct bitset_stats_info_struct
struct bitset_stats_info_struct bitset_stats_info_data;
struct bitset_stats_info_struct *bitset_stats_info;
int bitset_stats_enabled = 0;
bool bitset_stats_enabled = false;
/* Print a percentage histogram with message MSG to FILE. */
@@ -203,7 +203,7 @@ bitset_stats_print_1 (FILE *file, const char *name,
/* Print all bitset statistics to FILE. */
static void
bitset_stats_print (FILE *file, int verbose ATTRIBUTE_UNUSED)
bitset_stats_print (FILE *file, bool verbose ATTRIBUTE_UNUSED)
{
int i;
@@ -227,14 +227,14 @@ bitset_stats_enable (void)
{
if (!bitset_stats_info)
bitset_stats_info = &bitset_stats_info_data;
bitset_stats_enabled = 1;
bitset_stats_enabled = true;
}
void
bitset_stats_disable (void)
{
bitset_stats_enabled = 0;
bitset_stats_enabled = false;
}
@@ -298,7 +298,7 @@ bitset_stats_write (const char *filename)
void
bitset_stats_dump (FILE *file)
{
bitset_stats_print (file, 0);
bitset_stats_print (file, false);
}
@@ -306,7 +306,7 @@ bitset_stats_dump (FILE *file)
void
debug_bitset_stats (void)
{
bitset_stats_print (stderr, 1);
bitset_stats_print (stderr, true);
}
@@ -349,14 +349,14 @@ bitset_stats_reset (bitset dst, bitset_bindex bitno)
}
static int
static bool
bitset_stats_toggle (bitset src, bitset_bindex bitno)
{
return BITSET_TOGGLE_ (src->s.bset, bitno);
}
static int
static bool
bitset_stats_test (bitset src, bitset_bindex bitno)
{
bitset bset = src->s.bset;
@@ -389,7 +389,7 @@ bitset_stats_count (bitset src)
}
static int
static bool
bitset_stats_empty_p (bitset dst)
{
return BITSET_EMPTY_P_ (dst->s.bset);
@@ -418,7 +418,7 @@ bitset_stats_copy (bitset dst, bitset src)
}
static int
static bool
bitset_stats_disjoint_p (bitset dst, bitset src)
{
BITSET_CHECK2_ (dst, src);
@@ -426,7 +426,7 @@ bitset_stats_disjoint_p (bitset dst, bitset src)
}
static int
static bool
bitset_stats_equal_p (bitset dst, bitset src)
{
BITSET_CHECK2_ (dst, src);
@@ -442,7 +442,7 @@ bitset_stats_not (bitset dst, bitset src)
}
static int
static bool
bitset_stats_subset_p (bitset dst, bitset src)
{
BITSET_CHECK2_ (dst, src);
@@ -458,7 +458,7 @@ bitset_stats_and (bitset dst, bitset src1, bitset src2)
}
static int
static bool
bitset_stats_and_cmp (bitset dst, bitset src1, bitset src2)
{
BITSET_CHECK3_ (dst, src1, src2);
@@ -474,7 +474,7 @@ bitset_stats_andn (bitset dst, bitset src1, bitset src2)
}
static int
static bool
bitset_stats_andn_cmp (bitset dst, bitset src1, bitset src2)
{
BITSET_CHECK3_ (dst, src1, src2);
@@ -490,7 +490,7 @@ bitset_stats_or (bitset dst, bitset src1, bitset src2)
}
static int
static bool
bitset_stats_or_cmp (bitset dst, bitset src1, bitset src2)
{
BITSET_CHECK3_ (dst, src1, src2);
@@ -506,7 +506,7 @@ bitset_stats_xor (bitset dst, bitset src1, bitset src2)
}
static int
static bool
bitset_stats_xor_cmp (bitset dst, bitset src1, bitset src2)
{
BITSET_CHECK3_ (dst, src1, src2);
@@ -523,7 +523,7 @@ bitset_stats_and_or (bitset dst, bitset src1, bitset src2, bitset src3)
}
static int
static bool
bitset_stats_and_or_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
{
BITSET_CHECK4_ (dst, src1, src2, src3);
@@ -541,7 +541,7 @@ bitset_stats_andn_or (bitset dst, bitset src1, bitset src2, bitset src3)
}
static int
static bool
bitset_stats_andn_or_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
{
BITSET_CHECK4_ (dst, src1, src2, src3);
@@ -559,7 +559,7 @@ bitset_stats_or_and (bitset dst, bitset src1, bitset src2, bitset src3)
}
static int
static bool
bitset_stats_or_and_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
{
BITSET_CHECK4_ (dst, src1, src2, src3);

View File

@@ -1,5 +1,5 @@
/* Functions to support bitset statistics.
Copyright (C) 2002 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
@@ -21,7 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include "bbitset.h"
extern int bitset_stats_enabled;
extern bool bitset_stats_enabled;
extern enum bitset_type bitset_stats_type_get PARAMS ((bitset));

View File

@@ -1,5 +1,5 @@
/* Functions to support expandable bitsets.
Copyright (C) 2002 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
@@ -88,7 +88,7 @@ static ebitset_elt ebitset_zero_elts[1]; /* Elements of all zero bits. */
/* Obstack to allocate bitset elements from. */
static struct obstack ebitset_obstack;
static int ebitset_obstack_init = 0;
static bool ebitset_obstack_init = false;
static ebitset_elt *ebitset_free_list; /* Free list of bitset elements. */
#define EBITSET_ELTS(BSET) ((BSET)->e.elts)
@@ -154,7 +154,7 @@ ebitset_elt_alloc (void)
{
if (!ebitset_obstack_init)
{
ebitset_obstack_init = 1;
ebitset_obstack_init = true;
/* Let particular systems override the size of a chunk. */
@@ -242,17 +242,17 @@ ebitset_elt_add (bitset bset, ebitset_elt *elt, bitset_windex eindex)
}
/* Return nonzero if all bits in an element are zero. */
static inline int
/* Are all bits in an element zero? */
static inline bool
ebitset_elt_zero_p (ebitset_elt *elt)
{
int i;
for (i = 0; i < EBITSET_ELT_WORDS; i++)
if (EBITSET_WORDS (elt)[i])
return 0;
return false;
return 1;
return true;
}
@@ -402,7 +402,7 @@ ebitset_zero (bitset bset)
}
static inline int
static inline bool
ebitset_equal_p (bitset dst, bitset src)
{
ebitset_elts *selts;
@@ -410,13 +410,13 @@ ebitset_equal_p (bitset dst, bitset src)
bitset_windex j;
if (src == dst)
return 1;
return true;
ebitset_weed (dst);
ebitset_weed (src);
if (EBITSET_SIZE (src) != EBITSET_SIZE (dst))
return 0;
return false;
selts = EBITSET_ELTS (src);
delts = EBITSET_ELTS (dst);
@@ -430,13 +430,13 @@ ebitset_equal_p (bitset dst, bitset src)
if (!selt && !delt)
continue;
if ((selt && !delt) || (!selt && delt))
return 0;
return false;
for (i = 0; i < EBITSET_ELT_WORDS; i++)
if (EBITSET_WORDS (selt)[i] != EBITSET_WORDS (delt)[i])
return 0;
return false;
}
return 1;
return true;
}
@@ -476,13 +476,13 @@ ebitset_copy_ (bitset dst, bitset src)
}
/* Copy bits from bitset SRC to bitset DST. Return non-zero if
/* Copy bits from bitset SRC to bitset DST. Return true if
bitsets different. */
static inline int
static inline bool
ebitset_copy_cmp (bitset dst, bitset src)
{
if (src == dst)
return 0;
return false;
if (EBITSET_ZERO_P (dst))
{
@@ -491,10 +491,10 @@ ebitset_copy_cmp (bitset dst, bitset src)
}
if (ebitset_equal_p (dst, src))
return 0;
return false;
ebitset_copy_ (dst, src);
return 1;
return true;
}
@@ -539,16 +539,15 @@ ebitset_reset (bitset dst, bitset_bindex bitno)
/* Test bit BITNO in bitset SRC. */
static int
static bool
ebitset_test (bitset src, bitset_bindex bitno)
{
bitset_windex windex = bitno / BITSET_WORD_BITS;
if (!ebitset_elt_find (src, windex, EBITSET_FIND))
return 0;
return (src->b.
cdata[windex - src->b.cindex] >> (bitno % BITSET_WORD_BITS)) & 1;
return (ebitset_elt_find (src, windex, EBITSET_FIND)
&& ((src->b.cdata[windex - src->b.cindex]
>> (bitno % BITSET_WORD_BITS))
& 1));
}
@@ -808,7 +807,7 @@ ebitset_ones (bitset dst)
}
static int
static bool
ebitset_empty_p (bitset dst)
{
return !ebitset_weed (dst);
@@ -839,8 +838,8 @@ ebitset_not (bitset dst, bitset src)
}
/* Return 1 if DST == DST | SRC. */
static int
/* Is DST == DST | SRC? */
static bool
ebitset_subset_p (bitset dst, bitset src)
{
bitset_windex j;
@@ -875,14 +874,14 @@ ebitset_subset_p (bitset dst, bitset src)
for (i = 0; i < EBITSET_ELT_WORDS; i++)
if (EBITSET_WORDS (delt)[i]
!= (EBITSET_WORDS (selt)[i] | EBITSET_WORDS (delt)[i]))
return 0;
return false;
}
return 1;
return true;
}
/* Return 1 if DST & SRC == 0. */
static int
/* Is DST & SRC == 0? */
static bool
ebitset_disjoint_p (bitset dst, bitset src)
{
bitset_windex j;
@@ -911,14 +910,14 @@ ebitset_disjoint_p (bitset dst, bitset src)
for (i = 0; i < EBITSET_ELT_WORDS; i++)
if ((EBITSET_WORDS (selt)[i] & EBITSET_WORDS (delt)[i]))
return 0;
return false;
}
return 1;
return true;
}
static int
static bool
ebitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
{
bitset_windex ssize1;
@@ -931,7 +930,7 @@ ebitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
bitset_word *srcp1;
bitset_word *srcp2;
bitset_word *dstp;
int changed = 0;
bool changed = false;
unsigned int i;
bitset_windex j;
@@ -963,7 +962,7 @@ ebitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
{
if (delt)
{
changed = 1;
changed = true;
ebitset_elt_remove (dst, j);
}
continue;
@@ -990,7 +989,7 @@ ebitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
if (*dstp != tmp)
{
changed = 1;
changed = true;
*dstp = tmp;
}
}
@@ -1003,7 +1002,7 @@ ebitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
if (*dstp != tmp)
{
changed = 1;
changed = true;
*dstp = tmp;
}
}
@@ -1016,7 +1015,7 @@ ebitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
if (*dstp != tmp)
{
changed = 1;
changed = true;
*dstp = tmp;
}
}
@@ -1029,7 +1028,7 @@ ebitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
if (*dstp != tmp)
{
changed = 1;
changed = true;
*dstp = tmp;
}
}
@@ -1054,7 +1053,7 @@ ebitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
{
ebitset_elt *delt;
changed = 1;
changed = true;
delt = delts[j];
@@ -1067,10 +1066,10 @@ ebitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
}
static int
static bool
ebitset_and_cmp (bitset dst, bitset src1, bitset src2)
{
int changed;
bool changed;
if (EBITSET_ZERO_P (src2))
{
@@ -1097,10 +1096,10 @@ ebitset_and (bitset dst, bitset src1, bitset src2)
}
static int
static bool
ebitset_andn_cmp (bitset dst, bitset src1, bitset src2)
{
int changed;
bool changed;
if (EBITSET_ZERO_P (src2))
{
@@ -1124,7 +1123,7 @@ ebitset_andn (bitset dst, bitset src1, bitset src2)
}
static int
static bool
ebitset_or_cmp (bitset dst, bitset src1, bitset src2)
{
if (EBITSET_ZERO_P (src2))
@@ -1146,7 +1145,7 @@ ebitset_or (bitset dst, bitset src1, bitset src2)
}
static int
static bool
ebitset_xor_cmp (bitset dst, bitset src1, bitset src2)
{
if (EBITSET_ZERO_P (src2))
@@ -1253,7 +1252,7 @@ ebitset_release_memory (void)
ebitset_free_list = 0;
if (ebitset_obstack_init)
{
ebitset_obstack_init = 0;
ebitset_obstack_init = false;
obstack_free (&ebitset_obstack, NULL);
}
}

View File

@@ -1,5 +1,5 @@
/* Functions to support link list bitsets.
Copyright (C) 2002 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
@@ -71,7 +71,7 @@ static lbitset_elt lbitset_zero_elts[3]; /* Elements of all zero bits. */
/* Obstack to allocate bitset elements from. */
static struct obstack lbitset_obstack;
static int lbitset_obstack_init = 0;
static bool lbitset_obstack_init = false;
static lbitset_elt *lbitset_free_list; /* Free list of bitset elements. */
extern void debug_lbitset PARAMS ((bitset));
@@ -99,7 +99,7 @@ lbitset_elt_alloc (void)
{
if (!lbitset_obstack_init)
{
lbitset_obstack_init = 1;
lbitset_obstack_init = true;
/* Let particular systems override the size of a chunk. */
@@ -236,17 +236,17 @@ lbitset_prune (bitset bset, lbitset_elt *elt)
}
/* Return nonzero if all bits in an element are zero. */
static inline int
/* Are all bits in an element zero? */
static inline bool
lbitset_elt_zero_p (lbitset_elt *elt)
{
int i;
for (i = 0; i < LBITSET_ELT_WORDS; i++)
if (elt->words[i])
return 0;
return false;
return 1;
return true;
}
@@ -412,8 +412,8 @@ lbitset_zero (bitset bset)
}
/* Return 1 if DST == SRC. */
static inline int
/* Is DST == SRC? */
static inline bool
lbitset_equal_p (bitset dst, bitset src)
{
lbitset_elt *selt;
@@ -421,7 +421,7 @@ lbitset_equal_p (bitset dst, bitset src)
int j;
if (src == dst)
return 1;
return true;
lbitset_weed (src);
lbitset_weed (dst);
@@ -429,11 +429,11 @@ lbitset_equal_p (bitset dst, bitset src)
selt && delt; selt = selt->next, delt = delt->next)
{
if (selt->index != delt->index)
return 0;
return false;
for (j = 0; j < LBITSET_ELT_WORDS; j++)
if (delt->words[j] != selt->words[j])
return 0;
return false;
}
return !selt && !delt;
}
@@ -480,13 +480,13 @@ lbitset_copy (bitset dst, bitset src)
}
/* Copy bits from bitset SRC to bitset DST. Return non-zero if
/* Copy bits from bitset SRC to bitset DST. Return true if
bitsets different. */
static inline int
static inline bool
lbitset_copy_cmp (bitset dst, bitset src)
{
if (src == dst)
return 0;
return false;
if (!LBITSET_HEAD (dst))
{
@@ -495,10 +495,10 @@ lbitset_copy_cmp (bitset dst, bitset src)
}
if (lbitset_equal_p (dst, src))
return 0;
return false;
lbitset_copy (dst, src);
return 1;
return true;
}
@@ -547,16 +547,15 @@ lbitset_reset (bitset dst, bitset_bindex bitno)
/* Test bit BITNO in bitset SRC. */
static int
static bool
lbitset_test (bitset src, bitset_bindex bitno)
{
bitset_windex windex = bitno / BITSET_WORD_BITS;
if (!lbitset_elt_find (src, windex, LBITSET_FIND))
return 0;
return (src->b.cdata[windex - src->b.cindex]
>> (bitno % BITSET_WORD_BITS)) & 1;
return (lbitset_elt_find (src, windex, LBITSET_FIND)
&& ((src->b.cdata[windex - src->b.cindex]
>> (bitno % BITSET_WORD_BITS))
& 1));
}
@@ -865,13 +864,11 @@ lbitset_list (bitset bset, bitset_bindex *list,
}
static int
static bool
lbitset_empty_p (bitset dst)
{
lbitset_weed (dst);
if (LBITSET_HEAD (dst))
return 0;
return 1;
return !LBITSET_HEAD (dst);
}
@@ -934,8 +931,8 @@ lbitset_not (bitset dst, bitset src)
}
/* Return 1 if DST == DST | SRC. */
static int
/* Is DST == DST | SRC? */
static bool
lbitset_subset_p (bitset dst, bitset src)
{
lbitset_elt *selt;
@@ -965,14 +962,14 @@ lbitset_subset_p (bitset dst, bitset src)
for (j = 0; j < LBITSET_ELT_WORDS; j++)
if (delt->words[j] != (selt->words[j] | delt->words[j]))
return 0;
return false;
}
return 1;
return true;
}
/* Return 1 if DST & SRC == 0. */
static int
/* Is DST & SRC == 0? */
static bool
lbitset_disjoint_p (bitset dst, bitset src)
{
lbitset_elt *selt;
@@ -1001,13 +998,13 @@ lbitset_disjoint_p (bitset dst, bitset src)
for (j = 0; j < LBITSET_ELT_WORDS; j++)
if (selt->words[j] & delt->words[j])
return 0;
return false;
}
return 1;
return true;
}
static int
static bool
lbitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
{
lbitset_elt *selt1 = LBITSET_HEAD (src1);
@@ -1022,7 +1019,7 @@ lbitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
bitset_word *srcp1;
bitset_word *srcp2;
bitset_word *dstp;
int changed = 0;
bool changed = false;
unsigned int i;
LBITSET_HEAD (dst) = 0;
@@ -1066,7 +1063,7 @@ lbitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
elements that we've skipped. */
while (delt && delt->index < windex)
{
changed = 1;
changed = true;
dtmp = delt;
delt = delt->next;
lbitset_elt_free (dtmp);
@@ -1093,7 +1090,7 @@ lbitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
if (*dstp != tmp)
{
changed = 1;
changed = true;
*dstp = tmp;
}
}
@@ -1106,7 +1103,7 @@ lbitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
if (*dstp != tmp)
{
changed = 1;
changed = true;
*dstp = tmp;
}
}
@@ -1119,7 +1116,7 @@ lbitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
if (*dstp != tmp)
{
changed = 1;
changed = true;
*dstp = tmp;
}
}
@@ -1132,7 +1129,7 @@ lbitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
if (*dstp != tmp)
{
changed = 1;
changed = true;
*dstp = tmp;
}
}
@@ -1157,7 +1154,7 @@ lbitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
/* If we have elements of DST left over, free them all. */
if (delt)
{
changed = 1;
changed = true;
lbitset_prune (dst, delt);
}
@@ -1165,12 +1162,12 @@ lbitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
}
static int
static bool
lbitset_and_cmp (bitset dst, bitset src1, bitset src2)
{
lbitset_elt *selt1 = LBITSET_HEAD (src1);
lbitset_elt *selt2 = LBITSET_HEAD (src2);
int changed;
bool changed;
if (!selt2)
{
@@ -1197,12 +1194,12 @@ lbitset_and (bitset dst, bitset src1, bitset src2)
}
static int
static bool
lbitset_andn_cmp (bitset dst, bitset src1, bitset src2)
{
lbitset_elt *selt1 = LBITSET_HEAD (src1);
lbitset_elt *selt2 = LBITSET_HEAD (src2);
int changed;
bool changed;
if (!selt2)
{
@@ -1226,7 +1223,7 @@ lbitset_andn (bitset dst, bitset src1, bitset src2)
}
static int
static bool
lbitset_or_cmp (bitset dst, bitset src1, bitset src2)
{
lbitset_elt *selt1 = LBITSET_HEAD (src1);
@@ -1251,7 +1248,7 @@ lbitset_or (bitset dst, bitset src1, bitset src2)
}
static int
static bool
lbitset_xor_cmp (bitset dst, bitset src1, bitset src2)
{
lbitset_elt *selt1 = LBITSET_HEAD (src1);
@@ -1337,7 +1334,7 @@ lbitset_release_memory (void)
lbitset_free_list = 0;
if (lbitset_obstack_init)
{
lbitset_obstack_init = 0;
lbitset_obstack_init = false;
obstack_free (&lbitset_obstack, NULL);
}
}