Subversion Repositories Kolibri OS

Rev

Rev 4065 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4065 Rev 5270
Line 34... Line 34...
34
 
34
 
35
static __always_inline u64 hash_64(u64 val, unsigned int bits)
35
static __always_inline u64 hash_64(u64 val, unsigned int bits)
36
{
36
{
Line -... Line 37...
-
 
37
	u64 hash = val;
-
 
38
 
-
 
39
#if defined(CONFIG_ARCH_HAS_FAST_MULTIPLIER) && BITS_PER_LONG == 64
37
	u64 hash = val;
40
	hash = hash * GOLDEN_RATIO_PRIME_64;
38
 
41
#else
39
	/*  Sigh, gcc can't optimise this alone like it does for 32 bits. */
42
	/*  Sigh, gcc can't optimise this alone like it does for 32 bits. */
40
	u64 n = hash;
43
	u64 n = hash;
41
	n <<= 18;
44
	n <<= 18;
Line 48... Line 51...
48
	hash -= n;
51
	hash -= n;
49
	n <<= 4;
52
	n <<= 4;
50
	hash += n;
53
	hash += n;
51
	n <<= 2;
54
	n <<= 2;
52
	hash += n;
55
	hash += n;
-
 
56
#endif
Line 53... Line 57...
53
 
57
 
54
	/* High bits are more random, so use them. */
58
	/* High bits are more random, so use them. */
55
	return hash >> (64 - bits);
59
	return hash >> (64 - bits);
Line 76... Line 80...
76
#if BITS_PER_LONG == 64
80
#if BITS_PER_LONG == 64
77
	val ^= (val >> 32);
81
	val ^= (val >> 32);
78
#endif
82
#endif
79
	return (u32)val;
83
	return (u32)val;
80
}
84
}
-
 
85
 
81
#endif /* _LINUX_HASH_H */
86
#endif /* _LINUX_HASH_H */