Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:lib\list_sort.c Create Date:2022-07-28 06:20:50
Last Modify:2020-03-12 14:18:49 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:list_sort - sort a list*@priv: private data, opaque to list_sort(), passed to @cmp*@head: the list to sort*@cmp: the elements comparison function* The comparison funtion @cmp must return > 0 if @a should sort after*@b ("@a > @b" if you want an ascending

Proto:__attribute__((nonnull(2, 3))) void list_sort(void *priv, struct list_head *head, int (*cmp)(void *priv, struct list_head *a, struct list_head *b))

Type:void

Parameter:

TypeParameterName
void *priv
struct list_head *head
int (*cmp
192  struct list_head * list = next, * pending = NULL
193  count = 0
195  If list == prev Then Return
199  next = NULL
219  Do
221  tail = pending
224  When bits & 1 cycle tail = prev
228  a = tail , b = prev
232  prev = prev
233  tail = a
237  prev = pending
238  pending = list
239  list = next
240  next = NULL
241  count++
242  When list cycle
245  list = pending
246  pending = prev
247  cycle
248  next = prev
250  If Not next Then Break
252  list = Returns a list organized in an intermediate format suited* to chaining of merge() calls: null-terminated, no reserved or* sentinel head node, "prev" links not maintained.
253  pending = next
256  Combine final list merge with restoration of standard doubly-linked* list structure
Caller
NameDescribe
list_sort_test