Lines Matching defs:ida

16 void ida_dump(struct ida *ida) { }
18 #define IDA_BUG_ON(ida, x) do { \
21 ida_dump(ida); \
31 static void ida_check_alloc(struct ida *ida)
36 IDA_BUG_ON(ida, ida_alloc(ida, GFP_KERNEL) != i);
38 ida_free(ida, 20);
39 ida_free(ida, 21);
41 id = ida_alloc(ida, GFP_KERNEL);
42 IDA_BUG_ON(ida, id < 0);
44 IDA_BUG_ON(ida, id != 10000);
48 ida_free(ida, i);
50 IDA_BUG_ON(ida, ida_alloc_min(ida, 5000, GFP_KERNEL) != 10001);
51 ida_destroy(ida);
53 IDA_BUG_ON(ida, !ida_is_empty(ida));
57 static void ida_check_destroy_1(struct ida *ida, unsigned int base)
59 IDA_BUG_ON(ida, ida_alloc_min(ida, base, GFP_KERNEL) != base);
60 IDA_BUG_ON(ida, ida_is_empty(ida));
61 ida_destroy(ida);
62 IDA_BUG_ON(ida, !ida_is_empty(ida));
66 static void ida_check_destroy(struct ida *ida)
69 IDA_BUG_ON(ida, !ida_is_empty(ida));
70 ida_destroy(ida);
71 IDA_BUG_ON(ida, !ida_is_empty(ida));
73 ida_check_destroy_1(ida, 0);
74 ida_check_destroy_1(ida, 1);
75 ida_check_destroy_1(ida, 1023);
76 ida_check_destroy_1(ida, 1024);
77 ida_check_destroy_1(ida, 12345678);
84 static void ida_check_leaf(struct ida *ida, unsigned int base)
89 IDA_BUG_ON(ida, ida_alloc_min(ida, base, GFP_KERNEL) !=
93 ida_destroy(ida);
94 IDA_BUG_ON(ida, !ida_is_empty(ida));
96 IDA_BUG_ON(ida, ida_alloc(ida, GFP_KERNEL) != 0);
97 IDA_BUG_ON(ida, ida_is_empty(ida));
98 ida_free(ida, 0);
99 IDA_BUG_ON(ida, !ida_is_empty(ida));
107 static void ida_check_max(struct ida *ida)
114 IDA_BUG_ON(ida, ida_alloc_min(ida, base, GFP_KERNEL) !=
117 IDA_BUG_ON(ida, ida_alloc_min(ida, base, GFP_KERNEL) !=
119 ida_destroy(ida);
120 IDA_BUG_ON(ida, !ida_is_empty(ida));
127 static void ida_check_conv(struct ida *ida)
132 IDA_BUG_ON(ida, ida_alloc_min(ida, i + 1, GFP_KERNEL) != i + 1);
133 IDA_BUG_ON(ida, ida_alloc_min(ida, i + BITS_PER_LONG,
135 ida_free(ida, i + 1);
136 ida_free(ida, i + BITS_PER_LONG);
137 IDA_BUG_ON(ida, !ida_is_empty(ida));
141 IDA_BUG_ON(ida, ida_alloc(ida, GFP_KERNEL) != i);
143 ida_free(ida, i - 1);
144 IDA_BUG_ON(ida, !ida_is_empty(ida));
147 IDA_BUG_ON(ida, ida_alloc(ida, GFP_KERNEL) != i);
149 ida_free(ida, i - 1);
150 IDA_BUG_ON(ida, !ida_is_empty(ida));
156 static void ida_check_bad_free(struct ida *ida)
162 ida_free(ida, 0);
164 ida_free(ida, 1 << i);
167 IDA_BUG_ON(ida, ida_alloc_min(ida, 3, GFP_KERNEL) != 3);
168 ida_free(ida, 0);
170 ida_free(ida, 1 << i);
173 IDA_BUG_ON(ida, ida_alloc_min(ida, 1023, GFP_KERNEL) != 1023);
174 ida_free(ida, 0);
176 ida_free(ida, 1 << i);
179 IDA_BUG_ON(ida, ida_alloc_min(ida, (1 << 20) - 1, GFP_KERNEL) != (1 << 20) - 1);
180 ida_free(ida, 0);
182 ida_free(ida, 1 << i);
185 ida_free(ida, 3);
186 ida_free(ida, 1023);
187 ida_free(ida, (1 << 20) - 1);
189 IDA_BUG_ON(ida, !ida_is_empty(ida));
192 static DEFINE_IDA(ida);
196 IDA_BUG_ON(&ida, !ida_is_empty(&ida));
197 ida_check_alloc(&ida);
198 ida_check_destroy(&ida);
199 ida_check_leaf(&ida, 0);
200 ida_check_leaf(&ida, 1024);
201 ida_check_leaf(&ida, 1024 * 64);
202 ida_check_max(&ida);
203 ida_check_conv(&ida);
204 ida_check_bad_free(&ida);