1 /* SPDX-License-Identifier: GPL-2.0 */ << 2 extern struct btree_geo btree_geo128; 1 extern struct btree_geo btree_geo128; 3 2 4 struct btree_head128 { struct btree_head h; }; 3 struct btree_head128 { struct btree_head h; }; 5 4 6 static inline void btree_init_mempool128(struc 5 static inline void btree_init_mempool128(struct btree_head128 *head, 7 mempo 6 mempool_t *mempool) 8 { 7 { 9 btree_init_mempool(&head->h, mempool); 8 btree_init_mempool(&head->h, mempool); 10 } 9 } 11 10 12 static inline int btree_init128(struct btree_h 11 static inline int btree_init128(struct btree_head128 *head) 13 { 12 { 14 return btree_init(&head->h); 13 return btree_init(&head->h); 15 } 14 } 16 15 17 static inline void btree_destroy128(struct btr 16 static inline void btree_destroy128(struct btree_head128 *head) 18 { 17 { 19 btree_destroy(&head->h); 18 btree_destroy(&head->h); 20 } 19 } 21 20 22 static inline void *btree_lookup128(struct btr 21 static inline void *btree_lookup128(struct btree_head128 *head, u64 k1, u64 k2) 23 { 22 { 24 u64 key[2] = {k1, k2}; 23 u64 key[2] = {k1, k2}; 25 return btree_lookup(&head->h, &btree_g 24 return btree_lookup(&head->h, &btree_geo128, (unsigned long *)&key); 26 } 25 } 27 26 28 static inline void *btree_get_prev128(struct b 27 static inline void *btree_get_prev128(struct btree_head128 *head, 29 u64 *k1, 28 u64 *k1, u64 *k2) 30 { 29 { 31 u64 key[2] = {*k1, *k2}; 30 u64 key[2] = {*k1, *k2}; 32 void *val; 31 void *val; 33 32 34 val = btree_get_prev(&head->h, &btree_ 33 val = btree_get_prev(&head->h, &btree_geo128, 35 (unsigned long *) 34 (unsigned long *)&key); 36 *k1 = key[0]; 35 *k1 = key[0]; 37 *k2 = key[1]; 36 *k2 = key[1]; 38 return val; 37 return val; 39 } 38 } 40 39 41 static inline int btree_insert128(struct btree 40 static inline int btree_insert128(struct btree_head128 *head, u64 k1, u64 k2, 42 void *val, g 41 void *val, gfp_t gfp) 43 { 42 { 44 u64 key[2] = {k1, k2}; 43 u64 key[2] = {k1, k2}; 45 return btree_insert(&head->h, &btree_g 44 return btree_insert(&head->h, &btree_geo128, 46 (unsigned long *)& 45 (unsigned long *)&key, val, gfp); 47 } 46 } 48 47 49 static inline int btree_update128(struct btree 48 static inline int btree_update128(struct btree_head128 *head, u64 k1, u64 k2, 50 void *val) 49 void *val) 51 { 50 { 52 u64 key[2] = {k1, k2}; 51 u64 key[2] = {k1, k2}; 53 return btree_update(&head->h, &btree_g 52 return btree_update(&head->h, &btree_geo128, 54 (unsigned long *)& 53 (unsigned long *)&key, val); 55 } 54 } 56 55 57 static inline void *btree_remove128(struct btr 56 static inline void *btree_remove128(struct btree_head128 *head, u64 k1, u64 k2) 58 { 57 { 59 u64 key[2] = {k1, k2}; 58 u64 key[2] = {k1, k2}; 60 return btree_remove(&head->h, &btree_g 59 return btree_remove(&head->h, &btree_geo128, (unsigned long *)&key); 61 } 60 } 62 61 63 static inline void *btree_last128(struct btree 62 static inline void *btree_last128(struct btree_head128 *head, u64 *k1, u64 *k2) 64 { 63 { 65 u64 key[2]; 64 u64 key[2]; 66 void *val; 65 void *val; 67 66 68 val = btree_last(&head->h, &btree_geo1 67 val = btree_last(&head->h, &btree_geo128, (unsigned long *)&key[0]); 69 if (val) { 68 if (val) { 70 *k1 = key[0]; 69 *k1 = key[0]; 71 *k2 = key[1]; 70 *k2 = key[1]; 72 } 71 } 73 72 74 return val; 73 return val; 75 } 74 } 76 75 77 static inline int btree_merge128(struct btree_ 76 static inline int btree_merge128(struct btree_head128 *target, 78 struct btree_ 77 struct btree_head128 *victim, 79 gfp_t gfp) 78 gfp_t gfp) 80 { 79 { 81 return btree_merge(&target->h, &victim 80 return btree_merge(&target->h, &victim->h, &btree_geo128, gfp); 82 } 81 } 83 82 84 void visitor128(void *elem, unsigned long opaq 83 void visitor128(void *elem, unsigned long opaque, unsigned long *__key, 85 size_t index, void *__func); 84 size_t index, void *__func); 86 85 87 typedef void (*visitor128_t)(void *elem, unsig 86 typedef void (*visitor128_t)(void *elem, unsigned long opaque, 88 u64 key1, u64 key 87 u64 key1, u64 key2, size_t index); 89 88 90 static inline size_t btree_visitor128(struct b 89 static inline size_t btree_visitor128(struct btree_head128 *head, 91 unsigned 90 unsigned long opaque, 92 visitor1 91 visitor128_t func2) 93 { 92 { 94 return btree_visitor(&head->h, &btree_ 93 return btree_visitor(&head->h, &btree_geo128, opaque, 95 visitor128, func2 94 visitor128, func2); 96 } 95 } 97 96 98 static inline size_t btree_grim_visitor128(str 97 static inline size_t btree_grim_visitor128(struct btree_head128 *head, 99 uns 98 unsigned long opaque, 100 vis 99 visitor128_t func2) 101 { 100 { 102 return btree_grim_visitor(&head->h, &b 101 return btree_grim_visitor(&head->h, &btree_geo128, opaque, 103 visitor128, 102 visitor128, func2); 104 } 103 } 105 104 106 #define btree_for_each_safe128(head, k1, k2, v 105 #define btree_for_each_safe128(head, k1, k2, val) \ 107 for (val = btree_last128(head, &k1, &k 106 for (val = btree_last128(head, &k1, &k2); \ 108 val; 107 val; \ 109 val = btree_get_prev128(head, &k1 108 val = btree_get_prev128(head, &k1, &k2)) 110 109 111 110
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.