mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2024-12-26 19:19:32 +03:00
change libspl list member names to match kernel
This aids in debugging, so that we can use the same infrastructure to walk zfs's list_t in the kernel module and in the userland libraries (e.g. when debugging ztest). Reviewed-by: Serapheim Dimitropoulos <serapheim@delphix.com> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Matthew Ahrens <mahrens@delphix.com> Closes #10236
This commit is contained in:
parent
196bee4cfd
commit
5d4ed9614f
@ -34,8 +34,8 @@ extern "C" {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct list_node {
|
struct list_node {
|
||||||
struct list_node *list_next;
|
struct list_node *next;
|
||||||
struct list_node *list_prev;
|
struct list_node *prev;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct list {
|
struct list {
|
||||||
|
@ -35,28 +35,28 @@
|
|||||||
|
|
||||||
#define list_d2l(a, obj) ((list_node_t *)(((char *)obj) + (a)->list_offset))
|
#define list_d2l(a, obj) ((list_node_t *)(((char *)obj) + (a)->list_offset))
|
||||||
#define list_object(a, node) ((void *)(((char *)node) - (a)->list_offset))
|
#define list_object(a, node) ((void *)(((char *)node) - (a)->list_offset))
|
||||||
#define list_empty(a) ((a)->list_head.list_next == &(a)->list_head)
|
#define list_empty(a) ((a)->list_head.next == &(a)->list_head)
|
||||||
|
|
||||||
#define list_insert_after_node(list, node, object) { \
|
#define list_insert_after_node(list, node, object) { \
|
||||||
list_node_t *lnew = list_d2l(list, object); \
|
list_node_t *lnew = list_d2l(list, object); \
|
||||||
lnew->list_prev = (node); \
|
lnew->prev = (node); \
|
||||||
lnew->list_next = (node)->list_next; \
|
lnew->next = (node)->next; \
|
||||||
(node)->list_next->list_prev = lnew; \
|
(node)->next->prev = lnew; \
|
||||||
(node)->list_next = lnew; \
|
(node)->next = lnew; \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define list_insert_before_node(list, node, object) { \
|
#define list_insert_before_node(list, node, object) { \
|
||||||
list_node_t *lnew = list_d2l(list, object); \
|
list_node_t *lnew = list_d2l(list, object); \
|
||||||
lnew->list_next = (node); \
|
lnew->next = (node); \
|
||||||
lnew->list_prev = (node)->list_prev; \
|
lnew->prev = (node)->prev; \
|
||||||
(node)->list_prev->list_next = lnew; \
|
(node)->prev->next = lnew; \
|
||||||
(node)->list_prev = lnew; \
|
(node)->prev = lnew; \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define list_remove_node(node) \
|
#define list_remove_node(node) \
|
||||||
(node)->list_prev->list_next = (node)->list_next; \
|
(node)->prev->next = (node)->next; \
|
||||||
(node)->list_next->list_prev = (node)->list_prev; \
|
(node)->next->prev = (node)->prev; \
|
||||||
(node)->list_next = (node)->list_prev = NULL
|
(node)->next = (node)->prev = NULL
|
||||||
|
|
||||||
void
|
void
|
||||||
list_create(list_t *list, size_t size, size_t offset)
|
list_create(list_t *list, size_t size, size_t offset)
|
||||||
@ -67,8 +67,7 @@ list_create(list_t *list, size_t size, size_t offset)
|
|||||||
|
|
||||||
list->list_size = size;
|
list->list_size = size;
|
||||||
list->list_offset = offset;
|
list->list_offset = offset;
|
||||||
list->list_head.list_next = list->list_head.list_prev =
|
list->list_head.next = list->list_head.prev = &list->list_head;
|
||||||
&list->list_head;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -77,10 +76,10 @@ list_destroy(list_t *list)
|
|||||||
list_node_t *node = &list->list_head;
|
list_node_t *node = &list->list_head;
|
||||||
|
|
||||||
ASSERT(list);
|
ASSERT(list);
|
||||||
ASSERT(list->list_head.list_next == node);
|
ASSERT(list->list_head.next == node);
|
||||||
ASSERT(list->list_head.list_prev == node);
|
ASSERT(list->list_head.prev == node);
|
||||||
|
|
||||||
node->list_next = node->list_prev = NULL;
|
node->next = node->prev = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -124,14 +123,14 @@ list_remove(list_t *list, void *object)
|
|||||||
{
|
{
|
||||||
list_node_t *lold = list_d2l(list, object);
|
list_node_t *lold = list_d2l(list, object);
|
||||||
ASSERT(!list_empty(list));
|
ASSERT(!list_empty(list));
|
||||||
ASSERT(lold->list_next != NULL);
|
ASSERT(lold->next != NULL);
|
||||||
list_remove_node(lold);
|
list_remove_node(lold);
|
||||||
}
|
}
|
||||||
|
|
||||||
void *
|
void *
|
||||||
list_remove_head(list_t *list)
|
list_remove_head(list_t *list)
|
||||||
{
|
{
|
||||||
list_node_t *head = list->list_head.list_next;
|
list_node_t *head = list->list_head.next;
|
||||||
if (head == &list->list_head)
|
if (head == &list->list_head)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
list_remove_node(head);
|
list_remove_node(head);
|
||||||
@ -141,7 +140,7 @@ list_remove_head(list_t *list)
|
|||||||
void *
|
void *
|
||||||
list_remove_tail(list_t *list)
|
list_remove_tail(list_t *list)
|
||||||
{
|
{
|
||||||
list_node_t *tail = list->list_head.list_prev;
|
list_node_t *tail = list->list_head.prev;
|
||||||
if (tail == &list->list_head)
|
if (tail == &list->list_head)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
list_remove_node(tail);
|
list_remove_node(tail);
|
||||||
@ -153,7 +152,7 @@ list_head(list_t *list)
|
|||||||
{
|
{
|
||||||
if (list_empty(list))
|
if (list_empty(list))
|
||||||
return (NULL);
|
return (NULL);
|
||||||
return (list_object(list, list->list_head.list_next));
|
return (list_object(list, list->list_head.next));
|
||||||
}
|
}
|
||||||
|
|
||||||
void *
|
void *
|
||||||
@ -161,7 +160,7 @@ list_tail(list_t *list)
|
|||||||
{
|
{
|
||||||
if (list_empty(list))
|
if (list_empty(list))
|
||||||
return (NULL);
|
return (NULL);
|
||||||
return (list_object(list, list->list_head.list_prev));
|
return (list_object(list, list->list_head.prev));
|
||||||
}
|
}
|
||||||
|
|
||||||
void *
|
void *
|
||||||
@ -169,8 +168,8 @@ list_next(list_t *list, void *object)
|
|||||||
{
|
{
|
||||||
list_node_t *node = list_d2l(list, object);
|
list_node_t *node = list_d2l(list, object);
|
||||||
|
|
||||||
if (node->list_next != &list->list_head)
|
if (node->next != &list->list_head)
|
||||||
return (list_object(list, node->list_next));
|
return (list_object(list, node->next));
|
||||||
|
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
@ -180,8 +179,8 @@ list_prev(list_t *list, void *object)
|
|||||||
{
|
{
|
||||||
list_node_t *node = list_d2l(list, object);
|
list_node_t *node = list_d2l(list, object);
|
||||||
|
|
||||||
if (node->list_prev != &list->list_head)
|
if (node->prev != &list->list_head)
|
||||||
return (list_object(list, node->list_prev));
|
return (list_object(list, node->prev));
|
||||||
|
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
@ -201,13 +200,13 @@ list_move_tail(list_t *dst, list_t *src)
|
|||||||
if (list_empty(src))
|
if (list_empty(src))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
dstnode->list_prev->list_next = srcnode->list_next;
|
dstnode->prev->next = srcnode->next;
|
||||||
srcnode->list_next->list_prev = dstnode->list_prev;
|
srcnode->next->prev = dstnode->prev;
|
||||||
dstnode->list_prev = srcnode->list_prev;
|
dstnode->prev = srcnode->prev;
|
||||||
srcnode->list_prev->list_next = dstnode;
|
srcnode->prev->next = dstnode;
|
||||||
|
|
||||||
/* empty src list */
|
/* empty src list */
|
||||||
srcnode->list_next = srcnode->list_prev = srcnode;
|
srcnode->next = srcnode->prev = srcnode;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -216,24 +215,24 @@ list_link_replace(list_node_t *lold, list_node_t *lnew)
|
|||||||
ASSERT(list_link_active(lold));
|
ASSERT(list_link_active(lold));
|
||||||
ASSERT(!list_link_active(lnew));
|
ASSERT(!list_link_active(lnew));
|
||||||
|
|
||||||
lnew->list_next = lold->list_next;
|
lnew->next = lold->next;
|
||||||
lnew->list_prev = lold->list_prev;
|
lnew->prev = lold->prev;
|
||||||
lold->list_prev->list_next = lnew;
|
lold->prev->next = lnew;
|
||||||
lold->list_next->list_prev = lnew;
|
lold->next->prev = lnew;
|
||||||
lold->list_next = lold->list_prev = NULL;
|
lold->next = lold->prev = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
list_link_init(list_node_t *ln)
|
list_link_init(list_node_t *ln)
|
||||||
{
|
{
|
||||||
ln->list_next = NULL;
|
ln->next = NULL;
|
||||||
ln->list_prev = NULL;
|
ln->prev = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
list_link_active(list_node_t *ln)
|
list_link_active(list_node_t *ln)
|
||||||
{
|
{
|
||||||
return (ln->list_next != NULL);
|
return (ln->next != NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
Loading…
Reference in New Issue
Block a user