diff options
| author | Jakub Kicinski <kuba@kernel.org> | 2020-11-06 17:32:55 -0800 |
|---|---|---|
| committer | Jakub Kicinski <kuba@kernel.org> | 2020-11-06 17:33:38 -0800 |
| commit | ae0d0bb29b311ee3c71c8796f76d309a3779c8d9 (patch) | |
| tree | ae8e6f90d4eec5594bf42fe7aa9c3d989fc4317e /tools/perf/util/hashmap.h | |
| parent | 9f32c27eb4fc4426eedd511697d921a932f7dba6 (diff) | |
| parent | bf3e76289cd28b87f679cd53e26d67fd708d718a (diff) | |
Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'tools/perf/util/hashmap.h')
| -rw-r--r-- | tools/perf/util/hashmap.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/tools/perf/util/hashmap.h b/tools/perf/util/hashmap.h index e0af36b0e5d8..d9b385fe808c 100644 --- a/tools/perf/util/hashmap.h +++ b/tools/perf/util/hashmap.h @@ -25,6 +25,18 @@ static inline size_t hash_bits(size_t h, int bits) #endif } +/* generic C-string hashing function */ +static inline size_t str_hash(const char *s) +{ + size_t h = 0; + + while (*s) { + h = h * 31 + *s; + s++; + } + return h; +} + typedef size_t (*hashmap_hash_fn)(const void *key, void *ctx); typedef bool (*hashmap_equal_fn)(const void *key1, const void *key2, void *ctx); |