/* 80* Delete a list entry by making the prev/next entries 81* point to each other. 82* 83* This is only for internal list manipulation where we know 84* the prev/next entries already! 85*/ 86staticinline void__list_del(structlist_head *prev, structlist_head *next) 87{ 88next->prev = prev; 89prev->next = next; 90} 91
92/** 93* list_del - deletes entry from list. 94* @entry: the element to delete from the list. 95* Note: list_empty() on entry does not return true after this, the entry is 96* in an undefined state. 97*/ 98#ifndefCONFIG_DEBUG_LIST 99staticinline void__list_del_entry(structlist_head *entry) 100{ 101__list_del(entry->prev,entry->next); 102} 103 104staticinline voidlist_del(structlist_head *entry) 105{ 106__list_del(entry->prev,entry->next); 107entry->next = LIST_POISON1; 108entry->prev = LIST_POISON2; 109} 110#else
散列表链表的脱离链表代码:
90staticinline void__hlist_del(structhlist_node *n) 591{ 592 struct hlist_node *next = n->next; 593 struct hlist_node **pprev = n->pprev; 594 *pprev =next; 595 if (next) 596next->pprev = pprev; 597} 598 599staticinline voidhlist_del(structhlist_node *n) 600{ 601__hlist_del(n); 602n->next = LIST_POISON1; 603n->pprev = LIST_POISON2; 604} 605 看看LIST_POISON1和LIST_POISON2是何方神圣。16 17/* 18* These are non-NULL pointers that will result in page faults 19* under normal circumstances, used to verify that nobody uses 20* non-initialized list entries. 21*/ 22#defineLIST_POISON1 ((void *) 0x00100100 + POISON_POINTER_DELTA) 23#defineLIST_POISON2 ((void *) 0x00200200 + POISON_POINTER_DELTA) 24