[PATCH] rcu file: use atomic primitives
[linux-2.6-block.git] / include / linux / radix-tree.h
CommitLineData
1da177e4
LT
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 _LINUX_RADIX_TREE_H
20#define _LINUX_RADIX_TREE_H
21
095975da 22#include <linux/sched.h>
1da177e4
LT
23#include <linux/preempt.h>
24#include <linux/types.h>
25
26struct radix_tree_root {
27 unsigned int height;
fd4f2df2 28 gfp_t gfp_mask;
1da177e4
LT
29 struct radix_tree_node *rnode;
30};
31
32#define RADIX_TREE_INIT(mask) { \
33 .height = 0, \
34 .gfp_mask = (mask), \
35 .rnode = NULL, \
36}
37
38#define RADIX_TREE(name, mask) \
39 struct radix_tree_root name = RADIX_TREE_INIT(mask)
40
41#define INIT_RADIX_TREE(root, mask) \
42do { \
43 (root)->height = 0; \
44 (root)->gfp_mask = (mask); \
45 (root)->rnode = NULL; \
46} while (0)
47
48int radix_tree_insert(struct radix_tree_root *, unsigned long, void *);
49void *radix_tree_lookup(struct radix_tree_root *, unsigned long);
a4331366 50void **radix_tree_lookup_slot(struct radix_tree_root *, unsigned long);
1da177e4
LT
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);
dd0fc66f 55int radix_tree_preload(gfp_t gfp_mask);
1da177e4
LT
56void radix_tree_init(void);
57void *radix_tree_tag_set(struct radix_tree_root *root,
58 unsigned long index, int tag);
59void *radix_tree_tag_clear(struct radix_tree_root *root,
60 unsigned long index, int tag);
61int radix_tree_tag_get(struct radix_tree_root *root,
62 unsigned long index, int tag);
63unsigned int
64radix_tree_gang_lookup_tag(struct radix_tree_root *root, void **results,
65 unsigned long first_index, unsigned int max_items, int tag);
66int radix_tree_tagged(struct radix_tree_root *root, int tag);
67
68static inline void radix_tree_preload_end(void)
69{
70 preempt_enable();
71}
72
73#endif /* _LINUX_RADIX_TREE_H */