From be4c25fa55e645b077f2817906ce8fe0ea64f80b Mon Sep 17 00:00:00 2001 From: Matthias Braun Date: Tue, 11 Aug 2009 11:45:18 +0000 Subject: [PATCH] add rbitsets_have_common function [r26325] --- include/libfirm/adt/raw_bitset.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/include/libfirm/adt/raw_bitset.h b/include/libfirm/adt/raw_bitset.h index 5f81b1b6d..e08f4ba8b 100644 --- a/include/libfirm/adt/raw_bitset.h +++ b/include/libfirm/adt/raw_bitset.h @@ -348,6 +348,26 @@ static inline int rbitset_equal(const unsigned *bitset1, return memcmp(bitset1, bitset2, BITSET_SIZE_BYTES(size)) == 0; } +/** + * Tests wether 2 bitsets wether at least 1 bit is set in both. + * + * @param bitset1 the first bitset + * @param bitset2 the second bitset + * @param size size of both bitsets + */ +static inline int rbitsets_have_common(const unsigned *bitset1, + const unsigned *bitset2, size_t size) +{ + unsigned i; + unsigned n = BITSET_SIZE_ELEMS(size); + + for (i = 0; i < n; ++i) { + if ((bitset1[i] & bitset2[i]) != 0) + return 1; + } + return 0; +} + /** * Copy a raw bitset into another. * -- 2.20.1