From 741c3349b09c8774fcd013e3bdd7d9e7f6b470ce Mon Sep 17 00:00:00 2001 From: David Robillard Date: Thu, 31 Dec 2020 15:15:05 +0100 Subject: Format all code with clang-format --- zix/bitset.c | 98 ++++++++++++++++++++++++++++++------------------------------ 1 file changed, 49 insertions(+), 49 deletions(-) (limited to 'zix/bitset.c') diff --git a/zix/bitset.c b/zix/bitset.c index f447b74..cf82ad0 100644 --- a/zix/bitset.c +++ b/zix/bitset.c @@ -17,7 +17,7 @@ #include "zix/bitset.h" #ifdef _MSC_VER -#include +# include #endif #include @@ -29,96 +29,96 @@ static inline size_t zix_bitset_popcount(const ZixBitset value) { #ifdef _MSC_VER - return (size_t)__popcnt(value); + return (size_t)__popcnt(value); #else - return (size_t)__builtin_popcountl(value); + return (size_t)__builtin_popcountl(value); #endif } void zix_bitset_clear(ZixBitset* b, ZixBitsetTally* t, size_t n_bits) { - memset(b, 0, ZIX_BITSET_ELEMS(n_bits) * sizeof(ZixBitset)); - memset(t, 0, ZIX_BITSET_ELEMS(n_bits) * sizeof(ZixBitsetTally)); + memset(b, 0, ZIX_BITSET_ELEMS(n_bits) * sizeof(ZixBitset)); + memset(t, 0, ZIX_BITSET_ELEMS(n_bits) * sizeof(ZixBitsetTally)); } void zix_bitset_set(ZixBitset* b, ZixBitsetTally* t, size_t i) { - const size_t e = i / ZIX_BITSET_ELEM_BIT; - const size_t ebit = i & (ZIX_BITSET_ELEM_BIT - 1); // i % ELEM_BIT - const ZixBitset mask = (ZixBitset)1 << ebit; + const size_t e = i / ZIX_BITSET_ELEM_BIT; + const size_t ebit = i & (ZIX_BITSET_ELEM_BIT - 1); // i % ELEM_BIT + const ZixBitset mask = (ZixBitset)1 << ebit; - if (!(b[e] & mask)) { - ++t[e]; - } + if (!(b[e] & mask)) { + ++t[e]; + } - b[e] |= mask; + b[e] |= mask; } void zix_bitset_reset(ZixBitset* b, ZixBitsetTally* t, size_t i) { - const size_t e = i / ZIX_BITSET_ELEM_BIT; - const size_t ebit = i & (ZIX_BITSET_ELEM_BIT - 1); // i % ELEM_BIT - const ZixBitset mask = (ZixBitset)1 << ebit; + const size_t e = i / ZIX_BITSET_ELEM_BIT; + const size_t ebit = i & (ZIX_BITSET_ELEM_BIT - 1); // i % ELEM_BIT + const ZixBitset mask = (ZixBitset)1 << ebit; - if (b[e] & mask) { - --t[e]; - } + if (b[e] & mask) { + --t[e]; + } - b[e] &= ~mask; + b[e] &= ~mask; } bool zix_bitset_get(const ZixBitset* b, size_t i) { - const size_t e = i / ZIX_BITSET_ELEM_BIT; - const size_t ebit = i & (ZIX_BITSET_ELEM_BIT - 1); // i % ELEM_BIT - const ZixBitset mask = (ZixBitset)1 << ebit; + const size_t e = i / ZIX_BITSET_ELEM_BIT; + const size_t ebit = i & (ZIX_BITSET_ELEM_BIT - 1); // i % ELEM_BIT + const ZixBitset mask = (ZixBitset)1 << ebit; - return b[e] & mask; + return b[e] & mask; } size_t zix_bitset_count_up_to(const ZixBitset* b, const ZixBitsetTally* t, size_t i) { - const size_t full_elems = i / ZIX_BITSET_ELEM_BIT; - const size_t extra = i & (ZIX_BITSET_ELEM_BIT - 1); // i % ELEM_BIT + const size_t full_elems = i / ZIX_BITSET_ELEM_BIT; + const size_t extra = i & (ZIX_BITSET_ELEM_BIT - 1); // i % ELEM_BIT - size_t count = 0; - for (size_t e = 0; e < full_elems; ++e) { - count += t[e]; - } + size_t count = 0; + for (size_t e = 0; e < full_elems; ++e) { + count += t[e]; + } - if (extra) { - const ZixBitset mask = ~(~(ZixBitset)0 << extra); - count += zix_bitset_popcount(b[full_elems] & mask); - } + if (extra) { + const ZixBitset mask = ~(~(ZixBitset)0 << extra); + count += zix_bitset_popcount(b[full_elems] & mask); + } - return count; + return count; } size_t zix_bitset_count_up_to_if(const ZixBitset* b, const ZixBitsetTally* t, size_t i) { - const size_t full_elems = i / ZIX_BITSET_ELEM_BIT; - const size_t extra = i & (ZIX_BITSET_ELEM_BIT - 1); // i % ELEM_BIT + const size_t full_elems = i / ZIX_BITSET_ELEM_BIT; + const size_t extra = i & (ZIX_BITSET_ELEM_BIT - 1); // i % ELEM_BIT - const ZixBitset get_mask = (ZixBitset)1 << extra; - if (!(b[full_elems] & get_mask)) { - return (size_t)-1; - } + const ZixBitset get_mask = (ZixBitset)1 << extra; + if (!(b[full_elems] & get_mask)) { + return (size_t)-1; + } - size_t count = 0; - for (size_t e = 0; e < full_elems; ++e) { - count += t[e]; - } + size_t count = 0; + for (size_t e = 0; e < full_elems; ++e) { + count += t[e]; + } - if (extra) { - const ZixBitset mask = ~(~(ZixBitset)0 << extra); - count += zix_bitset_popcount(b[full_elems] & mask); - } + if (extra) { + const ZixBitset mask = ~(~(ZixBitset)0 << extra); + count += zix_bitset_popcount(b[full_elems] & mask); + } - return count; + return count; } -- cgit v1.2.1