2 * Copyright (C) 2007 Oracle. All rights reserved.
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public
6 * License v2 as published by the Free Software Foundation.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
13 * You should have received a copy of the GNU General Public
14 * License along with this program; if not, write to the
15 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
16 * Boston, MA 021110-1307, USA.
20 * Copyright (C) 2001 Momchil Velikov
21 * Portions Copyright (C) 2001 Christoph Hellwig
23 * This program is free software; you can redistribute it and/or
24 * modify it under the terms of the GNU General Public License as
25 * published by the Free Software Foundation; either version 2, or (at
26 * your option) any later version.
28 * This program is distributed in the hope that it will be useful, but
29 * WITHOUT ANY WARRANTY; without even the implied warranty of
30 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
31 * General Public License for more details.
33 * You should have received a copy of the GNU General Public License
34 * along with this program; if not, write to the Free Software
35 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
37 #ifndef _LINUX_RADIX_TREE_H
38 #define _LINUX_RADIX_TREE_H
40 #include "kerncompat.h"
42 #define RADIX_TREE_MAX_TAGS 2
44 /* root tags are stored in gfp_mask, shifted by __GFP_BITS_SHIFT */
45 struct radix_tree_root
{
48 struct radix_tree_node
*rnode
;
51 #define RADIX_TREE_INIT(mask) { \
57 #define RADIX_TREE(name, mask) \
58 struct radix_tree_root name = RADIX_TREE_INIT(mask)
60 #define INIT_RADIX_TREE(root, mask) \
63 (root)->gfp_mask = (mask); \
64 (root)->rnode = NULL; \
67 int radix_tree_insert(struct radix_tree_root
*, unsigned long, void *);
68 void *radix_tree_lookup(struct radix_tree_root
*, unsigned long);
69 void **radix_tree_lookup_slot(struct radix_tree_root
*, unsigned long);
70 void *radix_tree_delete(struct radix_tree_root
*, unsigned long);
72 radix_tree_gang_lookup(struct radix_tree_root
*root
, void **results
,
73 unsigned long first_index
, unsigned int max_items
);
74 int radix_tree_preload(gfp_t gfp_mask
);
75 void radix_tree_init(void);
76 void *radix_tree_tag_set(struct radix_tree_root
*root
,
77 unsigned long index
, unsigned int tag
);
78 void *radix_tree_tag_clear(struct radix_tree_root
*root
,
79 unsigned long index
, unsigned int tag
);
80 int radix_tree_tag_get(struct radix_tree_root
*root
,
81 unsigned long index
, unsigned int tag
);
83 radix_tree_gang_lookup_tag(struct radix_tree_root
*root
, void **results
,
84 unsigned long first_index
, unsigned int max_items
,
86 int radix_tree_tagged(struct radix_tree_root
*root
, unsigned int tag
);
88 static inline void radix_tree_preload_end(void)
93 #endif /* _LINUX_RADIX_TREE_H */