diff options
author | Daniel Mack <daniel@zonque.org> | 2014-09-17 18:39:22 +0200 |
---|---|---|
committer | Michael Mann <mmann78@netscape.net> | 2014-10-12 14:15:12 +0000 |
commit | ed0b19b94bf07056b5e0cfe64d4d05c3ebae801a (patch) | |
tree | 4c4dd80aa856bf0a4c55704c88761a2d2ab2199a /wsutil/bits_count_ones.h | |
parent | 29afac24a579b01c029b2b5404bda7a102fe2232 (diff) |
Make boolean bitmask type 64-bit wide
There are protocols out there that have 64-bit wide bit mask fields, so
make the internal representation and bitfield decoders 64-bit aware.
For this, the ws_ctz() fallback and bits_count_ones() have to be tweaked
slightly.
Change-Id: I19237b954a69c9e6c55864f281993c1e8731a233
Reviewed-on: https://code.wireshark.org/review/4158
Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'wsutil/bits_count_ones.h')
-rw-r--r-- | wsutil/bits_count_ones.h | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/wsutil/bits_count_ones.h b/wsutil/bits_count_ones.h index e2c2f94f3f..6a8fa1a555 100644 --- a/wsutil/bits_count_ones.h +++ b/wsutil/bits_count_ones.h @@ -37,15 +37,15 @@ */ static inline int -ws_count_ones(const guint32 x) +ws_count_ones(const guint64 x) { - int bits = x; + unsigned long long bits = x; - bits = bits - ((bits >> 1) & 0x55555555); - bits = (bits & 0x33333333) + ((bits >> 2) & 0x33333333); - bits = (bits + (bits >> 4)) & 0x0F0F0F0F; + bits = bits - ((bits >> 1) & 0x5555555555555555ULL); + bits = (bits & 0x3333333333333333ULL) + ((bits >> 2) & 0x3333333333333333ULL); + bits = (bits + (bits >> 4)) & 0x0F0F0F0F0F0F0F0F; - return (bits * 0x01010101) >> 24; + return (bits * 0x0101010101010101ULL) >> 56; } #endif /* __WSUTIL_BITS_COUNT_ONES_H__ */ |