Commit | Line | Data |
---|---|---|
4a11ef1c FD |
1 | /* SPDX-License-Identifier: (GPL-2.0 or LGPL-2.1) */ |
2 | #ifndef _LTTNG_UTILS_H | |
3 | #define _LTTNG_UTILS_H | |
4 | ||
5 | /* | |
6 | * Copyright (C) 2020 Francis Deslauriers <francis.deslauriers@efficios.com> | |
7 | */ | |
8 | ||
9 | #include <linux/jhash.h> | |
10 | #include <linux/string.h> | |
11 | #include <linux/types.h> | |
12 | ||
13 | static inline | |
14 | struct hlist_head *utils_borrow_hash_table_bucket( | |
15 | struct hlist_head *hash_table, | |
16 | unsigned int hash_table_size, | |
17 | const char *event_name) | |
18 | { | |
19 | size_t name_len; | |
20 | uint32_t hash; | |
21 | ||
22 | name_len = strlen(event_name); | |
23 | ||
24 | hash = jhash(event_name, name_len, 0); | |
25 | return &hash_table[hash & (hash_table_size - 1)]; | |
26 | } | |
27 | #endif /* _LTTNG_UTILS_H */ |