From e5679980aa5f813553a95ab7d31f111dd0893df6 Mon Sep 17 00:00:00 2001 From: Serge Petrenko <sergepetrenko@tarantool.org> Date: Thu, 5 Mar 2020 13:39:03 +0300 Subject: [PATCH] vclock: refactor vclock map to use type vclock_map_t We're using an unsigned int to hold vclock map, but there is no guarantee that unsigned int will be 4 bytes in size to fit all the 32 vclock components. So use uint32_t instead and add an alias to it vclock_map_t. --- src/box/vclock.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/box/vclock.h b/src/box/vclock.h index eb0fb5d8bf..79e5a1bc09 100644 --- a/src/box/vclock.h +++ b/src/box/vclock.h @@ -45,6 +45,8 @@ extern "C" { #endif /* defined(__cplusplus) */ +typedef uint32_t vclock_map_t; + enum { /** * The maximum number of components in vclock, should be power of two. @@ -82,7 +84,7 @@ enum { /** Cluster vector clock */ struct vclock { /** Map of used components in lsn array */ - unsigned int map; + vclock_map_t map; /** Sum of all components of vclock. */ int64_t signature; int64_t lsn[VCLOCK_MAX]; @@ -195,7 +197,7 @@ vclock_copy(struct vclock *dst, const struct vclock *src) static inline uint32_t vclock_size(const struct vclock *vclock) { - return __builtin_popcount(vclock->map); + return bit_count_u32(vclock->map); } static inline int64_t @@ -281,7 +283,7 @@ vclock_compare_generic(const struct vclock *a, const struct vclock *b, bool ignore_zero) { bool le = true, ge = true; - unsigned int map = a->map | b->map; + vclock_map_t map = a->map | b->map; struct bit_iterator it; bit_iterator_init(&it, &map, sizeof(map), true); -- GitLab