summaryrefslogtreecommitdiff
path: root/tools/testing/selftests/kvm/include/sparsebit.h
blob: 54cfeb6568d342f20369fd7bf0e9a82b665c1f25 (plain)
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/*
 * tools/testing/selftests/kvm/include/sparsebit.h
 *
 * Copyright (C) 2018, Google LLC.
 *
 * This work is licensed under the terms of the GNU GPL, version 2.
 *
 *
 * Header file that describes API to the sparsebit library.
 * This library provides a memory efficient means of storing
 * the settings of bits indexed via a uint64_t.  Memory usage
 * is reasonable, significantly less than (2^64 / 8) bytes, as
 * long as bits that are mostly set or mostly cleared are close
 * to each other.  This library is efficient in memory usage
 * even in the case where most bits are set.
 */

#ifndef _TEST_SPARSEBIT_H_
#define _TEST_SPARSEBIT_H_

#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>

#ifdef __cplusplus
extern "C" {
#endif

struct sparsebit;
typedef uint64_t sparsebit_idx_t;
typedef uint64_t sparsebit_num_t;

struct sparsebit *sparsebit_alloc(void);
void sparsebit_free(struct sparsebit **sbitp);
void sparsebit_copy(struct sparsebit *dstp, struct sparsebit *src);

bool sparsebit_is_set(struct sparsebit *sbit, sparsebit_idx_t idx);
bool sparsebit_is_set_num(struct sparsebit *sbit,
			  sparsebit_idx_t idx, sparsebit_num_t num);
bool sparsebit_is_clear(struct sparsebit *sbit, sparsebit_idx_t idx);
bool sparsebit_is_clear_num(struct sparsebit *sbit,
			    sparsebit_idx_t idx, sparsebit_num_t num);
sparsebit_num_t sparsebit_num_set(struct sparsebit *sbit);
bool sparsebit_any_set(struct sparsebit *sbit);
bool sparsebit_any_clear(struct sparsebit *sbit);
bool sparsebit_all_set(struct sparsebit *sbit);
bool sparsebit_all_clear(struct sparsebit *sbit);
sparsebit_idx_t sparsebit_first_set(struct sparsebit *sbit);
sparsebit_idx_t sparsebit_first_clear(struct sparsebit *sbit);
sparsebit_idx_t sparsebit_next_set(struct sparsebit *sbit, sparsebit_idx_t prev);
sparsebit_idx_t sparsebit_next_clear(struct sparsebit *sbit, sparsebit_idx_t prev);
sparsebit_idx_t sparsebit_next_set_num(struct sparsebit *sbit,
				       sparsebit_idx_t start, sparsebit_num_t num);
sparsebit_idx_t sparsebit_next_clear_num(struct sparsebit *sbit,
					 sparsebit_idx_t start, sparsebit_num_t num);

void sparsebit_set(struct sparsebit *sbitp, sparsebit_idx_t idx);
void sparsebit_set_num(struct sparsebit *sbitp, sparsebit_idx_t start,
		       sparsebit_num_t num);
void sparsebit_set_all(struct sparsebit *sbitp);

void sparsebit_clear(struct sparsebit *sbitp, sparsebit_idx_t idx);
void sparsebit_clear_num(struct sparsebit *sbitp,
			 sparsebit_idx_t start, sparsebit_num_t num);
void sparsebit_clear_all(struct sparsebit *sbitp);

void sparsebit_dump(FILE *stream, struct sparsebit *sbit,
		    unsigned int indent);
void sparsebit_validate_internal(struct sparsebit *sbit);

#ifdef __cplusplus
}
#endif

#endif /* _TEST_SPARSEBIT_H_ */
_btf.c?h=linux-6.6.y&id=0d7410ea6efcdfda56773999f692bbd5d4e4bc00'>tools/bpf: check precise {func, line, jited_line}_info_rec_size in test_btfYonghong Song 2018-12-18tools/bpf: test kernel bpffs map pretty print with struct kind_flagYonghong Song 2018-12-18tools/bpf: add test_btf unit tests for kind_flagYonghong Song 2018-12-13bpf: Remove !func_info and !line_info check from test_btf and bpftoolMartin KaFai Lau 2018-12-10Merge git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-nextDavid S. Miller 2018-12-10tools/bpf: rename *_info_cnt to nr_*_infoYonghong Song 2018-12-09Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/netDavid S. Miller 2018-12-09bpf: Add unit tests for bpf_line_infoMartin KaFai Lau 2018-12-09bpf: Refactor and bug fix in test_func_type in test_btf.cMartin KaFai Lau 2018-12-05bpf: Expect !info.func_info and insn_off name changes in test_btf/libbpf/bpftoolMartin KaFai Lau 2018-11-28tools/bpf: add addition type tests to test_btfYonghong Song 2018-11-28tools/bpf: fix two test_btf unit test casesMartin KaFai Lau 2018-11-26libbpf: Name changing for btf_get_from_idMartin KaFai Lau 2018-11-26tools/bpf: change selftest test_btf for both jit and non-jitYonghong Song 2018-11-22tools/bpf: fix spelling mistake "memeory" -> "memory"Colin Ian King 2018-11-20tools/bpf: enhance test_btf file testing to test func infoYonghong Song 2018-11-20tools/bpf: extends test_btf to test load/retrieve func_type infoYonghong Song 2018-11-20tools/bpf: Add tests for BTF_KIND_FUNC_PROTO and BTF_KIND_FUNCMartin KaFai Lau 2018-08-30tools/bpf: add bpffs percpu map pretty print tests in test_btfYonghong Song 2018-08-11bpf: Refactor ARRAY_SIZE macro to bpf_util.hMartin KaFai Lau 2018-08-10tools/bpf: add bpffs pretty print btf test for hash/lru_hash mapsYonghong Song 2018-07-27bpf: btf: Use exact btf value_size match in map_check_btf()Martin KaFai Lau 2018-07-24bpf: btf: Ensure the member->offset is in the right orderMartin KaFai Lau 2018-06-02bpf: btf: Ensure t->type == 0 for BTF_KIND_FWDMartin KaFai Lau 2018-06-02bpf: btf: Check array t->sizeMartin KaFai Lau 2018-05-23bpf: btf: Add tests for the btf uapi changesMartin KaFai Lau 2018-05-09bpf: btf: Tests for BPF_OBJ_GET_INFO_BY_FD and BPF_BTF_GET_FD_BY_IDMartin KaFai Lau 2018-05-09bpf: btf: Some test_btf clean upMartin KaFai Lau 2018-04-19bpf: btf: Add BTF testsMartin KaFai Lau