diff options
author | George Spelvin <linux@sciencehorizons.net> | 2016-05-26 22:22:01 -0400 |
---|---|---|
committer | George Spelvin <linux@sciencehorizons.net> | 2016-05-28 15:42:51 -0400 |
commit | 92d567740f2ab5937b2c23bee94ea4b284bb1f98 (patch) | |
tree | cac25a2b98245c5e95cc94f8e0671b400fd9a0da /include/linux/hash.h | |
parent | 917ea166f4672ec085f2cccc135c7c0eec72282c (diff) |
Change hash_64() return value to 32 bits
That's all that's ever asked for, and it makes the return
type of hash_long() consistent.
It also allows (upcoming patch) an optimized implementation
of hash_64 on 32-bit machines.
I tried adding a BUILD_BUG_ON to ensure the number of bits requested
was never more than 32 (most callers use a compile-time constant), but
adding <linux/bug.h> to <linux/hash.h> breaks the tools/perf compiler
unless tools/perf/MANIFEST is updated, and understanding that code base
well enough to update it is too much trouble. I did the rest of an
allyesconfig build with such a check, and nothing tripped.
Signed-off-by: George Spelvin <linux@sciencehorizons.net>
Diffstat (limited to 'include/linux/hash.h')
-rw-r--r-- | include/linux/hash.h | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/include/linux/hash.h b/include/linux/hash.h index 79c52fa81cac..f967dedb10e2 100644 --- a/include/linux/hash.h +++ b/include/linux/hash.h | |||
@@ -48,7 +48,7 @@ | |||
48 | #define GOLDEN_RATIO_32 0x61C88647 | 48 | #define GOLDEN_RATIO_32 0x61C88647 |
49 | #define GOLDEN_RATIO_64 0x61C8864680B583EBull | 49 | #define GOLDEN_RATIO_64 0x61C8864680B583EBull |
50 | 50 | ||
51 | static __always_inline u64 hash_64(u64 val, unsigned int bits) | 51 | static __always_inline u32 hash_64(u64 val, unsigned int bits) |
52 | { | 52 | { |
53 | u64 hash = val; | 53 | u64 hash = val; |
54 | 54 | ||
@@ -72,7 +72,7 @@ static __always_inline u64 hash_64(u64 val, unsigned int bits) | |||
72 | #endif | 72 | #endif |
73 | 73 | ||
74 | /* High bits are more random, so use them. */ | 74 | /* High bits are more random, so use them. */ |
75 | return hash >> (64 - bits); | 75 | return (u32)(hash >> (64 - bits)); |
76 | } | 76 | } |
77 | 77 | ||
78 | static inline u32 hash_32(u32 val, unsigned int bits) | 78 | static inline u32 hash_32(u32 val, unsigned int bits) |
@@ -84,7 +84,7 @@ static inline u32 hash_32(u32 val, unsigned int bits) | |||
84 | return hash >> (32 - bits); | 84 | return hash >> (32 - bits); |
85 | } | 85 | } |
86 | 86 | ||
87 | static inline unsigned long hash_ptr(const void *ptr, unsigned int bits) | 87 | static inline u32 hash_ptr(const void *ptr, unsigned int bits) |
88 | { | 88 | { |
89 | return hash_long((unsigned long)ptr, bits); | 89 | return hash_long((unsigned long)ptr, bits); |
90 | } | 90 | } |