Lines Matching refs:layer

136     idp->top->layer = new_node ? (new_node->layer + 1) : 0; // 注意特判空指针  in __idr_grow()
167 int layer = idp->top->layer; in __idr_get_empty_slot() local
168 BUG_ON(layer + 1 >= 7); in __idr_get_empty_slot()
169 stk[layer + 1] = NULL; // 标志为数组末尾 in __idr_get_empty_slot()
172 while (layer >= 0) in __idr_get_empty_slot()
174 stk[layer] = cur_layer; in __idr_get_empty_slot()
186 if (layer > 0 && NULL == cur_layer) // 只有非叶子节点才需要开辟儿子节点 in __idr_get_empty_slot()
192 cur_layer->layer = layer - 1; // 儿子节点的layer in __idr_get_empty_slot()
196 stk[layer]->ary[pos] = cur_layer; // 最后别忘了记录儿子节点 in __idr_get_empty_slot()
199 --layer; in __idr_get_empty_slot()
258 int layer = cur_layer->layer; in __idr_get_path() local
259 stk[layer + 1] = NULL; // 标志数组结尾 in __idr_get_path()
261 if (unlikely((__id >> ((layer + 1ull) * IDR_BITS)) > 0)) in __idr_get_path()
268 while (layer >= 0) in __idr_get_path()
270 stk[layer] = cur_layer; in __idr_get_path()
271 int64_t layer_id = (__id >> (layer * IDR_BITS)) & IDR_MASK; in __idr_get_path()
280 --layer; in __idr_get_path()
314 for (int layer = 1; stk[layer]; ++layer) in __idr_erase_full() local
319 if (NULL == stk[layer - 1]->bitmap) // 儿子是空节点 in __idr_erase_full()
321 stk[layer]->ary[layer_id] = NULL; in __idr_erase_full()
322 stk[layer]->bitmap ^= (1ull << layer_id); in __idr_erase_full()
324 if ((stk[layer]->full >> layer_id) & 1) in __idr_erase_full()
325 stk[layer]->full ^= (1ull << layer_id); in __idr_erase_full()
327 __idr_layer_free(stk[layer - 1]); in __idr_erase_full()
328 stk[layer - 1] = NULL; // 释放空间记得设置为 NULL in __idr_erase_full()
330 else if (stk[layer - 1]->full != IDR_FULL) in __idr_erase_full()
332 if ((stk[layer]->full >> layer_id) & 1) in __idr_erase_full()
333 stk[layer]->full ^= (1ull << layer_id); in __idr_erase_full()
340 while (idp->top != NULL && ((idp->top->bitmap <= 1 && idp->top->layer > 0) || // 一条链的情况 in __idr_erase_full()
341 (idp->top->layer == 0 && idp->top->bitmap == 0))) // 最后一个点的情况 in __idr_erase_full()
343 struct idr_layer *t = idp->top->layer ? idp->top->ary[0] : NULL; in __idr_erase_full()
435 int layer = cur_layer->layer; in __idr_remove_all_with_free() local
436 BUG_ON(layer + 1 >= 7); in __idr_remove_all_with_free()
437 stk[layer + 1] = NULL; // 标记数组结尾 in __idr_remove_all_with_free()
441 if (layer > 0 && cur_layer->bitmap) // 非叶子节点 in __idr_remove_all_with_free()
443 stk[layer] = cur_layer; // 入栈 in __idr_remove_all_with_free()
448 stk[layer]->ary[id] = NULL; in __idr_remove_all_with_free()
449 --layer; in __idr_remove_all_with_free()
463 ++layer; in __idr_remove_all_with_free()
465 cur_layer = stk[layer]; // 出栈 in __idr_remove_all_with_free()
529 int layer = cur_layer->layer; // 特判NULL in idr_find() local
532 if ((__id >> ((layer + 1) * IDR_BITS)) > 0) in idr_find()
537 while (layer >= 0 && cur_layer != NULL) in idr_find()
540 layer_id = (__id >> (IDR_BITS * layer)) & IDR_MASK; in idr_find()
543 --layer; in idr_find()
583 int layer = cur_layer->layer; in idr_find_next_getid() local
584 BUG_ON(layer + 1 >= 7); in idr_find_next_getid()
585 stk[layer + 1] = NULL; // 标记数组结尾 in idr_find_next_getid()
588 if ((start_id >> ((layer + 1) * IDR_BITS)) > 0) in idr_find_next_getid()
596 BUG_ON(layer < 0); in idr_find_next_getid()
599 stk[layer] = cur_layer; in idr_find_next_getid()
600 state[layer] = cur_state; in idr_find_next_getid()
601 pos_i[layer] = cur_state ? 0 : ((start_id >> (layer * IDR_BITS)) & IDR_MASK); in idr_find_next_getid()
605 pos_i[layer]++; in idr_find_next_getid()
606 state[layer] = cur_state = true; in idr_find_next_getid()
609 BUG_ON(pos_i[layer] >= 64); in idr_find_next_getid()
610 unsigned long t_bitmap = (cur_layer->bitmap >> pos_i[layer]); in idr_find_next_getid()
613 int64_t layer_id = __lowbit_id(t_bitmap) + pos_i[layer]; in idr_find_next_getid()
616 if ((cur_state == false) && (layer_id > pos_i[layer] > 0)) in idr_find_next_getid()
619 pos_i[layer] = layer_id; in idr_find_next_getid()
622 if (layer == 0) in idr_find_next_getid()
630 --layer; in idr_find_next_getid()
636 ++layer; in idr_find_next_getid()
637 cur_layer = stk[layer]; in idr_find_next_getid()
685 int64_t layer = cur_layer->layer; in idr_replace_get_old() local
687 if ((__id >> ((layer + 1) * IDR_BITS)) > 0) in idr_replace_get_old()
690 while (layer > 0) in idr_replace_get_old()
692 int64_t layer_id = (__id >> (layer * IDR_BITS)) & IDR_MASK; in idr_replace_get_old()
698 layer--; in idr_replace_get_old()
755 static bool __idr_cnt(int layer, int id, struct idr_layer *cur_layer) in __idr_cnt() argument
758 while (layer >= 0) // 提取路径 in __idr_cnt()
762 int64_t layer_id = (__id >> (layer * IDR_BITS)) & IDR_MASK; in __idr_cnt()
775 --layer; in __idr_cnt()
798 int layer = cur_layer->layer; in idr_count() local
801 if (unlikely((__id >> ((layer + 1ull) * IDR_BITS)) > 0)) in idr_count()
808 return __idr_cnt(layer, id, cur_layer); in idr_count()