Merge tag 'trace-printf-v6.13' of git://git.kernel.org/pub/scm/linux/kernel/git/trace...
[drm/drm-misc.git] / scripts / include / hash.h
blobefa904368a62e479839b9f73186d328bb67238fc
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 #ifndef HASH_H
3 #define HASH_H
5 static inline unsigned int hash_str(const char *s)
7 /* fnv32 hash */
8 unsigned int hash = 2166136261U;
10 for (; *s; s++)
11 hash = (hash ^ *s) * 0x01000193;
12 return hash;
15 /* simplified version of functions from include/linux/hash.h */
16 #define GOLDEN_RATIO_32 0x61C88647
18 static inline unsigned int hash_32(unsigned int val)
20 return 0x61C88647 * val;
23 static inline unsigned int hash_ptr(const void *ptr)
25 return hash_32((unsigned int)(unsigned long)ptr);
28 #endif /* HASH_H */