This source file includes following definitions.
- ulist_add_merge_ptr
1
2
3
4
5
6
7 #ifndef BTRFS_ULIST_H
8 #define BTRFS_ULIST_H
9
10 #include <linux/list.h>
11 #include <linux/rbtree.h>
12
13
14
15
16
17
18
19
20 struct ulist_iterator {
21 struct list_head *cur_list;
22 };
23
24
25
26
27 struct ulist_node {
28 u64 val;
29 u64 aux;
30
31 struct list_head list;
32 struct rb_node rb_node;
33 };
34
35 struct ulist {
36
37
38
39 unsigned long nnodes;
40
41 struct list_head nodes;
42 struct rb_root root;
43 };
44
45 void ulist_init(struct ulist *ulist);
46 void ulist_release(struct ulist *ulist);
47 void ulist_reinit(struct ulist *ulist);
48 struct ulist *ulist_alloc(gfp_t gfp_mask);
49 void ulist_free(struct ulist *ulist);
50 int ulist_add(struct ulist *ulist, u64 val, u64 aux, gfp_t gfp_mask);
51 int ulist_add_merge(struct ulist *ulist, u64 val, u64 aux,
52 u64 *old_aux, gfp_t gfp_mask);
53 int ulist_del(struct ulist *ulist, u64 val, u64 aux);
54
55
56 static inline int ulist_add_merge_ptr(struct ulist *ulist, u64 val, void *aux,
57 void **old_aux, gfp_t gfp_mask)
58 {
59 #if BITS_PER_LONG == 32
60 u64 old64 = (uintptr_t)*old_aux;
61 int ret = ulist_add_merge(ulist, val, (uintptr_t)aux, &old64, gfp_mask);
62 *old_aux = (void *)((uintptr_t)old64);
63 return ret;
64 #else
65 return ulist_add_merge(ulist, val, (u64)aux, (u64 *)old_aux, gfp_mask);
66 #endif
67 }
68
69 struct ulist_node *ulist_next(struct ulist *ulist,
70 struct ulist_iterator *uiter);
71
72 #define ULIST_ITER_INIT(uiter) ((uiter)->cur_list = NULL)
73
74 #endif