diff --git a/lib/bitmap.h b/lib/bitmap.h index a2ca46e32..cf5d3f078 100644 --- a/lib/bitmap.h +++ b/lib/bitmap.h @@ -269,13 +269,13 @@ bitmap_is_all_zeros(const unsigned long *bitmap, size_t n) #define BITMAP_FOR_EACH_1(IDX, SIZE, BITMAP) \ BITMAP_FOR_EACH_1_RANGE(IDX, 0, SIZE, BITMAP) -/* More efficient access to a map of single ulong. */ -#define ULONG_FOR_EACH_1(IDX, MAP) \ - for (unsigned long map__ = (MAP); \ +/* More efficient access to a map of single ullong. */ +#define ULLONG_FOR_EACH_1(IDX, MAP) \ + for (uint64_t map__ = (MAP); \ map__ && (((IDX) = raw_ctz(map__)), true); \ map__ = zero_rightmost_1bit(map__)) -#define ULONG_SET0(MAP, OFFSET) ((MAP) &= ~(1UL << (OFFSET))) -#define ULONG_SET1(MAP, OFFSET) ((MAP) |= 1UL << (OFFSET)) +#define ULLONG_SET0(MAP, OFFSET) ((MAP) &= ~(1ULL << (OFFSET))) +#define ULLONG_SET1(MAP, OFFSET) ((MAP) |= 1ULL << (OFFSET)) #endif /* bitmap.h */ diff --git a/lib/cmap.c b/lib/cmap.c index 8d11ae027..7a54ea6ab 100644 --- a/lib/cmap.c +++ b/lib/cmap.c @@ -390,13 +390,13 @@ cmap_find_batch(const struct cmap *cmap, unsigned long map, uint32_t c1s[sizeof map * CHAR_BIT]; /* Compute hashes and prefetch 1st buckets. */ - ULONG_FOR_EACH_1(i, map) { + ULLONG_FOR_EACH_1(i, map) { h1s[i] = rehash(impl, hashes[i]); b1s[i] = &impl->buckets[h1s[i] & impl->mask]; OVS_PREFETCH(b1s[i]); } /* Lookups, Round 1. Only look up at the first bucket. */ - ULONG_FOR_EACH_1(i, map) { + ULLONG_FOR_EACH_1(i, map) { uint32_t c1; const struct cmap_bucket *b1 = b1s[i]; const struct cmap_node *node; @@ -414,12 +414,12 @@ cmap_find_batch(const struct cmap *cmap, unsigned long map, continue; } /* Found. */ - ULONG_SET0(map, i); /* Ignore this on round 2. */ + ULLONG_SET0(map, i); /* Ignore this on round 2. */ OVS_PREFETCH(node); nodes[i] = node; } /* Round 2. Look into the 2nd bucket, if needed. */ - ULONG_FOR_EACH_1(i, map) { + ULLONG_FOR_EACH_1(i, map) { uint32_t c2; const struct cmap_bucket *b2 = b2s[i]; const struct cmap_node *node; @@ -445,7 +445,7 @@ cmap_find_batch(const struct cmap *cmap, unsigned long map, } } /* Not found. */ - ULONG_SET0(result, i); /* Fix the result. */ + ULLONG_SET0(result, i); /* Fix the result. */ continue; } found: diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c index 5009c5ff7..59f3f14db 100644 --- a/lib/dpif-netdev.c +++ b/lib/dpif-netdev.c @@ -3916,14 +3916,14 @@ dpcls_lookup(const struct dpcls *cls, const struct netdev_flow_key keys[], } /* Compute hashes for the remaining keys. */ - ULONG_FOR_EACH_1(i, map) { + ULLONG_FOR_EACH_1(i, map) { hashes[i] = netdev_flow_key_hash_in_mask(&mkeys[i], &subtable->mask); } /* Lookup. */ map = cmap_find_batch(&subtable->rules, map, hashes, nodes); /* Check results. */ - ULONG_FOR_EACH_1(i, map) { + ULLONG_FOR_EACH_1(i, map) { struct dpcls_rule *rule; CMAP_NODE_FOR_EACH (rule, cmap_node, nodes[i]) { @@ -3932,7 +3932,7 @@ dpcls_lookup(const struct dpcls *cls, const struct netdev_flow_key keys[], goto next; } } - ULONG_SET0(map, i); /* Did not match. */ + ULLONG_SET0(map, i); /* Did not match. */ next: ; /* Keep Sparse happy. */ } diff --git a/tests/test-cmap.c b/tests/test-cmap.c index 74037f086..c36ecb680 100644 --- a/tests/test-cmap.c +++ b/tests/test-cmap.c @@ -127,7 +127,7 @@ check_cmap(struct cmap *cmap, const int values[], size_t n, } map = cmap_find_batch(cmap, map, hashes, nodes); - ULONG_FOR_EACH_1(k, map) { + ULLONG_FOR_EACH_1(k, map) { struct element *e; CMAP_NODE_FOR_EACH (e, node, nodes[k]) { @@ -435,7 +435,7 @@ find_batch(const struct cmap *cmap, const int value) map >>= BITMAP_ULONG_BITS - i; /* Clear excess bits. */ map = cmap_find_batch(cmap, map, hashes, nodes); - ULONG_FOR_EACH_1(i, map) { + ULLONG_FOR_EACH_1(i, map) { struct element *e; CMAP_NODE_FOR_EACH (e, node, nodes[i]) {