File: utils.h

package info (click to toggle)
lttng-modules 2.14.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 4,808 kB
  • sloc: ansic: 74,851; sh: 548; makefile: 62
file content (27 lines) | stat: -rw-r--r-- 619 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only) */
#ifndef _LTTNG_UTILS_H
#define _LTTNG_UTILS_H

/*
 * Copyright (C) 2020 Francis Deslauriers <francis.deslauriers@efficios.com>
 */

#include <linux/jhash.h>
#include <linux/string.h>
#include <linux/types.h>

static inline
struct hlist_head *utils_borrow_hash_table_bucket(
		struct hlist_head *hash_table,
		unsigned int hash_table_size,
		const char *event_name)
{
	size_t name_len;
	uint32_t hash;

	name_len = strlen(event_name);

	hash = jhash(event_name, name_len, 0);
	return &hash_table[hash & (hash_table_size - 1)];
}
#endif /* _LTTNG_UTILS_H */