summaryrefslogtreecommitdiff
path: root/wsutil/bits_count_ones.h
diff options
context:
space:
mode:
authorPascal Quantin <pascal.quantin@gmail.com>2014-10-13 14:17:35 +0200
committerMichael Mann <mmann78@netscape.net>2014-10-13 15:34:09 +0000
commitb3ad51db7cb6f09f876e1a65343d97afc8713fb1 (patch)
tree246600040cc5cdd1f59b8ca652ee2a5f9a75bab2 /wsutil/bits_count_ones.h
parente8a63a5a464f56628f179cf14afd4429e61b7d91 (diff)
downloadwireshark-b3ad51db7cb6f09f876e1a65343d97afc8713fb1.tar.gz
Follow-up of ged0b19b (Make boolean bitmask type 64-bit wide)
- use G_GINT64_MODIFIER instead of "%ll" - use G_GUINT64_CONSTANT instead of ULL - add some missing explicit casts Change-Id: Ic048d9ee8966ea504ea542cefe55688edcfb2dc7 Reviewed-on: https://code.wireshark.org/review/4644 Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com> Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'wsutil/bits_count_ones.h')
-rw-r--r--wsutil/bits_count_ones.h8
1 files changed, 4 insertions, 4 deletions
diff --git a/wsutil/bits_count_ones.h b/wsutil/bits_count_ones.h
index 6a8fa1a555..f9a8c7c12b 100644
--- a/wsutil/bits_count_ones.h
+++ b/wsutil/bits_count_ones.h
@@ -41,11 +41,11 @@ ws_count_ones(const guint64 x)
{
unsigned long long bits = x;
- bits = bits - ((bits >> 1) & 0x5555555555555555ULL);
- bits = (bits & 0x3333333333333333ULL) + ((bits >> 2) & 0x3333333333333333ULL);
- bits = (bits + (bits >> 4)) & 0x0F0F0F0F0F0F0F0F;
+ bits = bits - ((bits >> 1) & G_GUINT64_CONSTANT(0x5555555555555555));
+ bits = (bits & G_GUINT64_CONSTANT(0x3333333333333333)) + ((bits >> 2) & G_GUINT64_CONSTANT(0x3333333333333333));
+ bits = (bits + (bits >> 4)) & G_GUINT64_CONSTANT(0x0F0F0F0F0F0F0F0F);
- return (bits * 0x0101010101010101ULL) >> 56;
+ return (int)((bits * G_GUINT64_CONSTANT(0x0101010101010101)) >> 56);
}
#endif /* __WSUTIL_BITS_COUNT_ONES_H__ */