~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/include/linux/btree-type.h

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /* SPDX-License-Identifier: GPL-2.0 */
  2 #define __BTREE_TP(pfx, type, sfx)      pfx ## type ## sfx
  3 #define _BTREE_TP(pfx, type, sfx)       __BTREE_TP(pfx, type, sfx)
  4 #define BTREE_TP(pfx)                   _BTREE_TP(pfx, BTREE_TYPE_SUFFIX,)
  5 #define BTREE_FN(name)                  BTREE_TP(btree_ ## name)
  6 #define BTREE_TYPE_HEAD                 BTREE_TP(struct btree_head)
  7 #define VISITOR_FN                      BTREE_TP(visitor)
  8 #define VISITOR_FN_T                    _BTREE_TP(visitor, BTREE_TYPE_SUFFIX, _t)
  9 
 10 BTREE_TYPE_HEAD {
 11         struct btree_head h;
 12 };
 13 
 14 static inline void BTREE_FN(init_mempool)(BTREE_TYPE_HEAD *head,
 15                                           mempool_t *mempool)
 16 {
 17         btree_init_mempool(&head->h, mempool);
 18 }
 19 
 20 static inline int BTREE_FN(init)(BTREE_TYPE_HEAD *head)
 21 {
 22         return btree_init(&head->h);
 23 }
 24 
 25 static inline void BTREE_FN(destroy)(BTREE_TYPE_HEAD *head)
 26 {
 27         btree_destroy(&head->h);
 28 }
 29 
 30 static inline int BTREE_FN(merge)(BTREE_TYPE_HEAD *target,
 31                                   BTREE_TYPE_HEAD *victim,
 32                                   gfp_t gfp)
 33 {
 34         return btree_merge(&target->h, &victim->h, BTREE_TYPE_GEO, gfp);
 35 }
 36 
 37 #if (BITS_PER_LONG > BTREE_TYPE_BITS)
 38 static inline void *BTREE_FN(lookup)(BTREE_TYPE_HEAD *head, BTREE_KEYTYPE key)
 39 {
 40         unsigned long _key = key;
 41         return btree_lookup(&head->h, BTREE_TYPE_GEO, &_key);
 42 }
 43 
 44 static inline int BTREE_FN(insert)(BTREE_TYPE_HEAD *head, BTREE_KEYTYPE key,
 45                                    void *val, gfp_t gfp)
 46 {
 47         unsigned long _key = key;
 48         return btree_insert(&head->h, BTREE_TYPE_GEO, &_key, val, gfp);
 49 }
 50 
 51 static inline int BTREE_FN(update)(BTREE_TYPE_HEAD *head, BTREE_KEYTYPE key,
 52                 void *val)
 53 {
 54         unsigned long _key = key;
 55         return btree_update(&head->h, BTREE_TYPE_GEO, &_key, val);
 56 }
 57 
 58 static inline void *BTREE_FN(remove)(BTREE_TYPE_HEAD *head, BTREE_KEYTYPE key)
 59 {
 60         unsigned long _key = key;
 61         return btree_remove(&head->h, BTREE_TYPE_GEO, &_key);
 62 }
 63 
 64 static inline void *BTREE_FN(last)(BTREE_TYPE_HEAD *head, BTREE_KEYTYPE *key)
 65 {
 66         unsigned long _key;
 67         void *val = btree_last(&head->h, BTREE_TYPE_GEO, &_key);
 68         if (val)
 69                 *key = _key;
 70         return val;
 71 }
 72 
 73 static inline void *BTREE_FN(get_prev)(BTREE_TYPE_HEAD *head, BTREE_KEYTYPE *key)
 74 {
 75         unsigned long _key = *key;
 76         void *val = btree_get_prev(&head->h, BTREE_TYPE_GEO, &_key);
 77         if (val)
 78                 *key = _key;
 79         return val;
 80 }
 81 #else
 82 static inline void *BTREE_FN(lookup)(BTREE_TYPE_HEAD *head, BTREE_KEYTYPE key)
 83 {
 84         return btree_lookup(&head->h, BTREE_TYPE_GEO, (unsigned long *)&key);
 85 }
 86 
 87 static inline int BTREE_FN(insert)(BTREE_TYPE_HEAD *head, BTREE_KEYTYPE key,
 88                            void *val, gfp_t gfp)
 89 {
 90         return btree_insert(&head->h, BTREE_TYPE_GEO, (unsigned long *)&key,
 91                             val, gfp);
 92 }
 93 
 94 static inline int BTREE_FN(update)(BTREE_TYPE_HEAD *head, BTREE_KEYTYPE key,
 95                 void *val)
 96 {
 97         return btree_update(&head->h, BTREE_TYPE_GEO, (unsigned long *)&key, val);
 98 }
 99 
100 static inline void *BTREE_FN(remove)(BTREE_TYPE_HEAD *head, BTREE_KEYTYPE key)
101 {
102         return btree_remove(&head->h, BTREE_TYPE_GEO, (unsigned long *)&key);
103 }
104 
105 static inline void *BTREE_FN(last)(BTREE_TYPE_HEAD *head, BTREE_KEYTYPE *key)
106 {
107         return btree_last(&head->h, BTREE_TYPE_GEO, (unsigned long *)key);
108 }
109 
110 static inline void *BTREE_FN(get_prev)(BTREE_TYPE_HEAD *head, BTREE_KEYTYPE *key)
111 {
112         return btree_get_prev(&head->h, BTREE_TYPE_GEO, (unsigned long *)key);
113 }
114 #endif
115 
116 void VISITOR_FN(void *elem, unsigned long opaque, unsigned long *key,
117                 size_t index, void *__func);
118 
119 typedef void (*VISITOR_FN_T)(void *elem, unsigned long opaque,
120                              BTREE_KEYTYPE key, size_t index);
121 
122 static inline size_t BTREE_FN(visitor)(BTREE_TYPE_HEAD *head,
123                                        unsigned long opaque,
124                                        VISITOR_FN_T func2)
125 {
126         return btree_visitor(&head->h, BTREE_TYPE_GEO, opaque,
127                              visitorl, func2);
128 }
129 
130 static inline size_t BTREE_FN(grim_visitor)(BTREE_TYPE_HEAD *head,
131                                             unsigned long opaque,
132                                             VISITOR_FN_T func2)
133 {
134         return btree_grim_visitor(&head->h, BTREE_TYPE_GEO, opaque,
135                                   visitorl, func2);
136 }
137 
138 #undef VISITOR_FN
139 #undef VISITOR_FN_T
140 #undef __BTREE_TP
141 #undef _BTREE_TP
142 #undef BTREE_TP
143 #undef BTREE_FN
144 #undef BTREE_TYPE_HEAD
145 #undef BTREE_TYPE_SUFFIX
146 #undef BTREE_TYPE_GEO
147 #undef BTREE_KEYTYPE
148 #undef BTREE_TYPE_BITS
149 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php