21 #ifndef _LINUX_RADIX_TREE_H
22 #define _LINUX_RADIX_TREE_H
25 #include <linux/types.h>
27 #include <linux/kernel.h>
44 #define RADIX_TREE_INDIRECT_PTR 1
51 #define RADIX_TREE_EXCEPTIONAL_ENTRY 2
52 #define RADIX_TREE_EXCEPTIONAL_SHIFT 2
54 static inline int radix_tree_is_indirect_ptr(
void *
ptr)
61 #define RADIX_TREE_MAX_TAGS 3
70 #define RADIX_TREE_INIT(mask) { \
76 #define RADIX_TREE(name, mask) \
77 struct radix_tree_root name = RADIX_TREE_INIT(mask)
79 #define INIT_RADIX_TREE(root, mask) \
82 (root)->gfp_mask = (mask); \
83 (root)->rnode = NULL; \
150 static inline void *radix_tree_deref_slot(
void **pslot)
165 static inline void *radix_tree_deref_slot_protected(
void **pslot,
178 static inline int radix_tree_deref_retry(
void *
arg)
188 static inline int radix_tree_exceptional_entry(
void *arg)
199 static inline int radix_tree_exception(
void *arg)
201 return unlikely((
unsigned long)arg &
213 static inline void radix_tree_replace_slot(
void **pslot,
void *
item)
215 BUG_ON(radix_tree_is_indirect_ptr(item));
225 unsigned long first_index,
unsigned int max_items);
227 void ***results,
unsigned long *indices,
228 unsigned long first_index,
unsigned int max_items);
230 unsigned long index,
unsigned long max_scan);
232 unsigned long index,
unsigned long max_scan);
236 unsigned long index,
unsigned int tag);
238 unsigned long index,
unsigned int tag);
240 unsigned long index,
unsigned int tag);
243 unsigned long first_index,
unsigned int max_items,
247 unsigned long first_index,
unsigned int max_items,
250 unsigned long *first_indexp,
unsigned long last_index,
251 unsigned long nr_to_tag,
252 unsigned int fromtag,
unsigned int totag);
256 static inline void radix_tree_preload_end(
void)
281 #define RADIX_TREE_ITER_TAG_MASK 0x00FF
282 #define RADIX_TREE_ITER_TAGGED 0x0100
283 #define RADIX_TREE_ITER_CONTIG 0x0200
360 iter->
index += offset + 1;
361 return slot + offset + 1;
364 unsigned size = radix_tree_chunk_size(iter) - 1;
371 if (flags & RADIX_TREE_ITER_CONTIG) {
392 #define radix_tree_for_each_chunk(slot, root, iter, start, flags) \
393 for (slot = radix_tree_iter_init(iter, start) ; \
394 (slot = radix_tree_next_chunk(root, iter, flags)) ;)
406 #define radix_tree_for_each_chunk_slot(slot, iter, flags) \
407 for (; slot ; slot = radix_tree_next_slot(slot, iter, flags))
419 #define radix_tree_for_each_slot(slot, root, iter, start) \
420 for (slot = radix_tree_iter_init(iter, start) ; \
421 slot || (slot = radix_tree_next_chunk(root, iter, 0)) ; \
422 slot = radix_tree_next_slot(slot, iter, 0))
434 #define radix_tree_for_each_contig(slot, root, iter, start) \
435 for (slot = radix_tree_iter_init(iter, start) ; \
436 slot || (slot = radix_tree_next_chunk(root, iter, \
437 RADIX_TREE_ITER_CONTIG)) ; \
438 slot = radix_tree_next_slot(slot, iter, \
439 RADIX_TREE_ITER_CONTIG))
452 #define radix_tree_for_each_tagged(slot, root, iter, start, tag) \
453 for (slot = radix_tree_iter_init(iter, start) ; \
454 slot || (slot = radix_tree_next_chunk(root, iter, \
455 RADIX_TREE_ITER_TAGGED | tag)) ; \
456 slot = radix_tree_next_slot(slot, iter, \
457 RADIX_TREE_ITER_TAGGED))