Skip to content

Commit 60e015a

Browse files
author
Delphix Engineering
committed
Merge branch 'refs/heads/upstream-HEAD' into repo-HEAD
2 parents a6a0725 + e4c52c5 commit 60e015a

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

libdrgn/hash_table.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1226,15 +1226,15 @@ static inline struct hash_pair hash_pair_from_non_avalanching_hash(size_t hash)
12261226
{
12271227
#if SIZE_MAX == 0xffffffffffffffff
12281228
#ifdef __SSE4_2__
1229-
/* 64-bit with SSE4.2 uses CRC32 */
1229+
/* 64-bit with SSE4.2 uses CRC32 */
12301230
size_t c = _mm_crc32_u64(0, hash);
12311231

12321232
return (struct hash_pair){
12331233
.first = hash + c,
12341234
.second = (c >> 24) | 0x80,
12351235
};
12361236
#else
1237-
/* 64-bit without SSE4.2 uses a 128-bit multiplication-based mixer */
1237+
/* 64-bit without SSE4.2 uses a 128-bit multiplication-based mixer */
12381238
static const uint64_t multiplier = UINT64_C(0xc4ceb9fe1a85ec53);
12391239
uint64_t hi, lo;
12401240

@@ -1244,20 +1244,20 @@ static inline struct hash_pair hash_pair_from_non_avalanching_hash(size_t hash)
12441244
hash *= multiplier;
12451245
return (struct hash_pair){
12461246
.first = hash >> 22,
1247-
.second = (hash >> 15) | 0x80,
1247+
.second = ((hash >> 15) & 0x7f) | 0x80,
12481248
};
12491249
#endif
12501250
#elif SIZE_MAX == 0xffffffff
1251-
/* 32-bit with SSE4.2 uses CRC32 */
12521251
#ifdef __SSE4_2__
1252+
/* 32-bit with SSE4.2 uses CRC32 */
12531253
size_t c = _mm_crc32_u32(0, hash);
12541254

12551255
return (struct hash_pair){
12561256
.first = hash + c,
12571257
.second = (uint8_t)(~(c >> 25)),
12581258
};
12591259
#else
1260-
/* 32-bit without SSE4.2 uses the 32-bit Murmur2 finalizer */
1260+
/* 32-bit without SSE4.2 uses the 32-bit Murmur2 finalizer */
12611261
hash ^= hash >> 13;
12621262
hash *= 0x5bd1e995;
12631263
hash ^= hash >> 15;

libdrgn/linux_kernel.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -820,15 +820,19 @@ static struct drgn_error *kmod_index_init(struct kmod_index *index,
820820

821821
static const char *kmod_index_find(struct kmod_index *index, const char *key)
822822
{
823+
static const uint32_t INDEX_NODE_MASK = UINT32_C(0x0fffffff);
824+
static const uint32_t INDEX_NODE_CHILDS = UINT32_C(0x20000000);
825+
static const uint32_t INDEX_NODE_VALUES = UINT32_C(0x40000000);
826+
static const uint32_t INDEX_NODE_PREFIX = UINT32_C(0x80000000);
823827
const char *ptr = index->ptr + 8;
824828
uint32_t offset;
825829

826830
for (;;) {
827831
if (!read_be32(&ptr, index->end, &offset))
828832
return NULL;
829-
ptr = index->ptr + (offset & 0x0fffffffU);
833+
ptr = index->ptr + (offset & INDEX_NODE_MASK);
830834

831-
if (offset & 0x80000000U) {
835+
if (offset & INDEX_NODE_PREFIX) {
832836
const char *prefix;
833837
size_t prefix_len;
834838

@@ -840,7 +844,7 @@ static const char *kmod_index_find(struct kmod_index *index, const char *key)
840844
key += prefix_len;
841845
}
842846

843-
if (offset & 0x20000000U) {
847+
if (offset & INDEX_NODE_CHILDS) {
844848
uint8_t first, last;
845849

846850
if (!read_u8(&ptr, index->end, &first) ||
@@ -864,7 +868,7 @@ static const char *kmod_index_find(struct kmod_index *index, const char *key)
864868
break;
865869
}
866870
}
867-
if (!(offset & 0x40000000U))
871+
if (!(offset & INDEX_NODE_VALUES))
868872
return NULL;
869873
return ptr;
870874
}

0 commit comments

Comments
 (0)