]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blame - include/radix-tree.h
Merge branch 'libxfs-4.17-sync' into for-next
[thirdparty/xfsprogs-dev.git] / include / radix-tree.h
CommitLineData
e9416bd3
DC
1/*
2 * Copyright (C) 2001 Momchil Velikov
3 * Portions Copyright (C) 2001 Christoph Hellwig
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; either version 2, or (at
8 * your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19#ifndef __XFS_SUPPORT_RADIX_TREE_H__
20#define __XFS_SUPPORT_RADIX_TREE_H__
21
22#define RADIX_TREE_TAGS
23
24struct radix_tree_root {
25 unsigned int height;
26 struct radix_tree_node *rnode;
27};
28
29#define RADIX_TREE_INIT(mask) { \
30 .height = 0, \
31 .rnode = NULL, \
32}
33
34#define RADIX_TREE(name, mask) \
35 struct radix_tree_root name = RADIX_TREE_INIT(mask)
36
37#define INIT_RADIX_TREE(root, mask) \
38do { \
39 (root)->height = 0; \
40 (root)->rnode = NULL; \
41} while (0)
42
43#ifdef RADIX_TREE_TAGS
44#define RADIX_TREE_MAX_TAGS 2
45#endif
46
47int radix_tree_insert(struct radix_tree_root *, unsigned long, void *);
48void *radix_tree_lookup(struct radix_tree_root *, unsigned long);
49void **radix_tree_lookup_slot(struct radix_tree_root *, unsigned long);
50void *radix_tree_lookup_first(struct radix_tree_root *, unsigned long *);
51void *radix_tree_delete(struct radix_tree_root *, unsigned long);
52unsigned int
53radix_tree_gang_lookup(struct radix_tree_root *root, void **results,
54 unsigned long first_index, unsigned int max_items);
55unsigned int
56radix_tree_gang_lookup_ex(struct radix_tree_root *root, void **results,
57 unsigned long first_index, unsigned long last_index,
58 unsigned int max_items);
59
60void radix_tree_init(void);
61
62#ifdef RADIX_TREE_TAGS
63void *radix_tree_tag_set(struct radix_tree_root *root,
64 unsigned long index, unsigned int tag);
65void *radix_tree_tag_clear(struct radix_tree_root *root,
66 unsigned long index, unsigned int tag);
67int radix_tree_tag_get(struct radix_tree_root *root,
68 unsigned long index, unsigned int tag);
69unsigned int
70radix_tree_gang_lookup_tag(struct radix_tree_root *root, void **results,
71 unsigned long first_index, unsigned int max_items,
72 unsigned int tag);
73int radix_tree_tagged(struct radix_tree_root *root, unsigned int tag);
74#endif
75
76#endif /* __XFS_SUPPORT_RADIX_TREE_H__ */